@objectstack/console 17.0.0-rc.2 → 17.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/dist/assets/{AdapterProvider-CtRy19L4.js → AdapterProvider-Bur-uZKZ.js} +1 -1
  3. package/dist/assets/{ApiConsolePage-CGg1YX-S.js → ApiConsolePage-D0rZy0lx.js} +1 -1
  4. package/dist/assets/{AppDocsIndex-BhbMTMti.js → AppDocsIndex-CQo6tZPY.js} +1 -1
  5. package/dist/assets/{AppManagementPage-H6lFpmYT.js → AppManagementPage-jLhhl_WS.js} +1 -1
  6. package/dist/assets/{ApprovalsInboxPage-CbWL6D_v.js → ApprovalsInboxPage-COyyj1KQ.js} +1 -1
  7. package/dist/assets/{CreateViewDialog-Dt1MUhLX.js → CreateViewDialog-C6sZGaIB.js} +1 -1
  8. package/dist/assets/{DashboardView-OZHG8o0x.js → DashboardView-S5Fshq0v.js} +1 -1
  9. package/dist/assets/{FlowRunsPage-DTUvw7r2.js → FlowRunsPage-DGyj2PBP.js} +1 -1
  10. package/dist/assets/{InterfaceListPage-bZdYVg1W.js → InterfaceListPage-DcFmVgXg.js} +1 -1
  11. package/dist/assets/{MarketplacePackagePage-MX3QKebj.js → MarketplacePackagePage-DZkqNaao.js} +1 -1
  12. package/dist/assets/{MetadataProvider-87BSQkFa.js → MetadataProvider-D9fSVVZp.js} +1 -1
  13. package/dist/assets/{ObjectDataPage-JASSibf6.js → ObjectDataPage-BZ4pf0ji.js} +1 -1
  14. package/dist/assets/{PageView-DwZUXknG.js → PageView-B8qkF17f.js} +1 -1
  15. package/dist/assets/{PublicFormsPage-Cu_VttTH.js → PublicFormsPage-C3z0TH0k.js} +1 -1
  16. package/dist/assets/{RecordFormPage-qcCOHj3T.js → RecordFormPage-CyAjEE1O.js} +1 -1
  17. package/dist/assets/{ReportDefaultInspector-Byof8OYm.js → ReportDefaultInspector-BqgFtk2E.js} +1 -1
  18. package/dist/assets/{ReportView-D91loQjH.js → ReportView-CfQ-Z9TJ.js} +1 -1
  19. package/dist/assets/{SearchResultsPage-Dzm_0iUD.js → SearchResultsPage-Ct2q9Lrf.js} +1 -1
  20. package/dist/assets/{SystemHubPage-B3uHe11N.js → SystemHubPage-BSunYA-X.js} +1 -1
  21. package/dist/assets/{createDerive-DmbuzviK.js → createDerive-CGF05Hgy.js} +1 -1
  22. package/dist/assets/{data-adapter-sj_1S7TJ.js → data-adapter-rnhaIuyx.js} +2 -2
  23. package/dist/assets/{index-rkbFgKQu.js → index-U6sSlA28.js} +1 -1
  24. package/dist/assets/{metadata-admin-DA08xWlg.js → metadata-admin-Ci8bBNxq.js} +1 -1
  25. package/dist/assets/{runtime-metadata-persistence-BsgvioOn.js → runtime-metadata-persistence-BjYxldgR.js} +1 -1
  26. package/dist/assets/{src-D0ueU0ix.js → src-CSrGzA_t.js} +2 -2
  27. package/dist/assets/{src-Chkzn0bG.js → src-DzTCerTm.js} +1 -1
  28. package/dist/assets/{use-book-data-CAZ23DZb.js → use-book-data-D8LHn21q.js} +1 -1
  29. package/dist/index.html +1 -1
  30. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @objectstack/console
2
2
 
3
+ ## 17.0.0-rc.3
4
+
3
5
  ## 17.0.0-rc.2
4
6
 
5
7
  ### Minor Changes
@@ -1,2 +1,2 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{y as r}from"./infrastructure-PXm1h5tB.js";import{j as i}from"./framework-UESyszCj.js";import{nl as a}from"./ui-components-BbC0qTrK.js";import{r as o}from"./vendor-ui-utils-CnzHPXVC.js";import{t as s}from"./data-adapter-sj_1S7TJ.js";var c=e(n(),1),l=0,u=new Set,d=[];function f(){for(let e of u)try{e(l)}catch{}if(l===0&&d.length>0){let e=d;d=[];for(let t of e)try{t()}catch{}}}function p(){l+=1,f()}function m(){l=Math.max(0,l-1),f()}function h(){return l}function g(){return l===0}function _(e){return u.add(e),()=>{u.delete(e)}}function v(e=1e4){return l===0?Promise.resolve():new Promise(t=>{let n=!1,r=()=>{n||(n=!0,t())};d.push(r),e>0&&typeof setTimeout<`u`&&setTimeout(r,e)})}function y(e){return(async(...t)=>{p();try{return await e(...t)}finally{m()}})}function b(){if(typeof window>`u`)return;let e=window,t=e.__objectui??={};Object.defineProperty(t,"pendingRequests",{get:h,configurable:!0}),Object.defineProperty(t,"idle",{get:g,configurable:!0}),t.whenIdle=v,t.subscribe=_}var x=t();function S(e,t){let n=new Map;for(let t of e.droppedFields){let e=n.get(t.reason)??[];for(let n of t.fields)e.includes(n)||e.push(n);n.set(t.reason,e)}let r=[];for(let[e,i]of n){if(i.length===0)continue;let n=i.join(`, `);r.push(e===`readonly_when`?t(`detail.writeStrippedByState`,{fields:n,defaultValue:`Not editable in this record's current state, so it was not saved: {{fields}}`}):t(`detail.writeStrippedReadonly`,{fields:n,defaultValue:`Read-only, so it was not saved: {{fields}}`}))}r.length!==0&&o.warning(t(`detail.writeStrippedTitle`,{defaultValue:`Some fields were not saved`}),{description:r.join(`
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{y as r}from"./infrastructure-PXm1h5tB.js";import{j as i}from"./framework-UESyszCj.js";import{nl as a}from"./ui-components-BbC0qTrK.js";import{r as o}from"./vendor-ui-utils-CnzHPXVC.js";import{t as s}from"./data-adapter-rnhaIuyx.js";var c=e(n(),1),l=0,u=new Set,d=[];function f(){for(let e of u)try{e(l)}catch{}if(l===0&&d.length>0){let e=d;d=[];for(let t of e)try{t()}catch{}}}function p(){l+=1,f()}function m(){l=Math.max(0,l-1),f()}function h(){return l}function g(){return l===0}function _(e){return u.add(e),()=>{u.delete(e)}}function v(e=1e4){return l===0?Promise.resolve():new Promise(t=>{let n=!1,r=()=>{n||(n=!0,t())};d.push(r),e>0&&typeof setTimeout<`u`&&setTimeout(r,e)})}function y(e){return(async(...t)=>{p();try{return await e(...t)}finally{m()}})}function b(){if(typeof window>`u`)return;let e=window,t=e.__objectui??={};Object.defineProperty(t,"pendingRequests",{get:h,configurable:!0}),Object.defineProperty(t,"idle",{get:g,configurable:!0}),t.whenIdle=v,t.subscribe=_}var x=t();function S(e,t){let n=new Map;for(let t of e.droppedFields){let e=n.get(t.reason)??[];for(let n of t.fields)e.includes(n)||e.push(n);n.set(t.reason,e)}let r=[];for(let[e,i]of n){if(i.length===0)continue;let n=i.join(`, `);r.push(e===`readonly_when`?t(`detail.writeStrippedByState`,{fields:n,defaultValue:`Not editable in this record's current state, so it was not saved: {{fields}}`}):t(`detail.writeStrippedReadonly`,{fields:n,defaultValue:`Read-only, so it was not saved: {{fields}}`}))}r.length!==0&&o.warning(t(`detail.writeStrippedTitle`,{defaultValue:`Some fields were not saved`}),{description:r.join(`
2
2
  `)})}function C({children:e,adapter:t}){let[n,o]=(0,c.useState)(t??null),{t:l}=a(),u=(0,c.useRef)(l);return u.current=l,(0,c.useEffect)(()=>{if(t){o(t);return}let e=!1,n;b();async function i(){try{let t=new s({baseUrl:``,fetch:y(r()),autoReconnect:!0,maxReconnectAttempts:5,reconnectDelay:1e3,cache:{maxSize:50,ttl:3e5}});n=t.onWriteWarning(e=>S(e,u.current)),await t.connect(),e||o(t)}catch(t){e||console.error(`[Console] Failed to initialize:`,t)}}return i(),()=>{e=!0,n?.()}},[t]),(0,x.jsx)(i.Provider,{value:n,children:e})}export{y as n,C as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{N as r,g as i}from"./framework-UESyszCj.js";import{Cr as a,Ji as o,Kr as s,Ms as c,Ro as l,_a as u,ac as d,di as f,ha as p,hr as m,ic as h,mr as g,nc as _,oa as v,oo as y,pr as b,ws as ee}from"./ui-components-BbC0qTrK.js";import"./src-D0ueU0ix.js";var x=e(n(),1),S=[`plugin`,`plugins`,`kind`,`package`];function C(e){return[{method:`POST`,path:`${e}/sign-in/email`,desc:`Sign in (email)`,group:`Auth`,bodyTemplate:{email:`user@example.com`,password:``}},{method:`POST`,path:`${e}/sign-up/email`,desc:`Sign up (email)`,group:`Auth`,bodyTemplate:{email:``,password:``,name:``}},{method:`POST`,path:`${e}/sign-out`,desc:`Sign out`,group:`Auth`},{method:`GET`,path:`${e}/get-session`,desc:`Get session`,group:`Auth`}]}var w={ai:{group:`AI`,defaultRoute:`/api/v1/ai`,endpoints:[{method:`POST`,path:`/chat`,desc:`Chat completion (JSON)`,bodyTemplate:{messages:[{role:`user`,content:``}],stream:!1}},{method:`POST`,path:`/chat/stream`,desc:`Streaming chat (SSE)`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/complete`,desc:`Text completion`,bodyTemplate:{prompt:``}},{method:`GET`,path:`/models`,desc:`List available models`},{method:`GET`,path:`/status`,desc:`Active LLM adapter provenance`},{method:`GET`,path:`/effective-model`,desc:`Effective model ids and where they came from`},{method:`POST`,path:`/conversations`,desc:`Create conversation`,bodyTemplate:{}},{method:`GET`,path:`/conversations`,desc:`List conversations`},{method:`GET`,path:`/conversations/:id`,desc:`Get conversation with message history`},{method:`PATCH`,path:`/conversations/:id`,desc:`Update conversation (title, metadata)`,bodyTemplate:{title:``}},{method:`DELETE`,path:`/conversations/:id`,desc:`Delete conversation`},{method:`POST`,path:`/conversations/:id/messages`,desc:`Add message to conversation`,bodyTemplate:{role:`user`,content:``}},{method:`GET`,path:`/conversations/:id/debug`,desc:`Reconcile a build conversation: agent-claimed vs live metadata`},{method:`GET`,path:`/agents`,desc:`List active agents`},{method:`POST`,path:`/agents/:agentName/chat`,desc:`Chat with a named agent (JSON)`,bodyTemplate:{messages:[{role:`user`,content:``}],stream:!1}},{method:`GET`,path:`/assistant`,desc:`Resolve the default assistant and its active skills`},{method:`GET`,path:`/assistant/skills`,desc:`List active skills for a context`},{method:`POST`,path:`/assistant/chat`,desc:`Ambient chat — auto-resolves agent and skills (JSON)`,bodyTemplate:{messages:[{role:`user`,content:``}],stream:!1}},{method:`GET`,path:`/tools`,desc:`List registered AI tools`},{method:`POST`,path:`/tools/:toolName/execute`,desc:`Execute one tool directly (playground)`,bodyTemplate:{parameters:{}}},{method:`GET`,path:`/pending-actions`,desc:`List pending actions awaiting approval`},{method:`GET`,path:`/pending-actions/:id`,desc:`Get one pending action`},{method:`POST`,path:`/pending-actions/:id/approve`,desc:`Approve a pending action and execute it`,bodyTemplate:{}},{method:`POST`,path:`/pending-actions/:id/reject`,desc:`Reject a pending action`,bodyTemplate:{reason:``}},{method:`POST`,path:`/evals/runs`,desc:`Run an eval case — ai:admin, makes paid LLM calls`,bodyTemplate:{caseId:``}},{method:`GET`,path:`/usage`,desc:`AI quota headroom per meter (console usage indicator)`}]},workflow:{group:`Workflow`,defaultRoute:`/api/v1/workflow`,endpoints:[{method:`GET`,path:`/:object/config`,desc:`Get workflow configuration`},{method:`GET`,path:`/:object/:recordId/state`,desc:`Get workflow state`},{method:`POST`,path:`/:object/:recordId/transition`,desc:`Execute workflow transition`,bodyTemplate:{targetState:``}},{method:`POST`,path:`/:object/:recordId/approve`,desc:`Approve workflow step`,bodyTemplate:{comment:``}},{method:`POST`,path:`/:object/:recordId/reject`,desc:`Reject workflow step`,bodyTemplate:{comment:``}}]},realtime:{group:`Realtime`,defaultRoute:`/api/v1/realtime`,endpoints:[{method:`POST`,path:`/connect`,desc:`Establish realtime connection`,bodyTemplate:{transport:`websocket`}},{method:`POST`,path:`/disconnect`,desc:`Close realtime connection`,bodyTemplate:{connectionId:``}},{method:`POST`,path:`/subscribe`,desc:`Subscribe to channel`,bodyTemplate:{channel:``}},{method:`POST`,path:`/unsubscribe`,desc:`Unsubscribe from channel`,bodyTemplate:{channel:``}},{method:`PUT`,path:`/presence/:channel`,desc:`Set presence state`,bodyTemplate:{status:`online`}},{method:`GET`,path:`/presence/:channel`,desc:`Get channel presence`}]},notification:{group:`Notifications`,defaultRoute:`/api/v1/notifications`,endpoints:[{method:`GET`,path:``,desc:`List notifications`},{method:`POST`,path:`/devices`,desc:`Register device for push`,bodyTemplate:{token:``,platform:`web`}},{method:`DELETE`,path:`/devices/:deviceId`,desc:`Unregister device`},{method:`GET`,path:`/preferences`,desc:`Get notification preferences`},{method:`PATCH`,path:`/preferences`,desc:`Update notification preferences`,bodyTemplate:{email:!0,push:!0}},{method:`POST`,path:`/read`,desc:`Mark notifications as read`,bodyTemplate:{ids:[]}},{method:`POST`,path:`/read/all`,desc:`Mark all as read`}]},analytics:{group:`Analytics`,defaultRoute:`/api/v1/analytics`,endpoints:[{method:`POST`,path:`/query`,desc:`Execute analytics query`,bodyTemplate:{measures:[],dimensions:[]}},{method:`GET`,path:`/meta`,desc:`Get analytics metadata`}]},automation:{group:`Automation`,defaultRoute:`/api/v1/automation`,endpoints:[{method:`POST`,path:`/trigger`,desc:`Trigger automation`,bodyTemplate:{name:``,params:{}}}]},i18n:{group:`i18n`,defaultRoute:`/api/v1/i18n`,endpoints:[{method:`GET`,path:`/locales`,desc:`Get available locales`},{method:`GET`,path:`/translations/:locale`,desc:`Get translations for locale`},{method:`GET`,path:`/labels/:object/:locale`,desc:`Get translated field labels`}]},ui:{group:`UI`,defaultRoute:`/api/v1/ui`,endpoints:[{method:`GET`,path:`/views`,desc:`List views`},{method:`GET`,path:`/views/:id`,desc:`Get view by ID`},{method:`POST`,path:`/views`,desc:`Create view`,bodyTemplate:{name:``,object:``,type:`list`}},{method:`PATCH`,path:`/views/:id`,desc:`Update view`,bodyTemplate:{name:``}},{method:`DELETE`,path:`/views/:id`,desc:`Delete view`}]},feed:{group:`Feed`,defaultRoute:`/api/v1/feed`,endpoints:[{method:`GET`,path:`/:object/:recordId`,desc:`Get feed items`},{method:`POST`,path:`/:object/:recordId`,desc:`Post feed item`,bodyTemplate:{body:``}}]},storage:{group:`Storage`,defaultRoute:`/api/v1/storage`,endpoints:[{method:`POST`,path:`/upload`,desc:`Upload file (multipart/form-data)`},{method:`GET`,path:`/:fileId`,desc:`Download file`},{method:`DELETE`,path:`/:fileId`,desc:`Delete file`}]}};function T(e,t){let n=w[e];return n?n.endpoints.map(e=>({method:e.method,path:`${t}${e.path}`,desc:e.desc,group:n.group,...e.bodyTemplate?{bodyTemplate:e.bodyTemplate}:{}})):[]}function te(){let e=r(),[t,n]=(0,x.useState)([]),[a,o]=(0,x.useState)([]),[s,c]=(0,x.useState)(!0),[l,u]=(0,x.useState)(null),d=(0,x.useCallback)(async()=>{c(!0),u(null);let t=`/api/v1`,r=`${t}/discovery`,a=[{method:`GET`,path:r,desc:`API Discovery`,group:`System`},{method:`GET`,path:`${t}/meta/types`,desc:`List metadata types`,group:`Metadata`},{method:`GET`,path:`${t}/packages`,desc:`List packages`,group:`System`},{method:`GET`,path:`/api/v1/health`,desc:`Health check`,group:`System`}];try{let s=`/api/v1/auth`,c={},l={};try{let e=await fetch(r);if(e.ok){let t=await e.json(),n=t?.data??t;l=n?.routes??{},c=n?.services??{},l.auth&&(s=l.auth)}}catch{}let u=[];for(let[e,t]of Object.entries(w)){let n=c[e],r=n?i(n):!1,a=n?.route??l[e]??t.defaultRoute;r&&u.push(...T(e,a))}let d=e?.getClient?.(),f=[];try{let e=await d?.meta?.getTypes?.();e&&Array.isArray(e.types)?f=e.types:Array.isArray(e)&&(f=e)}catch{}let p=[];try{let e=f.includes(`object`)?`object`:null;if(e&&d?.meta?.getItems){let t=await d.meta.getItems(e),n=[];Array.isArray(t)?n=t:t&&Array.isArray(t.items)?n=t.items:t&&Array.isArray(t.value)&&(n=t.value),p=n.map(e=>e.name||e.id).filter(Boolean)}}catch{}let m=p.flatMap(e=>{let n=e.startsWith(`sys_`)?`Data: system tables`:`Data: ${e}`;return[{method:`GET`,path:`${t}/data/${e}`,desc:`List ${e}`,group:n},{method:`POST`,path:`${t}/data/${e}`,desc:`Create ${e}`,group:n,bodyTemplate:{name:`example`}},{method:`GET`,path:`${t}/data/${e}/:id`,desc:`Get ${e} by ID`,group:n},{method:`PATCH`,path:`${t}/data/${e}/:id`,desc:`Update ${e}`,group:n,bodyTemplate:{name:`updated`}},{method:`DELETE`,path:`${t}/data/${e}/:id`,desc:`Delete ${e}`,group:n}]}),h=f.filter(e=>!S.includes(e)).map(e=>({method:`GET`,path:`${t}/meta/${e}`,desc:`List ${e} metadata`,group:`Metadata`})),g=p.map(e=>({method:`GET`,path:`${t}/meta/object/${e}`,desc:`${e} schema`,group:`Metadata`})),_=[...a,...C(s),...u,...h,...g,...m],v=new Map;for(let e of _){let t=v.get(e.group)||[];t.push(e),v.set(e.group,t)}let y=[`System`,`Auth`,`AI`,`Workflow`,`Realtime`,`Notifications`,`Analytics`,`Automation`,`i18n`,`UI`,`Feed`,`Storage`,`Metadata`],b=Array.from(v.entries()).sort(([e],[t])=>{let n=y.indexOf(e),r=y.indexOf(t);return n!==-1&&r!==-1?n-r:n===-1?r===-1?e.localeCompare(t):1:-1}).map(([e,t])=>({key:e,label:e,endpoints:t}));n(b),o(_)}catch(e){u(e.message||`Failed to discover APIs`)}finally{c(!1)}},[e]);return(0,x.useEffect)(()=>{d()},[d]),{groups:t,allEndpoints:a,loading:s,error:l,refresh:d}}var E=t(),D={GET:`text-emerald-600 bg-emerald-50 border-emerald-200 dark:text-emerald-400 dark:bg-emerald-950/50`,POST:`text-blue-600 bg-blue-50 border-blue-200 dark:text-blue-400 dark:bg-blue-950/50`,PATCH:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,PUT:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,DELETE:`text-red-600 bg-red-50 border-red-200 dark:text-red-400 dark:bg-red-950/50`},ne={2:`text-emerald-600 dark:text-emerald-400`,3:`text-blue-600 dark:text-blue-400`,4:`text-amber-600 dark:text-amber-400`,5:`text-red-600 dark:text-red-400`},re=[{key:`$top`,placeholder:`10`,hint:`limit`},{key:`$skip`,placeholder:`0`,hint:`offset`},{key:`$sort`,placeholder:`name`,hint:`sort field`},{key:`$select`,placeholder:`name,email`,hint:`fields`},{key:`$count`,placeholder:`true`,hint:`total count`},{key:`$filter`,placeholder:`status eq 'active'`,hint:`OData filter`}],O=1;function k(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:i}=te(),[S,C]=(0,x.useState)(``),[w,T]=(0,x.useState)(new Set),[k,A]=(0,x.useState)(null),[ie,j]=(0,x.useState)(``),[ae,M]=(0,x.useState)(``),[N,P]=(0,x.useState)(``),[F,I]=(0,x.useState)([]),[L,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(null),[V,H]=(0,x.useState)([]),[U,oe]=(0,x.useState)(null),[W,G]=(0,x.useState)(!1),K=(0,x.useMemo)(()=>{if(!S)return t;let e=S.toLowerCase();return t.map(t=>({...t,endpoints:t.endpoints.filter(t=>t.desc.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)||t.method.toLowerCase().includes(e))})).filter(e=>e.endpoints.length>0)},[t,S]),se=(0,x.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=(0,x.useCallback)(e=>{A(e),j(e.method),M(e.path),P(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),I([]),B(null)},[]),q=ie||k?.method||`GET`,J=ae||k?.path||``,Y=(0,x.useMemo)(()=>{let e=F.filter(e=>e.enabled&&e.key.trim());if(e.length===0)return J;let t=e.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join(`&`);return`${J}?${t}`},[J,F]),X=(0,x.useCallback)((e=``,t=``)=>{I(n=>[...n,{id:O++,key:e,value:t,enabled:!0}])},[]),le=(0,x.useCallback)(e=>{I(t=>t.filter(t=>t.id!==e))},[]),Z=(0,x.useCallback)((e,t,n)=>{I(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),ue=(0,x.useCallback)(e=>{I(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),Q=(0,x.useCallback)(async()=>{if(L||!Y)return;let t=`${e?.baseUrl??``}${Y}`;R(!0);let n=performance.now();try{let e={method:q,headers:{"Content-Type":`application/json`}};[`POST`,`PATCH`,`PUT`].includes(q)&&N.trim()&&(e.body=N);let r=await fetch(t,e),i=Math.round(performance.now()-n),a;if((r.headers.get(`content-type`)??``).includes(`json`)){let e=await r.json();a=JSON.stringify(e,null,2)}else a=await r.text();let o={status:r.status,body:a,duration:i};B(o),H(e=>[{id:Date.now(),method:q,url:Y,body:N||void 0,status:r.status,duration:i,response:a,timestamp:new Date},...e].slice(0,50))}catch(e){let t=Math.round(performance.now()-n);B({status:0,body:`Network Error: ${e.message}`,duration:t})}finally{R(!1)}},[e,Y,q,N,L]),de=(0,x.useCallback)(e=>{j(e.method);let[t,n]=e.url.split(`?`);if(M(t),P(e.body||``),n){let e=new URLSearchParams(n),t=[];e.forEach((e,n)=>{t.push({id:O++,key:n,value:e,enabled:!0})}),I(t)}else I([]);B(null),A(null)},[]),fe=(0,x.useCallback)(()=>{z?.body&&(navigator.clipboard.writeText(z.body),G(!0),setTimeout(()=>G(!1),1500))},[z]),$=e=>ne[String(e)[0]]??`text-muted-foreground`;return(0,E.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,E.jsx)(`button`,{onClick:i,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,E.jsx)(v,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(o,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,E.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`Search endpoints...`,className:`w-full rounded-md border bg-background pl-8 pr-3 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]})]}),(0,E.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,E.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,E.jsx)(y,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):K.length===0?(0,E.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,E.jsx)(l,{className:`h-6 w-6 opacity-30 mb-2`}),(0,E.jsx)(`span`,{children:S?`No matching endpoints`:`No endpoints found`})]}):K.map(e=>{let t=w.has(e.key)||!!S;return(0,E.jsxs)(b,{open:t,onOpenChange:()=>se(e.key),children:[(0,E.jsx)(m,{asChild:!0,children:(0,E.jsxs)(`button`,{className:`w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors`,children:[(0,E.jsx)(_,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-90`:``}`}),(0,E.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e.label}),(0,E.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums opacity-60`,children:e.endpoints.length})]})}),(0,E.jsx)(g,{children:(0,E.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,E.jsxs)(`button`,{onClick:()=>ce(e),className:`w-full text-left flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${k===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,E.jsx)(a,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${D[e.method]||``}`,children:e.method}),(0,E.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,E.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,E.jsxs)(`button`,{onClick:()=>X(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,E.jsx)(p,{className:`h-3 w-3`}),`Add`]})]}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:re.map(e=>(0,E.jsx)(`button`,{onClick:()=>X(e.key,``),className:`text-[10px] px-1.5 py-0.5 rounded border bg-muted/30 text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors font-mono`,title:e.hint,children:e.key},e.key))}),F.length>0&&(0,E.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,E.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>ue(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,E.jsx)(`input`,{type:`text`,value:e.key,onChange:t=>Z(e.id,`key`,t.target.value),placeholder:`key`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,E.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>Z(e.id,`value`,t.target.value),placeholder:`value`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,E.jsx)(`button`,{onClick:()=>le(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,E.jsx)(s,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,E.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`select`,{value:q,onChange:e=>j(e.target.value),className:`rounded-md border bg-background px-2 py-1.5 font-mono text-xs font-semibold focus:outline-none focus:ring-1 focus:ring-ring ${D[q]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))}),(0,E.jsx)(`input`,{type:`text`,value:J,onChange:e=>M(e.target.value),className:`flex-1 rounded-md border bg-background px-3 py-1.5 font-mono text-sm focus:outline-none focus:ring-1 focus:ring-ring`,placeholder:`/api/v1/...`,onKeyDown:e=>{e.key===`Enter`&&Q()}}),(0,E.jsxs)(`button`,{onClick:Q,disabled:L||!Y,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:[L?(0,E.jsx)(y,{className:`h-3.5 w-3.5 animate-spin`}):(0,E.jsx)(u,{className:`h-3.5 w-3.5`}),`Send`]})]}),F.some(e=>e.enabled&&e.key.trim())&&(0,E.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,Y]})]}),(0,E.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(q)&&(0,E.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,E.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,E.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),rows:5,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-ring resize-y`,placeholder:`{ "key": "value" }`})]}),L&&(0,E.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,E.jsx)(y,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),z&&!L&&(0,E.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,E.jsx)(`span`,{className:`font-mono font-semibold ${$(z.status)}`,children:z.status||`ERR`}),(0,E.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,E.jsx)(c,{className:`h-3 w-3`}),z.duration,`ms`]})]}),(0,E.jsxs)(`button`,{onClick:fe,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[W?(0,E.jsx)(d,{className:`h-3 w-3`}):(0,E.jsx)(ee,{className:`h-3 w-3`}),W?`Copied`:`Copy`]})]}),(0,E.jsx)(`pre`,{className:`flex-1 overflow-auto p-3 text-xs font-mono bg-muted/10 whitespace-pre-wrap break-all`,children:z.body})]}),!z&&!L&&(0,E.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:(0,E.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,E.jsx)(l,{className:`h-10 w-10 mx-auto opacity-20`}),(0,E.jsxs)(`p`,{children:[`Select an endpoint or type a URL and click `,(0,E.jsx)(`strong`,{children:`Send`})]}),(0,E.jsx)(`p`,{className:`text-xs opacity-60`,children:`All registered APIs are auto-discovered from the platform`})]})}),V.length>0&&(0,E.jsxs)(`div`,{className:`border-t`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,E.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:[`History (`,V.length,`)`]}),(0,E.jsxs)(`button`,{onClick:()=>H([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,E.jsx)(f,{className:`h-3 w-3`}),`Clear`]})]}),(0,E.jsx)(`div`,{className:`space-y-0.5 px-2 pb-2 max-h-60 overflow-auto`,children:V.map(e=>(0,E.jsxs)(`div`,{className:`rounded border`,children:[(0,E.jsxs)(`button`,{onClick:()=>oe(U===e.id?null:e.id),className:`w-full flex items-center gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 transition-colors`,children:[U===e.id?(0,E.jsx)(h,{className:`h-3 w-3 shrink-0`}):(0,E.jsx)(_,{className:`h-3 w-3 shrink-0`}),(0,E.jsx)(a,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${D[e.method]||``}`,children:e.method}),(0,E.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,E.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${$(e.status)}`,children:e.status}),(0,E.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,E.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:`Replay request`,children:(0,E.jsx)(u,{className:`h-2.5 w-2.5`})})]}),U===e.id&&(0,E.jsx)(`pre`,{className:`px-3 py-2 text-xs font-mono bg-muted/10 border-t overflow-auto max-h-40 whitespace-pre-wrap break-all`,children:e.response})]},e.id))})]})]})]})]})}export{k as ApiConsolePage};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{N as r,g as i}from"./framework-UESyszCj.js";import{Cr as a,Ji as o,Kr as s,Ms as c,Ro as l,_a as u,ac as d,di as f,ha as p,hr as m,ic as h,mr as g,nc as _,oa as v,oo as y,pr as b,ws as ee}from"./ui-components-BbC0qTrK.js";import"./src-CSrGzA_t.js";var x=e(n(),1),S=[`plugin`,`plugins`,`kind`,`package`];function C(e){return[{method:`POST`,path:`${e}/sign-in/email`,desc:`Sign in (email)`,group:`Auth`,bodyTemplate:{email:`user@example.com`,password:``}},{method:`POST`,path:`${e}/sign-up/email`,desc:`Sign up (email)`,group:`Auth`,bodyTemplate:{email:``,password:``,name:``}},{method:`POST`,path:`${e}/sign-out`,desc:`Sign out`,group:`Auth`},{method:`GET`,path:`${e}/get-session`,desc:`Get session`,group:`Auth`}]}var w={ai:{group:`AI`,defaultRoute:`/api/v1/ai`,endpoints:[{method:`POST`,path:`/chat`,desc:`Chat completion (JSON)`,bodyTemplate:{messages:[{role:`user`,content:``}],stream:!1}},{method:`POST`,path:`/chat/stream`,desc:`Streaming chat (SSE)`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/complete`,desc:`Text completion`,bodyTemplate:{prompt:``}},{method:`GET`,path:`/models`,desc:`List available models`},{method:`GET`,path:`/status`,desc:`Active LLM adapter provenance`},{method:`GET`,path:`/effective-model`,desc:`Effective model ids and where they came from`},{method:`POST`,path:`/conversations`,desc:`Create conversation`,bodyTemplate:{}},{method:`GET`,path:`/conversations`,desc:`List conversations`},{method:`GET`,path:`/conversations/:id`,desc:`Get conversation with message history`},{method:`PATCH`,path:`/conversations/:id`,desc:`Update conversation (title, metadata)`,bodyTemplate:{title:``}},{method:`DELETE`,path:`/conversations/:id`,desc:`Delete conversation`},{method:`POST`,path:`/conversations/:id/messages`,desc:`Add message to conversation`,bodyTemplate:{role:`user`,content:``}},{method:`GET`,path:`/conversations/:id/debug`,desc:`Reconcile a build conversation: agent-claimed vs live metadata`},{method:`GET`,path:`/agents`,desc:`List active agents`},{method:`POST`,path:`/agents/:agentName/chat`,desc:`Chat with a named agent (JSON)`,bodyTemplate:{messages:[{role:`user`,content:``}],stream:!1}},{method:`GET`,path:`/assistant`,desc:`Resolve the default assistant and its active skills`},{method:`GET`,path:`/assistant/skills`,desc:`List active skills for a context`},{method:`POST`,path:`/assistant/chat`,desc:`Ambient chat — auto-resolves agent and skills (JSON)`,bodyTemplate:{messages:[{role:`user`,content:``}],stream:!1}},{method:`GET`,path:`/tools`,desc:`List registered AI tools`},{method:`POST`,path:`/tools/:toolName/execute`,desc:`Execute one tool directly (playground)`,bodyTemplate:{parameters:{}}},{method:`GET`,path:`/pending-actions`,desc:`List pending actions awaiting approval`},{method:`GET`,path:`/pending-actions/:id`,desc:`Get one pending action`},{method:`POST`,path:`/pending-actions/:id/approve`,desc:`Approve a pending action and execute it`,bodyTemplate:{}},{method:`POST`,path:`/pending-actions/:id/reject`,desc:`Reject a pending action`,bodyTemplate:{reason:``}},{method:`POST`,path:`/evals/runs`,desc:`Run an eval case — ai:admin, makes paid LLM calls`,bodyTemplate:{caseId:``}},{method:`GET`,path:`/usage`,desc:`AI quota headroom per meter (console usage indicator)`}]},workflow:{group:`Workflow`,defaultRoute:`/api/v1/workflow`,endpoints:[{method:`GET`,path:`/:object/config`,desc:`Get workflow configuration`},{method:`GET`,path:`/:object/:recordId/state`,desc:`Get workflow state`},{method:`POST`,path:`/:object/:recordId/transition`,desc:`Execute workflow transition`,bodyTemplate:{targetState:``}},{method:`POST`,path:`/:object/:recordId/approve`,desc:`Approve workflow step`,bodyTemplate:{comment:``}},{method:`POST`,path:`/:object/:recordId/reject`,desc:`Reject workflow step`,bodyTemplate:{comment:``}}]},realtime:{group:`Realtime`,defaultRoute:`/api/v1/realtime`,endpoints:[{method:`POST`,path:`/connect`,desc:`Establish realtime connection`,bodyTemplate:{transport:`websocket`}},{method:`POST`,path:`/disconnect`,desc:`Close realtime connection`,bodyTemplate:{connectionId:``}},{method:`POST`,path:`/subscribe`,desc:`Subscribe to channel`,bodyTemplate:{channel:``}},{method:`POST`,path:`/unsubscribe`,desc:`Unsubscribe from channel`,bodyTemplate:{channel:``}},{method:`PUT`,path:`/presence/:channel`,desc:`Set presence state`,bodyTemplate:{status:`online`}},{method:`GET`,path:`/presence/:channel`,desc:`Get channel presence`}]},notification:{group:`Notifications`,defaultRoute:`/api/v1/notifications`,endpoints:[{method:`GET`,path:``,desc:`List notifications`},{method:`POST`,path:`/devices`,desc:`Register device for push`,bodyTemplate:{token:``,platform:`web`}},{method:`DELETE`,path:`/devices/:deviceId`,desc:`Unregister device`},{method:`GET`,path:`/preferences`,desc:`Get notification preferences`},{method:`PATCH`,path:`/preferences`,desc:`Update notification preferences`,bodyTemplate:{email:!0,push:!0}},{method:`POST`,path:`/read`,desc:`Mark notifications as read`,bodyTemplate:{ids:[]}},{method:`POST`,path:`/read/all`,desc:`Mark all as read`}]},analytics:{group:`Analytics`,defaultRoute:`/api/v1/analytics`,endpoints:[{method:`POST`,path:`/query`,desc:`Execute analytics query`,bodyTemplate:{measures:[],dimensions:[]}},{method:`GET`,path:`/meta`,desc:`Get analytics metadata`}]},automation:{group:`Automation`,defaultRoute:`/api/v1/automation`,endpoints:[{method:`POST`,path:`/trigger`,desc:`Trigger automation`,bodyTemplate:{name:``,params:{}}}]},i18n:{group:`i18n`,defaultRoute:`/api/v1/i18n`,endpoints:[{method:`GET`,path:`/locales`,desc:`Get available locales`},{method:`GET`,path:`/translations/:locale`,desc:`Get translations for locale`},{method:`GET`,path:`/labels/:object/:locale`,desc:`Get translated field labels`}]},ui:{group:`UI`,defaultRoute:`/api/v1/ui`,endpoints:[{method:`GET`,path:`/views`,desc:`List views`},{method:`GET`,path:`/views/:id`,desc:`Get view by ID`},{method:`POST`,path:`/views`,desc:`Create view`,bodyTemplate:{name:``,object:``,type:`list`}},{method:`PATCH`,path:`/views/:id`,desc:`Update view`,bodyTemplate:{name:``}},{method:`DELETE`,path:`/views/:id`,desc:`Delete view`}]},feed:{group:`Feed`,defaultRoute:`/api/v1/feed`,endpoints:[{method:`GET`,path:`/:object/:recordId`,desc:`Get feed items`},{method:`POST`,path:`/:object/:recordId`,desc:`Post feed item`,bodyTemplate:{body:``}}]},storage:{group:`Storage`,defaultRoute:`/api/v1/storage`,endpoints:[{method:`POST`,path:`/upload`,desc:`Upload file (multipart/form-data)`},{method:`GET`,path:`/:fileId`,desc:`Download file`},{method:`DELETE`,path:`/:fileId`,desc:`Delete file`}]}};function T(e,t){let n=w[e];return n?n.endpoints.map(e=>({method:e.method,path:`${t}${e.path}`,desc:e.desc,group:n.group,...e.bodyTemplate?{bodyTemplate:e.bodyTemplate}:{}})):[]}function te(){let e=r(),[t,n]=(0,x.useState)([]),[a,o]=(0,x.useState)([]),[s,c]=(0,x.useState)(!0),[l,u]=(0,x.useState)(null),d=(0,x.useCallback)(async()=>{c(!0),u(null);let t=`/api/v1`,r=`${t}/discovery`,a=[{method:`GET`,path:r,desc:`API Discovery`,group:`System`},{method:`GET`,path:`${t}/meta/types`,desc:`List metadata types`,group:`Metadata`},{method:`GET`,path:`${t}/packages`,desc:`List packages`,group:`System`},{method:`GET`,path:`/api/v1/health`,desc:`Health check`,group:`System`}];try{let s=`/api/v1/auth`,c={},l={};try{let e=await fetch(r);if(e.ok){let t=await e.json(),n=t?.data??t;l=n?.routes??{},c=n?.services??{},l.auth&&(s=l.auth)}}catch{}let u=[];for(let[e,t]of Object.entries(w)){let n=c[e],r=n?i(n):!1,a=n?.route??l[e]??t.defaultRoute;r&&u.push(...T(e,a))}let d=e?.getClient?.(),f=[];try{let e=await d?.meta?.getTypes?.();e&&Array.isArray(e.types)?f=e.types:Array.isArray(e)&&(f=e)}catch{}let p=[];try{let e=f.includes(`object`)?`object`:null;if(e&&d?.meta?.getItems){let t=await d.meta.getItems(e),n=[];Array.isArray(t)?n=t:t&&Array.isArray(t.items)?n=t.items:t&&Array.isArray(t.value)&&(n=t.value),p=n.map(e=>e.name||e.id).filter(Boolean)}}catch{}let m=p.flatMap(e=>{let n=e.startsWith(`sys_`)?`Data: system tables`:`Data: ${e}`;return[{method:`GET`,path:`${t}/data/${e}`,desc:`List ${e}`,group:n},{method:`POST`,path:`${t}/data/${e}`,desc:`Create ${e}`,group:n,bodyTemplate:{name:`example`}},{method:`GET`,path:`${t}/data/${e}/:id`,desc:`Get ${e} by ID`,group:n},{method:`PATCH`,path:`${t}/data/${e}/:id`,desc:`Update ${e}`,group:n,bodyTemplate:{name:`updated`}},{method:`DELETE`,path:`${t}/data/${e}/:id`,desc:`Delete ${e}`,group:n}]}),h=f.filter(e=>!S.includes(e)).map(e=>({method:`GET`,path:`${t}/meta/${e}`,desc:`List ${e} metadata`,group:`Metadata`})),g=p.map(e=>({method:`GET`,path:`${t}/meta/object/${e}`,desc:`${e} schema`,group:`Metadata`})),_=[...a,...C(s),...u,...h,...g,...m],v=new Map;for(let e of _){let t=v.get(e.group)||[];t.push(e),v.set(e.group,t)}let y=[`System`,`Auth`,`AI`,`Workflow`,`Realtime`,`Notifications`,`Analytics`,`Automation`,`i18n`,`UI`,`Feed`,`Storage`,`Metadata`],b=Array.from(v.entries()).sort(([e],[t])=>{let n=y.indexOf(e),r=y.indexOf(t);return n!==-1&&r!==-1?n-r:n===-1?r===-1?e.localeCompare(t):1:-1}).map(([e,t])=>({key:e,label:e,endpoints:t}));n(b),o(_)}catch(e){u(e.message||`Failed to discover APIs`)}finally{c(!1)}},[e]);return(0,x.useEffect)(()=>{d()},[d]),{groups:t,allEndpoints:a,loading:s,error:l,refresh:d}}var E=t(),D={GET:`text-emerald-600 bg-emerald-50 border-emerald-200 dark:text-emerald-400 dark:bg-emerald-950/50`,POST:`text-blue-600 bg-blue-50 border-blue-200 dark:text-blue-400 dark:bg-blue-950/50`,PATCH:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,PUT:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,DELETE:`text-red-600 bg-red-50 border-red-200 dark:text-red-400 dark:bg-red-950/50`},ne={2:`text-emerald-600 dark:text-emerald-400`,3:`text-blue-600 dark:text-blue-400`,4:`text-amber-600 dark:text-amber-400`,5:`text-red-600 dark:text-red-400`},re=[{key:`$top`,placeholder:`10`,hint:`limit`},{key:`$skip`,placeholder:`0`,hint:`offset`},{key:`$sort`,placeholder:`name`,hint:`sort field`},{key:`$select`,placeholder:`name,email`,hint:`fields`},{key:`$count`,placeholder:`true`,hint:`total count`},{key:`$filter`,placeholder:`status eq 'active'`,hint:`OData filter`}],O=1;function k(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:i}=te(),[S,C]=(0,x.useState)(``),[w,T]=(0,x.useState)(new Set),[k,A]=(0,x.useState)(null),[ie,j]=(0,x.useState)(``),[ae,M]=(0,x.useState)(``),[N,P]=(0,x.useState)(``),[F,I]=(0,x.useState)([]),[L,R]=(0,x.useState)(!1),[z,B]=(0,x.useState)(null),[V,H]=(0,x.useState)([]),[U,oe]=(0,x.useState)(null),[W,G]=(0,x.useState)(!1),K=(0,x.useMemo)(()=>{if(!S)return t;let e=S.toLowerCase();return t.map(t=>({...t,endpoints:t.endpoints.filter(t=>t.desc.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)||t.method.toLowerCase().includes(e))})).filter(e=>e.endpoints.length>0)},[t,S]),se=(0,x.useCallback)(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=(0,x.useCallback)(e=>{A(e),j(e.method),M(e.path),P(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),I([]),B(null)},[]),q=ie||k?.method||`GET`,J=ae||k?.path||``,Y=(0,x.useMemo)(()=>{let e=F.filter(e=>e.enabled&&e.key.trim());if(e.length===0)return J;let t=e.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join(`&`);return`${J}?${t}`},[J,F]),X=(0,x.useCallback)((e=``,t=``)=>{I(n=>[...n,{id:O++,key:e,value:t,enabled:!0}])},[]),le=(0,x.useCallback)(e=>{I(t=>t.filter(t=>t.id!==e))},[]),Z=(0,x.useCallback)((e,t,n)=>{I(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),ue=(0,x.useCallback)(e=>{I(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),Q=(0,x.useCallback)(async()=>{if(L||!Y)return;let t=`${e?.baseUrl??``}${Y}`;R(!0);let n=performance.now();try{let e={method:q,headers:{"Content-Type":`application/json`}};[`POST`,`PATCH`,`PUT`].includes(q)&&N.trim()&&(e.body=N);let r=await fetch(t,e),i=Math.round(performance.now()-n),a;if((r.headers.get(`content-type`)??``).includes(`json`)){let e=await r.json();a=JSON.stringify(e,null,2)}else a=await r.text();let o={status:r.status,body:a,duration:i};B(o),H(e=>[{id:Date.now(),method:q,url:Y,body:N||void 0,status:r.status,duration:i,response:a,timestamp:new Date},...e].slice(0,50))}catch(e){let t=Math.round(performance.now()-n);B({status:0,body:`Network Error: ${e.message}`,duration:t})}finally{R(!1)}},[e,Y,q,N,L]),de=(0,x.useCallback)(e=>{j(e.method);let[t,n]=e.url.split(`?`);if(M(t),P(e.body||``),n){let e=new URLSearchParams(n),t=[];e.forEach((e,n)=>{t.push({id:O++,key:n,value:e,enabled:!0})}),I(t)}else I([]);B(null),A(null)},[]),fe=(0,x.useCallback)(()=>{z?.body&&(navigator.clipboard.writeText(z.body),G(!0),setTimeout(()=>G(!1),1500))},[z]),$=e=>ne[String(e)[0]]??`text-muted-foreground`;return(0,E.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,E.jsx)(`button`,{onClick:i,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,E.jsx)(v,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,E.jsxs)(`div`,{className:`relative`,children:[(0,E.jsx)(o,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,E.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`Search endpoints...`,className:`w-full rounded-md border bg-background pl-8 pr-3 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]})]}),(0,E.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,E.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,E.jsx)(y,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):K.length===0?(0,E.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,E.jsx)(l,{className:`h-6 w-6 opacity-30 mb-2`}),(0,E.jsx)(`span`,{children:S?`No matching endpoints`:`No endpoints found`})]}):K.map(e=>{let t=w.has(e.key)||!!S;return(0,E.jsxs)(b,{open:t,onOpenChange:()=>se(e.key),children:[(0,E.jsx)(m,{asChild:!0,children:(0,E.jsxs)(`button`,{className:`w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors`,children:[(0,E.jsx)(_,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-90`:``}`}),(0,E.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e.label}),(0,E.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums opacity-60`,children:e.endpoints.length})]})}),(0,E.jsx)(g,{children:(0,E.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,E.jsxs)(`button`,{onClick:()=>ce(e),className:`w-full text-left flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${k===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,E.jsx)(a,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${D[e.method]||``}`,children:e.method}),(0,E.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,E.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,E.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,E.jsxs)(`button`,{onClick:()=>X(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,E.jsx)(p,{className:`h-3 w-3`}),`Add`]})]}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:re.map(e=>(0,E.jsx)(`button`,{onClick:()=>X(e.key,``),className:`text-[10px] px-1.5 py-0.5 rounded border bg-muted/30 text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors font-mono`,title:e.hint,children:e.key},e.key))}),F.length>0&&(0,E.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,E.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>ue(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,E.jsx)(`input`,{type:`text`,value:e.key,onChange:t=>Z(e.id,`key`,t.target.value),placeholder:`key`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,E.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>Z(e.id,`value`,t.target.value),placeholder:`value`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,E.jsx)(`button`,{onClick:()=>le(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,E.jsx)(s,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,E.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`select`,{value:q,onChange:e=>j(e.target.value),className:`rounded-md border bg-background px-2 py-1.5 font-mono text-xs font-semibold focus:outline-none focus:ring-1 focus:ring-ring ${D[q]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))}),(0,E.jsx)(`input`,{type:`text`,value:J,onChange:e=>M(e.target.value),className:`flex-1 rounded-md border bg-background px-3 py-1.5 font-mono text-sm focus:outline-none focus:ring-1 focus:ring-ring`,placeholder:`/api/v1/...`,onKeyDown:e=>{e.key===`Enter`&&Q()}}),(0,E.jsxs)(`button`,{onClick:Q,disabled:L||!Y,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:[L?(0,E.jsx)(y,{className:`h-3.5 w-3.5 animate-spin`}):(0,E.jsx)(u,{className:`h-3.5 w-3.5`}),`Send`]})]}),F.some(e=>e.enabled&&e.key.trim())&&(0,E.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,Y]})]}),(0,E.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(q)&&(0,E.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,E.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,E.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),rows:5,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-ring resize-y`,placeholder:`{ "key": "value" }`})]}),L&&(0,E.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,E.jsx)(y,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),z&&!L&&(0,E.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,E.jsx)(`span`,{className:`font-mono font-semibold ${$(z.status)}`,children:z.status||`ERR`}),(0,E.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,E.jsx)(c,{className:`h-3 w-3`}),z.duration,`ms`]})]}),(0,E.jsxs)(`button`,{onClick:fe,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[W?(0,E.jsx)(d,{className:`h-3 w-3`}):(0,E.jsx)(ee,{className:`h-3 w-3`}),W?`Copied`:`Copy`]})]}),(0,E.jsx)(`pre`,{className:`flex-1 overflow-auto p-3 text-xs font-mono bg-muted/10 whitespace-pre-wrap break-all`,children:z.body})]}),!z&&!L&&(0,E.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:(0,E.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,E.jsx)(l,{className:`h-10 w-10 mx-auto opacity-20`}),(0,E.jsxs)(`p`,{children:[`Select an endpoint or type a URL and click `,(0,E.jsx)(`strong`,{children:`Send`})]}),(0,E.jsx)(`p`,{className:`text-xs opacity-60`,children:`All registered APIs are auto-discovered from the platform`})]})}),V.length>0&&(0,E.jsxs)(`div`,{className:`border-t`,children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,E.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:[`History (`,V.length,`)`]}),(0,E.jsxs)(`button`,{onClick:()=>H([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,E.jsx)(f,{className:`h-3 w-3`}),`Clear`]})]}),(0,E.jsx)(`div`,{className:`space-y-0.5 px-2 pb-2 max-h-60 overflow-auto`,children:V.map(e=>(0,E.jsxs)(`div`,{className:`rounded border`,children:[(0,E.jsxs)(`button`,{onClick:()=>oe(U===e.id?null:e.id),className:`w-full flex items-center gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 transition-colors`,children:[U===e.id?(0,E.jsx)(h,{className:`h-3 w-3 shrink-0`}):(0,E.jsx)(_,{className:`h-3 w-3 shrink-0`}),(0,E.jsx)(a,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${D[e.method]||``}`,children:e.method}),(0,E.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,E.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${$(e.status)}`,children:e.status}),(0,E.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,E.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:`Replay request`,children:(0,E.jsx)(u,{className:`h-2.5 w-2.5`})})]}),U===e.id&&(0,E.jsx)(`pre`,{className:`px-3 py-2 text-xs font-mono bg-muted/10 border-t overflow-auto max-h-40 whitespace-pre-wrap break-all`,children:e.response})]},e.id))})]})]})]})]})}export{k as ApiConsolePage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,m as n,r,s as i,y as a}from"./vendor-react-DpRf6e0g.js";import{Ec as o,oo as s}from"./ui-components-BbC0qTrK.js";import{t as c}from"./DocShell-BhkelvR8.js";import{a as l,c as u,n as d}from"./use-book-data-CAZ23DZb.js";var f=e(a(),1),p=r();function m(){let{appName:e}=n(),{books:r,docs:a,state:m}=d(),h=(0,f.useMemo)(()=>r.filter(t=>u(t)===e),[r,e]),g=(0,f.useMemo)(()=>l(h,a),[h,a]);return m===`loading`?(0,p.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,p.jsx)(s,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):g.length===1?(0,p.jsx)(i,{to:`/apps/${e}/docs/${g[0].slug}`,replace:!0}):(0,p.jsx)(c,{children:(0,p.jsx)(`div`,{className:`mx-auto max-w-3xl p-4 sm:p-6`,children:g.length===0?(0,p.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16 text-center text-muted-foreground`,children:[(0,p.jsx)(o,{className:`h-10 w-10`}),(0,p.jsx)(`p`,{className:`text-sm`,children:`This app does not ship any documentation yet.`}),(0,p.jsx)(t,{to:`/docs`,className:`text-sm font-medium text-primary hover:underline`,children:`Browse all documentation`})]}):(0,p.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:g.map(n=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(t,{to:`/apps/${e}/docs/${n.slug}`,className:`flex h-full items-start gap-3 rounded-md border border-border p-3 hover:bg-muted/50`,children:[(0,p.jsx)(o,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,p.jsxs)(`div`,{className:`min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold`,children:n.label}),n.description?(0,p.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:n.description}):n.subtitle?(0,p.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground/70`,children:n.subtitle}):null,(0,p.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground/80`,children:[n.docCount,` `,n.docCount===1?`article`:`articles`]})]})]})},n.name))})})})}export{m as default};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,m as n,r,s as i,y as a}from"./vendor-react-DpRf6e0g.js";import{Ec as o,oo as s}from"./ui-components-BbC0qTrK.js";import{t as c}from"./DocShell-BhkelvR8.js";import{a as l,c as u,n as d}from"./use-book-data-D8LHn21q.js";var f=e(a(),1),p=r();function m(){let{appName:e}=n(),{books:r,docs:a,state:m}=d(),h=(0,f.useMemo)(()=>r.filter(t=>u(t)===e),[r,e]),g=(0,f.useMemo)(()=>l(h,a),[h,a]);return m===`loading`?(0,p.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,p.jsx)(s,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):g.length===1?(0,p.jsx)(i,{to:`/apps/${e}/docs/${g[0].slug}`,replace:!0}):(0,p.jsx)(c,{children:(0,p.jsx)(`div`,{className:`mx-auto max-w-3xl p-4 sm:p-6`,children:g.length===0?(0,p.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16 text-center text-muted-foreground`,children:[(0,p.jsx)(o,{className:`h-10 w-10`}),(0,p.jsx)(`p`,{className:`text-sm`,children:`This app does not ship any documentation yet.`}),(0,p.jsx)(t,{to:`/docs`,className:`text-sm font-medium text-primary hover:underline`,children:`Browse all documentation`})]}):(0,p.jsx)(`ul`,{className:`grid gap-3 sm:grid-cols-2`,children:g.map(n=>(0,p.jsx)(`li`,{children:(0,p.jsxs)(t,{to:`/apps/${e}/docs/${n.slug}`,className:`flex h-full items-start gap-3 rounded-md border border-border p-3 hover:bg-muted/50`,children:[(0,p.jsx)(o,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,p.jsxs)(`div`,{className:`min-w-0`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold`,children:n.label}),n.description?(0,p.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:n.description}):n.subtitle?(0,p.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground/70`,children:n.subtitle}):null,(0,p.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground/80`,children:[n.docCount,` `,n.docCount===1?`article`:`articles`]})]})]})},n.name))})})})}export{m as default};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{f as t,m as n,r,y as i}from"./vendor-react-DpRf6e0g.js";import{P as a}from"./framework-UESyszCj.js";import{Cr as o,Di as s,Ji as c,Pi as l,Sa as u,Tn as d,_r as f,di as p,fi as m,go as h,gr as g,ha as _,pi as v,ps as y,vr as b,zr as x}from"./ui-components-BbC0qTrK.js";import{r as S}from"./vendor-ui-utils-CnzHPXVC.js";import"./src-D0ueU0ix.js";var C=e(i(),1);function w(e,t){if(e!=null){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}}var T=r();function E(){let e=t(),{appName:r}=n(),i=r?`/apps/${r}`:``,{apps:E,refresh:D}=a(),[O,k]=(0,C.useState)(``),[A,j]=(0,C.useState)(new Set),[M,N]=(0,C.useState)(null),[P,F]=(0,C.useState)(!1),I=(E||[]).filter(e=>{if(!O)return!0;let t=O.toLowerCase();return(e.name||``).toLowerCase().includes(t)||(e.label||``).toLowerCase().includes(t)||(e.description||``).toLowerCase().includes(t)}),L=(0,C.useCallback)(e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),R=(0,C.useCallback)(()=>{A.size===I.length?j(new Set):j(new Set(I.map(e=>e.name)))},[A.size,I]),z=(0,C.useCallback)(async e=>{F(!0);try{let t=e.active===!1;S.success(`${e.label||e.name} ${t?`enabled`:`disabled`}`),await D()}catch{S.error(`Failed to toggle app status`)}finally{F(!1)}},[D]),B=(0,C.useCallback)(async e=>{F(!0);try{S.success(`${e.label||e.name} set as default`),await D()}catch{S.error(`Failed to set default app`)}finally{F(!1)}},[D]),V=(0,C.useCallback)(async e=>{if(M!==e.name){N(e.name);return}F(!0);try{S.success(`${e.label||e.name} deleted`),N(null),await D()}catch{S.error(`Failed to delete app`)}finally{F(!1)}},[M,D]),H=(0,C.useCallback)(async e=>{F(!0);try{S.success(`${A.size} apps ${e?`enabled`:`disabled`}`),j(new Set),await D()}catch{S.error(`Bulk operation failed`)}finally{F(!1)}},[A,D]);return(0,T.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Applications`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage all configured applications`})]}),(0,T.jsxs)(x,{onClick:()=>e(`${i}/create-app`),"data-testid":`create-app-btn`,children:[(0,T.jsx)(_,{className:`h-4 w-4 mr-2`}),`New App`]})]}),(0,T.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[(0,T.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,T.jsx)(`label`,{htmlFor:`app-search`,className:`sr-only`,children:`Search apps`}),(0,T.jsx)(c,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,T.jsx)(d,{id:`app-search`,placeholder:`Search apps...`,value:O,onChange:e=>k(e.target.value),className:`pl-8`,"data-testid":`app-search-input`})]}),A.size>0&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsxs)(o,{variant:`secondary`,children:[A.size,` selected`]}),(0,T.jsx)(x,{variant:`outline`,size:`sm`,onClick:()=>H(!0),disabled:P,children:`Enable`}),(0,T.jsx)(x,{variant:`outline`,size:`sm`,onClick:()=>H(!1),disabled:P,children:`Disable`})]})]}),I.length>0&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,T.jsx)(g,{id:`select-all-apps`,checked:A.size===I.length&&I.length>0,onCheckedChange:()=>R()}),(0,T.jsxs)(`label`,{htmlFor:`select-all-apps`,className:`cursor-pointer`,children:[`Select all (`,I.length,`)`]})]}),I.length===0?(0,T.jsxs)(`div`,{className:`text-center py-12 text-muted-foreground`,"data-testid":`no-apps-message`,children:[(0,T.jsx)(h,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,T.jsx)(`p`,{children:`No apps found.`})]}):(0,T.jsx)(`div`,{className:`grid gap-3`,children:I.map(t=>{let n=t.active!==!1,r=t.isDefault===!0,a=M===t.name;return(0,T.jsx)(f,{className:n?``:`opacity-60`,"data-testid":`app-card-${t.name}`,children:(0,T.jsxs)(b,{className:`flex items-center gap-3 py-3 px-4`,children:[(0,T.jsx)(g,{id:`select-app-${t.name}`,checked:A.has(t.name),onCheckedChange:()=>L(t.name),"aria-label":`Select ${t.label||t.name}`,className:`shrink-0`}),(0,T.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,T.jsx)(h,{className:`h-4 w-4`})}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`font-medium truncate`,children:w(t.label)||t.name}),r&&(0,T.jsx)(o,{variant:`default`,className:`text-xs`,children:`Default`}),(0,T.jsx)(o,{variant:n?`secondary`:`outline`,className:`text-xs`,children:n?`Active`:`Inactive`})]}),t.description&&(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:w(t.description)})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:`Open app`,"aria-label":`Open ${t.label||t.name}`,onClick:()=>e(`/apps/${t._packageId??t.name}`),children:(0,T.jsx)(y,{className:`h-4 w-4`})}),(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:`Edit app`,"aria-label":`Edit ${t.label||t.name}`,onClick:()=>e(`${i}/edit-app/${t.name}`),children:(0,T.jsx)(u,{className:`h-4 w-4`})}),t._packageId?(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:`Edit with AI`,"aria-label":`Edit ${t.label||t.name} with AI`,onClick:()=>e(`/ai/build?package=${encodeURIComponent(t._packageId)}&new=1`),children:(0,T.jsx)(l,{className:`h-4 w-4`})}):null,(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:n?`Disable app`:`Enable app`,"aria-label":n?`Disable ${t.label||t.name}`:`Enable ${t.label||t.name}`,onClick:()=>z(t),disabled:P,children:n?(0,T.jsx)(m,{className:`h-4 w-4`}):(0,T.jsx)(v,{className:`h-4 w-4`})}),(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:`Set as default`,"aria-label":`Set ${t.label||t.name} as default`,onClick:()=>B(t),disabled:P||r,children:(0,T.jsx)(s,{className:`h-4 w-4 ${r?`fill-current text-yellow-500`:``}`})}),(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:a?`Click again to confirm delete`:`Delete app`,"aria-label":a?`Confirm delete ${t.label||t.name}`:`Delete ${t.label||t.name}`,onClick:()=>V(t),disabled:P,className:a?`text-destructive`:``,children:(0,T.jsx)(p,{className:`h-4 w-4`})})]})]})},t.name)})})]})}export{E as AppManagementPage};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{f as t,m as n,r,y as i}from"./vendor-react-DpRf6e0g.js";import{P as a}from"./framework-UESyszCj.js";import{Cr as o,Di as s,Ji as c,Pi as l,Sa as u,Tn as d,_r as f,di as p,fi as m,go as h,gr as g,ha as _,pi as v,ps as y,vr as b,zr as x}from"./ui-components-BbC0qTrK.js";import{r as S}from"./vendor-ui-utils-CnzHPXVC.js";import"./src-CSrGzA_t.js";var C=e(i(),1);function w(e,t){if(e!=null){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}}var T=r();function E(){let e=t(),{appName:r}=n(),i=r?`/apps/${r}`:``,{apps:E,refresh:D}=a(),[O,k]=(0,C.useState)(``),[A,j]=(0,C.useState)(new Set),[M,N]=(0,C.useState)(null),[P,F]=(0,C.useState)(!1),I=(E||[]).filter(e=>{if(!O)return!0;let t=O.toLowerCase();return(e.name||``).toLowerCase().includes(t)||(e.label||``).toLowerCase().includes(t)||(e.description||``).toLowerCase().includes(t)}),L=(0,C.useCallback)(e=>{j(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),R=(0,C.useCallback)(()=>{A.size===I.length?j(new Set):j(new Set(I.map(e=>e.name)))},[A.size,I]),z=(0,C.useCallback)(async e=>{F(!0);try{let t=e.active===!1;S.success(`${e.label||e.name} ${t?`enabled`:`disabled`}`),await D()}catch{S.error(`Failed to toggle app status`)}finally{F(!1)}},[D]),B=(0,C.useCallback)(async e=>{F(!0);try{S.success(`${e.label||e.name} set as default`),await D()}catch{S.error(`Failed to set default app`)}finally{F(!1)}},[D]),V=(0,C.useCallback)(async e=>{if(M!==e.name){N(e.name);return}F(!0);try{S.success(`${e.label||e.name} deleted`),N(null),await D()}catch{S.error(`Failed to delete app`)}finally{F(!1)}},[M,D]),H=(0,C.useCallback)(async e=>{F(!0);try{S.success(`${A.size} apps ${e?`enabled`:`disabled`}`),j(new Set),await D()}catch{S.error(`Bulk operation failed`)}finally{F(!1)}},[A,D]);return(0,T.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Applications`}),(0,T.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage all configured applications`})]}),(0,T.jsxs)(x,{onClick:()=>e(`${i}/create-app`),"data-testid":`create-app-btn`,children:[(0,T.jsx)(_,{className:`h-4 w-4 mr-2`}),`New App`]})]}),(0,T.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[(0,T.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,T.jsx)(`label`,{htmlFor:`app-search`,className:`sr-only`,children:`Search apps`}),(0,T.jsx)(c,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,T.jsx)(d,{id:`app-search`,placeholder:`Search apps...`,value:O,onChange:e=>k(e.target.value),className:`pl-8`,"data-testid":`app-search-input`})]}),A.size>0&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsxs)(o,{variant:`secondary`,children:[A.size,` selected`]}),(0,T.jsx)(x,{variant:`outline`,size:`sm`,onClick:()=>H(!0),disabled:P,children:`Enable`}),(0,T.jsx)(x,{variant:`outline`,size:`sm`,onClick:()=>H(!1),disabled:P,children:`Disable`})]})]}),I.length>0&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,T.jsx)(g,{id:`select-all-apps`,checked:A.size===I.length&&I.length>0,onCheckedChange:()=>R()}),(0,T.jsxs)(`label`,{htmlFor:`select-all-apps`,className:`cursor-pointer`,children:[`Select all (`,I.length,`)`]})]}),I.length===0?(0,T.jsxs)(`div`,{className:`text-center py-12 text-muted-foreground`,"data-testid":`no-apps-message`,children:[(0,T.jsx)(h,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,T.jsx)(`p`,{children:`No apps found.`})]}):(0,T.jsx)(`div`,{className:`grid gap-3`,children:I.map(t=>{let n=t.active!==!1,r=t.isDefault===!0,a=M===t.name;return(0,T.jsx)(f,{className:n?``:`opacity-60`,"data-testid":`app-card-${t.name}`,children:(0,T.jsxs)(b,{className:`flex items-center gap-3 py-3 px-4`,children:[(0,T.jsx)(g,{id:`select-app-${t.name}`,checked:A.has(t.name),onCheckedChange:()=>L(t.name),"aria-label":`Select ${t.label||t.name}`,className:`shrink-0`}),(0,T.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,T.jsx)(h,{className:`h-4 w-4`})}),(0,T.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`span`,{className:`font-medium truncate`,children:w(t.label)||t.name}),r&&(0,T.jsx)(o,{variant:`default`,className:`text-xs`,children:`Default`}),(0,T.jsx)(o,{variant:n?`secondary`:`outline`,className:`text-xs`,children:n?`Active`:`Inactive`})]}),t.description&&(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:w(t.description)})]}),(0,T.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:`Open app`,"aria-label":`Open ${t.label||t.name}`,onClick:()=>e(`/apps/${t._packageId??t.name}`),children:(0,T.jsx)(y,{className:`h-4 w-4`})}),(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:`Edit app`,"aria-label":`Edit ${t.label||t.name}`,onClick:()=>e(`${i}/edit-app/${t.name}`),children:(0,T.jsx)(u,{className:`h-4 w-4`})}),t._packageId?(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:`Edit with AI`,"aria-label":`Edit ${t.label||t.name} with AI`,onClick:()=>e(`/ai/build?package=${encodeURIComponent(t._packageId)}&new=1`),children:(0,T.jsx)(l,{className:`h-4 w-4`})}):null,(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:n?`Disable app`:`Enable app`,"aria-label":n?`Disable ${t.label||t.name}`:`Enable ${t.label||t.name}`,onClick:()=>z(t),disabled:P,children:n?(0,T.jsx)(m,{className:`h-4 w-4`}):(0,T.jsx)(v,{className:`h-4 w-4`})}),(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:`Set as default`,"aria-label":`Set ${t.label||t.name} as default`,onClick:()=>B(t),disabled:P||r,children:(0,T.jsx)(s,{className:`h-4 w-4 ${r?`fill-current text-yellow-500`:``}`})}),(0,T.jsx)(x,{variant:`ghost`,size:`icon`,title:a?`Click again to confirm delete`:`Delete app`,"aria-label":a?`Confirm delete ${t.label||t.name}`:`Delete ${t.label||t.name}`,onClick:()=>V(t),disabled:P,className:a?`text-destructive`:``,children:(0,T.jsx)(p,{className:`h-4 w-4`})})]})]})},t.name)})})]})}export{E as AppManagementPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,h as n,m as r,r as i,y as a}from"./vendor-react-DpRf6e0g.js";import{_ as o,b as s,y as ee}from"./infrastructure-PXm1h5tB.js";import{Ar as te,At as ne,Cr as c,Dr as re,Fr as ie,Ft as l,Gc as u,Ic as ae,Ir as oe,It as d,Ji as se,Jr as ce,Kr as le,Lr as ue,Ls as de,Lt as fe,Mi as pe,Mr as me,Ms as he,Mt as ge,Nr as _e,Nt as ve,Or as ye,Pr as be,Pt as xe,Rr as Se,Rs as Ce,Rt as we,Tn as Te,Xs as Ee,_n as De,_r as Oe,ac as ke,an as f,cn as Ae,ct as je,dn as Me,dt as Ne,fn as Pe,gn as Fe,gr as Ie,hn as p,jr as Le,jt as Re,kt as ze,ln as Be,mn as Ve,nc as He,nl as Ue,oa as We,pn as Ge,ps as Ke,qi as qe,qs as Je,rc as Ye,sn as Xe,st as Ze,ti as Qe,un as $e,vr as et,wa as tt,ws as nt,zr as m}from"./ui-components-BbC0qTrK.js";import{r as h}from"./vendor-ui-utils-CnzHPXVC.js";import{p as rt}from"./src-D0ueU0ix.js";var g=e(a(),1),it=`${``.replace(/\/$/,``)}/api/v1`;async function _(e,t){let n=s.get(),r=await fetch(`${it}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...n?{Authorization:`Bearer ${n}`}:{},...t?.headers||{}},...t}),i=null;try{i=await r.json()}catch{}if(!r.ok){let e=i?.code??`HTTP_${r.status}`,t=i?.message??i?.error??r.statusText,n=Error(`${e}: ${t}`);throw n.code=e,n.status=r.status,n.details=i,n}return i}var v={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return _(`/approvals/processes${n?`?${n}`:``}`)},listRequests(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.object&&t.set(`object`,e.object),e.recordId&&t.set(`recordId`,e.recordId);let n=Array.isArray(e.approverId)?e.approverId.filter(Boolean).join(`,`):e.approverId;n&&t.set(`approverId`,n),e.submitterId&&t.set(`submitterId`,e.submitterId),e.q?.trim()&&t.set(`q`,e.q.trim()),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let r=t.toString();return _(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await _(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return _(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/approve`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async reject(e,t){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/reject`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async recall(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/remind`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,notified:n.notified}},async requestInfo(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/revise`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,autoRejected:n.autoRejected===!0}},async resubmit(e,t={}){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/resubmit`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,resumed:n.resumed===!0}},async comment(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return _(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function at(e){if(!e)return[];let t=new Set;e.id&&t.add(e.id),e.email&&t.add(e.email);let n=[...e.roles||[],...typeof e.role==`string`?e.role.split(`,`):[]];for(let e of n){let n=String(e).trim();n&&t.add(`role:${n}`)}return Array.from(t)}var y=i(),ot=50,b={pending:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400`,approved:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-400`,rejected:`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`,recalled:`border-border bg-muted text-muted-foreground`,returned:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-400`};function st({status:e,label:t}){return(0,y.jsx)(c,{variant:`outline`,className:u(`font-medium`,b[e]??``),children:t})}function ct(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function x(e){return e?e.includes(`@`)?e:e.startsWith(`role:`)?`Role: ${e.slice(5)}`:e.length>14?`${e.slice(0,6)}…${e.slice(-4)}`:e:`—`}function S(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function C(e){return e.process_label||S(e.process_name)}function lt(e){return e.step_label?e.step_label:e.current_step?S(e.current_step):null}function ut(e){return e.submitter_name||x(e.submitter_id)}function dt(e,t){return t.pending_approver_names?.[e]||x(e)}function w(e,t){let n=t.pending_approver_groups?.[e];return n&&n.length?n.join(` / `):void 0}function ft(e){let t=[],n=new Map;for(let r of e.pending_approvers||[]){let i=dt(r,e),a=w(r,e),o=a?`${i} ${a}`:i,s=n.get(o);s?(s.count+=1,r&&!s.title.split(`, `).includes(r)&&(s.title+=`, ${r}`)):(n.set(o,{label:i,group:a,count:1,title:r||i}),t.push(o))}return t.map(e=>n.get(e))}function pt(e){if(e.submitter_name)return!1;let t=(e.submitter_id||``).trim();return!t||t.startsWith(`flow:`)||t.startsWith(`system:`)}function mt(e){return e.object_label||e.object_name}function T(e){return e.submitted_at||e.created_at||void 0}function ht(e,t){let n=T(e);if(!n)return null;let r=Date.parse(n);return Number.isNaN(r)?null:(t-r)/36e5}function gt(e,t){if(e.status!==`pending`)return`text-muted-foreground`;let n=ht(e,t);return n==null?`text-muted-foreground`:n>72?`text-red-600 dark:text-red-400 font-medium`:n>24?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function _t(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}function vt(e,t){if(!e)return null;let n=Date.parse(e);return Number.isNaN(n)?null:{overdue:n<t,ms:Math.abs(t-n)}}var E=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function D(e){let t=e.split(`_`).filter(Boolean);return t.length>1&&t[t.length-1].toLowerCase()===`id`&&t.pop(),t.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function O(e,t){if(typeof t==`boolean`)return t?`✓`:`—`;if(typeof t==`number`){if(t>0xe8d4a51000&&/(_at$|_date$|^date_|_time$)/.test(e))try{return new Date(t).toLocaleDateString()}catch{}return t.toLocaleString()}let n=String(t);if(/^\d{4}-\d{2}-\d{2}T\d{2}/.test(n))try{return new Date(n).toLocaleString()}catch{}return n}var yt=/^[A-Za-z0-9_-]{15,}$/;function bt(e,t,n,r=6,i){if(!e||typeof e!=`object`||Array.isArray(e))return[];let a=[];for(let[o,s]of Object.entries(e)){if(E.has(o)||i&&o===i||s==null||typeof s==`object`||String(s).trim()===``)continue;let e=t?.[o];if(!(!e&&typeof s==`string`&&yt.test(s.trim())&&!/^\d+$/.test(s.trim()))&&(a.push([n?.[o]??D(o),e??O(o,s)]),a.length>=r))break}return a}var xt=/(amount|total|price|value|cost|sum|budget|salary|fee|revenue|balance|金额|总额|价格|费用|预算|金额)/i;function k(e){let t=e.payload;if(!t||typeof t!=`object`||Array.isArray(t))return null;for(let[n,r]of Object.entries(t)){if(E.has(n)||!xt.test(n))continue;let t=typeof r==`number`?r:typeof r==`string`&&r.trim()!==``&&Number.isFinite(Number(r))?Number(r):null;if(!(t==null||!Number.isFinite(t)))return{key:n,label:e.payload_labels?.[n]??D(n),value:t,display:e.payload_display?.[n]??t.toLocaleString()}}return null}function A(){let{t:e,language:i}=Ue(),{user:a}=o(),{appName:s}=r(),[it,_]=n(),b=(0,g.useMemo)(()=>at(a),[a]),S=(0,g.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),[w,ht]=(0,g.useState)(()=>Date.now());(0,g.useEffect)(()=>{let e=setInterval(()=>ht(Date.now()),6e4);return()=>clearInterval(e)},[]);let E=(0,g.useCallback)(e=>{if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Math.round((w-t)/1e3);if(n<45)return S(`justNow`,`just now`);let r=Math.round(n/60);if(r<60)return S(`minutesAgo`,`{{count}}m ago`,{count:r});let a=Math.round(r/60);if(a<24)return S(`hoursAgo`,`{{count}}h ago`,{count:a});let o=Math.round(a/24);if(o<30)return S(`daysAgo`,`{{count}}d ago`,{count:o});try{return new Date(e).toLocaleDateString(i)}catch{return e}},[S,i,w]),D=(0,g.useCallback)(e=>{switch(e){case`pending`:return S(`statusPending`,`Pending`);case`approved`:return S(`statusApproved`,`Approved`);case`rejected`:return S(`statusRejected`,`Rejected`);case`recalled`:return S(`statusRecalled`,`Recalled`);case`returned`:return S(`statusReturned`,`Returned for revision`);default:return e}},[S]),O=(0,g.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?S(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?S(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?S(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?S(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?S(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[S]),yt=(0,g.useCallback)(e=>e.overdue?S(`slaOverdue`,`SLA overdue {{dur}}`,{dur:_t(e.ms)}):S(`slaRemaining`,`SLA {{dur}} left`,{dur:_t(e.ms)}),[S]),xt=(0,g.useCallback)(e=>`/apps/${s||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[s]),[A,St]=(0,g.useState)(`pending`),[j,Ct]=(0,g.useState)([]),[wt,Tt]=(0,g.useState)(!1),[Et,Dt]=(0,g.useState)(!1),[Ot,M]=(0,g.useState)(null),[kt,At]=(0,g.useState)(null),[jt,Mt]=(0,g.useState)(0),[N,Nt]=(0,g.useState)(null),[P,F]=(0,g.useState)(null),[Pt,I]=(0,g.useState)([]),[Ft,It]=(0,g.useState)(!1),Lt=(0,g.useMemo)(()=>ee(),[]),Rt=(0,g.useCallback)(async e=>{let t=window.open(``,`_blank`,`noopener`);try{let n=``.replace(/\/$/,``),r=await Lt(`${n}/api/v1/storage/files/${encodeURIComponent(e.id)}/url`);if(!r.ok)throw Error(`HTTP_${r.status}`);let i=await r.json().catch(()=>null),a=i?.data?.url??i?.url;if(!a)throw Error(`NO_URL`);let o=/^https?:\/\//i.test(a)?a:`${n}${a}`;t?t.location.href=o:window.open(o,`_blank`,`noopener`)}catch{t?.close(),h.error(S(`attachmentOpenFailed`,`Could not open the attachment — please try again`))}},[Lt,S]),[L,zt]=(0,g.useState)(``),[R,Bt]=(0,g.useState)(``),[z,Vt]=(0,g.useState)(`all`),[B,Ht]=(0,g.useState)(`all`),[V,Ut]=(0,g.useState)(`all`),[Wt,Gt]=(0,g.useState)(`recent`),[H,Kt]=(0,g.useState)(new Set),[qt,Jt]=(0,g.useState)(!1),[U,Yt]=(0,g.useState)(null),[W,Xt]=(0,g.useState)(null),[Zt,Qt]=(0,g.useState)(null),[G,$t]=(0,g.useState)(``),[en,tn]=(0,g.useState)(!1),[nn,rn]=(0,g.useState)(-1);(0,g.useEffect)(()=>{if(A===`pending`)return;let e=window.setTimeout(()=>Bt(L),350);return()=>window.clearTimeout(e)},[L,A]);let K=(0,g.useCallback)(async()=>{Tt(!0),At(null);try{let e=[];if(A===`pending`)e=b.length?(await v.listRequests({status:`pending`,approverId:b})).data:[],Mt(e.length),M(null);else{let t={q:R||void 0,status:V===`all`?void 0:V,limit:ot,offset:0};if(A===`submitted`){let n=a?.id;if(n){let r=await v.listRequests({submitterId:n,...t});e=r.data,M(r.total??r.data.length)}else e=[],M(0)}else{let n=await v.listRequests(t);e=n.data,M(n.total??n.data.length)}b.length&&v.listRequests({status:`pending`,approverId:b}).then(e=>Mt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(T(t)||``).localeCompare(T(e)||``)),Ct(e)}catch(e){At(e?.message||String(e)),Ct([])}finally{Tt(!1)}},[A,b,a?.id,R,V]);(0,g.useEffect)(()=>{K()},[K]);let an=(0,g.useCallback)(async()=>{if(!(A===`pending`||Et)){Dt(!0);try{let e=await v.listRequests({submitterId:A===`submitted`?a?.id??void 0:void 0,q:R||void 0,status:V===`all`?void 0:V,limit:ot,offset:j.length});Ct(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&M(e.total)}catch(e){h.error(O(e,S(`loadFailed`,`Failed to load request`)))}finally{Dt(!1)}}},[A,Et,a?.id,R,V,j.length,O,S]),q=(0,g.useCallback)(async e=>{Nt(e),It(!0);try{let[t,n]=await Promise.all([v.getRequest(e),v.listActions(e)]);F(t.data),I(n.data)}catch(e){h.error(O(e,S(`loadFailed`,`Failed to load request`))),F(null),I([])}finally{It(!1)}},[O,S]),on=()=>{Nt(null),F(null),I([])};(0,g.useEffect)(()=>{let e=it.get(`request`);e&&(_(e=>{let t=new URLSearchParams(e);return t.delete(`request`),t},{replace:!0}),q(e))},[it]);let J=(0,g.useCallback)(()=>{b.length&&v.listRequests({status:`pending`,approverId:b}).then(e=>Mt(e.data.length)).catch(()=>{})},[b]),sn=(0,g.useCallback)(async e=>{let[t,n]=await Promise.all([v.getRequest(e),v.listActions(e)]);F(t.data),I(n.data),K()},[K]),cn=(0,g.useCallback)(async()=>{if(!P)return;let e=P.id;try{let[t,n]=await Promise.all([v.getRequest(e),v.listActions(e)]);F(t.data),I(n.data),K();let r=new Set(t.data.pending_approvers||[]),i=t.data.status===`pending`&&b.some(e=>r.has(e));if(A===`pending`&&!i){let t=Cn.current,n=t.findIndex(t=>t.id===e),r=t[n+1]??t[n-1];if(r&&r.id!==e){q(r.id);return}on()}}catch{sn(e)}},[P,b,A,K,q,on,sn]),ln=(0,g.useCallback)(async()=>{if(!(!P||!G.trim())){tn(!0);try{await v.comment(P.id,{actor_id:a?.id,comment:G.trim()}),$t(``),await sn(P.id)}catch(e){h.error(O(e,S(`actionFailed`,`Action failed`)))}finally{tn(!1)}}},[P,G,a?.id,sn,O,S]),un=(0,g.useMemo)(()=>{if(!P||P.status!==`pending`)return!1;if(P.viewer)return P.viewer.can_act||!!P.viewer.can_override;let e=new Set(P.pending_approvers||[]);return b.some(t=>e.has(t))},[P,b]),dn=(0,g.useMemo)(()=>!P||P.status!==`pending`?!1:P.viewer?P.viewer.is_submitter:P.submitter_id===a?.id,[P,a?.id]),fn=(0,g.useMemo)(()=>!P||P.status!==`returned`?!1:P.viewer?P.viewer.is_submitter:P.submitter_id===a?.id,[P,a?.id]),pn=(0,g.useMemo)(()=>{let e=new Set;for(let t of j)e.add(C(t));return Array.from(e).sort()},[j]),mn=(0,g.useMemo)(()=>{let e=new Set;for(let t of j)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[j]),Y=(0,g.useMemo)(()=>{let e=L.trim().toLowerCase(),t=j.filter(t=>z!==`all`&&C(t)!==z||B!==`all`&&t.object_name!==B||V!==`all`&&t.status!==V?!1:A!==`pending`||!e||[t.process_name,t.process_label,t.step_label,t.object_name,t.record_id,t.record_title,t.submitter_id,t.submitter_name,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e));if(Wt===`recent`)return t;let n=[...t];return Wt===`amount`?n.sort((e,t)=>{let n=k(e)?.value,r=k(t)?.value;return n==null&&r==null?0:n==null?1:r==null?-1:r-n}):n.sort((e,t)=>(T(e)||``).localeCompare(T(t)||``)),n},[j,L,z,B,V,A,Wt]),X=(0,g.useMemo)(()=>N?Y.findIndex(e=>e.id===N):-1,[Y,N]);(0,g.useEffect)(()=>{if(H.size===0)return;let e=new Set(Y.map(e=>e.id)),t=!1,n=new Set;for(let r of H)e.has(r)?n.add(r):t=!0;t&&Kt(n)},[Y,H]),(0,g.useEffect)(()=>{nn>=Y.length&&rn(Y.length-1)},[Y.length,nn]);let hn=(0,g.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(b);return(e.pending_approvers||[]).some(e=>t.has(e))},[b]),Z=(0,g.useCallback)(e=>Array.isArray(e.decision_outputs)&&e.decision_outputs.length>0,[]),gn=(0,g.useCallback)(e=>hn(e)&&!Z(e),[hn,Z]),Q=(0,g.useMemo)(()=>Y.filter(e=>H.has(e.id)&&gn(e)),[Y,H,gn]),$=Y.filter(e=>e.status===`pending`),_n=$.length>0&&$.every(e=>H.has(e.id)),vn=(0,g.useCallback)(()=>{Kt(e=>{if(_n)return new Set;let t=new Set(e);for(let e of $)t.add(e.id);return t})},[_n,$]),yn=(0,g.useCallback)(e=>{Kt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),bn=(0,g.useCallback)(async e=>{let t=Q;if(t.length===0)return;Jt(!0);let n=0,r=[];for(let i of t){let t=new Set(i.pending_approvers||[]),o=b.find(e=>t.has(e))||a?.id||``;try{await(e===`approve`?v.approve:v.reject)(i.id,{actor_id:o}),n++}catch{r.push(i.record_title||x(i.record_id))}}if(Jt(!1),Kt(new Set),r.length===0)h.success(e===`approve`?S(`bulkApproved`,`Approved {{count}} requests`,{count:n}):S(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);h.error(S(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),J()},[Q,b,a?.id,K,J,S]),xn=(0,g.useCallback)(async()=>{let e=U;if(!e)return;let t=new Set(e.pending_approvers||[]),n=b.find(e=>t.has(e))||a?.id||``;Qt(e.id),Yt(null);try{let t=await v.approve(e.id,{actor_id:n});h.success(t.finalized?S(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||x(e.record_id)}):S(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),J()}catch(e){h.error(O(e,S(`actionFailed`,`Action failed`)))}finally{Qt(null)}},[U,b,a?.id,K,J,O,S]),Sn=(0,g.useCallback)(async()=>{let e=W;if(!e)return;let t=new Set(e.pending_approvers||[]),n=b.find(e=>t.has(e))||a?.id||``;Qt(e.id),Xt(null);try{await v.reject(e.id,{actor_id:n}),h.success(S(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||x(e.record_id)})),K(),J()}catch(e){h.error(O(e,S(`actionFailed`,`Action failed`)))}finally{Qt(null)}},[W,b,a?.id,K,J,O,S]),Cn=(0,g.useRef)(Y);Cn.current=Y;let wn=(0,g.useRef)(nn);wn.current=nn,(0,g.useEffect)(()=>{let e=e=>{if(N||U||W)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Cn.current;if(!r.length)return;let i=wn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),rn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),rn(Math.max(i-1,0))):e.key===`Enter`&&i>=0&&r[i]?(e.preventDefault(),q(r[i].id)):(e.key===`x`||e.key===` `)&&i>=0&&r[i]&&A===`pending`?(e.preventDefault(),yn(r[i].id)):e.key===`a`&&i>=0&&r[i]&&gn(r[i])?(e.preventDefault(),Yt(r[i])):e.key===`r`&&i>=0&&r[i]&&gn(r[i])&&(e.preventDefault(),Xt(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,U,W,A,q,yn,gn]),(0,g.useEffect)(()=>{if(!N)return;let e=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Cn.current,i=r.findIndex(e=>e.id===N);if(i<0)return;let a=e.key===`ArrowLeft`?r[i-1]:r[i+1];a&&(e.preventDefault(),q(a.id))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,q]);let Tn=!!L||z!==`all`||B!==`all`||V!==`all`,En=e=>{St(e),Ut(`all`),Vt(`all`),Ht(`all`),zt(``),Gt(`recent`),rn(-1)};function Dn({r:e}){return(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`div`,{className:`font-medium truncate`,children:C(e)}),(0,y.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[lt(e)||`—`,(e.round??1)>1&&(0,y.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:S(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function On({r:e}){let n=k(e);return(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(t,{to:xt(e),onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-sm hover:underline truncate max-w-full`,title:e.record_id,children:[(0,y.jsx)(`span`,{className:`truncate`,children:e.record_title||x(e.record_id)}),(0,y.jsx)(Ke,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,y.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[mt(e),n&&(0,y.jsxs)(`span`,{className:`ml-1.5 font-medium text-foreground`,title:`${n.label}: ${n.display}`,children:[`· `,n.display]})]})]})}function kn({r:e}){if(!hn(e))return null;let t=Zt===e.id,n=Z(e),r=S(`needsDecisionInputs`,`This approval collects decision outputs — open it to decide.`);return(0,y.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),title:n?r:void 0,children:[(0,y.jsx)(m,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-emerald-700 hover:text-emerald-800 hover:bg-emerald-50 dark:text-emerald-400`,disabled:t||n,onClick:()=>Yt(e),"aria-label":n?r:S(`approve`,`Approve`),children:(0,y.jsx)(Je,{className:`h-4 w-4`})}),(0,y.jsx)(m,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400`,disabled:t||n,onClick:()=>Xt(e),"aria-label":n?r:S(`reject`,`Reject`),children:(0,y.jsx)(Ce,{className:`h-4 w-4`})})]})}return(0,y.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,y.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,y.jsx)(pe,{className:`h-6 w-6`}),S(`title`,`Approvals Inbox`)]}),(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:S(`subtitle`,`Review and act on approval requests.`)})]}),(0,y.jsxs)(m,{variant:`outline`,size:`sm`,onClick:K,disabled:wt,className:`self-start sm:self-auto`,children:[(0,y.jsx)(We,{className:`h-4 w-4 mr-2 ${wt?`animate-spin`:``}`}),S(`refresh`,`Refresh`)]})]}),kt&&(0,y.jsxs)(re,{variant:`destructive`,children:[(0,y.jsx)(Ee,{className:`h-4 w-4`}),(0,y.jsx)(ye,{children:kt})]}),(0,y.jsxs)(ze,{value:A,onValueChange:En,children:[(0,y.jsxs)(Re,{children:[(0,y.jsxs)(ge,{value:`pending`,children:[S(`tabMyPending`,`My Pending`),jt>0&&(0,y.jsx)(c,{variant:`secondary`,className:`ml-2`,children:jt})]}),(0,y.jsx)(ge,{value:`submitted`,children:S(`tabSubmitted`,`Submitted by me`)}),(0,y.jsx)(ge,{value:`all`,children:S(`tabAll`,`All`)})]}),(0,y.jsxs)(ne,{value:A,className:`mt-4 space-y-3`,children:[!wt&&(j.length>0||A!==`pending`&&(R||V!==`all`))&&(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,y.jsx)(se,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,y.jsx)(Te,{value:L,onChange:e=>zt(e.target.value),placeholder:S(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),L&&(0,y.jsx)(`button`,{type:`button`,onClick:()=>zt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":S(`clearSearch`,`Clear search`),children:(0,y.jsx)(le,{className:`h-3.5 w-3.5`})})]}),A!==`pending`&&(0,y.jsxs)(Ge,{value:V,onValueChange:Ut,children:[(0,y.jsx)(Fe,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,y.jsx)(De,{placeholder:S(`statusFilter`,`Status`)})}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`all`,children:S(`allStatuses`,`All statuses`)}),(0,y.jsx)(p,{value:`pending`,children:D(`pending`)}),(0,y.jsx)(p,{value:`approved`,children:D(`approved`)}),(0,y.jsx)(p,{value:`rejected`,children:D(`rejected`)}),(0,y.jsx)(p,{value:`recalled`,children:D(`recalled`)}),(0,y.jsx)(p,{value:`returned`,children:D(`returned`)})]})]}),pn.length>1&&(0,y.jsxs)(Ge,{value:z,onValueChange:Vt,children:[(0,y.jsx)(Fe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,y.jsx)(De,{placeholder:S(`processFilter`,`Process`)})}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`all`,children:S(`allProcesses`,`All processes`)}),pn.map(e=>(0,y.jsx)(p,{value:e,children:e},e))]})]}),mn.length>1&&(0,y.jsxs)(Ge,{value:B,onValueChange:Ht,children:[(0,y.jsx)(Fe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,y.jsx)(De,{placeholder:S(`objectFilter`,`Object`)})}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`all`,children:S(`allObjects`,`All objects`)}),mn.map(e=>(0,y.jsx)(p,{value:e,children:e},e))]})]}),(0,y.jsxs)(Ge,{value:Wt,onValueChange:e=>Gt(e),children:[(0,y.jsxs)(Fe,{className:`h-8 w-auto min-w-[120px] text-sm`,children:[(0,y.jsx)(ae,{className:`h-3.5 w-3.5 mr-1 text-muted-foreground`}),(0,y.jsx)(De,{placeholder:S(`sortBy`,`Sort`)})]}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`recent`,children:S(`sortRecent`,`Newest first`)}),(0,y.jsx)(p,{value:`oldest`,children:S(`sortOldest`,`Oldest first`)}),(0,y.jsx)(p,{value:`amount`,children:S(`sortAmount`,`Amount (high→low)`)})]})]}),Tn&&(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`filterCount`,`{{shown}} of {{total}}`,{shown:Y.length,total:j.length})})]}),A===`pending`&&H.size>0&&(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,y.jsxs)(`span`,{children:[(0,y.jsx)(`strong`,{children:H.size}),` `,S(`selected`,`selected`),Q.length!==H.size&&(0,y.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:S(`actionableCount`,`({{count}} actionable)`,{count:Q.length})})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsxs)(te,{children:[(0,y.jsx)(Se,{asChild:!0,children:(0,y.jsxs)(m,{size:`sm`,disabled:qt||Q.length===0,children:[(0,y.jsx)(Je,{className:`h-3.5 w-3.5 mr-1`}),S(`approveN`,`Approve {{count}}`,{count:Q.length||``})]})}),(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:Q.length})}),(0,y.jsx)(be,{children:S(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>bn(`approve`),children:S(`approveN`,`Approve {{count}}`,{count:Q.length})})]})]})]}),(0,y.jsxs)(te,{children:[(0,y.jsx)(Se,{asChild:!0,children:(0,y.jsxs)(m,{size:`sm`,variant:`outline`,disabled:qt||Q.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,y.jsx)(Ce,{className:`h-3.5 w-3.5 mr-1`}),S(`rejectN`,`Reject {{count}}`,{count:Q.length||``})]})}),(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:Q.length})}),(0,y.jsx)(be,{children:S(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>bn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`rejectN`,`Reject {{count}}`,{count:Q.length})})]})]})]}),(0,y.jsx)(m,{size:`sm`,variant:`ghost`,onClick:()=>Kt(new Set),disabled:qt,children:S(`clear`,`Clear`)})]})]}),wt?(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(f,{className:`h-10 w-full`}),(0,y.jsx)(f,{className:`h-10 w-full`}),(0,y.jsx)(f,{className:`h-10 w-full`})]}):j.length===0?(0,y.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,y.jsxs)(Ze,{children:[(0,y.jsx)(Ne,{children:S(`emptyTitle`,`No requests`)}),(0,y.jsx)(je,{children:A===`pending`?S(`emptyPending`,`You're all caught up — nothing is waiting on you.`):S(`emptyOther`,`Nothing here yet.`)}),A===`pending`&&(0,y.jsx)(m,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>En(`all`),children:S(`emptyViewAll`,`Browse all requests`)})]})}):Y.length===0?(0,y.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:S(`noMatches`,`No matches for current filters.`)}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Oe,{className:`hidden md:block`,children:(0,y.jsx)(et,{className:`p-0`,children:(0,y.jsxs)(ve,{children:[(0,y.jsx)(fe,{children:(0,y.jsxs)(we,{children:[A===`pending`&&(0,y.jsx)(d,{className:`w-10`,children:(0,y.jsx)(Ie,{checked:_n,onCheckedChange:vn,"aria-label":S(`selectAll`,`Select all`),disabled:$.length===0})}),(0,y.jsx)(d,{className:`w-[22%]`,children:S(`colRequest`,`Request`)}),(0,y.jsx)(d,{className:`w-[30%]`,children:S(`colRecord`,`Record`)}),(0,y.jsx)(d,{className:`w-[16%]`,children:S(`colRequester`,`Requester`)}),(0,y.jsx)(d,{className:`w-[110px] min-w-[96px] whitespace-nowrap`,children:S(`colStatus`,`Status`)}),(0,y.jsx)(d,{className:`w-[132px]`,children:S(`colWaiting`,`Submitted`)}),(0,y.jsx)(d,{className:`w-20`,"aria-label":S(`colActions`,`Actions`)})]})}),(0,y.jsx)(xe,{children:Y.map((e,t)=>(0,y.jsxs)(we,{className:u(`group cursor-pointer hover:bg-accent/50`,nn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{rn(t),q(e.id)},children:[A===`pending`&&(0,y.jsx)(l,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,y.jsx)(Ie,{checked:H.has(e.id),onCheckedChange:()=>yn(e.id),disabled:e.status!==`pending`,"aria-label":S(`selectRow`,`Select request`)})}),(0,y.jsx)(l,{children:(0,y.jsx)(Dn,{r:e})}),(0,y.jsx)(l,{children:(0,y.jsx)(On,{r:e})}),(0,y.jsx)(l,{children:pt(e)?(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,y.jsx)(ce,{className:`h-3.5 w-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate italic`,children:S(`flowOrigin`,`Flow-initiated`)})]}):(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,y.jsx)(Qe,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:ut(e)})]})}),(0,y.jsx)(l,{children:(0,y.jsx)(st,{status:e.status,label:D(e.status)})}),(0,y.jsxs)(l,{className:u(`text-xs whitespace-nowrap`,gt(e,w)),title:ct(T(e)),children:[(0,y.jsx)(he,{className:`h-3 w-3 inline mr-1`}),E(T(e)),e.status===`pending`&&(()=>{let t=vt(e.sla_due_at,w);return t?(0,y.jsx)(`div`,{className:u(`mt-0.5 text-[10px] font-medium`,t.overdue?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:yt(t)}):null})()]}),(0,y.jsx)(l,{className:`w-20`,children:(0,y.jsx)(kn,{r:e})})]},e.id))})]})})}),(0,y.jsx)(`div`,{className:`md:hidden space-y-2`,children:Y.map(e=>(0,y.jsx)(Oe,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,y.jsxs)(et,{className:`p-3 space-y-1.5`,children:[(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,y.jsx)(`div`,{className:`font-medium text-sm truncate`,children:C(e)}),(0,y.jsx)(st,{status:e.status,label:D(e.status)})]}),(0,y.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||x(e.record_id),(0,y.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:mt(e)}),(()=>{let t=k(e);return t?(0,y.jsxs)(`span`,{className:`text-xs ml-1.5 font-medium`,title:t.label,children:[`· `,t.display]}):null})()]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[pt(e)?(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate italic`,children:[(0,y.jsx)(ce,{className:`h-3 w-3`}),S(`flowOrigin`,`Flow-initiated`)]}):(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,y.jsx)(Qe,{className:`h-3 w-3`}),ut(e)]}),(0,y.jsxs)(`span`,{className:u(`inline-flex items-center gap-1 whitespace-nowrap`,gt(e,w)),children:[(0,y.jsx)(he,{className:`h-3 w-3`}),E(T(e))]})]}),hn(e)&&(0,y.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),title:Z(e)?S(`needsDecisionInputs`,`This approval collects decision outputs — open it to decide.`):void 0,children:[(0,y.jsxs)(m,{size:`sm`,className:`h-7 flex-1`,disabled:Zt===e.id||Z(e),onClick:()=>Yt(e),children:[(0,y.jsx)(Je,{className:`h-3.5 w-3.5 mr-1`}),S(`approve`,`Approve`)]}),(0,y.jsxs)(m,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:Zt===e.id||Z(e),onClick:()=>Xt(e),children:[(0,y.jsx)(Ce,{className:`h-3.5 w-3.5 mr-1`}),S(`reject`,`Reject`)]})]})]})},e.id))}),A!==`pending`&&Ot!=null&&(0,y.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:j.length,total:Ot})}),j.length<Ot&&(0,y.jsx)(m,{size:`sm`,variant:`outline`,disabled:Et,onClick:()=>void an(),children:Et?S(`loadingMore`,`Loading…`):S(`loadMore`,`Load more`)})]}),(0,y.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:S(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,y.jsx)(te,{open:!!U,onOpenChange:e=>!e&&Yt(null),children:(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`approveOneTitle`,`Approve "{{title}}"?`,{title:U?U.record_title||x(U.record_id):``})}),(0,y.jsx)(be,{children:S(`approveOneBody`,`This approves the request with your identity. To add a comment or attachment, open the request instead.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>void xn(),children:S(`approve`,`Approve`)})]})]})}),(0,y.jsx)(te,{open:!!W,onOpenChange:e=>!e&&Xt(null),children:(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`rejectOneTitle`,`Reject "{{title}}"?`,{title:W?W.record_title||x(W.record_id):``})}),(0,y.jsx)(be,{children:S(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>void Sn(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`reject`,`Reject`)})]})]})}),(0,y.jsx)(Xe,{open:!!N,onOpenChange:e=>!e&&on(),children:(0,y.jsxs)(Ae,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,y.jsxs)($e,{children:[(0,y.jsx)(Me,{children:P?C(P):S(`drawerTitle`,`Approval Request`)}),(0,y.jsx)(Be,{children:P?lt(P)||mt(P):``})]}),P&&X>=0&&Y.length>1&&(0,y.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,y.jsxs)(m,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X<=0,onClick:()=>{let e=Y[X-1];e&&q(e.id)},children:[(0,y.jsx)(Ye,{className:`h-4 w-4 mr-0.5`}),S(`prevRequest`,`Previous`)]}),(0,y.jsx)(`span`,{children:S(`positionOf`,`Request {{index}} of {{total}}`,{index:X+1,total:Y.length})}),(0,y.jsxs)(m,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X>=Y.length-1,onClick:()=>{let e=Y[X+1];e&&q(e.id)},children:[S(`nextRequest`,`Next`),(0,y.jsx)(He,{className:`h-4 w-4 ml-0.5`})]})]}),Ft?(0,y.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,y.jsx)(f,{className:`h-6 w-3/4`}),(0,y.jsx)(f,{className:`h-6 w-1/2`}),(0,y.jsx)(f,{className:`h-20 w-full`})]}):P?(0,y.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,y.jsx)(st,{status:P.status,label:D(P.status)}),(P.round??1)>1&&(0,y.jsx)(c,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:S(`roundChip`,`Round {{n}}`,{n:P.round})}),(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:ct(T(P)),children:[(0,y.jsx)(he,{className:`h-3 w-3`}),S(`submittedAgo`,`Submitted {{when}}`,{when:E(T(P))})]}),P.completed_at&&(0,y.jsxs)(`span`,{children:[`· `,S(`completedAt`,`Completed {{when}}`,{when:E(P.completed_at)})]}),P.status===`pending`&&(()=>{let e=vt(P.sla_due_at,w);return e?(0,y.jsx)(c,{variant:`outline`,className:u(`text-[10px]`,e.overdue?`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`:`border-border text-muted-foreground`),children:yt(e)}):null})()]}),(()=>{let e=k(P),n=bt(P.payload,P.payload_display,P.payload_labels,6,e?.key);return(0,y.jsx)(Oe,{children:(0,y.jsxs)(et,{className:`p-4 space-y-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(t,{to:xt(P),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,y.jsx)(`span`,{className:`truncate`,children:P.record_title||x(P.record_id)}),(0,y.jsx)(Ke,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:mt(P)})]}),(0,y.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,y.jsx)(`div`,{className:`inline-flex items-center gap-1`,children:pt(P)?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(ce,{className:`h-3 w-3`}),(0,y.jsx)(`span`,{className:`italic`,children:S(`flowOrigin`,`Flow-initiated`)})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Qe,{className:`h-3 w-3`}),(0,y.jsx)(`span`,{title:P.submitter_id||``,children:ut(P)})]})})})]}),e&&(0,y.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,y.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e.label}),(0,y.jsx)(`div`,{className:`text-xl font-semibold tabular-nums`,title:e.display,children:e.display})]}),n.length>0&&(0,y.jsx)(`div`,{className:u(`grid grid-cols-2 gap-x-4 gap-y-2 text-sm`,!e&&`border-t pt-3`),children:n.map(([e,t])=>(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,y.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),P.decision_progress&&(()=>{let e=P.decision_progress,t=(P.pending_approvers||[]).length;return(0,y.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 mb-1.5`,children:[(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.behavior===`per_group`?S(`progressGroups`,`Sign-off progress — {{got}} of {{need}} groups`,{got:e.got,need:e.need}):S(`progressApprovals`,`Approvals — {{got}} of {{need}}`,{got:e.got,need:e.need})}),e.behavior!==`per_group`&&P.status===`pending`&&t>0&&(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:S(`progressEligible`,`{{count}} eligible approver(s)`,{count:t})})]}),(0,y.jsx)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":e.need,"aria-valuenow":Math.min(e.got,e.need),"aria-label":S(`progressBar`,`Decision progress`),className:`flex gap-1`,children:e.need>0&&e.need<=12?Array.from({length:e.need}).map((t,n)=>(0,y.jsx)(`div`,{className:u(`h-1.5 flex-1 rounded-full`,n<e.got?`bg-emerald-500`:`bg-muted`)},n)):(0,y.jsx)(`div`,{className:`h-1.5 flex-1 rounded-full bg-muted overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${e.need>0?Math.min(100,e.got/e.need*100):0}%`}})})}),e.groups&&(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.groups.map(e=>(0,y.jsxs)(c,{variant:`outline`,className:u(`text-[11px] gap-1`,e.satisfied?`border-emerald-300 text-emerald-700 dark:border-emerald-700 dark:text-emerald-400`:`text-muted-foreground`),title:`${e.got}/${e.need}`,children:[e.satisfied?(0,y.jsx)(ke,{className:`h-3 w-3`}):(0,y.jsx)(de,{className:`h-2.5 w-2.5`}),e.group,` `,e.got,`/`,e.need]},e.group))})]})})(),P.status===`pending`&&(P.pending_approvers||[]).length>0&&(0,y.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,y.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:S(`waitingOn`,`Waiting on`)}),(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:ft(P).map((e,t)=>(0,y.jsxs)(c,{variant:`outline`,className:`text-[11px]`,title:e.title,children:[e.label,e.group&&(0,y.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`· `,e.group]}),e.count>1&&(0,y.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`×`,e.count]})]},`${e.label}-${e.group??``}-${t}`))})]})]})})})(),(P.flow_steps?.length??0)>1&&(0,y.jsx)(`div`,{className:`flex items-center px-1`,"aria-label":S(`stepProgress`,`Approval steps`),children:P.flow_steps.map((e,t)=>(0,y.jsxs)(g.Fragment,{children:[t>0&&(0,y.jsx)(`div`,{className:u(`h-px flex-1 mx-2`,e.state===`done`||e.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,y.jsx)(`span`,{className:u(`flex items-center justify-center h-5 w-5 rounded-full text-[10px] font-semibold`,e.state===`done`&&`bg-emerald-500 text-white`,e.state===`current`&&`bg-amber-500 text-white ring-2 ring-amber-200 dark:ring-amber-500/30`,e.state===`upcoming`&&`bg-muted text-muted-foreground border`),children:e.state===`done`?(0,y.jsx)(ke,{className:`h-3 w-3`}):t+1}),(0,y.jsx)(`span`,{className:u(`text-xs`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]})]},e.id))}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:S(`history`,`Activity`)}),Pt.length===0?(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`noActions`,`No actions yet.`)}):(0,y.jsx)(`ol`,{className:`relative space-y-3 pl-5 before:absolute before:left-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border`,children:Pt.map(e=>{let t=e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:e.action===`reassign`?`bg-indigo-500`:e.action===`remind`||e.action===`request_info`?`bg-amber-500`:e.action===`comment`?`bg-slate-400`:e.action===`escalate`?`bg-red-500`:e.action===`revise`?`bg-violet-500`:e.action===`resubmit`?`bg-blue-500`:`bg-muted-foreground`,n=e.actor_id===`system:sla`?S(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===P.submitter_id?ut(P):x(e.actor_id)),r=e.action===`submit`?S(`actSubmit`,`Submitted`):e.action===`approve`?S(`actApprove`,`Approved`):e.action===`reject`?S(`actReject`,`Rejected`):e.action===`recall`?S(`actRecall`,`Recalled`):e.action===`reassign`?S(`actReassign`,`Reassigned`):e.action===`remind`?S(`actRemind`,`Reminder sent`):e.action===`request_info`?S(`actRequestInfo`,`Requested more info`):e.action===`comment`?S(`actComment`,`Commented`):e.action===`escalate`?S(`actEscalate`,`SLA escalated`):e.action===`revise`?S(`actRevise`,`Sent back for revision`):e.action===`resubmit`?S(`actResubmit`,`Resubmitted`):e.action;return(0,y.jsxs)(`li`,{className:`relative text-xs`,children:[(0,y.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,y.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,y.jsx)(`span`,{className:`font-medium`,children:r}),(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,y.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,y.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:ct(e.created_at),children:E(e.created_at)})]}),(()=>{let t=e;return e.action!==`reassign`||!t.reassign_from&&!t.reassign_to?null:(0,y.jsx)(`div`,{className:`text-muted-foreground mt-0.5`,children:S(`reassignFromTo`,`from {{from}} to {{to}}`,{from:t.reassign_from_name??x(t.reassign_from),to:t.reassign_to_name??x(t.reassign_to)})})})(),e.comment&&(0,y.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]}),Array.isArray(e.attachments)&&e.attachments.length>0&&(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:e.attachments.map((t,n)=>(0,y.jsxs)(`button`,{type:`button`,onClick:()=>void Rt(t),className:`inline-flex items-center gap-1 text-[11px] px-2 py-0.5 rounded-full border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:t.name||t.id,children:[(0,y.jsx)(tt,{className:`h-3 w-3`}),t.name||`${S(`attachmentChip`,`Attachment`)}${e.attachments.length>1?` ${n+1}`:``}`]},t.id||n))})]},e.id)})}),P.status===`pending`&&(un||dn)&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,y.jsx)(Te,{value:G,onChange:e=>$t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&G.trim()&&(e.preventDefault(),ln())},placeholder:S(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,y.jsx)(m,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!G.trim()||en,onClick:()=>void ln(),children:(0,y.jsx)(qe,{className:`h-3.5 w-3.5`})})]})]}),P.payload!=null&&(0,y.jsxs)(`details`,{className:`group`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:S(`rawData`,`Raw data (JSON)`)}),(0,y.jsxs)(`div`,{className:`mt-2`,children:[(0,y.jsx)(`div`,{className:`flex justify-end`,children:(0,y.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(P.payload,null,2)),h.success(S(`copied`,`Copied`))}catch{h.error(S(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,y.jsx)(nt,{className:`h-3 w-3`}),S(`copy`,`Copy`)]})}),(0,y.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(P.payload,null,2)})]})]}),P.status===`pending`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Pe,{}),(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(rt,{objectName:`sys_approval_request`,record:P,location:`record_section`,label:S(`declaredActions`,`Actions`),onDone:()=>{cn()}}),!un&&(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:dn?S(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):S(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(P.pending_approvers||[]).map(e=>dt(e,P)).join(`, `)||`—`})})]})]}),fn&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Pe,{}),(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,y.jsxs)(`div`,{className:`flex gap-2 flex-wrap items-center`,children:[(0,y.jsx)(m,{asChild:!0,size:`sm`,variant:`outline`,children:(0,y.jsxs)(t,{to:xt(P),children:[(0,y.jsx)(Ke,{className:`h-4 w-4 mr-1`}),S(`editRecordBtn`,`Edit record`)]})}),(0,y.jsx)(rt,{objectName:`sys_approval_request`,record:P,location:`record_section`,onDone:()=>{sn(P.id),K()}})]})]})]})]}):null]})})]})}export{A as ApprovalsInboxPage};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{a as t,h as n,m as r,r as i,y as a}from"./vendor-react-DpRf6e0g.js";import{_ as o,b as s,y as ee}from"./infrastructure-PXm1h5tB.js";import{Ar as te,At as ne,Cr as c,Dr as re,Fr as ie,Ft as l,Gc as u,Ic as ae,Ir as oe,It as d,Ji as se,Jr as ce,Kr as le,Lr as ue,Ls as de,Lt as fe,Mi as pe,Mr as me,Ms as he,Mt as ge,Nr as _e,Nt as ve,Or as ye,Pr as be,Pt as xe,Rr as Se,Rs as Ce,Rt as we,Tn as Te,Xs as Ee,_n as De,_r as Oe,ac as ke,an as f,cn as Ae,ct as je,dn as Me,dt as Ne,fn as Pe,gn as Fe,gr as Ie,hn as p,jr as Le,jt as Re,kt as ze,ln as Be,mn as Ve,nc as He,nl as Ue,oa as We,pn as Ge,ps as Ke,qi as qe,qs as Je,rc as Ye,sn as Xe,st as Ze,ti as Qe,un as $e,vr as et,wa as tt,ws as nt,zr as m}from"./ui-components-BbC0qTrK.js";import{r as h}from"./vendor-ui-utils-CnzHPXVC.js";import{p as rt}from"./src-CSrGzA_t.js";var g=e(a(),1),it=`${``.replace(/\/$/,``)}/api/v1`;async function _(e,t){let n=s.get(),r=await fetch(`${it}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...n?{Authorization:`Bearer ${n}`}:{},...t?.headers||{}},...t}),i=null;try{i=await r.json()}catch{}if(!r.ok){let e=i?.code??`HTTP_${r.status}`,t=i?.message??i?.error??r.statusText,n=Error(`${e}: ${t}`);throw n.code=e,n.status=r.status,n.details=i,n}return i}var v={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return _(`/approvals/processes${n?`?${n}`:``}`)},listRequests(e={}){let t=new URLSearchParams;e.status&&t.set(`status`,e.status),e.object&&t.set(`object`,e.object),e.recordId&&t.set(`recordId`,e.recordId);let n=Array.isArray(e.approverId)?e.approverId.filter(Boolean).join(`,`):e.approverId;n&&t.set(`approverId`,n),e.submitterId&&t.set(`submitterId`,e.submitterId),e.q?.trim()&&t.set(`q`,e.q.trim()),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let r=t.toString();return _(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await _(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return _(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/approve`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async reject(e,t){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/reject`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,finalized:n.finalized}},async recall(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/remind`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,notified:n.notified}},async requestInfo(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/revise`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,autoRejected:n.autoRejected===!0}},async resubmit(e,t={}){let n=await _(`/approvals/requests/${encodeURIComponent(e)}/resubmit`,{method:`POST`,body:JSON.stringify(t)});return{data:n.request,resumed:n.resumed===!0}},async comment(e,t){return{data:(await _(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return _(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function at(e){if(!e)return[];let t=new Set;e.id&&t.add(e.id),e.email&&t.add(e.email);let n=[...e.roles||[],...typeof e.role==`string`?e.role.split(`,`):[]];for(let e of n){let n=String(e).trim();n&&t.add(`role:${n}`)}return Array.from(t)}var y=i(),ot=50,b={pending:`border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-500/30 dark:bg-amber-500/10 dark:text-amber-400`,approved:`border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-500/30 dark:bg-emerald-500/10 dark:text-emerald-400`,rejected:`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`,recalled:`border-border bg-muted text-muted-foreground`,returned:`border-violet-200 bg-violet-50 text-violet-700 dark:border-violet-500/30 dark:bg-violet-500/10 dark:text-violet-400`};function st({status:e,label:t}){return(0,y.jsx)(c,{variant:`outline`,className:u(`font-medium`,b[e]??``),children:t})}function ct(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function x(e){return e?e.includes(`@`)?e:e.startsWith(`role:`)?`Role: ${e.slice(5)}`:e.length>14?`${e.slice(0,6)}…${e.slice(-4)}`:e:`—`}function S(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function C(e){return e.process_label||S(e.process_name)}function lt(e){return e.step_label?e.step_label:e.current_step?S(e.current_step):null}function ut(e){return e.submitter_name||x(e.submitter_id)}function dt(e,t){return t.pending_approver_names?.[e]||x(e)}function w(e,t){let n=t.pending_approver_groups?.[e];return n&&n.length?n.join(` / `):void 0}function ft(e){let t=[],n=new Map;for(let r of e.pending_approvers||[]){let i=dt(r,e),a=w(r,e),o=a?`${i} ${a}`:i,s=n.get(o);s?(s.count+=1,r&&!s.title.split(`, `).includes(r)&&(s.title+=`, ${r}`)):(n.set(o,{label:i,group:a,count:1,title:r||i}),t.push(o))}return t.map(e=>n.get(e))}function pt(e){if(e.submitter_name)return!1;let t=(e.submitter_id||``).trim();return!t||t.startsWith(`flow:`)||t.startsWith(`system:`)}function mt(e){return e.object_label||e.object_name}function T(e){return e.submitted_at||e.created_at||void 0}function ht(e,t){let n=T(e);if(!n)return null;let r=Date.parse(n);return Number.isNaN(r)?null:(t-r)/36e5}function gt(e,t){if(e.status!==`pending`)return`text-muted-foreground`;let n=ht(e,t);return n==null?`text-muted-foreground`:n>72?`text-red-600 dark:text-red-400 font-medium`:n>24?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function _t(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}function vt(e,t){if(!e)return null;let n=Date.parse(e);return Number.isNaN(n)?null:{overdue:n<t,ms:Math.abs(t-n)}}var E=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function D(e){let t=e.split(`_`).filter(Boolean);return t.length>1&&t[t.length-1].toLowerCase()===`id`&&t.pop(),t.map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function O(e,t){if(typeof t==`boolean`)return t?`✓`:`—`;if(typeof t==`number`){if(t>0xe8d4a51000&&/(_at$|_date$|^date_|_time$)/.test(e))try{return new Date(t).toLocaleDateString()}catch{}return t.toLocaleString()}let n=String(t);if(/^\d{4}-\d{2}-\d{2}T\d{2}/.test(n))try{return new Date(n).toLocaleString()}catch{}return n}var yt=/^[A-Za-z0-9_-]{15,}$/;function bt(e,t,n,r=6,i){if(!e||typeof e!=`object`||Array.isArray(e))return[];let a=[];for(let[o,s]of Object.entries(e)){if(E.has(o)||i&&o===i||s==null||typeof s==`object`||String(s).trim()===``)continue;let e=t?.[o];if(!(!e&&typeof s==`string`&&yt.test(s.trim())&&!/^\d+$/.test(s.trim()))&&(a.push([n?.[o]??D(o),e??O(o,s)]),a.length>=r))break}return a}var xt=/(amount|total|price|value|cost|sum|budget|salary|fee|revenue|balance|金额|总额|价格|费用|预算|金额)/i;function k(e){let t=e.payload;if(!t||typeof t!=`object`||Array.isArray(t))return null;for(let[n,r]of Object.entries(t)){if(E.has(n)||!xt.test(n))continue;let t=typeof r==`number`?r:typeof r==`string`&&r.trim()!==``&&Number.isFinite(Number(r))?Number(r):null;if(!(t==null||!Number.isFinite(t)))return{key:n,label:e.payload_labels?.[n]??D(n),value:t,display:e.payload_display?.[n]??t.toLocaleString()}}return null}function A(){let{t:e,language:i}=Ue(),{user:a}=o(),{appName:s}=r(),[it,_]=n(),b=(0,g.useMemo)(()=>at(a),[a]),S=(0,g.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),[w,ht]=(0,g.useState)(()=>Date.now());(0,g.useEffect)(()=>{let e=setInterval(()=>ht(Date.now()),6e4);return()=>clearInterval(e)},[]);let E=(0,g.useCallback)(e=>{if(!e)return`—`;let t=Date.parse(e);if(Number.isNaN(t))return e;let n=Math.round((w-t)/1e3);if(n<45)return S(`justNow`,`just now`);let r=Math.round(n/60);if(r<60)return S(`minutesAgo`,`{{count}}m ago`,{count:r});let a=Math.round(r/60);if(a<24)return S(`hoursAgo`,`{{count}}h ago`,{count:a});let o=Math.round(a/24);if(o<30)return S(`daysAgo`,`{{count}}d ago`,{count:o});try{return new Date(e).toLocaleDateString(i)}catch{return e}},[S,i,w]),D=(0,g.useCallback)(e=>{switch(e){case`pending`:return S(`statusPending`,`Pending`);case`approved`:return S(`statusApproved`,`Approved`);case`rejected`:return S(`statusRejected`,`Rejected`);case`recalled`:return S(`statusRecalled`,`Recalled`);case`returned`:return S(`statusReturned`,`Returned for revision`);default:return e}},[S]),O=(0,g.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?S(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?S(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?S(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?S(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?S(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[S]),yt=(0,g.useCallback)(e=>e.overdue?S(`slaOverdue`,`SLA overdue {{dur}}`,{dur:_t(e.ms)}):S(`slaRemaining`,`SLA {{dur}} left`,{dur:_t(e.ms)}),[S]),xt=(0,g.useCallback)(e=>`/apps/${s||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[s]),[A,St]=(0,g.useState)(`pending`),[j,Ct]=(0,g.useState)([]),[wt,Tt]=(0,g.useState)(!1),[Et,Dt]=(0,g.useState)(!1),[Ot,M]=(0,g.useState)(null),[kt,At]=(0,g.useState)(null),[jt,Mt]=(0,g.useState)(0),[N,Nt]=(0,g.useState)(null),[P,F]=(0,g.useState)(null),[Pt,I]=(0,g.useState)([]),[Ft,It]=(0,g.useState)(!1),Lt=(0,g.useMemo)(()=>ee(),[]),Rt=(0,g.useCallback)(async e=>{let t=window.open(``,`_blank`,`noopener`);try{let n=``.replace(/\/$/,``),r=await Lt(`${n}/api/v1/storage/files/${encodeURIComponent(e.id)}/url`);if(!r.ok)throw Error(`HTTP_${r.status}`);let i=await r.json().catch(()=>null),a=i?.data?.url??i?.url;if(!a)throw Error(`NO_URL`);let o=/^https?:\/\//i.test(a)?a:`${n}${a}`;t?t.location.href=o:window.open(o,`_blank`,`noopener`)}catch{t?.close(),h.error(S(`attachmentOpenFailed`,`Could not open the attachment — please try again`))}},[Lt,S]),[L,zt]=(0,g.useState)(``),[R,Bt]=(0,g.useState)(``),[z,Vt]=(0,g.useState)(`all`),[B,Ht]=(0,g.useState)(`all`),[V,Ut]=(0,g.useState)(`all`),[Wt,Gt]=(0,g.useState)(`recent`),[H,Kt]=(0,g.useState)(new Set),[qt,Jt]=(0,g.useState)(!1),[U,Yt]=(0,g.useState)(null),[W,Xt]=(0,g.useState)(null),[Zt,Qt]=(0,g.useState)(null),[G,$t]=(0,g.useState)(``),[en,tn]=(0,g.useState)(!1),[nn,rn]=(0,g.useState)(-1);(0,g.useEffect)(()=>{if(A===`pending`)return;let e=window.setTimeout(()=>Bt(L),350);return()=>window.clearTimeout(e)},[L,A]);let K=(0,g.useCallback)(async()=>{Tt(!0),At(null);try{let e=[];if(A===`pending`)e=b.length?(await v.listRequests({status:`pending`,approverId:b})).data:[],Mt(e.length),M(null);else{let t={q:R||void 0,status:V===`all`?void 0:V,limit:ot,offset:0};if(A===`submitted`){let n=a?.id;if(n){let r=await v.listRequests({submitterId:n,...t});e=r.data,M(r.total??r.data.length)}else e=[],M(0)}else{let n=await v.listRequests(t);e=n.data,M(n.total??n.data.length)}b.length&&v.listRequests({status:`pending`,approverId:b}).then(e=>Mt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(T(t)||``).localeCompare(T(e)||``)),Ct(e)}catch(e){At(e?.message||String(e)),Ct([])}finally{Tt(!1)}},[A,b,a?.id,R,V]);(0,g.useEffect)(()=>{K()},[K]);let an=(0,g.useCallback)(async()=>{if(!(A===`pending`||Et)){Dt(!0);try{let e=await v.listRequests({submitterId:A===`submitted`?a?.id??void 0:void 0,q:R||void 0,status:V===`all`?void 0:V,limit:ot,offset:j.length});Ct(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&M(e.total)}catch(e){h.error(O(e,S(`loadFailed`,`Failed to load request`)))}finally{Dt(!1)}}},[A,Et,a?.id,R,V,j.length,O,S]),q=(0,g.useCallback)(async e=>{Nt(e),It(!0);try{let[t,n]=await Promise.all([v.getRequest(e),v.listActions(e)]);F(t.data),I(n.data)}catch(e){h.error(O(e,S(`loadFailed`,`Failed to load request`))),F(null),I([])}finally{It(!1)}},[O,S]),on=()=>{Nt(null),F(null),I([])};(0,g.useEffect)(()=>{let e=it.get(`request`);e&&(_(e=>{let t=new URLSearchParams(e);return t.delete(`request`),t},{replace:!0}),q(e))},[it]);let J=(0,g.useCallback)(()=>{b.length&&v.listRequests({status:`pending`,approverId:b}).then(e=>Mt(e.data.length)).catch(()=>{})},[b]),sn=(0,g.useCallback)(async e=>{let[t,n]=await Promise.all([v.getRequest(e),v.listActions(e)]);F(t.data),I(n.data),K()},[K]),cn=(0,g.useCallback)(async()=>{if(!P)return;let e=P.id;try{let[t,n]=await Promise.all([v.getRequest(e),v.listActions(e)]);F(t.data),I(n.data),K();let r=new Set(t.data.pending_approvers||[]),i=t.data.status===`pending`&&b.some(e=>r.has(e));if(A===`pending`&&!i){let t=Cn.current,n=t.findIndex(t=>t.id===e),r=t[n+1]??t[n-1];if(r&&r.id!==e){q(r.id);return}on()}}catch{sn(e)}},[P,b,A,K,q,on,sn]),ln=(0,g.useCallback)(async()=>{if(!(!P||!G.trim())){tn(!0);try{await v.comment(P.id,{actor_id:a?.id,comment:G.trim()}),$t(``),await sn(P.id)}catch(e){h.error(O(e,S(`actionFailed`,`Action failed`)))}finally{tn(!1)}}},[P,G,a?.id,sn,O,S]),un=(0,g.useMemo)(()=>{if(!P||P.status!==`pending`)return!1;if(P.viewer)return P.viewer.can_act||!!P.viewer.can_override;let e=new Set(P.pending_approvers||[]);return b.some(t=>e.has(t))},[P,b]),dn=(0,g.useMemo)(()=>!P||P.status!==`pending`?!1:P.viewer?P.viewer.is_submitter:P.submitter_id===a?.id,[P,a?.id]),fn=(0,g.useMemo)(()=>!P||P.status!==`returned`?!1:P.viewer?P.viewer.is_submitter:P.submitter_id===a?.id,[P,a?.id]),pn=(0,g.useMemo)(()=>{let e=new Set;for(let t of j)e.add(C(t));return Array.from(e).sort()},[j]),mn=(0,g.useMemo)(()=>{let e=new Set;for(let t of j)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[j]),Y=(0,g.useMemo)(()=>{let e=L.trim().toLowerCase(),t=j.filter(t=>z!==`all`&&C(t)!==z||B!==`all`&&t.object_name!==B||V!==`all`&&t.status!==V?!1:A!==`pending`||!e||[t.process_name,t.process_label,t.step_label,t.object_name,t.record_id,t.record_title,t.submitter_id,t.submitter_name,...t.pending_approvers||[]].filter(Boolean).join(` `).toLowerCase().includes(e));if(Wt===`recent`)return t;let n=[...t];return Wt===`amount`?n.sort((e,t)=>{let n=k(e)?.value,r=k(t)?.value;return n==null&&r==null?0:n==null?1:r==null?-1:r-n}):n.sort((e,t)=>(T(e)||``).localeCompare(T(t)||``)),n},[j,L,z,B,V,A,Wt]),X=(0,g.useMemo)(()=>N?Y.findIndex(e=>e.id===N):-1,[Y,N]);(0,g.useEffect)(()=>{if(H.size===0)return;let e=new Set(Y.map(e=>e.id)),t=!1,n=new Set;for(let r of H)e.has(r)?n.add(r):t=!0;t&&Kt(n)},[Y,H]),(0,g.useEffect)(()=>{nn>=Y.length&&rn(Y.length-1)},[Y.length,nn]);let hn=(0,g.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(b);return(e.pending_approvers||[]).some(e=>t.has(e))},[b]),Z=(0,g.useCallback)(e=>Array.isArray(e.decision_outputs)&&e.decision_outputs.length>0,[]),gn=(0,g.useCallback)(e=>hn(e)&&!Z(e),[hn,Z]),Q=(0,g.useMemo)(()=>Y.filter(e=>H.has(e.id)&&gn(e)),[Y,H,gn]),$=Y.filter(e=>e.status===`pending`),_n=$.length>0&&$.every(e=>H.has(e.id)),vn=(0,g.useCallback)(()=>{Kt(e=>{if(_n)return new Set;let t=new Set(e);for(let e of $)t.add(e.id);return t})},[_n,$]),yn=(0,g.useCallback)(e=>{Kt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),bn=(0,g.useCallback)(async e=>{let t=Q;if(t.length===0)return;Jt(!0);let n=0,r=[];for(let i of t){let t=new Set(i.pending_approvers||[]),o=b.find(e=>t.has(e))||a?.id||``;try{await(e===`approve`?v.approve:v.reject)(i.id,{actor_id:o}),n++}catch{r.push(i.record_title||x(i.record_id))}}if(Jt(!1),Kt(new Set),r.length===0)h.success(e===`approve`?S(`bulkApproved`,`Approved {{count}} requests`,{count:n}):S(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);h.error(S(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),J()},[Q,b,a?.id,K,J,S]),xn=(0,g.useCallback)(async()=>{let e=U;if(!e)return;let t=new Set(e.pending_approvers||[]),n=b.find(e=>t.has(e))||a?.id||``;Qt(e.id),Yt(null);try{let t=await v.approve(e.id,{actor_id:n});h.success(t.finalized?S(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||x(e.record_id)}):S(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),J()}catch(e){h.error(O(e,S(`actionFailed`,`Action failed`)))}finally{Qt(null)}},[U,b,a?.id,K,J,O,S]),Sn=(0,g.useCallback)(async()=>{let e=W;if(!e)return;let t=new Set(e.pending_approvers||[]),n=b.find(e=>t.has(e))||a?.id||``;Qt(e.id),Xt(null);try{await v.reject(e.id,{actor_id:n}),h.success(S(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||x(e.record_id)})),K(),J()}catch(e){h.error(O(e,S(`actionFailed`,`Action failed`)))}finally{Qt(null)}},[W,b,a?.id,K,J,O,S]),Cn=(0,g.useRef)(Y);Cn.current=Y;let wn=(0,g.useRef)(nn);wn.current=nn,(0,g.useEffect)(()=>{let e=e=>{if(N||U||W)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Cn.current;if(!r.length)return;let i=wn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),rn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),rn(Math.max(i-1,0))):e.key===`Enter`&&i>=0&&r[i]?(e.preventDefault(),q(r[i].id)):(e.key===`x`||e.key===` `)&&i>=0&&r[i]&&A===`pending`?(e.preventDefault(),yn(r[i].id)):e.key===`a`&&i>=0&&r[i]&&gn(r[i])?(e.preventDefault(),Yt(r[i])):e.key===`r`&&i>=0&&r[i]&&gn(r[i])&&(e.preventDefault(),Xt(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,U,W,A,q,yn,gn]),(0,g.useEffect)(()=>{if(!N)return;let e=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Cn.current,i=r.findIndex(e=>e.id===N);if(i<0)return;let a=e.key===`ArrowLeft`?r[i-1]:r[i+1];a&&(e.preventDefault(),q(a.id))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,q]);let Tn=!!L||z!==`all`||B!==`all`||V!==`all`,En=e=>{St(e),Ut(`all`),Vt(`all`),Ht(`all`),zt(``),Gt(`recent`),rn(-1)};function Dn({r:e}){return(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`div`,{className:`font-medium truncate`,children:C(e)}),(0,y.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[lt(e)||`—`,(e.round??1)>1&&(0,y.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:S(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function On({r:e}){let n=k(e);return(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(t,{to:xt(e),onClick:e=>e.stopPropagation(),className:`inline-flex items-center gap-1 text-sm hover:underline truncate max-w-full`,title:e.record_id,children:[(0,y.jsx)(`span`,{className:`truncate`,children:e.record_title||x(e.record_id)}),(0,y.jsx)(Ke,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,y.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[mt(e),n&&(0,y.jsxs)(`span`,{className:`ml-1.5 font-medium text-foreground`,title:`${n.label}: ${n.display}`,children:[`· `,n.display]})]})]})}function kn({r:e}){if(!hn(e))return null;let t=Zt===e.id,n=Z(e),r=S(`needsDecisionInputs`,`This approval collects decision outputs — open it to decide.`);return(0,y.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),title:n?r:void 0,children:[(0,y.jsx)(m,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-emerald-700 hover:text-emerald-800 hover:bg-emerald-50 dark:text-emerald-400`,disabled:t||n,onClick:()=>Yt(e),"aria-label":n?r:S(`approve`,`Approve`),children:(0,y.jsx)(Je,{className:`h-4 w-4`})}),(0,y.jsx)(m,{size:`sm`,variant:`ghost`,className:`h-7 px-2 text-red-600 hover:text-red-700 hover:bg-red-50 dark:text-red-400`,disabled:t||n,onClick:()=>Xt(e),"aria-label":n?r:S(`reject`,`Reject`),children:(0,y.jsx)(Ce,{className:`h-4 w-4`})})]})}return(0,y.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,y.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,y.jsx)(pe,{className:`h-6 w-6`}),S(`title`,`Approvals Inbox`)]}),(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:S(`subtitle`,`Review and act on approval requests.`)})]}),(0,y.jsxs)(m,{variant:`outline`,size:`sm`,onClick:K,disabled:wt,className:`self-start sm:self-auto`,children:[(0,y.jsx)(We,{className:`h-4 w-4 mr-2 ${wt?`animate-spin`:``}`}),S(`refresh`,`Refresh`)]})]}),kt&&(0,y.jsxs)(re,{variant:`destructive`,children:[(0,y.jsx)(Ee,{className:`h-4 w-4`}),(0,y.jsx)(ye,{children:kt})]}),(0,y.jsxs)(ze,{value:A,onValueChange:En,children:[(0,y.jsxs)(Re,{children:[(0,y.jsxs)(ge,{value:`pending`,children:[S(`tabMyPending`,`My Pending`),jt>0&&(0,y.jsx)(c,{variant:`secondary`,className:`ml-2`,children:jt})]}),(0,y.jsx)(ge,{value:`submitted`,children:S(`tabSubmitted`,`Submitted by me`)}),(0,y.jsx)(ge,{value:`all`,children:S(`tabAll`,`All`)})]}),(0,y.jsxs)(ne,{value:A,className:`mt-4 space-y-3`,children:[!wt&&(j.length>0||A!==`pending`&&(R||V!==`all`))&&(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,y.jsx)(se,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,y.jsx)(Te,{value:L,onChange:e=>zt(e.target.value),placeholder:S(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),L&&(0,y.jsx)(`button`,{type:`button`,onClick:()=>zt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":S(`clearSearch`,`Clear search`),children:(0,y.jsx)(le,{className:`h-3.5 w-3.5`})})]}),A!==`pending`&&(0,y.jsxs)(Ge,{value:V,onValueChange:Ut,children:[(0,y.jsx)(Fe,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,y.jsx)(De,{placeholder:S(`statusFilter`,`Status`)})}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`all`,children:S(`allStatuses`,`All statuses`)}),(0,y.jsx)(p,{value:`pending`,children:D(`pending`)}),(0,y.jsx)(p,{value:`approved`,children:D(`approved`)}),(0,y.jsx)(p,{value:`rejected`,children:D(`rejected`)}),(0,y.jsx)(p,{value:`recalled`,children:D(`recalled`)}),(0,y.jsx)(p,{value:`returned`,children:D(`returned`)})]})]}),pn.length>1&&(0,y.jsxs)(Ge,{value:z,onValueChange:Vt,children:[(0,y.jsx)(Fe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,y.jsx)(De,{placeholder:S(`processFilter`,`Process`)})}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`all`,children:S(`allProcesses`,`All processes`)}),pn.map(e=>(0,y.jsx)(p,{value:e,children:e},e))]})]}),mn.length>1&&(0,y.jsxs)(Ge,{value:B,onValueChange:Ht,children:[(0,y.jsx)(Fe,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,y.jsx)(De,{placeholder:S(`objectFilter`,`Object`)})}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`all`,children:S(`allObjects`,`All objects`)}),mn.map(e=>(0,y.jsx)(p,{value:e,children:e},e))]})]}),(0,y.jsxs)(Ge,{value:Wt,onValueChange:e=>Gt(e),children:[(0,y.jsxs)(Fe,{className:`h-8 w-auto min-w-[120px] text-sm`,children:[(0,y.jsx)(ae,{className:`h-3.5 w-3.5 mr-1 text-muted-foreground`}),(0,y.jsx)(De,{placeholder:S(`sortBy`,`Sort`)})]}),(0,y.jsxs)(Ve,{children:[(0,y.jsx)(p,{value:`recent`,children:S(`sortRecent`,`Newest first`)}),(0,y.jsx)(p,{value:`oldest`,children:S(`sortOldest`,`Oldest first`)}),(0,y.jsx)(p,{value:`amount`,children:S(`sortAmount`,`Amount (high→low)`)})]})]}),Tn&&(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`filterCount`,`{{shown}} of {{total}}`,{shown:Y.length,total:j.length})})]}),A===`pending`&&H.size>0&&(0,y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,y.jsxs)(`span`,{children:[(0,y.jsx)(`strong`,{children:H.size}),` `,S(`selected`,`selected`),Q.length!==H.size&&(0,y.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:S(`actionableCount`,`({{count}} actionable)`,{count:Q.length})})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsxs)(te,{children:[(0,y.jsx)(Se,{asChild:!0,children:(0,y.jsxs)(m,{size:`sm`,disabled:qt||Q.length===0,children:[(0,y.jsx)(Je,{className:`h-3.5 w-3.5 mr-1`}),S(`approveN`,`Approve {{count}}`,{count:Q.length||``})]})}),(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:Q.length})}),(0,y.jsx)(be,{children:S(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>bn(`approve`),children:S(`approveN`,`Approve {{count}}`,{count:Q.length})})]})]})]}),(0,y.jsxs)(te,{children:[(0,y.jsx)(Se,{asChild:!0,children:(0,y.jsxs)(m,{size:`sm`,variant:`outline`,disabled:qt||Q.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,y.jsx)(Ce,{className:`h-3.5 w-3.5 mr-1`}),S(`rejectN`,`Reject {{count}}`,{count:Q.length||``})]})}),(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:Q.length})}),(0,y.jsx)(be,{children:S(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>bn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`rejectN`,`Reject {{count}}`,{count:Q.length})})]})]})]}),(0,y.jsx)(m,{size:`sm`,variant:`ghost`,onClick:()=>Kt(new Set),disabled:qt,children:S(`clear`,`Clear`)})]})]}),wt?(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(f,{className:`h-10 w-full`}),(0,y.jsx)(f,{className:`h-10 w-full`}),(0,y.jsx)(f,{className:`h-10 w-full`})]}):j.length===0?(0,y.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,y.jsxs)(Ze,{children:[(0,y.jsx)(Ne,{children:S(`emptyTitle`,`No requests`)}),(0,y.jsx)(je,{children:A===`pending`?S(`emptyPending`,`You're all caught up — nothing is waiting on you.`):S(`emptyOther`,`Nothing here yet.`)}),A===`pending`&&(0,y.jsx)(m,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>En(`all`),children:S(`emptyViewAll`,`Browse all requests`)})]})}):Y.length===0?(0,y.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:S(`noMatches`,`No matches for current filters.`)}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Oe,{className:`hidden md:block`,children:(0,y.jsx)(et,{className:`p-0`,children:(0,y.jsxs)(ve,{children:[(0,y.jsx)(fe,{children:(0,y.jsxs)(we,{children:[A===`pending`&&(0,y.jsx)(d,{className:`w-10`,children:(0,y.jsx)(Ie,{checked:_n,onCheckedChange:vn,"aria-label":S(`selectAll`,`Select all`),disabled:$.length===0})}),(0,y.jsx)(d,{className:`w-[22%]`,children:S(`colRequest`,`Request`)}),(0,y.jsx)(d,{className:`w-[30%]`,children:S(`colRecord`,`Record`)}),(0,y.jsx)(d,{className:`w-[16%]`,children:S(`colRequester`,`Requester`)}),(0,y.jsx)(d,{className:`w-[110px] min-w-[96px] whitespace-nowrap`,children:S(`colStatus`,`Status`)}),(0,y.jsx)(d,{className:`w-[132px]`,children:S(`colWaiting`,`Submitted`)}),(0,y.jsx)(d,{className:`w-20`,"aria-label":S(`colActions`,`Actions`)})]})}),(0,y.jsx)(xe,{children:Y.map((e,t)=>(0,y.jsxs)(we,{className:u(`group cursor-pointer hover:bg-accent/50`,nn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{rn(t),q(e.id)},children:[A===`pending`&&(0,y.jsx)(l,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,y.jsx)(Ie,{checked:H.has(e.id),onCheckedChange:()=>yn(e.id),disabled:e.status!==`pending`,"aria-label":S(`selectRow`,`Select request`)})}),(0,y.jsx)(l,{children:(0,y.jsx)(Dn,{r:e})}),(0,y.jsx)(l,{children:(0,y.jsx)(On,{r:e})}),(0,y.jsx)(l,{children:pt(e)?(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm text-muted-foreground`,children:[(0,y.jsx)(ce,{className:`h-3.5 w-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate italic`,children:S(`flowOrigin`,`Flow-initiated`)})]}):(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,y.jsx)(Qe,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:ut(e)})]})}),(0,y.jsx)(l,{children:(0,y.jsx)(st,{status:e.status,label:D(e.status)})}),(0,y.jsxs)(l,{className:u(`text-xs whitespace-nowrap`,gt(e,w)),title:ct(T(e)),children:[(0,y.jsx)(he,{className:`h-3 w-3 inline mr-1`}),E(T(e)),e.status===`pending`&&(()=>{let t=vt(e.sla_due_at,w);return t?(0,y.jsx)(`div`,{className:u(`mt-0.5 text-[10px] font-medium`,t.overdue?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:yt(t)}):null})()]}),(0,y.jsx)(l,{className:`w-20`,children:(0,y.jsx)(kn,{r:e})})]},e.id))})]})})}),(0,y.jsx)(`div`,{className:`md:hidden space-y-2`,children:Y.map(e=>(0,y.jsx)(Oe,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,y.jsxs)(et,{className:`p-3 space-y-1.5`,children:[(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,y.jsx)(`div`,{className:`font-medium text-sm truncate`,children:C(e)}),(0,y.jsx)(st,{status:e.status,label:D(e.status)})]}),(0,y.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||x(e.record_id),(0,y.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:mt(e)}),(()=>{let t=k(e);return t?(0,y.jsxs)(`span`,{className:`text-xs ml-1.5 font-medium`,title:t.label,children:[`· `,t.display]}):null})()]}),(0,y.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[pt(e)?(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate italic`,children:[(0,y.jsx)(ce,{className:`h-3 w-3`}),S(`flowOrigin`,`Flow-initiated`)]}):(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,y.jsx)(Qe,{className:`h-3 w-3`}),ut(e)]}),(0,y.jsxs)(`span`,{className:u(`inline-flex items-center gap-1 whitespace-nowrap`,gt(e,w)),children:[(0,y.jsx)(he,{className:`h-3 w-3`}),E(T(e))]})]}),hn(e)&&(0,y.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),title:Z(e)?S(`needsDecisionInputs`,`This approval collects decision outputs — open it to decide.`):void 0,children:[(0,y.jsxs)(m,{size:`sm`,className:`h-7 flex-1`,disabled:Zt===e.id||Z(e),onClick:()=>Yt(e),children:[(0,y.jsx)(Je,{className:`h-3.5 w-3.5 mr-1`}),S(`approve`,`Approve`)]}),(0,y.jsxs)(m,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:Zt===e.id||Z(e),onClick:()=>Xt(e),children:[(0,y.jsx)(Ce,{className:`h-3.5 w-3.5 mr-1`}),S(`reject`,`Reject`)]})]})]})},e.id))}),A!==`pending`&&Ot!=null&&(0,y.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:S(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:j.length,total:Ot})}),j.length<Ot&&(0,y.jsx)(m,{size:`sm`,variant:`outline`,disabled:Et,onClick:()=>void an(),children:Et?S(`loadingMore`,`Loading…`):S(`loadMore`,`Load more`)})]}),(0,y.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:S(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,y.jsx)(te,{open:!!U,onOpenChange:e=>!e&&Yt(null),children:(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`approveOneTitle`,`Approve "{{title}}"?`,{title:U?U.record_title||x(U.record_id):``})}),(0,y.jsx)(be,{children:S(`approveOneBody`,`This approves the request with your identity. To add a comment or attachment, open the request instead.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>void xn(),children:S(`approve`,`Approve`)})]})]})}),(0,y.jsx)(te,{open:!!W,onOpenChange:e=>!e&&Xt(null),children:(0,y.jsxs)(_e,{children:[(0,y.jsxs)(oe,{children:[(0,y.jsx)(ue,{children:S(`rejectOneTitle`,`Reject "{{title}}"?`,{title:W?W.record_title||x(W.record_id):``})}),(0,y.jsx)(be,{children:S(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,y.jsxs)(ie,{children:[(0,y.jsx)(me,{children:S(`cancel`,`Cancel`)}),(0,y.jsx)(Le,{onClick:()=>void Sn(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:S(`reject`,`Reject`)})]})]})}),(0,y.jsx)(Xe,{open:!!N,onOpenChange:e=>!e&&on(),children:(0,y.jsxs)(Ae,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,y.jsxs)($e,{children:[(0,y.jsx)(Me,{children:P?C(P):S(`drawerTitle`,`Approval Request`)}),(0,y.jsx)(Be,{children:P?lt(P)||mt(P):``})]}),P&&X>=0&&Y.length>1&&(0,y.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,y.jsxs)(m,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X<=0,onClick:()=>{let e=Y[X-1];e&&q(e.id)},children:[(0,y.jsx)(Ye,{className:`h-4 w-4 mr-0.5`}),S(`prevRequest`,`Previous`)]}),(0,y.jsx)(`span`,{children:S(`positionOf`,`Request {{index}} of {{total}}`,{index:X+1,total:Y.length})}),(0,y.jsxs)(m,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:X>=Y.length-1,onClick:()=>{let e=Y[X+1];e&&q(e.id)},children:[S(`nextRequest`,`Next`),(0,y.jsx)(He,{className:`h-4 w-4 ml-0.5`})]})]}),Ft?(0,y.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,y.jsx)(f,{className:`h-6 w-3/4`}),(0,y.jsx)(f,{className:`h-6 w-1/2`}),(0,y.jsx)(f,{className:`h-20 w-full`})]}):P?(0,y.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,y.jsx)(st,{status:P.status,label:D(P.status)}),(P.round??1)>1&&(0,y.jsx)(c,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:S(`roundChip`,`Round {{n}}`,{n:P.round})}),(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:ct(T(P)),children:[(0,y.jsx)(he,{className:`h-3 w-3`}),S(`submittedAgo`,`Submitted {{when}}`,{when:E(T(P))})]}),P.completed_at&&(0,y.jsxs)(`span`,{children:[`· `,S(`completedAt`,`Completed {{when}}`,{when:E(P.completed_at)})]}),P.status===`pending`&&(()=>{let e=vt(P.sla_due_at,w);return e?(0,y.jsx)(c,{variant:`outline`,className:u(`text-[10px]`,e.overdue?`border-red-200 bg-red-50 text-red-700 dark:border-red-500/30 dark:bg-red-500/10 dark:text-red-400`:`border-border text-muted-foreground`),children:yt(e)}):null})()]}),(()=>{let e=k(P),n=bt(P.payload,P.payload_display,P.payload_labels,6,e?.key);return(0,y.jsx)(Oe,{children:(0,y.jsxs)(et,{className:`p-4 space-y-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsxs)(t,{to:xt(P),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,y.jsx)(`span`,{className:`truncate`,children:P.record_title||x(P.record_id)}),(0,y.jsx)(Ke,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:mt(P)})]}),(0,y.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,y.jsx)(`div`,{className:`inline-flex items-center gap-1`,children:pt(P)?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(ce,{className:`h-3 w-3`}),(0,y.jsx)(`span`,{className:`italic`,children:S(`flowOrigin`,`Flow-initiated`)})]}):(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Qe,{className:`h-3 w-3`}),(0,y.jsx)(`span`,{title:P.submitter_id||``,children:ut(P)})]})})})]}),e&&(0,y.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,y.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e.label}),(0,y.jsx)(`div`,{className:`text-xl font-semibold tabular-nums`,title:e.display,children:e.display})]}),n.length>0&&(0,y.jsx)(`div`,{className:u(`grid grid-cols-2 gap-x-4 gap-y-2 text-sm`,!e&&`border-t pt-3`),children:n.map(([e,t])=>(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,y.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),P.decision_progress&&(()=>{let e=P.decision_progress,t=(P.pending_approvers||[]).length;return(0,y.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 mb-1.5`,children:[(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.behavior===`per_group`?S(`progressGroups`,`Sign-off progress — {{got}} of {{need}} groups`,{got:e.got,need:e.need}):S(`progressApprovals`,`Approvals — {{got}} of {{need}}`,{got:e.got,need:e.need})}),e.behavior!==`per_group`&&P.status===`pending`&&t>0&&(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:S(`progressEligible`,`{{count}} eligible approver(s)`,{count:t})})]}),(0,y.jsx)(`div`,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":e.need,"aria-valuenow":Math.min(e.got,e.need),"aria-label":S(`progressBar`,`Decision progress`),className:`flex gap-1`,children:e.need>0&&e.need<=12?Array.from({length:e.need}).map((t,n)=>(0,y.jsx)(`div`,{className:u(`h-1.5 flex-1 rounded-full`,n<e.got?`bg-emerald-500`:`bg-muted`)},n)):(0,y.jsx)(`div`,{className:`h-1.5 flex-1 rounded-full bg-muted overflow-hidden`,children:(0,y.jsx)(`div`,{className:`h-full rounded-full bg-emerald-500`,style:{width:`${e.need>0?Math.min(100,e.got/e.need*100):0}%`}})})}),e.groups&&(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:e.groups.map(e=>(0,y.jsxs)(c,{variant:`outline`,className:u(`text-[11px] gap-1`,e.satisfied?`border-emerald-300 text-emerald-700 dark:border-emerald-700 dark:text-emerald-400`:`text-muted-foreground`),title:`${e.got}/${e.need}`,children:[e.satisfied?(0,y.jsx)(ke,{className:`h-3 w-3`}):(0,y.jsx)(de,{className:`h-2.5 w-2.5`}),e.group,` `,e.got,`/`,e.need]},e.group))})]})})(),P.status===`pending`&&(P.pending_approvers||[]).length>0&&(0,y.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,y.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:S(`waitingOn`,`Waiting on`)}),(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:ft(P).map((e,t)=>(0,y.jsxs)(c,{variant:`outline`,className:`text-[11px]`,title:e.title,children:[e.label,e.group&&(0,y.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`· `,e.group]}),e.count>1&&(0,y.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`×`,e.count]})]},`${e.label}-${e.group??``}-${t}`))})]})]})})})(),(P.flow_steps?.length??0)>1&&(0,y.jsx)(`div`,{className:`flex items-center px-1`,"aria-label":S(`stepProgress`,`Approval steps`),children:P.flow_steps.map((e,t)=>(0,y.jsxs)(g.Fragment,{children:[t>0&&(0,y.jsx)(`div`,{className:u(`h-px flex-1 mx-2`,e.state===`done`||e.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,y.jsx)(`span`,{className:u(`flex items-center justify-center h-5 w-5 rounded-full text-[10px] font-semibold`,e.state===`done`&&`bg-emerald-500 text-white`,e.state===`current`&&`bg-amber-500 text-white ring-2 ring-amber-200 dark:ring-amber-500/30`,e.state===`upcoming`&&`bg-muted text-muted-foreground border`),children:e.state===`done`?(0,y.jsx)(ke,{className:`h-3 w-3`}):t+1}),(0,y.jsx)(`span`,{className:u(`text-xs`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]})]},e.id))}),(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:S(`history`,`Activity`)}),Pt.length===0?(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`noActions`,`No actions yet.`)}):(0,y.jsx)(`ol`,{className:`relative space-y-3 pl-5 before:absolute before:left-[7px] before:top-1 before:bottom-1 before:w-px before:bg-border`,children:Pt.map(e=>{let t=e.action===`approve`?`bg-emerald-500`:e.action===`reject`?`bg-destructive`:e.action===`submit`?`bg-blue-500`:e.action===`reassign`?`bg-indigo-500`:e.action===`remind`||e.action===`request_info`?`bg-amber-500`:e.action===`comment`?`bg-slate-400`:e.action===`escalate`?`bg-red-500`:e.action===`revise`?`bg-violet-500`:e.action===`resubmit`?`bg-blue-500`:`bg-muted-foreground`,n=e.actor_id===`system:sla`?S(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===P.submitter_id?ut(P):x(e.actor_id)),r=e.action===`submit`?S(`actSubmit`,`Submitted`):e.action===`approve`?S(`actApprove`,`Approved`):e.action===`reject`?S(`actReject`,`Rejected`):e.action===`recall`?S(`actRecall`,`Recalled`):e.action===`reassign`?S(`actReassign`,`Reassigned`):e.action===`remind`?S(`actRemind`,`Reminder sent`):e.action===`request_info`?S(`actRequestInfo`,`Requested more info`):e.action===`comment`?S(`actComment`,`Commented`):e.action===`escalate`?S(`actEscalate`,`SLA escalated`):e.action===`revise`?S(`actRevise`,`Sent back for revision`):e.action===`resubmit`?S(`actResubmit`,`Resubmitted`):e.action;return(0,y.jsxs)(`li`,{className:`relative text-xs`,children:[(0,y.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,y.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,y.jsx)(`span`,{className:`font-medium`,children:r}),(0,y.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,y.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,y.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:ct(e.created_at),children:E(e.created_at)})]}),(()=>{let t=e;return e.action!==`reassign`||!t.reassign_from&&!t.reassign_to?null:(0,y.jsx)(`div`,{className:`text-muted-foreground mt-0.5`,children:S(`reassignFromTo`,`from {{from}} to {{to}}`,{from:t.reassign_from_name??x(t.reassign_from),to:t.reassign_to_name??x(t.reassign_to)})})})(),e.comment&&(0,y.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]}),Array.isArray(e.attachments)&&e.attachments.length>0&&(0,y.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1`,children:e.attachments.map((t,n)=>(0,y.jsxs)(`button`,{type:`button`,onClick:()=>void Rt(t),className:`inline-flex items-center gap-1 text-[11px] px-2 py-0.5 rounded-full border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,title:t.name||t.id,children:[(0,y.jsx)(tt,{className:`h-3 w-3`}),t.name||`${S(`attachmentChip`,`Attachment`)}${e.attachments.length>1?` ${n+1}`:``}`]},t.id||n))})]},e.id)})}),P.status===`pending`&&(un||dn)&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,y.jsx)(Te,{value:G,onChange:e=>$t(e.target.value),onKeyDown:e=>{e.key===`Enter`&&G.trim()&&(e.preventDefault(),ln())},placeholder:S(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,y.jsx)(m,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!G.trim()||en,onClick:()=>void ln(),children:(0,y.jsx)(qe,{className:`h-3.5 w-3.5`})})]})]}),P.payload!=null&&(0,y.jsxs)(`details`,{className:`group`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:S(`rawData`,`Raw data (JSON)`)}),(0,y.jsxs)(`div`,{className:`mt-2`,children:[(0,y.jsx)(`div`,{className:`flex justify-end`,children:(0,y.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(P.payload,null,2)),h.success(S(`copied`,`Copied`))}catch{h.error(S(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,y.jsx)(nt,{className:`h-3 w-3`}),S(`copy`,`Copy`)]})}),(0,y.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(P.payload,null,2)})]})]}),P.status===`pending`&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Pe,{}),(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(rt,{objectName:`sys_approval_request`,record:P,location:`record_section`,label:S(`declaredActions`,`Actions`),onDone:()=>{cn()}}),!un&&(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:dn?S(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):S(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(P.pending_approvers||[]).map(e=>dt(e,P)).join(`, `)||`—`})})]})]}),fn&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Pe,{}),(0,y.jsxs)(`div`,{className:`space-y-3`,children:[(0,y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:S(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,y.jsxs)(`div`,{className:`flex gap-2 flex-wrap items-center`,children:[(0,y.jsx)(m,{asChild:!0,size:`sm`,variant:`outline`,children:(0,y.jsxs)(t,{to:xt(P),children:[(0,y.jsx)(Ke,{className:`h-4 w-4 mr-1`}),S(`editRecordBtn`,`Edit record`)]})}),(0,y.jsx)(rt,{objectName:`sys_approval_request`,record:P,location:`record_section`,onDone:()=>{sn(P.id),K()}})]})]})]})]}):null]})})]})}export{A as ApprovalsInboxPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{Gc as r,Ms as i,Ni as a,Oo as o,Tn as s,Xs as c,co as l,cr as u,dr as d,eo as f,fr as ee,go as p,hc as m,ji as h,lr as g,nl as _,pc as v,sr as y,ur as te,zr as b}from"./ui-components-BbC0qTrK.js";import{n as x}from"./createDerive-DmbuzviK.js";import{a as S,i as C,n as w,o as T,r as E,s as ne,t as D}from"./plugin-view-Dy9ZzWYn.js";var O=e(n(),1),k=t();function A({title:e,description:t,icon:n,actions:i,accentColor:a,sticky:o=!1,className:s,"data-testid":c}){return(0,k.jsxs)(`div`,{style:{"--page-header-accent":a||`hsl(var(--primary))`},className:r(`relative shrink-0 border-b bg-background z-10`,o&&`sticky top-0 bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/75`,s),"data-testid":c??`page-header`,children:[(0,k.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-80`,style:{background:`linear-gradient(90deg, transparent, var(--page-header-accent), transparent)`}}),(0,k.jsxs)(`div`,{className:`flex justify-between items-center gap-3 py-2.5 sm:py-3 px-4 sm:px-6`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[n&&(0,k.jsx)(`div`,{className:r(`shrink-0 inline-flex items-center justify-center rounded-lg`,`h-9 w-9 sm:h-10 sm:w-10`,`[&_svg]:h-[18px] [&_svg]:w-[18px] sm:[&_svg]:h-5 sm:[&_svg]:w-5`),style:{color:`var(--page-header-accent)`,background:`linear-gradient(135deg, color-mix(in srgb, var(--page-header-accent) 18%, transparent), color-mix(in srgb, var(--page-header-accent) 6%, transparent))`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, var(--page-header-accent) 22%, transparent)`},children:n}),(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`h1`,{className:`text-base sm:text-lg lg:text-xl font-semibold tracking-tight text-foreground truncate leading-tight`,children:e}),t&&(0,k.jsx)(`p`,{className:`text-xs sm:text-sm text-muted-foreground truncate hidden sm:block max-w-xl mt-0.5`,children:t})]})]}),i&&(0,k.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:i})]})]})}function j(e){return[{type:`grid`,icon:p,label:e(`console.objectView.viewTypeGrid`),description:e(`console.objectView.viewTypeGridDesc`)},{type:`kanban`,icon:h,label:e(`console.objectView.viewTypeKanban`),description:e(`console.objectView.viewTypeKanbanDesc`)},{type:`calendar`,icon:m,label:e(`console.objectView.viewTypeCalendar`),description:e(`console.objectView.viewTypeCalendarDesc`)},{type:`gallery`,icon:o,label:e(`console.objectView.viewTypeGallery`),description:e(`console.objectView.viewTypeGalleryDesc`)},{type:`timeline`,icon:i,label:e(`console.objectView.viewTypeTimeline`),description:e(`console.objectView.viewTypeTimelineDesc`)},{type:`gantt`,icon:a,label:e(`console.objectView.viewTypeGantt`),description:e(`console.objectView.viewTypeGanttDesc`)},{type:`map`,icon:f,label:e(`console.objectView.viewTypeMap`),description:e(`console.objectView.viewTypeMapDesc`)},{type:`chart`,icon:v,label:e(`console.objectView.viewTypeChart`),description:e(`console.objectView.viewTypeChartDesc`)},{type:`tree`,icon:l,label:e(`console.objectView.viewTypeTree`),description:e(`console.objectView.viewTypeTreeDesc`)}]}function M(e,t){for(let n=1;n<1e3;n++){let r=`${e} ${n}`;if(!t.has(r))return r}return e}var N={kanban:[{key:`groupByField`,i18nKey:`console.objectView.groupByField`,helpI18nKey:`console.objectView.groupByFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`,preferred:w}],calendar:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.startDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],timeline:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.timelineDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gantt:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.ganttStartDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`endDateField`,i18nKey:`console.objectView.endDateField`,helpI18nKey:`console.objectView.ganttEndDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gallery:[{key:`coverField`,i18nKey:`console.objectView.imageField`,helpI18nKey:`console.objectView.imageFieldHelp`,filter:e=>T(e)}],map:[{key:`latitudeField`,i18nKey:`console.objectView.latitudeField`,helpI18nKey:`console.objectView.latitudeFieldHelp`,filter:e=>e.type===`number`&&S(e,`latitude`)},{key:`longitudeField`,i18nKey:`console.objectView.longitudeField`,helpI18nKey:`console.objectView.longitudeFieldHelp`,filter:e=>e.type===`number`&&S(e,`longitude`)}],chart:[{key:`chartType`,i18nKey:`console.objectView.chartType`,helpI18nKey:`console.objectView.chartTypeHelp`,kind:`enum`,enumOptions:[{value:`bar`,i18nKey:`console.objectView.chartTypeBar`},{value:`line`,i18nKey:`console.objectView.chartTypeLine`},{value:`pie`,i18nKey:`console.objectView.chartTypePie`},{value:`area`,i18nKey:`console.objectView.chartTypeArea`},{value:`scatter`,i18nKey:`console.objectView.chartTypeScatter`}],defaultValue:`bar`},{key:`xAxisField`,i18nKey:`console.objectView.xAxisField`,helpI18nKey:`console.objectView.xAxisFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`||e.type===`date`||e.type===`text`,preferred:w},{key:`yAxisFields`,i18nKey:`console.objectView.yAxisField`,helpI18nKey:`console.objectView.yAxisFieldHelp`,filter:e=>e.type===`number`}],tree:[{key:`parentField`,i18nKey:`console.objectView.parentField`,helpI18nKey:`console.objectView.parentFieldHelp`,filter:e=>e.rawType===`tree`||e.rawType===`lookup`||e.rawType===`master_detail`}]};function P({open:e,onOpenChange:t,onCreate:n,existingLabels:i,availableTypes:a,objectDef:o}){let{t:l}=_(),f=(0,O.useMemo)(()=>j(l),[l]),p=(0,O.useMemo)(()=>a&&a.length>0?f.filter(e=>a.includes(e.type)):f,[f,a]),m=(i??[]).join(`\0`),h=(0,O.useMemo)(()=>new Set(i??[]),[m]),v=(0,O.useMemo)(()=>o?C(o):[],[o]),[S,w]=(0,O.useState)(p[0]?.type??`grid`),[T,E]=(0,O.useState)(``),[D,A]=(0,O.useState)(!1),[P,F]=(0,O.useState)(``),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)({});(0,O.useEffect)(()=>{e&&(w(p[0]?.type??`grid`),A(!1),L(!1),z({}))},[e,p]),(0,O.useEffect)(()=>{if(!D){let e=p.find(e=>e.type===S);E(M(e?.label??`View`,h))}},[S,D,p,h]),(0,O.useEffect)(()=>{I||F(x(T))},[T,I]);let B=N[S]??[],V=e=>e.kind===`enum`?(e.enumOptions?.length??0)>0:!o||(e.filter?v.filter(e.filter):v).length>0,H=(0,O.useMemo)(()=>{let e={};return p.forEach(t=>{let n=(N[t.type]??[]).find(e=>!V(e));e[t.type]=n??null}),e},[p,v,o]),U=e=>R[`${S}.${e}`]??``,W=(e,t)=>z(n=>({...n,[`${S}.${e}`]:t})),G=T.trim(),K=G.length>0&&h.has(G),q=B.every(e=>U(e.key).length>0),J=/^[a-z_][a-z0-9_]*$/,Y=P.trim(),X=Y.length===0,Z=Y.length>0&&!J.test(Y),Q=G.length>0&&!K&&q&&!X&&!Z;(0,O.useEffect)(()=>{B.length!==0&&B.forEach(e=>{if(U(e.key).length>0)return;if(e.kind===`enum`){e.defaultValue&&W(e.key,e.defaultValue);return}let t=e.filter?v.filter(e.filter):v;if(t.length===0)return;if(t.length===1){W(e.key,t[0].value);return}let n=ne(t,e.preferred??[]);n&&W(e.key,n)})},[S,v]);let $=()=>{if(!Q)return;let e={};B.forEach(t=>{let n=U(t.key);n&&(e[t.key]=t.key===`yAxisFields`?[n]:n)});let r={type:S,label:G,name:Y};Object.keys(e).length>0&&(r[S]=e),n(r),t(!1)};return(0,k.jsx)(y,{open:e,onOpenChange:t,children:(0,k.jsxs)(u,{className:`sm:max-w-[560px]`,"data-testid":`create-view-dialog`,children:[(0,k.jsxs)(d,{children:[(0,k.jsx)(ee,{children:l(`console.objectView.createView`)}),(0,k.jsx)(g,{children:l(`console.objectView.createViewDesc`)})]}),(0,k.jsx)(`div`,{className:`grid grid-cols-4 gap-2 py-2`,"data-testid":`create-view-type-grid`,children:p.map(({type:e,label:t,description:n,icon:i})=>{let a=e===S,o=H[e],s=!!o,c=s?l(`console.objectView.viewTypeUnavailable`,{field:l(o.i18nKey)}):void 0;return(0,k.jsxs)(`button`,{type:`button`,"data-testid":`create-view-type-${e}`,"aria-pressed":a,"aria-disabled":s,disabled:s,title:c,onClick:()=>{s||w(e)},className:r(`group flex flex-col items-start gap-1 rounded-lg border bg-background p-3 text-left transition-colors`,!s&&`hover:border-primary/60 hover:bg-accent/40`,a&&!s?`border-primary ring-2 ring-primary/30 bg-accent/40`:`border-border`,s&&`opacity-50 cursor-not-allowed`),children:[(0,k.jsx)(i,{className:r(`h-5 w-5`,a&&!s?`text-primary`:`text-muted-foreground group-hover:text-foreground`)}),(0,k.jsx)(`div`,{className:`text-xs font-medium leading-tight`,children:t}),(0,k.jsx)(`div`,{className:`text-[10px] leading-tight text-muted-foreground line-clamp-2`,children:s?l(`console.objectView.viewTypeUnavailableShort`):n})]},e)})}),B.length>0&&(0,k.jsx)(`div`,{className:`space-y-3 rounded-md border border-dashed bg-muted/30 p-3`,"data-testid":`create-view-required-fields`,children:B.map(e=>{let t=U(e.key),n=e.kind===`enum`,i=n?[]:e.filter?v.filter(e.filter):v,a=!n&&v.length>0&&i.length===0;return(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-required-${e.key}`,className:`text-xs font-medium`,children:[l(e.i18nKey),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,k.jsxs)(`select`,{id:`create-view-required-${e.key}`,"data-testid":`create-view-required-${e.key}`,value:t,onChange:t=>W(e.key,t.target.value),disabled:a,className:r(`h-9 w-full rounded-md border bg-background px-2 text-xs`,`border-input`),children:[(0,k.jsx)(`option`,{value:``,children:l(n?`console.objectView.selectOption`:`console.objectView.selectField`)}),n?e.enumOptions.map(e=>(0,k.jsx)(`option`,{value:e.value,children:l(e.i18nKey)},e.value)):i.map(e=>(0,k.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),e.helpI18nKey&&!a&&(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:l(e.helpI18nKey)}),a&&(0,k.jsxs)(`p`,{className:`flex items-center gap-1 text-[11px] text-destructive`,"data-testid":`create-view-error-no-field-${e.key}`,children:[(0,k.jsx)(c,{className:`h-3 w-3`}),l(`console.objectView.noEligibleFieldForType`)]})]},e.key)})}),(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-name-input`,className:`text-xs font-medium`,children:[l(`console.objectView.title`),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,k.jsx)(s,{id:`create-view-name-input`,"data-testid":`create-view-name-input`,autoFocus:!0,value:T,onChange:e=>{E(e.target.value),A(!0)},onKeyDown:e=>{e.key===`Enter`&&Q&&$()},placeholder:l(`console.objectView.newView`),className:`h-9`}),K&&(0,k.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-duplicate`,children:l(`console.objectView.duplicateViewName`)})]}),(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-machine-name-input`,className:`text-xs font-medium`,children:[l(`console.objectView.viewName`),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,k.jsx)(s,{id:`create-view-machine-name-input`,"data-testid":`create-view-machine-name-input`,value:P,onChange:e=>{F(e.target.value),L(!0)},onKeyDown:e=>{e.key===`Enter`&&Q&&$()},placeholder:`grid_1`,className:`h-9 font-mono`}),X?(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-testid":`create-view-machine-name-help`,children:l(`console.objectView.viewNameRequired`)}):Z?(0,k.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-machine-name`,children:l(`console.objectView.viewNameInvalid`)}):(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-testid":`create-view-machine-name-help`,children:l(`console.objectView.viewNameHelp`)})]}),(0,k.jsxs)(te,{className:`mt-2`,children:[(0,k.jsx)(b,{type:`button`,variant:`outline`,onClick:()=>t(!1),"data-testid":`create-view-cancel`,children:l(`console.objectView.cancel`)}),(0,k.jsx)(b,{type:`button`,disabled:!Q,onClick:$,"data-testid":`create-view-submit`,children:l(`console.objectView.create`)})]})]})})}export{A as n,P as t};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{Gc as r,Ms as i,Ni as a,Oo as o,Tn as s,Xs as c,co as l,cr as u,dr as d,eo as f,fr as ee,go as p,hc as m,ji as h,lr as g,nl as _,pc as v,sr as y,ur as te,zr as b}from"./ui-components-BbC0qTrK.js";import{n as x}from"./createDerive-CGF05Hgy.js";import{a as S,i as C,n as w,o as T,r as E,s as ne,t as D}from"./plugin-view-Dy9ZzWYn.js";var O=e(n(),1),k=t();function A({title:e,description:t,icon:n,actions:i,accentColor:a,sticky:o=!1,className:s,"data-testid":c}){return(0,k.jsxs)(`div`,{style:{"--page-header-accent":a||`hsl(var(--primary))`},className:r(`relative shrink-0 border-b bg-background z-10`,o&&`sticky top-0 bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/75`,s),"data-testid":c??`page-header`,children:[(0,k.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-80`,style:{background:`linear-gradient(90deg, transparent, var(--page-header-accent), transparent)`}}),(0,k.jsxs)(`div`,{className:`flex justify-between items-center gap-3 py-2.5 sm:py-3 px-4 sm:px-6`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[n&&(0,k.jsx)(`div`,{className:r(`shrink-0 inline-flex items-center justify-center rounded-lg`,`h-9 w-9 sm:h-10 sm:w-10`,`[&_svg]:h-[18px] [&_svg]:w-[18px] sm:[&_svg]:h-5 sm:[&_svg]:w-5`),style:{color:`var(--page-header-accent)`,background:`linear-gradient(135deg, color-mix(in srgb, var(--page-header-accent) 18%, transparent), color-mix(in srgb, var(--page-header-accent) 6%, transparent))`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, var(--page-header-accent) 22%, transparent)`},children:n}),(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`h1`,{className:`text-base sm:text-lg lg:text-xl font-semibold tracking-tight text-foreground truncate leading-tight`,children:e}),t&&(0,k.jsx)(`p`,{className:`text-xs sm:text-sm text-muted-foreground truncate hidden sm:block max-w-xl mt-0.5`,children:t})]})]}),i&&(0,k.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:i})]})]})}function j(e){return[{type:`grid`,icon:p,label:e(`console.objectView.viewTypeGrid`),description:e(`console.objectView.viewTypeGridDesc`)},{type:`kanban`,icon:h,label:e(`console.objectView.viewTypeKanban`),description:e(`console.objectView.viewTypeKanbanDesc`)},{type:`calendar`,icon:m,label:e(`console.objectView.viewTypeCalendar`),description:e(`console.objectView.viewTypeCalendarDesc`)},{type:`gallery`,icon:o,label:e(`console.objectView.viewTypeGallery`),description:e(`console.objectView.viewTypeGalleryDesc`)},{type:`timeline`,icon:i,label:e(`console.objectView.viewTypeTimeline`),description:e(`console.objectView.viewTypeTimelineDesc`)},{type:`gantt`,icon:a,label:e(`console.objectView.viewTypeGantt`),description:e(`console.objectView.viewTypeGanttDesc`)},{type:`map`,icon:f,label:e(`console.objectView.viewTypeMap`),description:e(`console.objectView.viewTypeMapDesc`)},{type:`chart`,icon:v,label:e(`console.objectView.viewTypeChart`),description:e(`console.objectView.viewTypeChartDesc`)},{type:`tree`,icon:l,label:e(`console.objectView.viewTypeTree`),description:e(`console.objectView.viewTypeTreeDesc`)}]}function M(e,t){for(let n=1;n<1e3;n++){let r=`${e} ${n}`;if(!t.has(r))return r}return e}var N={kanban:[{key:`groupByField`,i18nKey:`console.objectView.groupByField`,helpI18nKey:`console.objectView.groupByFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`,preferred:w}],calendar:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.startDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],timeline:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.timelineDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gantt:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.ganttStartDateFieldHelp`,filter:e=>e.type===`date`,preferred:E},{key:`endDateField`,i18nKey:`console.objectView.endDateField`,helpI18nKey:`console.objectView.ganttEndDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gallery:[{key:`coverField`,i18nKey:`console.objectView.imageField`,helpI18nKey:`console.objectView.imageFieldHelp`,filter:e=>T(e)}],map:[{key:`latitudeField`,i18nKey:`console.objectView.latitudeField`,helpI18nKey:`console.objectView.latitudeFieldHelp`,filter:e=>e.type===`number`&&S(e,`latitude`)},{key:`longitudeField`,i18nKey:`console.objectView.longitudeField`,helpI18nKey:`console.objectView.longitudeFieldHelp`,filter:e=>e.type===`number`&&S(e,`longitude`)}],chart:[{key:`chartType`,i18nKey:`console.objectView.chartType`,helpI18nKey:`console.objectView.chartTypeHelp`,kind:`enum`,enumOptions:[{value:`bar`,i18nKey:`console.objectView.chartTypeBar`},{value:`line`,i18nKey:`console.objectView.chartTypeLine`},{value:`pie`,i18nKey:`console.objectView.chartTypePie`},{value:`area`,i18nKey:`console.objectView.chartTypeArea`},{value:`scatter`,i18nKey:`console.objectView.chartTypeScatter`}],defaultValue:`bar`},{key:`xAxisField`,i18nKey:`console.objectView.xAxisField`,helpI18nKey:`console.objectView.xAxisFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`||e.type===`date`||e.type===`text`,preferred:w},{key:`yAxisFields`,i18nKey:`console.objectView.yAxisField`,helpI18nKey:`console.objectView.yAxisFieldHelp`,filter:e=>e.type===`number`}],tree:[{key:`parentField`,i18nKey:`console.objectView.parentField`,helpI18nKey:`console.objectView.parentFieldHelp`,filter:e=>e.rawType===`tree`||e.rawType===`lookup`||e.rawType===`master_detail`}]};function P({open:e,onOpenChange:t,onCreate:n,existingLabels:i,availableTypes:a,objectDef:o}){let{t:l}=_(),f=(0,O.useMemo)(()=>j(l),[l]),p=(0,O.useMemo)(()=>a&&a.length>0?f.filter(e=>a.includes(e.type)):f,[f,a]),m=(i??[]).join(`\0`),h=(0,O.useMemo)(()=>new Set(i??[]),[m]),v=(0,O.useMemo)(()=>o?C(o):[],[o]),[S,w]=(0,O.useState)(p[0]?.type??`grid`),[T,E]=(0,O.useState)(``),[D,A]=(0,O.useState)(!1),[P,F]=(0,O.useState)(``),[I,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)({});(0,O.useEffect)(()=>{e&&(w(p[0]?.type??`grid`),A(!1),L(!1),z({}))},[e,p]),(0,O.useEffect)(()=>{if(!D){let e=p.find(e=>e.type===S);E(M(e?.label??`View`,h))}},[S,D,p,h]),(0,O.useEffect)(()=>{I||F(x(T))},[T,I]);let B=N[S]??[],V=e=>e.kind===`enum`?(e.enumOptions?.length??0)>0:!o||(e.filter?v.filter(e.filter):v).length>0,H=(0,O.useMemo)(()=>{let e={};return p.forEach(t=>{let n=(N[t.type]??[]).find(e=>!V(e));e[t.type]=n??null}),e},[p,v,o]),U=e=>R[`${S}.${e}`]??``,W=(e,t)=>z(n=>({...n,[`${S}.${e}`]:t})),G=T.trim(),K=G.length>0&&h.has(G),q=B.every(e=>U(e.key).length>0),J=/^[a-z_][a-z0-9_]*$/,Y=P.trim(),X=Y.length===0,Z=Y.length>0&&!J.test(Y),Q=G.length>0&&!K&&q&&!X&&!Z;(0,O.useEffect)(()=>{B.length!==0&&B.forEach(e=>{if(U(e.key).length>0)return;if(e.kind===`enum`){e.defaultValue&&W(e.key,e.defaultValue);return}let t=e.filter?v.filter(e.filter):v;if(t.length===0)return;if(t.length===1){W(e.key,t[0].value);return}let n=ne(t,e.preferred??[]);n&&W(e.key,n)})},[S,v]);let $=()=>{if(!Q)return;let e={};B.forEach(t=>{let n=U(t.key);n&&(e[t.key]=t.key===`yAxisFields`?[n]:n)});let r={type:S,label:G,name:Y};Object.keys(e).length>0&&(r[S]=e),n(r),t(!1)};return(0,k.jsx)(y,{open:e,onOpenChange:t,children:(0,k.jsxs)(u,{className:`sm:max-w-[560px]`,"data-testid":`create-view-dialog`,children:[(0,k.jsxs)(d,{children:[(0,k.jsx)(ee,{children:l(`console.objectView.createView`)}),(0,k.jsx)(g,{children:l(`console.objectView.createViewDesc`)})]}),(0,k.jsx)(`div`,{className:`grid grid-cols-4 gap-2 py-2`,"data-testid":`create-view-type-grid`,children:p.map(({type:e,label:t,description:n,icon:i})=>{let a=e===S,o=H[e],s=!!o,c=s?l(`console.objectView.viewTypeUnavailable`,{field:l(o.i18nKey)}):void 0;return(0,k.jsxs)(`button`,{type:`button`,"data-testid":`create-view-type-${e}`,"aria-pressed":a,"aria-disabled":s,disabled:s,title:c,onClick:()=>{s||w(e)},className:r(`group flex flex-col items-start gap-1 rounded-lg border bg-background p-3 text-left transition-colors`,!s&&`hover:border-primary/60 hover:bg-accent/40`,a&&!s?`border-primary ring-2 ring-primary/30 bg-accent/40`:`border-border`,s&&`opacity-50 cursor-not-allowed`),children:[(0,k.jsx)(i,{className:r(`h-5 w-5`,a&&!s?`text-primary`:`text-muted-foreground group-hover:text-foreground`)}),(0,k.jsx)(`div`,{className:`text-xs font-medium leading-tight`,children:t}),(0,k.jsx)(`div`,{className:`text-[10px] leading-tight text-muted-foreground line-clamp-2`,children:s?l(`console.objectView.viewTypeUnavailableShort`):n})]},e)})}),B.length>0&&(0,k.jsx)(`div`,{className:`space-y-3 rounded-md border border-dashed bg-muted/30 p-3`,"data-testid":`create-view-required-fields`,children:B.map(e=>{let t=U(e.key),n=e.kind===`enum`,i=n?[]:e.filter?v.filter(e.filter):v,a=!n&&v.length>0&&i.length===0;return(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-required-${e.key}`,className:`text-xs font-medium`,children:[l(e.i18nKey),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,k.jsxs)(`select`,{id:`create-view-required-${e.key}`,"data-testid":`create-view-required-${e.key}`,value:t,onChange:t=>W(e.key,t.target.value),disabled:a,className:r(`h-9 w-full rounded-md border bg-background px-2 text-xs`,`border-input`),children:[(0,k.jsx)(`option`,{value:``,children:l(n?`console.objectView.selectOption`:`console.objectView.selectField`)}),n?e.enumOptions.map(e=>(0,k.jsx)(`option`,{value:e.value,children:l(e.i18nKey)},e.value)):i.map(e=>(0,k.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),e.helpI18nKey&&!a&&(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:l(e.helpI18nKey)}),a&&(0,k.jsxs)(`p`,{className:`flex items-center gap-1 text-[11px] text-destructive`,"data-testid":`create-view-error-no-field-${e.key}`,children:[(0,k.jsx)(c,{className:`h-3 w-3`}),l(`console.objectView.noEligibleFieldForType`)]})]},e.key)})}),(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-name-input`,className:`text-xs font-medium`,children:[l(`console.objectView.title`),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,k.jsx)(s,{id:`create-view-name-input`,"data-testid":`create-view-name-input`,autoFocus:!0,value:T,onChange:e=>{E(e.target.value),A(!0)},onKeyDown:e=>{e.key===`Enter`&&Q&&$()},placeholder:l(`console.objectView.newView`),className:`h-9`}),K&&(0,k.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-duplicate`,children:l(`console.objectView.duplicateViewName`)})]}),(0,k.jsxs)(`div`,{className:`space-y-1`,children:[(0,k.jsxs)(`label`,{htmlFor:`create-view-machine-name-input`,className:`text-xs font-medium`,children:[l(`console.objectView.viewName`),(0,k.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,k.jsx)(s,{id:`create-view-machine-name-input`,"data-testid":`create-view-machine-name-input`,value:P,onChange:e=>{F(e.target.value),L(!0)},onKeyDown:e=>{e.key===`Enter`&&Q&&$()},placeholder:`grid_1`,className:`h-9 font-mono`}),X?(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-testid":`create-view-machine-name-help`,children:l(`console.objectView.viewNameRequired`)}):Z?(0,k.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-machine-name`,children:l(`console.objectView.viewNameInvalid`)}):(0,k.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,"data-testid":`create-view-machine-name-help`,children:l(`console.objectView.viewNameHelp`)})]}),(0,k.jsxs)(te,{className:`mt-2`,children:[(0,k.jsx)(b,{type:`button`,variant:`outline`,onClick:()=>t(!1),"data-testid":`create-view-cancel`,children:l(`console.objectView.cancel`)}),(0,k.jsx)(b,{type:`button`,disabled:!Q,onClick:$,"data-testid":`create-view-submit`,children:l(`console.objectView.create`)})]})]})})}export{A as n,P as t};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{m as n,r,y as i}from"./vendor-react-DpRf6e0g.js";import{N as a,P as o,b as s}from"./framework-UESyszCj.js";import{Zc as c,_o as l,cr as u,ct as d,dr as f,dt as p,fr as m,lr as h,nl as g,sr as _,st as v,ur as y,zr as b}from"./ui-components-BbC0qTrK.js";import{r as x}from"./vendor-ui-utils-CnzHPXVC.js";import"./AdapterProvider-CtRy19L4.js";import{n as S}from"./plugin-form-D_JAwPGr.js";import"./MetadataProvider-87BSQkFa.js";import{r as C}from"./ExpressionProvider-BQFSoabd.js";import{t as w}from"./preferLocal-CKqyhTP9.js";import{t as T}from"./utils-CFdPTF34.js";import{n as E,t as D}from"./MetadataInspector-B7LigfJm.js";import{n as O}from"./skeletons-C8REUFE6.js";import{n as k}from"./plugin-dashboard-Cz2sTF7I.js";import{t as A}from"./useOpenRecordList-aRVznRXU.js";var j=t({DashboardView:()=>P}),M=e(i(),1),N=r();function P({dataSource:e}){let t=A(),{dashboardName:r}=n(),{showDebug:i}=E(),j=a(),{t:P}=g(),{dashboardLabel:F,dashboardDescription:I}=c(),[L,R]=(0,M.useState)(!0),[z,B]=(0,M.useState)(null),V=(0,M.useCallback)(e=>{B(t=>(t&&t.resolve(e),null))},[]),H=(0,M.useCallback)(e=>new Promise(t=>{let n;if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);if(t){let e=t[1];n={objectName:t[2],mode:e===`edit`||e===`update`?`edit`:`create`}}else n={objectName:e,mode:`create`}}else n=e;B({schema:n,resolve:t})}),[]),U=(0,M.useMemo)(()=>({export_dashboard_pdf:async()=>{x.info(P(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return x.error(P(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(x.info(P(`dashboardActions.forecastSoon`)),{success:!0})}),[P]);(0,M.useEffect)(()=>{R(!0),queueMicrotask(()=>R(!1))},[r]);let{dashboards:W,objects:G}=o(),{app:K}=C(),q=w(W,r,K?._packageId),J=(0,M.useMemo)(()=>new Set((G||[]).map(e=>e?.name).filter(Boolean)),[G]),Y=(0,M.useMemo)(()=>{if(!q||J.size===0)return q;let e=q.widgets;if(!Array.isArray(e)||e.length===0)return q;let t=e.filter(e=>{let t=e?.requiresObject??e?.object;return!t||J.has(t)});return t.length===e.length?q:{...q,widgets:t}},[q,J]);return L?(0,N.jsx)(O,{}):q?(0,N.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,N.jsx)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=T((Y||q).title,P),t=T(q.label,P),n=F({name:q.name,label:t}),r=e||n||q.name;return(0,N.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:r})})(),(()=>{let e=(Y||q).description??q.description,t=I({name:q.name,description:T(e,P)});return t?(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]})}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,N.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,N.jsx)(s,{value:{openRecordList:t},children:(0,N.jsx)(k,{schema:Y,dataSource:e,modalHandler:H,scriptHandlers:U,hideHeaderText:!0})})}),(0,N.jsx)(D,{open:i,sections:[{title:`Dashboard Configuration`,data:Y}]})]}),z&&z.schema?.objectName?(0,N.jsx)(S,{schema:{type:`object-form`,formType:`modal`,objectName:z.schema.objectName,mode:z.schema.mode||`create`,recordId:z.schema.recordId,title:z.schema.title,description:z.schema.description,fields:z.schema.fields,open:!0,onOpenChange:e=>{e||V({success:!1})},onSuccess:e=>{V({success:!0,reload:!0,data:e})},onCancel:()=>{V({success:!1})},showSubmit:!0,showCancel:!0},dataSource:j}):z?(0,N.jsx)(_,{open:!0,onOpenChange:e=>{e||V({success:!1})},children:(0,N.jsxs)(u,{children:[(0,N.jsxs)(f,{children:[(0,N.jsx)(m,{children:z.schema?.title||P(`actionDialog.defaultActionTitle`)}),z.schema?.description&&(0,N.jsx)(h,{children:z.schema.description})]}),(0,N.jsxs)(y,{children:[(0,N.jsx)(b,{variant:`outline`,onClick:()=>V({success:!1}),children:P(`actionDialog.cancel`)}),(0,N.jsx)(b,{onClick:()=>V({success:!0}),children:P(`actionDialog.ok`)})]})]})}):null]}):(0,N.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,N.jsxs)(v,{children:[(0,N.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,N.jsx)(l,{className:`h-6 w-6 text-muted-foreground`})}),(0,N.jsx)(p,{children:P(`empty.dashboardNotFound`)}),(0,N.jsx)(d,{children:P(`empty.dashboardNotFoundDescription`,{name:r})})]})})}export{j as t};
1
+ import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{m as n,r,y as i}from"./vendor-react-DpRf6e0g.js";import{N as a,P as o,b as s}from"./framework-UESyszCj.js";import{Zc as c,_o as l,cr as u,ct as d,dr as f,dt as p,fr as m,lr as h,nl as g,sr as _,st as v,ur as y,zr as b}from"./ui-components-BbC0qTrK.js";import{r as x}from"./vendor-ui-utils-CnzHPXVC.js";import"./AdapterProvider-Bur-uZKZ.js";import{n as S}from"./plugin-form-D_JAwPGr.js";import"./MetadataProvider-D9fSVVZp.js";import{r as C}from"./ExpressionProvider-BQFSoabd.js";import{t as w}from"./preferLocal-CKqyhTP9.js";import{t as T}from"./utils-CFdPTF34.js";import{n as E,t as D}from"./MetadataInspector-B7LigfJm.js";import{n as O}from"./skeletons-C8REUFE6.js";import{n as k}from"./plugin-dashboard-Cz2sTF7I.js";import{t as A}from"./useOpenRecordList-aRVznRXU.js";var j=t({DashboardView:()=>P}),M=e(i(),1),N=r();function P({dataSource:e}){let t=A(),{dashboardName:r}=n(),{showDebug:i}=E(),j=a(),{t:P}=g(),{dashboardLabel:F,dashboardDescription:I}=c(),[L,R]=(0,M.useState)(!0),[z,B]=(0,M.useState)(null),V=(0,M.useCallback)(e=>{B(t=>(t&&t.resolve(e),null))},[]),H=(0,M.useCallback)(e=>new Promise(t=>{let n;if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);if(t){let e=t[1];n={objectName:t[2],mode:e===`edit`||e===`update`?`edit`:`create`}}else n={objectName:e,mode:`create`}}else n=e;B({schema:n,resolve:t})}),[]),U=(0,M.useMemo)(()=>({export_dashboard_pdf:async()=>{x.info(P(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return x.error(P(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(x.info(P(`dashboardActions.forecastSoon`)),{success:!0})}),[P]);(0,M.useEffect)(()=>{R(!0),queueMicrotask(()=>R(!1))},[r]);let{dashboards:W,objects:G}=o(),{app:K}=C(),q=w(W,r,K?._packageId),J=(0,M.useMemo)(()=>new Set((G||[]).map(e=>e?.name).filter(Boolean)),[G]),Y=(0,M.useMemo)(()=>{if(!q||J.size===0)return q;let e=q.widgets;if(!Array.isArray(e)||e.length===0)return q;let t=e.filter(e=>{let t=e?.requiresObject??e?.object;return!t||J.has(t)});return t.length===e.length?q:{...q,widgets:t}},[q,J]);return L?(0,N.jsx)(O,{}):q?(0,N.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,N.jsx)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=T((Y||q).title,P),t=T(q.label,P),n=F({name:q.name,label:t}),r=e||n||q.name;return(0,N.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:r})})(),(()=>{let e=(Y||q).description??q.description,t=I({name:q.name,description:T(e,P)});return t?(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]})}),(0,N.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,N.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,N.jsx)(s,{value:{openRecordList:t},children:(0,N.jsx)(k,{schema:Y,dataSource:e,modalHandler:H,scriptHandlers:U,hideHeaderText:!0})})}),(0,N.jsx)(D,{open:i,sections:[{title:`Dashboard Configuration`,data:Y}]})]}),z&&z.schema?.objectName?(0,N.jsx)(S,{schema:{type:`object-form`,formType:`modal`,objectName:z.schema.objectName,mode:z.schema.mode||`create`,recordId:z.schema.recordId,title:z.schema.title,description:z.schema.description,fields:z.schema.fields,open:!0,onOpenChange:e=>{e||V({success:!1})},onSuccess:e=>{V({success:!0,reload:!0,data:e})},onCancel:()=>{V({success:!1})},showSubmit:!0,showCancel:!0},dataSource:j}):z?(0,N.jsx)(_,{open:!0,onOpenChange:e=>{e||V({success:!1})},children:(0,N.jsxs)(u,{children:[(0,N.jsxs)(f,{children:[(0,N.jsx)(m,{children:z.schema?.title||P(`actionDialog.defaultActionTitle`)}),z.schema?.description&&(0,N.jsx)(h,{children:z.schema.description})]}),(0,N.jsxs)(y,{children:[(0,N.jsx)(b,{variant:`outline`,onClick:()=>V({success:!1}),children:P(`actionDialog.cancel`)}),(0,N.jsx)(b,{onClick:()=>V({success:!0}),children:P(`actionDialog.ok`)})]})]})}):null]}):(0,N.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,N.jsxs)(v,{children:[(0,N.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,N.jsx)(l,{className:`h-6 w-6 text-muted-foreground`})}),(0,N.jsx)(p,{children:P(`empty.dashboardNotFound`)}),(0,N.jsx)(d,{children:P(`empty.dashboardNotFoundDescription`,{name:r})})]})})}export{j as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{y as r}from"./infrastructure-PXm1h5tB.js";import{N as i,P as a}from"./framework-UESyszCj.js";import{Cr as o,Ft as s,It as c,Jr as l,Lt as u,Ms as d,Nt as f,Ot as p,Pt as m,Rs as h,Rt as g,Tn as _,Xs as v,_a as y,_r as b,an as x,br as S,cn as C,dn as w,kn as T,ln as E,oa as D,oo as O,qs as k,sn as A,un as j,vn as M,vr as N,xr as P,yr as F,zr as I,zt as L}from"./ui-components-BbC0qTrK.js";import"./src-D0ueU0ix.js";import{E as R}from"./RecordDetailView-CP1b5rdr.js";var z=e(n(),1),B=t();function V({status:e}){let t={success:{icon:k,cls:`text-emerald-600 border-emerald-300`},completed:{icon:k,cls:`text-emerald-600 border-emerald-300`},failed:{icon:h,cls:`text-red-600 border-red-300`},error:{icon:h,cls:`text-red-600 border-red-300`},running:{icon:O,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:d,cls:`text-amber-600 border-amber-300`},paused:{icon:d,cls:`text-amber-600 border-amber-300`},skipped:{icon:v,cls:`text-muted-foreground`}}[e]??{icon:v,cls:`text-muted-foreground`},n=t.icon;return(0,B.jsxs)(o,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,B.jsx)(n,{className:`h-3 w-3`}),e]})}function H(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function U(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function W({data:e}){return(0,B.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function G(){let e=i()?.getClient?.(),[t,n]=(0,z.useState)([]),[r,a]=(0,z.useState)(!0),[o,s]=(0,z.useState)(null),[c,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(0),p=(0,z.useCallback)(async()=>{if(!e?.meta?.getItems){s(`meta.getItems is not available on this client`),a(!1);return}a(!0),s(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!c&&r.length>0&&u(r[0].name)}catch(e){s(e?.message??String(e))}finally{a(!1)}},[e,c]);(0,z.useEffect)(()=>{p()},[p]);let m=(0,z.useMemo)(()=>t.find(e=>e.name===c)??null,[t,c]);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,B.jsx)(l,{className:`h-5 w-5`}),`Flow Runs`]}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,B.jsxs)(b,{children:[(0,B.jsx)(S,{className:`pb-3`,children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(P,{className:`text-base`,children:`Flow`}),(0,B.jsx)(F,{children:`Select a flow definition to test`})]}),(0,B.jsxs)(I,{variant:`outline`,size:`sm`,onClick:p,disabled:r,children:[(0,B.jsx)(D,{className:`h-3.5 w-3.5 mr-2 ${r?`animate-spin`:``}`}),`Refresh`]})]})}),(0,B.jsxs)(N,{children:[r&&(0,B.jsx)(x,{className:`h-9 w-72`}),o&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:o}),!r&&!o&&t.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!r&&!o&&t.length>0&&(0,B.jsx)(`select`,{value:c,onChange:e=>u(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,B.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),m&&(0,B.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,B.jsx)(K,{client:e,flow:m.spec,onExecuted:()=>f(e=>e+1)}),(0,B.jsx)(q,{client:e,flowName:m.name,refreshKey:d})]})]})}function K({client:e,flow:t,onExecuted:n}){let s=(0,z.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),c=i(),{objects:l}=a(),u=(0,z.useMemo)(()=>r(),[]),[f,m]=(0,z.useState)({}),[g,v]=(0,z.useState)(!1),[x,C]=(0,z.useState)(null),[w,E]=(0,z.useState)(null),[D,A]=(0,z.useState)(null);(0,z.useEffect)(()=>{m({}),C(null),E(null),A(null)},[t?.name]);let j=(e,t)=>m(n=>({...n,[e]:t}));return(0,B.jsxs)(b,{children:[(0,B.jsxs)(S,{className:`pb-3`,children:[(0,B.jsx)(P,{className:`text-base`,children:`Test Run`}),(0,B.jsx)(F,{children:`Provide input values and invoke the flow`})]}),(0,B.jsxs)(N,{className:`space-y-3`,children:[s.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),s.map(e=>(0,B.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,B.jsxs)(T,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,B.jsx)(o,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(L,{id:`var-${e.name}`,checked:f[e.name]===`true`,onCheckedChange:t=>j(e.name,t?`true`:`false`)}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:f[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,B.jsx)(p,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:f[e.name]??``,onChange:t=>j(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,B.jsx)(_,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:f[e.name]??``,onChange:t=>j(e.name,t.target.value)})]},e.name)),(0,B.jsx)(`div`,{className:`pt-1`,children:(0,B.jsxs)(I,{onClick:async()=>{if(!e?.automation?.execute){E(`automation.execute is not available on this client`);return}v(!0),E(null),C(null),A(null);try{let r={};for(let e of s){let t=f[e.name];t!==void 0&&(r[e.name]=U(t,e.type))}let i=await e.automation.execute(t.name,{params:r});C(i),i?.status===`paused`&&i?.screen&&i?.runId&&A({flowName:t.name,runId:i.runId,screen:i.screen}),n?.()}catch(e){E(e?.message??String(e))}finally{v(!1)}},disabled:g,size:`sm`,children:[g?(0,B.jsx)(O,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,B.jsx)(y,{className:`h-3.5 w-3.5 mr-2`}),g?`Running…`:`Run Flow`]})}),(x||w)&&(0,B.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[w||x?.success===!1?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(h,{className:`h-4 w-4 text-red-500`}),` Failed`]}):x?.status===`paused`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(d,{className:`h-4 w-4 text-amber-500`}),` Waiting for input`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(k,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof x?.durationMs==`number`&&(0,B.jsxs)(o,{variant:`secondary`,className:`text-[10px] font-mono`,children:[x.durationMs,` ms`]})]}),w&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:w}),x?.status===`paused`&&x?.screen&&x?.runId&&!D&&(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This run is paused at screen `,(0,B.jsx)(`span`,{className:`font-mono`,children:x.screen.nodeId}),`.`]}),(0,B.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>A({flowName:t.name,runId:x.runId,screen:x.screen}),children:`Continue run`})]}),x&&(0,B.jsx)(W,{data:x})]})]}),(0,B.jsx)(R,{state:D,authFetch:u,baseUrl:``,dataSource:c,objects:l,onClose:()=>{A(null),n?.()},onComplete:()=>{A(null),n?.()}})]})}function q({client:e,flowName:t,refreshKey:n}){let[r,i]=(0,z.useState)([]),[a,l]=(0,z.useState)(!0),[d,p]=(0,z.useState)(null),[h,_]=(0,z.useState)(null),[v,y]=(0,z.useState)(null),[T,k]=(0,z.useState)(!1),[L,R]=(0,z.useState)(null),U=(0,z.useCallback)(async()=>{if(!e?.automation?.listRuns){p(`automation.listRuns is not available on this client`),l(!1);return}l(!0),p(null);try{let n=await e.automation.listRuns(t,{limit:20}),r=Array.isArray(n)?n:n?.items??n?.runs??[];i(r)}catch(e){p(e?.message??String(e))}finally{l(!1)}},[e,t]);(0,z.useEffect)(()=>{U()},[U,n]);let G=async n=>{_(n),y(null),R(null),k(!0);try{let r=await e.automation.getRun(t,n);y(r?.run??r)}catch(e){R(e?.message??String(e))}finally{k(!1)}};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(b,{children:[(0,B.jsx)(S,{className:`pb-3`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(P,{className:`text-base`,children:`Recent Runs`}),(0,B.jsx)(F,{className:`font-mono text-xs`,children:t})]}),(0,B.jsxs)(I,{variant:`outline`,size:`sm`,onClick:U,disabled:a,children:[a?(0,B.jsx)(O,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,B.jsx)(D,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,B.jsxs)(N,{children:[a&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(x,{className:`h-8 w-full`}),(0,B.jsx)(x,{className:`h-8 w-full`}),(0,B.jsx)(x,{className:`h-8 w-full`})]}),!a&&d&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:d}),!a&&!d&&r.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!a&&!d&&r.length>0&&(0,B.jsxs)(f,{children:[(0,B.jsx)(u,{children:(0,B.jsxs)(g,{children:[(0,B.jsx)(c,{children:`Run`}),(0,B.jsx)(c,{children:`Status`}),(0,B.jsx)(c,{children:`Started`}),(0,B.jsx)(c,{className:`text-right`,children:`Duration`})]})}),(0,B.jsx)(m,{children:r.map(e=>(0,B.jsxs)(g,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,B.jsxs)(s,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,B.jsx)(s,{children:(0,B.jsx)(V,{status:e.status})}),(0,B.jsx)(s,{className:`text-xs text-muted-foreground`,children:H(e.startedAt)}),(0,B.jsx)(s,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,B.jsx)(A,{open:!!h,onOpenChange:e=>{e||(_(null),y(null))},children:(0,B.jsxs)(C,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,B.jsxs)(j,{className:`p-4 border-b`,children:[(0,B.jsxs)(w,{className:`font-mono text-sm break-all`,children:[`Run `,h]}),(0,B.jsx)(E,{children:v&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,B.jsx)(V,{status:v.status}),typeof v.durationMs==`number`&&(0,B.jsxs)(o,{variant:`secondary`,className:`text-[10px] font-mono`,children:[v.durationMs,` ms`]}),(0,B.jsx)(`span`,{className:`text-xs`,children:H(v.startedAt)})]})})]}),(0,B.jsxs)(M,{className:`flex-1 p-4`,children:[T&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(x,{className:`h-16 w-full`}),(0,B.jsx)(x,{className:`h-16 w-full`}),(0,B.jsx)(x,{className:`h-16 w-full`})]}),L&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:L}),!T&&v&&(0,B.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(v.steps)&&v.steps.length>0?v.steps.map((e,t)=>(0,B.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,B.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,B.jsx)(o,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,B.jsx)(V,{status:e.status}),typeof e.durationMs==`number`&&(0,B.jsxs)(o,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,B.jsx)(W,{data:e.input})]}),e.output!==void 0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,B.jsx)(W,{data:e.output})]}),e.error&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,B.jsx)(W,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,B.jsx)(W,{data:v})]})})]})]})})]})}export{G as FlowRunsPage};
1
+ import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{y as r}from"./infrastructure-PXm1h5tB.js";import{N as i,P as a}from"./framework-UESyszCj.js";import{Cr as o,Ft as s,It as c,Jr as l,Lt as u,Ms as d,Nt as f,Ot as p,Pt as m,Rs as h,Rt as g,Tn as _,Xs as v,_a as y,_r as b,an as x,br as S,cn as C,dn as w,kn as T,ln as E,oa as D,oo as O,qs as k,sn as A,un as j,vn as M,vr as N,xr as P,yr as F,zr as I,zt as L}from"./ui-components-BbC0qTrK.js";import"./src-CSrGzA_t.js";import{E as R}from"./RecordDetailView-CP1b5rdr.js";var z=e(n(),1),B=t();function V({status:e}){let t={success:{icon:k,cls:`text-emerald-600 border-emerald-300`},completed:{icon:k,cls:`text-emerald-600 border-emerald-300`},failed:{icon:h,cls:`text-red-600 border-red-300`},error:{icon:h,cls:`text-red-600 border-red-300`},running:{icon:O,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:d,cls:`text-amber-600 border-amber-300`},paused:{icon:d,cls:`text-amber-600 border-amber-300`},skipped:{icon:v,cls:`text-muted-foreground`}}[e]??{icon:v,cls:`text-muted-foreground`},n=t.icon;return(0,B.jsxs)(o,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,B.jsx)(n,{className:`h-3 w-3`}),e]})}function H(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function U(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function W({data:e}){return(0,B.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function G(){let e=i()?.getClient?.(),[t,n]=(0,z.useState)([]),[r,a]=(0,z.useState)(!0),[o,s]=(0,z.useState)(null),[c,u]=(0,z.useState)(``),[d,f]=(0,z.useState)(0),p=(0,z.useCallback)(async()=>{if(!e?.meta?.getItems){s(`meta.getItems is not available on this client`),a(!1);return}a(!0),s(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!c&&r.length>0&&u(r[0].name)}catch(e){s(e?.message??String(e))}finally{a(!1)}},[e,c]);(0,z.useEffect)(()=>{p()},[p]);let m=(0,z.useMemo)(()=>t.find(e=>e.name===c)??null,[t,c]);return(0,B.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,B.jsx)(l,{className:`h-5 w-5`}),`Flow Runs`]}),(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,B.jsxs)(b,{children:[(0,B.jsx)(S,{className:`pb-3`,children:(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(P,{className:`text-base`,children:`Flow`}),(0,B.jsx)(F,{children:`Select a flow definition to test`})]}),(0,B.jsxs)(I,{variant:`outline`,size:`sm`,onClick:p,disabled:r,children:[(0,B.jsx)(D,{className:`h-3.5 w-3.5 mr-2 ${r?`animate-spin`:``}`}),`Refresh`]})]})}),(0,B.jsxs)(N,{children:[r&&(0,B.jsx)(x,{className:`h-9 w-72`}),o&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:o}),!r&&!o&&t.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!r&&!o&&t.length>0&&(0,B.jsx)(`select`,{value:c,onChange:e=>u(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,B.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),m&&(0,B.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,B.jsx)(K,{client:e,flow:m.spec,onExecuted:()=>f(e=>e+1)}),(0,B.jsx)(q,{client:e,flowName:m.name,refreshKey:d})]})]})}function K({client:e,flow:t,onExecuted:n}){let s=(0,z.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),c=i(),{objects:l}=a(),u=(0,z.useMemo)(()=>r(),[]),[f,m]=(0,z.useState)({}),[g,v]=(0,z.useState)(!1),[x,C]=(0,z.useState)(null),[w,E]=(0,z.useState)(null),[D,A]=(0,z.useState)(null);(0,z.useEffect)(()=>{m({}),C(null),E(null),A(null)},[t?.name]);let j=(e,t)=>m(n=>({...n,[e]:t}));return(0,B.jsxs)(b,{children:[(0,B.jsxs)(S,{className:`pb-3`,children:[(0,B.jsx)(P,{className:`text-base`,children:`Test Run`}),(0,B.jsx)(F,{children:`Provide input values and invoke the flow`})]}),(0,B.jsxs)(N,{className:`space-y-3`,children:[s.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),s.map(e=>(0,B.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,B.jsxs)(T,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,B.jsx)(o,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(L,{id:`var-${e.name}`,checked:f[e.name]===`true`,onCheckedChange:t=>j(e.name,t?`true`:`false`)}),(0,B.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:f[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,B.jsx)(p,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:f[e.name]??``,onChange:t=>j(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,B.jsx)(_,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:f[e.name]??``,onChange:t=>j(e.name,t.target.value)})]},e.name)),(0,B.jsx)(`div`,{className:`pt-1`,children:(0,B.jsxs)(I,{onClick:async()=>{if(!e?.automation?.execute){E(`automation.execute is not available on this client`);return}v(!0),E(null),C(null),A(null);try{let r={};for(let e of s){let t=f[e.name];t!==void 0&&(r[e.name]=U(t,e.type))}let i=await e.automation.execute(t.name,{params:r});C(i),i?.status===`paused`&&i?.screen&&i?.runId&&A({flowName:t.name,runId:i.runId,screen:i.screen}),n?.()}catch(e){E(e?.message??String(e))}finally{v(!1)}},disabled:g,size:`sm`,children:[g?(0,B.jsx)(O,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,B.jsx)(y,{className:`h-3.5 w-3.5 mr-2`}),g?`Running…`:`Run Flow`]})}),(x||w)&&(0,B.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[w||x?.success===!1?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(h,{className:`h-4 w-4 text-red-500`}),` Failed`]}):x?.status===`paused`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(d,{className:`h-4 w-4 text-amber-500`}),` Waiting for input`]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(k,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof x?.durationMs==`number`&&(0,B.jsxs)(o,{variant:`secondary`,className:`text-[10px] font-mono`,children:[x.durationMs,` ms`]})]}),w&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:w}),x?.status===`paused`&&x?.screen&&x?.runId&&!D&&(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,B.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`This run is paused at screen `,(0,B.jsx)(`span`,{className:`font-mono`,children:x.screen.nodeId}),`.`]}),(0,B.jsx)(I,{size:`sm`,variant:`outline`,onClick:()=>A({flowName:t.name,runId:x.runId,screen:x.screen}),children:`Continue run`})]}),x&&(0,B.jsx)(W,{data:x})]})]}),(0,B.jsx)(R,{state:D,authFetch:u,baseUrl:``,dataSource:c,objects:l,onClose:()=>{A(null),n?.()},onComplete:()=>{A(null),n?.()}})]})}function q({client:e,flowName:t,refreshKey:n}){let[r,i]=(0,z.useState)([]),[a,l]=(0,z.useState)(!0),[d,p]=(0,z.useState)(null),[h,_]=(0,z.useState)(null),[v,y]=(0,z.useState)(null),[T,k]=(0,z.useState)(!1),[L,R]=(0,z.useState)(null),U=(0,z.useCallback)(async()=>{if(!e?.automation?.listRuns){p(`automation.listRuns is not available on this client`),l(!1);return}l(!0),p(null);try{let n=await e.automation.listRuns(t,{limit:20}),r=Array.isArray(n)?n:n?.items??n?.runs??[];i(r)}catch(e){p(e?.message??String(e))}finally{l(!1)}},[e,t]);(0,z.useEffect)(()=>{U()},[U,n]);let G=async n=>{_(n),y(null),R(null),k(!0);try{let r=await e.automation.getRun(t,n);y(r?.run??r)}catch(e){R(e?.message??String(e))}finally{k(!1)}};return(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(b,{children:[(0,B.jsx)(S,{className:`pb-3`,children:(0,B.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(P,{className:`text-base`,children:`Recent Runs`}),(0,B.jsx)(F,{className:`font-mono text-xs`,children:t})]}),(0,B.jsxs)(I,{variant:`outline`,size:`sm`,onClick:U,disabled:a,children:[a?(0,B.jsx)(O,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,B.jsx)(D,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,B.jsxs)(N,{children:[a&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(x,{className:`h-8 w-full`}),(0,B.jsx)(x,{className:`h-8 w-full`}),(0,B.jsx)(x,{className:`h-8 w-full`})]}),!a&&d&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:d}),!a&&!d&&r.length===0&&(0,B.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!a&&!d&&r.length>0&&(0,B.jsxs)(f,{children:[(0,B.jsx)(u,{children:(0,B.jsxs)(g,{children:[(0,B.jsx)(c,{children:`Run`}),(0,B.jsx)(c,{children:`Status`}),(0,B.jsx)(c,{children:`Started`}),(0,B.jsx)(c,{className:`text-right`,children:`Duration`})]})}),(0,B.jsx)(m,{children:r.map(e=>(0,B.jsxs)(g,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,B.jsxs)(s,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,B.jsx)(s,{children:(0,B.jsx)(V,{status:e.status})}),(0,B.jsx)(s,{className:`text-xs text-muted-foreground`,children:H(e.startedAt)}),(0,B.jsx)(s,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,B.jsx)(A,{open:!!h,onOpenChange:e=>{e||(_(null),y(null))},children:(0,B.jsxs)(C,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,B.jsxs)(j,{className:`p-4 border-b`,children:[(0,B.jsxs)(w,{className:`font-mono text-sm break-all`,children:[`Run `,h]}),(0,B.jsx)(E,{children:v&&(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,B.jsx)(V,{status:v.status}),typeof v.durationMs==`number`&&(0,B.jsxs)(o,{variant:`secondary`,className:`text-[10px] font-mono`,children:[v.durationMs,` ms`]}),(0,B.jsx)(`span`,{className:`text-xs`,children:H(v.startedAt)})]})})]}),(0,B.jsxs)(M,{className:`flex-1 p-4`,children:[T&&(0,B.jsxs)(`div`,{className:`space-y-2`,children:[(0,B.jsx)(x,{className:`h-16 w-full`}),(0,B.jsx)(x,{className:`h-16 w-full`}),(0,B.jsx)(x,{className:`h-16 w-full`})]}),L&&(0,B.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:L}),!T&&v&&(0,B.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(v.steps)&&v.steps.length>0?v.steps.map((e,t)=>(0,B.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,B.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,B.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,B.jsx)(o,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,B.jsx)(V,{status:e.status}),typeof e.durationMs==`number`&&(0,B.jsxs)(o,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,B.jsx)(W,{data:e.input})]}),e.output!==void 0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,B.jsx)(W,{data:e.output})]}),e.error&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,B.jsx)(W,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,B.jsx)(W,{data:v})]})})]})]})})]})}export{G as FlowRunsPage};