@objectstack/console 11.7.0 → 11.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (99) hide show
  1. package/dist/.objectui-sha +1 -1
  2. package/dist/assets/{AdapterProvider-DvWb2IeS.js → AdapterProvider-DVMiVYFP.js} +1 -1
  3. package/dist/assets/{AiPendingActionsPage-BZfkGc0a.js → AiPendingActionsPage-Bou3pWLX.js} +1 -1
  4. package/dist/assets/ApiConsolePage-BcYl4bAX.js +1 -0
  5. package/dist/assets/{AppDocsIndex-DNt53Oi9.js → AppDocsIndex-C_YBwvgj.js} +1 -1
  6. package/dist/assets/{AppManagementPage-Cy8KizoY.js → AppManagementPage-YsvEXLrM.js} +1 -1
  7. package/dist/assets/ApprovalsInboxPage-ZUhRdtFJ.js +1 -0
  8. package/dist/assets/{AuditLogPage-CB99k9wq.js → AuditLogPage-CF4t6YyY.js} +1 -1
  9. package/dist/assets/{ComponentNavView-BuCUzee1.js → ComponentNavView-B2h1_hKD.js} +1 -1
  10. package/dist/assets/{ConsoleFloatingChatbot-ChPZiQGQ.js → ConsoleFloatingChatbot-B-0CCFP0.js} +1 -1
  11. package/dist/assets/DashboardView-h39c92Wy.js +1 -0
  12. package/dist/assets/DashboardWidgetInspector-C09xfdI4.js +1 -0
  13. package/dist/assets/{DeveloperHubPage-BJG70ylS.js → DeveloperHubPage-tKxNPDnb.js} +1 -1
  14. package/dist/assets/{ExpressionProvider-DHcGo-ds.js → ExpressionProvider-Ccb8aGyF.js} +1 -1
  15. package/dist/assets/FlowRunsPage-DgR4Cvr0.js +1 -0
  16. package/dist/assets/{IntegrationsPage-D11m2Mgs.js → IntegrationsPage-DHRFBzYf.js} +2 -2
  17. package/dist/assets/InterfaceListPage-DNilCW1a.js +1 -0
  18. package/dist/assets/{ManagedByBadge-B_3CAxVP.js → ManagedByBadge-CBYGpiPD.js} +1 -1
  19. package/dist/assets/{MarketplaceAccessDenied-H_Jx42ON.js → MarketplaceAccessDenied-yP86owRY.js} +1 -1
  20. package/dist/assets/{MarketplaceInstalledPage-Cspj47M8.js → MarketplaceInstalledPage-BT9VRrrF.js} +1 -1
  21. package/dist/assets/{MarketplacePackagePage-BrIitTbZ.js → MarketplacePackagePage-DfBf7Y3G.js} +2 -2
  22. package/dist/assets/{MarketplacePage-h3TH16Xi.js → MarketplacePage-DUrowkIP.js} +1 -1
  23. package/dist/assets/{MetadataInspector--jXw9q3_.js → MetadataInspector-Cd9-_Ogw.js} +1 -1
  24. package/dist/assets/{MetadataProvider-DuoHqlCv.js → MetadataProvider-A34LFAxj.js} +1 -1
  25. package/dist/assets/{PageView-B7XyzoE3.js → PageView-DFYIJhh4.js} +1 -1
  26. package/dist/assets/{ProfilePage-CGieHQKA.js → ProfilePage-BWc59SYM.js} +1 -1
  27. package/dist/assets/{PublicFormsPage-C5YlZJCf.js → PublicFormsPage-Bon7Mqob.js} +1 -1
  28. package/dist/assets/RecordDetailView-CQfdHDqF.js +9 -0
  29. package/dist/assets/{RecordFormPage-BWF_n9K1.js → RecordFormPage-BfX89gAL.js} +1 -1
  30. package/dist/assets/{ReportDefaultInspector-DXCs9PIk.js → ReportDefaultInspector-DdZJIfG8.js} +4 -4
  31. package/dist/assets/{ReportView-CnNDV38L.js → ReportView-Bp_UWpRC.js} +1 -1
  32. package/dist/assets/{SearchResultsPage-DXU1qpcP.js → SearchResultsPage-DpUit7MF.js} +1 -1
  33. package/dist/assets/{SettingsHub-Dgn8w9aO.js → SettingsHub-Bx2yYwy8.js} +1 -1
  34. package/dist/assets/{SettingsView-C9v8ffrk.js → SettingsView-CwMpw6lM.js} +1 -1
  35. package/dist/assets/{SystemHubPage-_QTnnAxO.js → SystemHubPage-B46BQlXn.js} +1 -1
  36. package/dist/assets/data-adapter-CkwHF3aY.js +7 -0
  37. package/dist/assets/{framework-BzwUcFJm.js → framework-CAn_0ZHj.js} +6 -6
  38. package/dist/assets/{highlighted-body-OFNGDK62-JtalCdv1.js → highlighted-body-OFNGDK62-Cek-BVxH.js} +1 -1
  39. package/dist/assets/index-Ci5dbUDe.css +2 -0
  40. package/dist/assets/index-Dw-VsD8-.js +2 -0
  41. package/dist/assets/mermaid-GHXKKRXX-CntU1OOA.js +1 -0
  42. package/dist/assets/metadata-admin-CUGZYzm9.js +22 -0
  43. package/dist/assets/plugin-calendar-BYYpyQXW.js +1 -0
  44. package/dist/assets/plugin-charts-CeCFBrf0.js +7 -0
  45. package/dist/assets/{plugin-chatbot-0LmsN1Va.js → plugin-chatbot-Ds6mwpav.js} +7 -7
  46. package/dist/assets/plugin-dashboard-DjVYQ8s5.js +6 -0
  47. package/dist/assets/plugin-form-BefVAcDj.js +1 -0
  48. package/dist/assets/plugin-gantt-sL0M2g77.js +93 -0
  49. package/dist/assets/plugin-grid-xiUREPgU.js +8 -0
  50. package/dist/assets/plugin-kanban-De5n2Rkv.js +1 -0
  51. package/dist/assets/plugin-map-BpSLuy6T.js +1 -0
  52. package/dist/assets/{plugin-markdown-Dlim2oQH.js → plugin-markdown-DnUEVbKI.js} +1 -1
  53. package/dist/assets/plugin-report-CIAIFu54.js +59 -0
  54. package/dist/assets/plugin-timeline-CmsJV3D0.js +1 -0
  55. package/dist/assets/plugin-tree-DS93-F9J.js +1 -0
  56. package/dist/assets/plugin-view-DDQkdQz8.js +1 -0
  57. package/dist/assets/plugins-views-CtiW6Mj2.js +4 -0
  58. package/dist/assets/{skeletons-CRKtyrMr.js → skeletons-DE_bYYsB.js} +1 -1
  59. package/dist/assets/src-CnWu84r5.js +12 -0
  60. package/dist/assets/{src-ClJ9jvV1.js → src-wFj3msfP.js} +1 -1
  61. package/dist/assets/{types-BXER-wux.js → types-CdToCFDG.js} +1 -1
  62. package/dist/assets/ui-components-BNnJ5f3_.js +42 -0
  63. package/dist/assets/{ui-layout-FpTj4VqO.js → ui-layout-CFpFE-2o.js} +1 -1
  64. package/dist/assets/{useOpenRecordList-DzVq8Uen.js → useOpenRecordList-Cjt1zpXo.js} +1 -1
  65. package/dist/assets/useReconcileOnError-DIcM3hYv.js +1 -0
  66. package/dist/assets/useRecordApprovals-cQzq7nP6.js +1 -0
  67. package/dist/assets/vendor-objectstack-BGWJwgbT.js +95 -0
  68. package/dist/index.html +4 -4
  69. package/package.json +1 -1
  70. package/dist/assets/ApiConsolePage-C5gnskHZ.js +0 -1
  71. package/dist/assets/ApprovalsInboxPage-DvlDfedF.js +0 -1
  72. package/dist/assets/DashboardView-CjTWewIf.js +0 -1
  73. package/dist/assets/DashboardWidgetInspector-BhYevZBF.js +0 -1
  74. package/dist/assets/FlowRunsPage-CaFZwtCv.js +0 -1
  75. package/dist/assets/InterfaceListPage-qgFW8tPe.js +0 -1
  76. package/dist/assets/RecordDetailView-DdNF49JU.js +0 -9
  77. package/dist/assets/data-adapter-B8GFCm-C.js +0 -7
  78. package/dist/assets/index-Ba1vnWIZ.css +0 -2
  79. package/dist/assets/index-BopJm3PU.js +0 -2
  80. package/dist/assets/mermaid-GHXKKRXX-G7SDbIK1.js +0 -1
  81. package/dist/assets/metadata-admin-BklciJ5H.js +0 -22
  82. package/dist/assets/plugin-calendar-DVu__gQc.js +0 -1
  83. package/dist/assets/plugin-charts-yK7P8AX5.js +0 -7
  84. package/dist/assets/plugin-dashboard-BCk2PLlx.js +0 -6
  85. package/dist/assets/plugin-form-DGPdqA5u.js +0 -1
  86. package/dist/assets/plugin-gantt-DcuxnZEc.js +0 -93
  87. package/dist/assets/plugin-grid-BVUr9dNv.js +0 -8
  88. package/dist/assets/plugin-kanban-cqlDEL7v.js +0 -1
  89. package/dist/assets/plugin-map-DufmkIU8.js +0 -1
  90. package/dist/assets/plugin-report-nKNTjtyj.js +0 -59
  91. package/dist/assets/plugin-timeline-HVMwCSYX.js +0 -1
  92. package/dist/assets/plugin-tree-CVXeKvcL.js +0 -1
  93. package/dist/assets/plugin-view-CF03uyex.js +0 -1
  94. package/dist/assets/plugins-views-D-6k7FrC.js +0 -4
  95. package/dist/assets/src-Ce8iWu_4.js +0 -12
  96. package/dist/assets/ui-components-CLgu4Fon.js +0 -42
  97. package/dist/assets/useActionModal-BPkUp8XL.js +0 -1
  98. package/dist/assets/useReconcileOnError-DSjYP3Fi.js +0 -1
  99. package/dist/assets/vendor-objectstack-DTDITeDR.js +0 -95
package/dist/index.html CHANGED
@@ -18,12 +18,12 @@
18
18
  <script>
19
19
  window.process = window.process || { env: { NODE_ENV: 'development' }, version: '', platform: 'browser' };
20
20
  </script>
21
- <script type="module" crossorigin src="./assets/index-BopJm3PU.js"></script>
21
+ <script type="module" crossorigin src="./assets/index-Dw-VsD8-.js"></script>
22
22
  <link rel="stylesheet" crossorigin href="./assets/ui-components-BL3SEdAz.css">
23
23
  <link rel="stylesheet" crossorigin href="./assets/plugin-dashboard-DnNKJB60.css">
24
- <link rel="stylesheet" crossorigin href="./assets/index-Ba1vnWIZ.css">
25
- <link rel="modulepreload" href="./assets/framework-BzwUcFJm.js" />
26
- <link rel="modulepreload" href="./assets/ui-components-CLgu4Fon.js" />
24
+ <link rel="stylesheet" crossorigin href="./assets/index-Ci5dbUDe.css">
25
+ <link rel="modulepreload" href="./assets/framework-CAn_0ZHj.js" />
26
+ <link rel="modulepreload" href="./assets/ui-components-BNnJ5f3_.js" />
27
27
  <link rel="modulepreload" href="./assets/vendor-radix-DniuRzL-.js" />
28
28
  <link rel="modulepreload" href="./assets/vendor-react-slxo-5GC.js" />
29
29
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectstack/console",
3
- "version": "11.7.0",
3
+ "version": "11.10.0",
4
4
  "description": "Prebuilt Console SPA pinned to this @objectstack/framework release. Source of truth: @object-ui/console (https://github.com/objectstack-ai/objectui).",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/objectstack-ai/framework/tree/main/packages/console",
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{j as r}from"./framework-BzwUcFJm.js";import{$i as i,$n as a,Ai as o,Ar as s,Qn as c,Ui as l,Us as u,Va as d,Vs as f,Ws as p,Yr as m,Zi as h,Zn as g,_s as _,ls as v,sr as y,yo as b}from"./ui-components-CLgu4Fon.js";import"./src-Ce8iWu_4.js";var x=e(t(),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`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{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:`POST`,path:`/nlq`,desc:`Natural language query`,bodyTemplate:{query:``}},{method:`POST`,path:`/suggest`,desc:`AI-powered suggestions`,bodyTemplate:{object:``,field:``,context:{}}},{method:`POST`,path:`/insights`,desc:`AI-generated insights`,bodyTemplate:{object:``,recordIds:[]}},{method:`POST`,path:`/conversations`,desc:`Create conversation`,bodyTemplate:{}},{method:`GET`,path:`/conversations`,desc:`List conversations`},{method:`POST`,path:`/conversations/:id/messages`,desc:`Add message to conversation`,bodyTemplate:{role:`user`,content:``}},{method:`DELETE`,path:`/conversations/:id`,desc:`Delete conversation`}]},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 ee(){let e=r(),[t,n]=(0,x.useState)([]),[i,a]=(0,x.useState)([]),[o,s]=(0,x.useState)(!0),[c,l]=(0,x.useState)(null),u=(0,x.useCallback)(async()=>{s(!0),l(null);let t=`/api/v1`,r=`${t}/discovery`,i=[{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 o=`/api/v1/auth`,s={},c={};try{let e=await fetch(r);if(e.ok){let t=await e.json(),n=t?.data??t;c=n?.routes??{},s=n?.services??{},c.auth&&(o=c.auth)}}catch{}let l=[];for(let[e,t]of Object.entries(w)){let n=s[e],r=n?.enabled??!1,i=n?.handlerReady??(n?.status===`available`||n?.status===`degraded`),a=n?.route??c[e]??t.defaultRoute;r&&i&&l.push(...T(e,a))}let u=e?.getClient?.(),d=[];try{let e=await u?.meta?.getTypes?.();e&&Array.isArray(e.types)?d=e.types:Array.isArray(e)&&(d=e)}catch{}let f=[];try{let e=d.includes(`object`)?`object`:null;if(e&&u?.meta?.getItems){let t=await u.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),f=n.map(e=>e.name||e.id).filter(Boolean)}}catch{}let p=f.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}]}),m=d.filter(e=>!S.includes(e)).map(e=>({method:`GET`,path:`${t}/meta/${e}`,desc:`List ${e} metadata`,group:`Metadata`})),h=f.map(e=>({method:`GET`,path:`${t}/meta/object/${e}`,desc:`${e} schema`,group:`Metadata`})),g=[...i,...C(o),...l,...m,...h,...p],_=new Map;for(let e of g){let t=_.get(e.group)||[];t.push(e),_.set(e.group,t)}let v=[`System`,`Auth`,`AI`,`Workflow`,`Realtime`,`Notifications`,`Analytics`,`Automation`,`i18n`,`UI`,`Feed`,`Storage`,`Metadata`];n(Array.from(_.entries()).sort(([e],[t])=>{let n=v.indexOf(e),r=v.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}))),a(g)}catch(e){l(e.message||`Failed to discover APIs`)}finally{s(!1)}},[e]);return(0,x.useEffect)(()=>{u()},[u]),{groups:t,allEndpoints:i,loading:o,error:c,refresh:u}}var E=n(),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`},te={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`},ne=[{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:S}=ee(),[C,w]=(0,x.useState)(``),[T,k]=(0,x.useState)(new Set),[A,j]=(0,x.useState)(null),[re,M]=(0,x.useState)(``),[ie,N]=(0,x.useState)(``),[P,F]=(0,x.useState)(``),[I,L]=(0,x.useState)([]),[R,z]=(0,x.useState)(!1),[B,V]=(0,x.useState)(null),[H,U]=(0,x.useState)([]),[W,ae]=(0,x.useState)(null),[G,K]=(0,x.useState)(!1),q=(0,x.useMemo)(()=>{if(!C)return t;let e=C.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,C]),oe=(0,x.useCallback)(e=>{k(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),se=(0,x.useCallback)(e=>{j(e),M(e.method),N(e.path),F(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),L([]),V(null)},[]),J=re||A?.method||`GET`,Y=ie||A?.path||``,X=(0,x.useMemo)(()=>{let e=I.filter(e=>e.enabled&&e.key.trim());return e.length===0?Y:`${Y}?${e.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join(`&`)}`},[Y,I]),Z=(0,x.useCallback)((e=``,t=``)=>{L(n=>[...n,{id:O++,key:e,value:t,enabled:!0}])},[]),ce=(0,x.useCallback)(e=>{L(t=>t.filter(t=>t.id!==e))},[]),Q=(0,x.useCallback)((e,t,n)=>{L(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),le=(0,x.useCallback)(e=>{L(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),$=(0,x.useCallback)(async()=>{if(R||!X)return;let t=`${e?.baseUrl??``}${X}`;z(!0);let n=performance.now();try{let e={method:J,headers:{"Content-Type":`application/json`}};[`POST`,`PATCH`,`PUT`].includes(J)&&P.trim()&&(e.body=P);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();V({status:r.status,body:a,duration:i}),U(e=>[{id:Date.now(),method:J,url:X,body:P||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);V({status:0,body:`Network Error: ${e.message}`,duration:t})}finally{z(!1)}},[e,X,J,P,R]),ue=(0,x.useCallback)(e=>{M(e.method);let[t,n]=e.url.split(`?`);if(N(t),F(e.body||``),n){let e=new URLSearchParams(n),t=[];e.forEach((e,n)=>{t.push({id:O++,key:n,value:e,enabled:!0})}),L(t)}else L([]);V(null),j(null)},[]),de=(0,x.useCallback)(()=>{B?.body&&(navigator.clipboard.writeText(B.body),K(!0),setTimeout(()=>K(!1),1500))},[B]),fe=e=>te[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:S,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,E.jsx)(l,{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:C,onChange:e=>w(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)(d,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):q.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)(b,{className:`h-6 w-6 opacity-30 mb-2`}),(0,E.jsx)(`span`,{children:C?`No matching endpoints`:`No endpoints found`})]}):q.map(e=>{let t=T.has(e.key)||!!C;return(0,E.jsxs)(g,{open:t,onOpenChange:()=>oe(e.key),children:[(0,E.jsx)(a,{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)(f,{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)(c,{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:()=>se(e),className:`w-full text-left flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${A===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,E.jsx)(y,{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:()=>Z(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,E.jsx)(h,{className:`h-3 w-3`}),`Add`]})]}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:ne.map(e=>(0,E.jsx)(`button`,{onClick:()=>Z(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))}),I.length>0&&(0,E.jsx)(`div`,{className:`space-y-1`,children:I.map(e=>(0,E.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>le(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,E.jsx)(`input`,{type:`text`,value:e.key,onChange:t=>Q(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=>Q(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:()=>ce(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:J,onChange:e=>M(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[J]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,E.jsx)(`option`,{value:e,children:e},e))}),(0,E.jsx)(`input`,{type:`text`,value:Y,onChange:e=>N(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`&&$()}}),(0,E.jsxs)(`button`,{onClick:$,disabled:R||!X,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:[R?(0,E.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,E.jsx)(i,{className:`h-3.5 w-3.5`}),`Send`]})]}),I.some(e=>e.enabled&&e.key.trim())&&(0,E.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,X]})]}),(0,E.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(J)&&(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:P,onChange:e=>F(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" }`})]}),R&&(0,E.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,E.jsx)(d,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),B&&!R&&(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 ${fe(B.status)}`,children:B.status||`ERR`}),(0,E.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,E.jsx)(_,{className:`h-3 w-3`}),B.duration,`ms`]})]}),(0,E.jsxs)(`button`,{onClick:de,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[G?(0,E.jsx)(p,{className:`h-3 w-3`}):(0,E.jsx)(v,{className:`h-3 w-3`}),G?`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:B.body})]}),!B&&!R&&(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)(b,{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`})]})}),H.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 (`,H.length,`)`]}),(0,E.jsxs)(`button`,{onClick:()=>U([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,E.jsx)(m,{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:H.map(e=>(0,E.jsxs)(`div`,{className:`rounded border`,children:[(0,E.jsxs)(`button`,{onClick:()=>ae(W===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:[W===e.id?(0,E.jsx)(u,{className:`h-3 w-3 shrink-0`}):(0,E.jsx)(f,{className:`h-3 w-3 shrink-0`}),(0,E.jsx)(y,{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 ${fe(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(),ue(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)(i,{className:`h-2.5 w-2.5`})})]}),W===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 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,f as n,r,t as i}from"./vendor-react-slxo-5GC.js";import{d as a,f as ee}from"./infrastructure-BySW-NB0.js";import{a as te}from"./framework-BzwUcFJm.js";import{Ac as o,Ai as ne,Ar as re,Cc as ie,Cr as s,Cs as ae,Ds as oe,Fs as se,G as ce,Gt as le,Hs as ue,Ht as de,Jt as fe,K as pe,Kt as me,Ms as he,Sr as ge,Ui as _e,Ut as ve,Vs as ye,Vt as be,Wr as xe,Ws as Se,Wt as Ce,Xt as we,Y as Te,Yo as Ee,Yt as c,Zt as De,_r as l,_s as Oe,_t as ke,br as u,ct as Ae,dr as je,dt as Me,er as Ne,fr as Pe,ft as Fe,gr as d,gt as f,hi as Ie,hr as p,ht as m,ki as Le,ln as Re,ls as ze,lt as Be,mc as Ve,mr as h,mt as He,nr as Ue,os as We,pn as Ge,pt as Ke,qt as qe,sr as Je,tr as Ye,ut as Xe,vr as g,vt as Ze,xr as _,yr as v,zr as Qe,zt as $e}from"./ui-components-CLgu4Fon.js";import{r as y}from"./vendor-ui-utils-C1OpMExs.js";var b=e(t(),1),et=`${``.replace(/\/$/,``)}/api/v1`;async function x(e,t){let n=await fetch(`${et}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=r?.code??`HTTP_${n.status}`,t=r?.message??r?.error??n.statusText,i=Error(`${e}: ${t}`);throw i.code=e,i.status=n.status,i.details=r,i}return r}var S={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return x(`/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 x(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await x(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return x(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await x(`/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 x(`/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 x(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await x(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await x(`/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 x(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await x(`/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 x(`/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 x(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return x(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function tt(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 C=i(),nt=50,rt={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 it(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function w(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 T(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function at(e){return e.process_label||T(e.process_name)}function ot(e){return e.step_label?e.step_label:e.current_step?T(e.current_step):null}function st(e){return e.submitter_name||w(e.submitter_id)}function ct(e,t){return t.pending_approver_names?.[e]||w(e)}function lt(e){return e.object_label||e.object_name}function E(e){return e.submitted_at||e.created_at||void 0}function D(e){let t=E(e);if(!t)return null;let n=Date.parse(t);return Number.isNaN(n)?null:(Date.now()-n)/36e5}function ut(e){if(e.status!==`pending`)return`text-muted-foreground`;let t=D(e);return t==null?`text-muted-foreground`:t>72?`text-red-600 dark:text-red-400 font-medium`:t>24?`text-amber-600 dark:text-amber-400`:`text-muted-foreground`}function dt(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}var O=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function k(e){return e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function A(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 ft=/^[A-Za-z0-9_-]{15,}$/;function pt(e,t,n=6){if(!e||typeof e!=`object`||Array.isArray(e))return[];let r=[];for(let[i,a]of Object.entries(e)){if(O.has(i)||a==null||typeof a==`object`||String(a).trim()===``)continue;let e=t?.[i];if(!(!e&&typeof a==`string`&&ft.test(a.trim())&&!/^\d+$/.test(a.trim()))&&(r.push([k(i),e??A(i,a)]),r.length>=n))break}return r}function mt(){let{t:e,language:t}=te(),{user:i}=ee(),et=a(),{appName:x}=n(),T=(0,b.useMemo)(()=>tt(i),[i]),D=(0,b.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),O=(0,b.useCallback)(e=>{if(!e)return`—`;let n=Date.parse(e);if(Number.isNaN(n))return e;let r=Math.round((Date.now()-n)/1e3);if(r<45)return D(`justNow`,`just now`);let i=Math.round(r/60);if(i<60)return D(`minutesAgo`,`{{count}}m ago`,{count:i});let a=Math.round(i/60);if(a<24)return D(`hoursAgo`,`{{count}}h ago`,{count:a});let ee=Math.round(a/24);if(ee<30)return D(`daysAgo`,`{{count}}d ago`,{count:ee});try{return new Date(e).toLocaleDateString(t)}catch{return e}},[D,t]),k=(0,b.useCallback)(e=>{switch(e){case`pending`:return D(`statusPending`,`Pending`);case`approved`:return D(`statusApproved`,`Approved`);case`rejected`:return D(`statusRejected`,`Rejected`);case`recalled`:return D(`statusRecalled`,`Recalled`);case`returned`:return D(`statusReturned`,`Returned for revision`);default:return e}},[D]),A=(0,b.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?D(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?D(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?D(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?D(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?D(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[D]);function ft({status:e}){return(0,C.jsx)(Je,{variant:`outline`,className:o(`font-medium`,rt[e]??``),children:k(e)})}let mt=(0,b.useCallback)(e=>`/apps/${x||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[x]),[j,ht]=(0,b.useState)(`pending`),[M,gt]=(0,b.useState)([]),[_t,vt]=(0,b.useState)(!1),[yt,bt]=(0,b.useState)(!1),[xt,St]=(0,b.useState)(null),[Ct,wt]=(0,b.useState)(null),[Tt,Et]=(0,b.useState)(0),[N,Dt]=(0,b.useState)(null),[P,Ot]=(0,b.useState)(null),[kt,At]=(0,b.useState)([]),[jt,Mt]=(0,b.useState)(!1),[F,I]=(0,b.useState)(``),[L,Nt]=(0,b.useState)(``),[R,Pt]=(0,b.useState)(null),[z,Ft]=(0,b.useState)(``),[It,Lt]=(0,b.useState)(``),[Rt,zt]=(0,b.useState)(`all`),[Bt,Vt]=(0,b.useState)(`all`),[B,Ht]=(0,b.useState)(`all`),[V,Ut]=(0,b.useState)(new Set),[Wt,Gt]=(0,b.useState)(!1),[H,Kt]=(0,b.useState)(null),[qt,Jt]=(0,b.useState)(null),[Yt,Xt]=(0,b.useState)(!1),[Zt,Qt]=(0,b.useState)(``),[$t,en]=(0,b.useState)(!1),[tn,nn]=(0,b.useState)(``),[rn,an]=(0,b.useState)(!1),[on,sn]=(0,b.useState)(``),[cn,ln]=(0,b.useState)(!1),[un,dn]=(0,b.useState)(``),[U,W]=(0,b.useState)(!1),[fn,pn]=(0,b.useState)([]),[mn,hn]=(0,b.useState)(-1);(0,b.useEffect)(()=>{if(j===`pending`)return;let e=window.setTimeout(()=>Lt(z),350);return()=>window.clearTimeout(e)},[z,j]);let G=(0,b.useCallback)(async()=>{vt(!0),wt(null);try{let e=[];if(j===`pending`)e=T.length?(await S.listRequests({status:`pending`,approverId:T})).data:[],Et(e.length),St(null);else{let t={q:It||void 0,status:B===`all`?void 0:B,limit:nt,offset:0};if(j===`submitted`){let n=i?.id;if(n){let r=await S.listRequests({submitterId:n,...t});e=r.data,St(r.total??r.data.length)}else e=[],St(0)}else{let n=await S.listRequests(t);e=n.data,St(n.total??n.data.length)}T.length&&S.listRequests({status:`pending`,approverId:T}).then(e=>Et(e.data.length)).catch(()=>{})}e.sort((e,t)=>(E(t)||``).localeCompare(E(e)||``)),gt(e)}catch(e){wt(e?.message||String(e)),gt([])}finally{vt(!1)}},[j,T,i?.id,It,B]);(0,b.useEffect)(()=>{G()},[G]);let gn=(0,b.useCallback)(async()=>{if(!(j===`pending`||yt)){bt(!0);try{let e=await S.listRequests({submitterId:j===`submitted`?i?.id??void 0:void 0,q:It||void 0,status:B===`all`?void 0:B,limit:nt,offset:M.length});gt(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&St(e.total)}catch(e){y.error(A(e,D(`loadFailed`,`Failed to load request`)))}finally{bt(!1)}}},[j,yt,i?.id,It,B,M.length,A,D]),K=(0,b.useCallback)(async e=>{Dt(e),Mt(!0),I(``),Nt(``);try{let[t,n]=await Promise.all([S.getRequest(e),S.listActions(e)]);Ot(t.data),At(n.data)}catch(e){y.error(A(e,D(`loadFailed`,`Failed to load request`))),Ot(null),At([])}finally{Mt(!1)}},[A,D]),_n=()=>{Dt(null),Ot(null),At([]),I(``),Nt(``)},q=(0,b.useCallback)(e=>{if(L.trim())return L.trim();if(!e)return i?.id||``;let t=new Set(e.pending_approvers||[]);for(let e of T)if(t.has(e))return e;return i?.id||``},[L,T,i?.id]),J=(0,b.useCallback)(()=>{T.length&&S.listRequests({status:`pending`,approverId:T}).then(e=>Et(e.data.length)).catch(()=>{})},[T]),vn=(0,b.useCallback)(async e=>{if(!P)return;let t=e===`recall`&&i?.id||q(P);if(!t){y.error(D(`noActor`,`Cannot determine the acting identity`));return}Pt(e);try{let n={actor_id:t,comment:F.trim()||void 0},r=await(e===`approve`?S.approve:e===`reject`?S.reject:S.recall)(P.id,n);if(y.success(e===`approve`?r.finalized?D(`approvedFinal`,`Approved`):D(`approvedWaiting`,`Approved — waiting on the remaining approvers`):e===`reject`?D(`rejectedToast`,`Rejected`):D(`recalledToast`,`Request recalled`)),I(``),e!==`recall`&&j===`pending`){let e=Rn.current,t=e.findIndex(e=>e.id===P.id),n=e[t+1]??e[t-1];G(),n&&n.id!==P.id?K(n.id):_n();return}let[i,a]=await Promise.all([S.getRequest(P.id),S.listActions(P.id)]);Ot(i.data),At(a.data),G()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{Pt(null)}},[P,q,F,G,i?.id,A,D,j,K]),Y=(0,b.useCallback)(async e=>{let[t,n]=await Promise.all([S.getRequest(e),S.listActions(e)]);Ot(t.data),At(n.data),G()},[G]),yn=(0,b.useCallback)(async()=>{if(!(!P||!Zt.trim())){W(!0);try{await S.reassign(P.id,{actor_id:q(P),to:Zt.trim(),comment:F.trim()||void 0}),y.success(D(`reassignSuccess`,`Handed to {{to}}`,{to:Zt.trim()})),Xt(!1),Qt(``),I(``),await Y(P.id),J()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{W(!1)}}},[P,Zt,F,q,Y,J,A,D]),bn=(0,b.useCallback)(async()=>{if(P){W(!0);try{let e=await S.remind(P.id,{actor_id:i?.id});y.success(D(`remindSuccess`,`Reminder sent to {{count}} approver(s)`,{count:e.notified})),await Y(P.id)}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{W(!1)}}},[P,i?.id,Y,A,D]),xn=(0,b.useCallback)(async()=>{if(!(!P||!tn.trim())){W(!0);try{await S.requestInfo(P.id,{actor_id:q(P),comment:tn.trim()}),y.success(D(`requestInfoSent`,`Sent back to the requester for more information`)),en(!1),nn(``),await Y(P.id)}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{W(!1)}}},[P,tn,q,Y,A,D]),Sn=(0,b.useCallback)(async()=>{if(P){W(!0);try{let e=await S.sendBack(P.id,{actor_id:q(P),comment:on.trim()||void 0});y.success(e.autoRejected?D(`sendBackAutoRejected`,`Revision limit reached — the request was auto-rejected`):D(`sendBackSuccess`,`Sent back for revision — the requester can now edit and resubmit`)),an(!1),sn(``),await Y(P.id),J()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{W(!1)}}},[P,on,q,Y,J,A,D]),Cn=(0,b.useCallback)(async()=>{if(P){ln(!0);try{await S.resubmit(P.id,{actor_id:i?.id,comment:F.trim()||void 0}),y.success(D(`resubmitSuccess`,`Resubmitted — a new approval round has opened`)),I(``),await Y(P.id),J()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{ln(!1)}}},[P,F,i?.id,Y,J,A,D]),wn=(0,b.useCallback)(async()=>{if(!(!P||!un.trim())){W(!0);try{await S.comment(P.id,{actor_id:i?.id,comment:un.trim()}),dn(``),await Y(P.id)}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{W(!1)}}},[P,un,i?.id,Y,A,D]),Tn=(0,b.useCallback)(async()=>{if(!fn.length)try{let e=``.replace(/\/$/,``);pn(((await(await fetch(`${e}/api/v1/data/sys_user?limit=100`,{credentials:`include`})).json()).records||[]).filter(e=>e.email&&e.name&&e.id!==i?.id).map(e=>({name:String(e.name),email:String(e.email)})))}catch{}},[fn.length,i?.id]),En=(0,b.useMemo)(()=>{if(!P||P.status!==`pending`)return!1;let e=new Set(P.pending_approvers||[]);return T.some(t=>e.has(t))||L.trim().length>0},[P,T,L]),Dn=(0,b.useMemo)(()=>!P||P.status!==`pending`?!1:P.submitter_id===i?.id||L.trim().length>0,[P,i?.id,L]),On=(0,b.useMemo)(()=>!P||P.status!==`returned`?!1:P.submitter_id===i?.id||L.trim().length>0,[P,i?.id,L]),kn=(0,b.useMemo)(()=>{let e=new Set;for(let t of M)e.add(at(t));return Array.from(e).sort()},[M]),An=(0,b.useMemo)(()=>{let e=new Set;for(let t of M)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[M]),X=(0,b.useMemo)(()=>{let e=z.trim().toLowerCase();return M.filter(t=>Rt!==`all`&&at(t)!==Rt||Bt!==`all`&&t.object_name!==Bt||B!==`all`&&t.status!==B?!1:j!==`pending`||!e?!0:[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))},[M,z,Rt,Bt,B,j]),Z=(0,b.useMemo)(()=>N?X.findIndex(e=>e.id===N):-1,[X,N]);(0,b.useEffect)(()=>{if(V.size===0)return;let e=new Set(X.map(e=>e.id)),t=!1,n=new Set;for(let r of V)e.has(r)?n.add(r):t=!0;t&&Ut(n)},[X,V]),(0,b.useEffect)(()=>{mn>=X.length&&hn(X.length-1)},[X.length,mn]);let Q=(0,b.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(T);return(e.pending_approvers||[]).some(e=>t.has(e))},[T]),$=(0,b.useMemo)(()=>X.filter(e=>V.has(e.id)&&Q(e)),[X,V,Q]),jn=X.filter(e=>e.status===`pending`),Mn=jn.length>0&&jn.every(e=>V.has(e.id)),Nn=(0,b.useCallback)(()=>{Ut(e=>{if(Mn)return new Set;let t=new Set(e);for(let e of jn)t.add(e.id);return t})},[Mn,jn]),Pn=(0,b.useCallback)(e=>{Ut(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Fn=(0,b.useCallback)(async e=>{let t=$;if(t.length===0)return;Gt(!0);let n=0,r=[];for(let a of t){let t=new Set(a.pending_approvers||[]),ee=T.find(e=>t.has(e))||i?.id||``;try{await(e===`approve`?S.approve:S.reject)(a.id,{actor_id:ee}),n++}catch{r.push(a.record_title||w(a.record_id))}}if(Gt(!1),Ut(new Set),r.length===0)y.success(e===`approve`?D(`bulkApproved`,`Approved {{count}} requests`,{count:n}):D(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);y.error(D(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}G(),J()},[$,T,i?.id,G,J,D]),In=(0,b.useCallback)(async e=>{if(!Q(e)||qt)return;let t=new Set(e.pending_approvers||[]),n=T.find(e=>t.has(e))||i?.id||``;Jt(e.id);try{let t=await S.approve(e.id,{actor_id:n});y.success(t.finalized?D(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||w(e.record_id)}):D(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),G(),J()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{Jt(null)}},[Q,qt,T,i?.id,G,J,A,D]),Ln=(0,b.useCallback)(async()=>{let e=H;if(!e)return;let t=new Set(e.pending_approvers||[]),n=T.find(e=>t.has(e))||i?.id||``;Jt(e.id),Kt(null);try{await S.reject(e.id,{actor_id:n}),y.success(D(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||w(e.record_id)})),G(),J()}catch(e){y.error(A(e,D(`actionFailed`,`Action failed`)))}finally{Jt(null)}},[H,T,i?.id,G,J,A,D]),Rn=(0,b.useRef)(X);Rn.current=X;let zn=(0,b.useRef)(mn);zn.current=mn,(0,b.useEffect)(()=>{let e=e=>{if(N||H)return;let t=e.target,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t?.isContentEditable||document.querySelector(`[role="alertdialog"]`))return;let r=Rn.current;if(!r.length)return;let i=zn.current;e.key===`j`||e.key===`ArrowDown`?(e.preventDefault(),hn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),hn(Math.max(i-1,0))):e.key===`Enter`&&i>=0&&r[i]?(e.preventDefault(),K(r[i].id)):(e.key===`x`||e.key===` `)&&i>=0&&r[i]&&j===`pending`?(e.preventDefault(),Pn(r[i].id)):e.key===`a`&&i>=0&&r[i]?(e.preventDefault(),In(r[i])):e.key===`r`&&i>=0&&r[i]&&Q(r[i])&&(e.preventDefault(),Kt(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,H,j,K,Pn,In,Q]),(0,b.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=Rn.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(),K(a.id))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[N,K]);let Bn=!!z||Rt!==`all`||Bt!==`all`||B!==`all`,Vn=e=>{ht(e),Ht(`all`),zt(`all`),Vt(`all`),Ft(``),hn(-1)};function Hn({r:e}){return(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`font-medium truncate`,children:at(e)}),(0,C.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[ot(e)||`—`,(e.round??1)>1&&(0,C.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:D(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function Un({r:e}){return(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsxs)(r,{to:mt(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,C.jsx)(`span`,{className:`truncate`,children:e.record_title||w(e.record_id)}),(0,C.jsx)(Ee,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:lt(e)})]})}function Wn({r:e}){if(!Q(e))return null;let t=qt===e.id;return(0,C.jsxs)(`div`,{className:`flex items-center gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),children:[(0,C.jsx)(s,{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,onClick:()=>void In(e),"aria-label":D(`approve`,`Approve`),children:(0,C.jsx)(he,{className:`h-4 w-4`})}),(0,C.jsx)(s,{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,onClick:()=>Kt(e),"aria-label":D(`reject`,`Reject`),children:(0,C.jsx)(ae,{className:`h-4 w-4`})})]})}return(0,C.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,C.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,C.jsxs)(`div`,{children:[(0,C.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,C.jsx)(Ie,{className:`h-6 w-6`}),D(`title`,`Approvals Inbox`)]}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:D(`subtitle`,`Review and act on approval requests.`)})]}),(0,C.jsxs)(s,{variant:`outline`,size:`sm`,onClick:G,disabled:_t,className:`self-start sm:self-auto`,children:[(0,C.jsx)(_e,{className:`h-4 w-4 mr-2 ${_t?`animate-spin`:``}`}),D(`refresh`,`Refresh`)]})]}),Ct&&(0,C.jsxs)(je,{variant:`destructive`,children:[(0,C.jsx)(se,{className:`h-4 w-4`}),(0,C.jsx)(Pe,{children:Ct})]}),(0,C.jsxs)(Be,{value:j,onValueChange:Vn,children:[(0,C.jsxs)(Me,{children:[(0,C.jsxs)(Fe,{value:`pending`,children:[D(`tabMyPending`,`My Pending`),Tt>0&&(0,C.jsx)(Je,{variant:`secondary`,className:`ml-2`,children:Tt})]}),(0,C.jsx)(Fe,{value:`submitted`,children:D(`tabSubmitted`,`Submitted by me`)}),(0,C.jsx)(Fe,{value:`all`,children:D(`tabAll`,`All`)})]}),(0,C.jsxs)(Xe,{value:j,className:`mt-4 space-y-3`,children:[!_t&&(M.length>0||j!==`pending`&&(It||B!==`all`))&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,C.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,C.jsx)(ne,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,C.jsx)(Re,{value:z,onChange:e=>Ft(e.target.value),placeholder:D(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),z&&(0,C.jsx)(`button`,{type:`button`,onClick:()=>Ft(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":D(`clearSearch`,`Clear search`),children:(0,C.jsx)(re,{className:`h-3.5 w-3.5`})})]}),j!==`pending`&&(0,C.jsxs)(qe,{value:B,onValueChange:Ht,children:[(0,C.jsx)(we,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,C.jsx)(De,{placeholder:D(`statusFilter`,`Status`)})}),(0,C.jsxs)(fe,{children:[(0,C.jsx)(c,{value:`all`,children:D(`allStatuses`,`All statuses`)}),(0,C.jsx)(c,{value:`pending`,children:k(`pending`)}),(0,C.jsx)(c,{value:`approved`,children:k(`approved`)}),(0,C.jsx)(c,{value:`rejected`,children:k(`rejected`)}),(0,C.jsx)(c,{value:`recalled`,children:k(`recalled`)}),(0,C.jsx)(c,{value:`returned`,children:k(`returned`)})]})]}),kn.length>1&&(0,C.jsxs)(qe,{value:Rt,onValueChange:zt,children:[(0,C.jsx)(we,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,C.jsx)(De,{placeholder:D(`processFilter`,`Process`)})}),(0,C.jsxs)(fe,{children:[(0,C.jsx)(c,{value:`all`,children:D(`allProcesses`,`All processes`)}),kn.map(e=>(0,C.jsx)(c,{value:e,children:e},e))]})]}),An.length>1&&(0,C.jsxs)(qe,{value:Bt,onValueChange:Vt,children:[(0,C.jsx)(we,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,C.jsx)(De,{placeholder:D(`objectFilter`,`Object`)})}),(0,C.jsxs)(fe,{children:[(0,C.jsx)(c,{value:`all`,children:D(`allObjects`,`All objects`)}),An.map(e=>(0,C.jsx)(c,{value:e,children:e},e))]})]}),Bn&&(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`filterCount`,`{{shown}} of {{total}}`,{shown:X.length,total:M.length})})]}),j===`pending`&&V.size>0&&(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,C.jsxs)(`span`,{children:[(0,C.jsx)(`strong`,{children:V.size}),` `,D(`selected`,`selected`),$.length!==V.size&&(0,C.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:D(`actionableCount`,`({{count}} actionable)`,{count:$.length})})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsxs)(h,{children:[(0,C.jsx)(ge,{asChild:!0,children:(0,C.jsxs)(s,{size:`sm`,disabled:Wt||$.length===0,children:[(0,C.jsx)(he,{className:`h-3.5 w-3.5 mr-1`}),D(`approveN`,`Approve {{count}}`,{count:$.length||``})]})}),(0,C.jsxs)(l,{children:[(0,C.jsxs)(u,{children:[(0,C.jsx)(_,{children:D(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:$.length})}),(0,C.jsx)(g,{children:D(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,C.jsxs)(v,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(p,{onClick:()=>Fn(`approve`),children:D(`approveN`,`Approve {{count}}`,{count:$.length})})]})]})]}),(0,C.jsxs)(h,{children:[(0,C.jsx)(ge,{asChild:!0,children:(0,C.jsxs)(s,{size:`sm`,variant:`outline`,disabled:Wt||$.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,C.jsx)(ae,{className:`h-3.5 w-3.5 mr-1`}),D(`rejectN`,`Reject {{count}}`,{count:$.length||``})]})}),(0,C.jsxs)(l,{children:[(0,C.jsxs)(u,{children:[(0,C.jsx)(_,{children:D(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:$.length})}),(0,C.jsx)(g,{children:D(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,C.jsxs)(v,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(p,{onClick:()=>Fn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:D(`rejectN`,`Reject {{count}}`,{count:$.length})})]})]})]}),(0,C.jsx)(s,{size:`sm`,variant:`ghost`,onClick:()=>Ut(new Set),disabled:Wt,children:D(`clear`,`Clear`)})]})]}),_t?(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)($e,{className:`h-10 w-full`}),(0,C.jsx)($e,{className:`h-10 w-full`}),(0,C.jsx)($e,{className:`h-10 w-full`})]}):M.length===0?(0,C.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,C.jsxs)(ce,{children:[(0,C.jsx)(Te,{children:D(`emptyTitle`,`No requests`)}),(0,C.jsx)(pe,{children:j===`pending`?D(`emptyPending`,`You're all caught up — nothing is waiting on you.`):D(`emptyOther`,`Nothing here yet.`)}),j===`pending`&&(0,C.jsx)(s,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>Vn(`all`),children:D(`emptyViewAll`,`Browse all requests`)})]})}):X.length===0?(0,C.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:D(`noMatches`,`No matches for current filters.`)}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(Ye,{className:`hidden md:block`,children:(0,C.jsx)(Ue,{className:`p-0`,children:(0,C.jsxs)(Ke,{children:[(0,C.jsx)(ke,{children:(0,C.jsxs)(Ze,{children:[j===`pending`&&(0,C.jsx)(f,{className:`w-10`,children:(0,C.jsx)(Ne,{checked:Mn,onCheckedChange:Nn,"aria-label":D(`selectAll`,`Select all`),disabled:jn.length===0})}),(0,C.jsx)(f,{children:D(`colRequest`,`Request`)}),(0,C.jsx)(f,{children:D(`colRecord`,`Record`)}),(0,C.jsx)(f,{children:D(`colRequester`,`Requester`)}),(0,C.jsx)(f,{children:D(`colStatus`,`Status`)}),(0,C.jsx)(f,{children:D(`colWaiting`,`Submitted`)}),(0,C.jsx)(f,{className:`w-20`,"aria-label":D(`colActions`,`Actions`)})]})}),(0,C.jsx)(He,{children:X.map((e,t)=>(0,C.jsxs)(Ze,{className:o(`group cursor-pointer hover:bg-accent/50`,mn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{hn(t),K(e.id)},children:[j===`pending`&&(0,C.jsx)(m,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,C.jsx)(Ne,{checked:V.has(e.id),onCheckedChange:()=>Pn(e.id),disabled:e.status!==`pending`,"aria-label":D(`selectRow`,`Select request`)})}),(0,C.jsx)(m,{children:(0,C.jsx)(Hn,{r:e})}),(0,C.jsx)(m,{children:(0,C.jsx)(Un,{r:e})}),(0,C.jsx)(m,{children:(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,C.jsx)(Qe,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,C.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:st(e)})]})}),(0,C.jsx)(m,{children:(0,C.jsx)(ft,{status:e.status})}),(0,C.jsxs)(m,{className:o(`text-xs whitespace-nowrap`,ut(e)),title:it(E(e)),children:[(0,C.jsx)(Oe,{className:`h-3 w-3 inline mr-1`}),O(E(e)),e.status===`pending`&&e.sla_due_at&&(0,C.jsx)(`div`,{className:o(`mt-0.5 text-[10px] font-medium`,Date.parse(e.sla_due_at)<Date.now()?`text-red-600 dark:text-red-400`:`text-muted-foreground`),children:Date.parse(e.sla_due_at)<Date.now()?D(`slaOverdue`,`SLA overdue {{dur}}`,{dur:dt(Date.now()-Date.parse(e.sla_due_at))}):D(`slaRemaining`,`SLA {{dur}} left`,{dur:dt(Date.parse(e.sla_due_at)-Date.now())})})]}),(0,C.jsx)(m,{className:`w-20`,children:(0,C.jsx)(Wn,{r:e})})]},e.id))})]})})}),(0,C.jsx)(`div`,{className:`md:hidden space-y-2`,children:X.map(e=>(0,C.jsx)(Ye,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void K(e.id),children:(0,C.jsxs)(Ue,{className:`p-3 space-y-1.5`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,C.jsx)(`div`,{className:`font-medium text-sm truncate`,children:at(e)}),(0,C.jsx)(ft,{status:e.status})]}),(0,C.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||w(e.record_id),(0,C.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:lt(e)})]}),(0,C.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,C.jsx)(Qe,{className:`h-3 w-3`}),st(e)]}),(0,C.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 whitespace-nowrap`,ut(e)),children:[(0,C.jsx)(Oe,{className:`h-3 w-3`}),O(E(e))]})]}),Q(e)&&(0,C.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),children:[(0,C.jsxs)(s,{size:`sm`,className:`h-7 flex-1`,disabled:qt===e.id,onClick:()=>void In(e),children:[(0,C.jsx)(he,{className:`h-3.5 w-3.5 mr-1`}),D(`approve`,`Approve`)]}),(0,C.jsxs)(s,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:qt===e.id,onClick:()=>Kt(e),children:[(0,C.jsx)(ae,{className:`h-3.5 w-3.5 mr-1`}),D(`reject`,`Reject`)]})]})]})},e.id))}),j!==`pending`&&xt!=null&&(0,C.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:D(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:M.length,total:xt})}),M.length<xt&&(0,C.jsx)(s,{size:`sm`,variant:`outline`,disabled:yt,onClick:()=>void gn(),children:yt?D(`loadingMore`,`Loading…`):D(`loadMore`,`Load more`)})]}),(0,C.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:D(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,C.jsx)(h,{open:Yt,onOpenChange:e=>{e||(Xt(!1),Qt(``))},children:(0,C.jsxs)(l,{children:[(0,C.jsxs)(u,{children:[(0,C.jsx)(_,{children:D(`reassignTitle`,`Hand this approval to someone else?`)}),(0,C.jsx)(g,{children:D(`reassignBody`,`Your approver slot moves to the person you pick — they are notified and can act immediately.`)})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(Ge,{htmlFor:`reassign-to`,className:`text-xs`,children:D(`reassignTo`,`New approver`)}),(0,C.jsx)(Re,{id:`reassign-to`,list:`reassign-user-options`,value:Zt,onChange:e=>Qt(e.target.value),placeholder:D(`reassignToPlaceholder`,`Pick a user or type an email / role:<name>`),className:`mt-1`}),(0,C.jsx)(`datalist`,{id:`reassign-user-options`,children:fn.map(e=>(0,C.jsx)(`option`,{value:e.email,children:e.name},e.email))})]}),(0,C.jsxs)(v,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(p,{disabled:!Zt.trim()||U,onClick:()=>void yn(),children:D(`reassignBtn`,`Reassign`)})]})]})}),(0,C.jsx)(h,{open:$t,onOpenChange:e=>{e||(en(!1),nn(``))},children:(0,C.jsxs)(l,{children:[(0,C.jsxs)(u,{children:[(0,C.jsx)(_,{children:D(`requestInfoTitle`,`Ask the requester for more information?`)}),(0,C.jsx)(g,{children:D(`requestInfoBody`,`The request stays pending; the requester is notified and can reply on the thread.`)})]}),(0,C.jsx)(Ae,{value:tn,onChange:e=>nn(e.target.value),rows:3,placeholder:D(`requestInfoPlaceholder`,`What do you need from the requester?`)}),(0,C.jsxs)(v,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(p,{disabled:!tn.trim()||U,onClick:()=>void xn(),children:D(`requestInfoBtn`,`Request info`)})]})]})}),(0,C.jsx)(h,{open:rn,onOpenChange:e=>{e||(an(!1),sn(``))},children:(0,C.jsxs)(l,{children:[(0,C.jsxs)(u,{children:[(0,C.jsx)(_,{children:D(`sendBackTitle`,`Send this request back for revision?`)}),(0,C.jsx)(g,{children:D(`sendBackBody`,`This round ends and the record unlocks so the requester can fix the data. When they resubmit, a fresh approval round opens for all approvers.`)})]}),(0,C.jsx)(Ae,{value:on,onChange:e=>sn(e.target.value),rows:3,placeholder:D(`sendBackPlaceholder`,`What needs to be fixed before this can be approved?`)}),(0,C.jsxs)(v,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(p,{disabled:U,onClick:()=>void Sn(),children:D(`sendBackBtn`,`Send back`)})]})]})}),(0,C.jsx)(h,{open:!!H,onOpenChange:e=>!e&&Kt(null),children:(0,C.jsxs)(l,{children:[(0,C.jsxs)(u,{children:[(0,C.jsx)(_,{children:D(`rejectOneTitle`,`Reject "{{title}}"?`,{title:H?H.record_title||w(H.record_id):``})}),(0,C.jsx)(g,{children:D(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,C.jsxs)(v,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(p,{onClick:()=>void Ln(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:D(`reject`,`Reject`)})]})]})}),(0,C.jsx)(be,{open:!!N,onOpenChange:e=>!e&&_n(),children:(0,C.jsxs)(de,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,C.jsxs)(Ce,{children:[(0,C.jsx)(le,{children:P?at(P):D(`drawerTitle`,`Approval Request`)}),(0,C.jsx)(ve,{children:P?ot(P)||lt(P):``})]}),P&&Z>=0&&X.length>1&&(0,C.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,C.jsxs)(s,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:Z<=0,onClick:()=>{let e=X[Z-1];e&&K(e.id)},children:[(0,C.jsx)(ue,{className:`h-4 w-4 mr-0.5`}),D(`prevRequest`,`Previous`)]}),(0,C.jsx)(`span`,{children:D(`positionOf`,`{{index}} of {{total}}`,{index:Z+1,total:X.length})}),(0,C.jsxs)(s,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:Z>=X.length-1,onClick:()=>{let e=X[Z+1];e&&K(e.id)},children:[D(`nextRequest`,`Next`),(0,C.jsx)(ye,{className:`h-4 w-4 ml-0.5`})]})]}),jt?(0,C.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,C.jsx)($e,{className:`h-6 w-3/4`}),(0,C.jsx)($e,{className:`h-6 w-1/2`}),(0,C.jsx)($e,{className:`h-20 w-full`})]}):P?(0,C.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,C.jsx)(ft,{status:P.status}),(P.round??1)>1&&(0,C.jsx)(Je,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:D(`roundChip`,`Round {{n}}`,{n:P.round})}),(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:it(E(P)),children:[(0,C.jsx)(Oe,{className:`h-3 w-3`}),D(`submittedAgo`,`Submitted {{when}}`,{when:O(E(P))})]}),P.completed_at&&(0,C.jsxs)(`span`,{children:[`· `,D(`completedAt`,`Completed {{when}}`,{when:O(P.completed_at)})]}),P.status===`pending`&&P.sla_due_at&&(0,C.jsx)(Je,{variant:`outline`,className:o(`text-[10px]`,Date.parse(P.sla_due_at)<Date.now()?`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:Date.parse(P.sla_due_at)<Date.now()?D(`slaOverdue`,`SLA overdue {{dur}}`,{dur:dt(Date.now()-Date.parse(P.sla_due_at))}):D(`slaRemaining`,`SLA {{dur}} left`,{dur:dt(Date.parse(P.sla_due_at)-Date.now())})})]}),(0,C.jsx)(Ye,{children:(0,C.jsxs)(Ue,{className:`p-4 space-y-3`,children:[(0,C.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsxs)(r,{to:mt(P),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,C.jsx)(`span`,{className:`truncate`,children:P.record_title||w(P.record_id)}),(0,C.jsx)(Ee,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:lt(P)})]}),(0,C.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,C.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,C.jsx)(Qe,{className:`h-3 w-3`}),(0,C.jsx)(`span`,{title:P.submitter_id||``,children:st(P)})]})})]}),pt(P.payload,P.payload_display).length>0&&(0,C.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-sm border-t pt-3`,children:pt(P.payload,P.payload_display).map(([e,t])=>(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,C.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),P.status===`pending`&&(P.pending_approvers||[]).length>0&&(0,C.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,C.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:D(`waitingOn`,`Waiting on`)}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(P.pending_approvers||[]).map((e,t)=>(0,C.jsx)(Je,{variant:`outline`,className:`text-[11px]`,title:e,children:ct(e,P)},t))})]})]})}),(P.flow_steps?.length??0)>1&&(0,C.jsx)(`div`,{className:`flex items-center px-1`,"aria-label":D(`stepProgress`,`Approval steps`),children:P.flow_steps.map((e,t)=>(0,C.jsxs)(b.Fragment,{children:[t>0&&(0,C.jsx)(`div`,{className:o(`h-px flex-1 mx-2`,e.state===`done`||e.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)}),(0,C.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,C.jsx)(`span`,{className:o(`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,C.jsx)(Se,{className:`h-3 w-3`}):t+1}),(0,C.jsx)(`span`,{className:o(`text-xs`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]})]},e.id))}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:D(`history`,`Activity`)}),kt.length===0?(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:D(`noActions`,`No actions yet.`)}):(0,C.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:kt.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`?D(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===P.submitter_id?st(P):w(e.actor_id)),r=e.action===`submit`?D(`actSubmit`,`Submitted`):e.action===`approve`?D(`actApprove`,`Approved`):e.action===`reject`?D(`actReject`,`Rejected`):e.action===`recall`?D(`actRecall`,`Recalled`):e.action===`reassign`?D(`actReassign`,`Reassigned`):e.action===`remind`?D(`actRemind`,`Reminder sent`):e.action===`request_info`?D(`actRequestInfo`,`Requested more info`):e.action===`comment`?D(`actComment`,`Commented`):e.action===`escalate`?D(`actEscalate`,`SLA escalated`):e.action===`revise`?D(`actRevise`,`Sent back for revision`):e.action===`resubmit`?D(`actResubmit`,`Resubmitted`):e.action;return(0,C.jsxs)(`li`,{className:`relative text-xs`,children:[(0,C.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,C.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,C.jsx)(`span`,{className:`font-medium`,children:r}),(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,C.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,C.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:it(e.created_at),children:O(e.created_at)})]}),e.comment&&(0,C.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]})]},e.id)})}),P.status===`pending`&&(En||Dn)&&(0,C.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,C.jsx)(Re,{value:un,onChange:e=>dn(e.target.value),onKeyDown:e=>{e.key===`Enter`&&un.trim()&&(e.preventDefault(),wn())},placeholder:D(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,C.jsx)(s,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!un.trim()||U,onClick:()=>void wn(),children:(0,C.jsx)(Le,{className:`h-3.5 w-3.5`})})]})]}),P.payload!=null&&(0,C.jsxs)(`details`,{className:`group`,children:[(0,C.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:D(`rawData`,`Raw data (JSON)`)}),(0,C.jsxs)(`div`,{className:`mt-2`,children:[(0,C.jsx)(`div`,{className:`flex justify-end`,children:(0,C.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(P.payload,null,2)),y.success(D(`copied`,`Copied`))}catch{y.error(D(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,C.jsx)(ze,{className:`h-3 w-3`}),D(`copy`,`Copy`)]})}),(0,C.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,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(me,{}),(0,C.jsxs)(`div`,{className:`space-y-3`,children:[et&&(0,C.jsxs)(`details`,{className:`group`,children:[(0,C.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:D(`overrideActor`,`Act as another identity (admin)`)}),(0,C.jsxs)(`div`,{className:`mt-2`,children:[(0,C.jsx)(Ge,{htmlFor:`actor-override`,className:`text-xs`,children:D(`actor`,`Actor`)}),(0,C.jsx)(`input`,{id:`actor-override`,type:`text`,value:L,onChange:e=>Nt(e.target.value),placeholder:`${D(`auto`,`Auto`)}: ${q(P)||`—`}`,className:`w-full mt-1 px-3 py-2 text-sm border rounded-md bg-background`}),(0,C.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:D(`overrideHint`,`e.g. role:sales_manager. Leave blank to use the auto-detected identity.`)})]})]}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(Ge,{htmlFor:`comment`,className:`text-xs`,children:D(`comment`,`Comment (optional)`)}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1.5`,children:[D(`quickPhrase1`,`Approved — meets requirements.`),D(`quickPhrase2`,`Approved with conditions — please monitor execution.`),D(`quickPhrase3`,`Please add supporting material and resubmit.`)].map(e=>(0,C.jsx)(`button`,{type:`button`,onClick:()=>I(e),className:`text-[11px] px-2 py-0.5 rounded-full border text-muted-foreground hover:text-foreground hover:bg-accent transition-colors`,children:e},e))}),(0,C.jsx)(Ae,{id:`comment`,value:F,onChange:e=>I(e.target.value),rows:2,className:`mt-1`})]}),(0,C.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,C.jsxs)(s,{size:`sm`,onClick:()=>vn(`approve`),disabled:!En||R!==null,children:[(0,C.jsx)(he,{className:`h-4 w-4 mr-1`}),R===`approve`?D(`approving`,`Approving…`):D(`approve`,`Approve`)]}),(0,C.jsxs)(h,{children:[(0,C.jsx)(ge,{asChild:!0,children:(0,C.jsxs)(s,{size:`sm`,variant:`outline`,disabled:!En||R!==null,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,C.jsx)(ae,{className:`h-4 w-4 mr-1`}),R===`reject`?D(`rejecting`,`Rejecting…`):D(`reject`,`Reject`)]})}),(0,C.jsxs)(l,{children:[(0,C.jsxs)(u,{children:[(0,C.jsx)(_,{children:D(`rejectTitle`,`Reject this request?`)}),(0,C.jsx)(g,{children:D(`rejectBody`,`This marks the request as rejected and notifies the submitter.`)})]}),(0,C.jsxs)(v,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(p,{onClick:()=>vn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:D(`reject`,`Reject`)})]})]})]}),En&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsxs)(s,{size:`sm`,variant:`outline`,disabled:R!==null||U,className:`border-violet-300 text-violet-700 hover:bg-violet-50 dark:text-violet-400`,onClick:()=>an(!0),children:[(0,C.jsx)(We,{className:`h-4 w-4 mr-1`}),D(`sendBackBtn`,`Send back`)]}),(0,C.jsxs)(s,{size:`sm`,variant:`outline`,disabled:R!==null||U,className:`border-amber-300 text-amber-700 hover:bg-amber-50 dark:text-amber-400`,onClick:()=>en(!0),children:[(0,C.jsx)(oe,{className:`h-4 w-4 mr-1`}),D(`requestInfoBtn`,`Request info`)]}),(0,C.jsxs)(s,{size:`sm`,variant:`outline`,disabled:R!==null||U,onClick:()=>{Tn(),Xt(!0)},children:[(0,C.jsx)(ie,{className:`h-4 w-4 mr-1`}),D(`reassignBtn`,`Reassign`)]})]}),Dn&&(0,C.jsxs)(s,{size:`sm`,variant:`outline`,disabled:U,onClick:()=>void bn(),children:[(0,C.jsx)(Ve,{className:`h-4 w-4 mr-1`}),D(`remindBtn`,`Send reminder`)]}),Dn&&(0,C.jsxs)(h,{children:[(0,C.jsx)(ge,{asChild:!0,children:(0,C.jsxs)(s,{size:`sm`,variant:`outline`,disabled:R!==null,children:[(0,C.jsx)(xe,{className:`h-4 w-4 mr-1`}),R===`recall`?D(`recalling`,`Recalling…`):D(`recall`,`Recall`)]})}),(0,C.jsxs)(l,{children:[(0,C.jsxs)(u,{children:[(0,C.jsx)(_,{children:D(`recallTitle`,`Recall this request?`)}),(0,C.jsx)(g,{children:D(`recallBody`,`This withdraws your request. Approvers can no longer act on it, and the record is unlocked.`)})]}),(0,C.jsxs)(v,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(p,{onClick:()=>vn(`recall`),children:D(`recall`,`Recall`)})]})]})]})]}),!En&&(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:Dn?D(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):D(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(P.pending_approvers||[]).map(e=>ct(e,P)).join(`, `)||`—`})})]})]}),On&&(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(me,{}),(0,C.jsxs)(`div`,{className:`space-y-3`,children:[(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:D(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(Ge,{htmlFor:`resubmit-comment`,className:`text-xs`,children:D(`comment`,`Comment (optional)`)}),(0,C.jsx)(Ae,{id:`resubmit-comment`,value:F,onChange:e=>I(e.target.value),rows:2,className:`mt-1`,placeholder:D(`resubmitPlaceholder`,`What did you change?`)})]}),(0,C.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,C.jsx)(s,{asChild:!0,size:`sm`,variant:`outline`,children:(0,C.jsxs)(r,{to:mt(P),children:[(0,C.jsx)(Ee,{className:`h-4 w-4 mr-1`}),D(`editRecordBtn`,`Edit record`)]})}),(0,C.jsxs)(s,{size:`sm`,disabled:cn,onClick:()=>void Cn(),children:[(0,C.jsx)(_e,{className:o(`h-4 w-4 mr-1`,cn&&`animate-spin`)}),cn?D(`resubmitting`,`Resubmitting…`):D(`resubmitBtn`,`Resubmit`)]}),(0,C.jsxs)(h,{children:[(0,C.jsx)(ge,{asChild:!0,children:(0,C.jsxs)(s,{size:`sm`,variant:`outline`,disabled:cn,children:[(0,C.jsx)(xe,{className:`h-4 w-4 mr-1`}),D(`recall`,`Recall`)]})}),(0,C.jsxs)(l,{children:[(0,C.jsxs)(u,{children:[(0,C.jsx)(_,{children:D(`abandonTitle`,`Abandon this revision?`)}),(0,C.jsx)(g,{children:D(`abandonBody`,`This withdraws the request instead of resubmitting it. The approval ends here.`)})]}),(0,C.jsxs)(v,{children:[(0,C.jsx)(d,{children:D(`cancel`,`Cancel`)}),(0,C.jsx)(p,{onClick:()=>vn(`recall`),children:D(`recall`,`Recall`)})]})]})]})]})]})]})]}):null]})})]})}export{mt as ApprovalsInboxPage};
@@ -1 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i}from"./vendor-react-slxo-5GC.js";import{d as a}from"./infrastructure-BySW-NB0.js";import{M as o,a as s,b as c,j as l}from"./framework-BzwUcFJm.js";import{Ar as u,Cr as d,G as f,Gn as p,Ic as m,Jn as h,K as g,Kn as _,Qa as v,Qs as y,Xn as b,Y as x,Yn as S,Yr as C,Za as w,Zi as T,Zs as E,ia as D,oi as O,qn as ee,qr as k,qs as A,wc as j}from"./ui-components-CLgu4Fon.js";import{r as M}from"./vendor-ui-utils-C1OpMExs.js";import"./AdapterProvider-DvWb2IeS.js";import{n as te}from"./plugin-form-DGPdqA5u.js";import"./MetadataProvider-DuoHqlCv.js";import{r as ne}from"./ExpressionProvider-DHcGo-ds.js";import{Q as re,v as N}from"./ReportDefaultInspector-DXCs9PIk.js";import{t as P}from"./utils-CFXe_XCU.js";import{n as ie,r as ae,t as oe}from"./MetadataInspector--jXw9q3_.js";import{n as F,t as I}from"./DashboardWidgetInspector-BhYevZBF.js";import{i as se,n as L,t as ce}from"./useOpenRecordList-DzVq8Uen.js";import{n as le}from"./skeletons-CRKtyrMr.js";import{n as ue}from"./plugin-dashboard-BCk2PLlx.js";var R=e(n(),1),z=i();function de({open:e,onClose:t,schema:n,selectedWidgetId:r,onSelectWidget:i,onSave:a,onChange:o,onRemoveWidget:c,name:l,metadataClient:f,onAfterChange:p}){let{t:m}=s(),h=(0,R.useMemo)(()=>N(),[]),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(0),b=(0,R.useCallback)(e=>{_(!0),o({...n??{},...e})},[n,o]),x=(0,R.useCallback)(e=>{o(e),_(!1)},[o]),S=(0,R.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),w=Array.isArray(n?.widgets)?n.widgets:[],T=r?w.find(e=>e?.id===r):null;if(!e)return null;let E=typeof n?.name==`string`?n.name:``,D=T?m(`widget.editor.title`,{defaultValue:`Edit widget`}):m(`dashboard.editor.title`,{defaultValue:`Edit dashboard`});return(0,z.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`dashboard-config-panel`,role:`complementary`,"aria-label":D,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[T&&(0,z.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>i(null),className:`h-7 w-7 p-0`,"aria-label":m(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),title:m(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),"data-testid":`dashboard-config-back`,children:(0,z.jsx)(j,{className:`h-4 w-4`})}),(0,z.jsx)(`div`,{className:`text-sm font-medium truncate`,children:D})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[T&&c&&(0,z.jsx)(d,{variant:`ghost`,size:`sm`,onClick:()=>c(r),className:`h-7 w-7 p-0 text-destructive hover:text-destructive`,"aria-label":m(`widget.editor.delete`,{defaultValue:`Delete widget`}),title:m(`widget.editor.delete`,{defaultValue:`Delete widget`}),"data-testid":`widget-delete-button`,children:(0,z.jsx)(C,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(d,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":m(`common.close`,{defaultValue:`Close`}),"data-testid":`dashboard-config-close`,children:(0,z.jsx)(u,{className:`h-4 w-4`})})]})]}),(0,z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:T?(0,z.jsx)(I,{type:`dashboard`,name:E,draft:n??{},selection:{kind:`widget`,id:r},onPatch:b,onClearSelection:()=>i(null),onSelectionChange:S,readOnly:!1,locale:h}):(0,z.jsx)(F,{type:`dashboard`,name:E,draft:n??{},onPatch:b,onSelectionChange:S,readOnly:!1,locale:h})}),(0,z.jsxs)(`div`,{"data-testid":`dashboard-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,z.jsx)(L,{type:`dashboard`,name:l||E||void 0,metadataClient:f,dirty:g,onResume:x,savedSignal:v,onAfterChange:p}),(0,z.jsx)(d,{size:`sm`,onClick:()=>{a(n??{}),_(!1),y(e=>e+1)},"data-testid":`dashboard-config-save`,children:m(`common.save`,{defaultValue:`Save`})})]})]})}var B=t({DashboardView:()=>W}),V=[{type:`metric`,label:`KPI Metric`,Icon:k},{type:`bar`,label:`Bar Chart`,Icon:y},{type:`line`,label:`Line Chart`,Icon:E},{type:`pie`,label:`Pie Chart`,Icon:A},{type:`table`,label:`Table`,Icon:O},{type:`pivot`,label:`Pivot`,Icon:w}],H=0;function U(){return H+=1,`widget_${Date.now()}_${H}`}function fe(e){return!e.widgets?.length||!e.widgets.some(e=>!e.id)?e:{...e,widgets:e.widgets.map(e=>e.id?e:{...e,id:U()})}}function pe(e){let t=V.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function W({dataSource:e}){let t=ce(),{dashboardName:n}=r(),{showDebug:i}=ie(),u=l(),y=re(),{t:C}=s(),{dashboardLabel:w,dashboardDescription:E}=m(),O=a(),[k,A]=(0,R.useState)(!0),[j,N]=(0,R.useState)(!1),[F,I]=(0,R.useState)(null),[L,B]=(0,R.useState)(null),H=(0,R.useCallback)(e=>{B(t=>(t&&t.resolve(e),null))},[]),W=(0,R.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})}),[]),me=(0,R.useMemo)(()=>({export_dashboard_pdf:async()=>{M.info(C(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return M.error(C(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(M.info(C(`dashboardActions.forecastSoon`)),{success:!0})}),[C]);(0,R.useEffect)(()=>{A(!0),Y(null),N(!1),I(null),queueMicrotask(()=>A(!1))},[n]);let{dashboards:he,objects:G,refresh:K}=o(),{app:ge}=ne(),q=ae(he,n,ge?._packageId),[J,Y]=(0,R.useState)(null);(0,R.useEffect)(()=>{j||Y(null)},[q]);let X=(0,R.useCallback)(async e=>{try{y&&await se(`dashboard`,n,e,{metadataClient:y}),K().catch(()=>{})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[DashboardView] Auto-save failed:`,e),M.error(`Failed to save dashboard: ${t}`)}},[y,n,K]),_e=(0,R.useCallback)(()=>{Y(fe(q)),N(!0)},[q]),ve=(0,R.useCallback)(()=>{N(!1),I(null)},[]),ye=(0,R.useCallback)(e=>{if(!J)return;let t=U(),n={id:t,title:pe(e),type:e,layout:{x:0,y:J.widgets?.length??0,w:J.columns??2,h:1}},r={...J,widgets:[...J.widgets||[],n]};Y(r),X(r),I(t)},[J,X]),be=(0,R.useCallback)(e=>{if(!J)return;let t={...J,widgets:J.widgets.filter(t=>t.id!==e)};Y(t),X(t),F===e&&I(null)},[J,F,X]),xe=(0,R.useCallback)(e=>{let t=J||q;if(!t)return;let n={...t,widgets:e};Y(n),X(n)},[J,q,X]),Se=(J||q)??null,Z=(0,R.useMemo)(()=>new Set((G||[]).map(e=>e?.name).filter(Boolean)),[G]),Q=J||q,$=(0,R.useMemo)(()=>{if(!Q||Z.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?Z.has(t):!0});return t.length===e.length?Q:{...Q,widgets:t}},[Q,Z]);return k?(0,z.jsx)(le,{}):q?(0,z.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,z.jsxs)(`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,z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=P(($||q).title,C),t=P(q.label,C),n=w({name:q.name,label:t});return(0,z.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:e||n||q.name})})(),(()=>{let e=($||q).description??q.description,t=E({name:q.name,description:P(e,C)});return t?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]}),(0,z.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:[j&&(0,z.jsx)(`div`,{className:`flex items-center gap-1 mr-2`,role:`toolbar`,"aria-label":`Add widgets`,"data-testid":`dashboard-widget-toolbar`,children:V.map(({type:e,label:t,Icon:n})=>(0,z.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>ye(e),className:`inline-flex items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,title:`Add ${t}`,"aria-label":`Add ${t} widget`,children:[(0,z.jsx)(T,{className:`h-3 w-3`}),(0,z.jsx)(n,{className:`h-3 w-3`})]},e))}),O&&(0,z.jsxs)(`button`,{type:`button`,onClick:_e,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`dashboard-edit-button`,children:[(0,z.jsx)(D,{className:`h-3.5 w-3.5`}),C(`common.edit`,{defaultValue:`Edit`})]})]})]}),(0,z.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,z.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,z.jsx)(c,{value:{openRecordList:t},children:(0,z.jsx)(ue,{schema:$,dataSource:e,designMode:j,selectedWidgetId:F,onWidgetClick:I,onWidgetsReorder:xe,modalHandler:W,scriptHandlers:me,hideHeaderText:!0})})}),(0,z.jsx)(de,{open:j&&O,onClose:ve,schema:Se,selectedWidgetId:F,onSelectWidget:I,onSave:X,onChange:Y,onRemoveWidget:be,name:n,metadataClient:y,onAfterChange:()=>K().catch(()=>{})}),(0,z.jsx)(oe,{open:i,sections:[{title:`Dashboard Configuration`,data:$}]})]}),L&&L.schema?.objectName?(0,z.jsx)(te,{schema:{type:`object-form`,formType:`modal`,objectName:L.schema.objectName,mode:L.schema.mode||`create`,recordId:L.schema.recordId,title:L.schema.title,description:L.schema.description,fields:L.schema.fields,open:!0,onOpenChange:e=>{e||H({success:!1})},onSuccess:e=>{H({success:!0,reload:!0,data:e})},onCancel:()=>{H({success:!1})},showSubmit:!0,showCancel:!0},dataSource:u}):L?(0,z.jsx)(p,{open:!0,onOpenChange:e=>{e||H({success:!1})},children:(0,z.jsxs)(_,{children:[(0,z.jsxs)(S,{children:[(0,z.jsx)(b,{children:L.schema?.title||C(`actionDialog.defaultActionTitle`)}),L.schema?.description&&(0,z.jsx)(ee,{children:L.schema.description})]}),(0,z.jsxs)(h,{children:[(0,z.jsx)(d,{variant:`outline`,onClick:()=>H({success:!1}),children:C(`actionDialog.cancel`)}),(0,z.jsx)(d,{onClick:()=>H({success:!0}),children:C(`actionDialog.ok`)})]})]})}):null]}):(0,z.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,z.jsxs)(f,{children:[(0,z.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,z.jsx)(v,{className:`h-6 w-6 text-muted-foreground`})}),(0,z.jsx)(x,{children:C(`empty.dashboardNotFound`)}),(0,z.jsx)(g,{children:C(`empty.dashboardNotFoundDescription`,{name:n})})]})})}export{B as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{L as r,c as i,p as a}from"./vendor-objectstack-DTDITeDR.js";import{$s as o,Ac as s,Ai as c,Ar as l,Bn as u,Cr as d,Ha as f,Hn as p,Jr as m,Jt as h,Ks as g,Ln as _,Ls as v,Un as y,Vn as b,Ws as x,Xs as S,Xt as C,Ys as w,Yt as T,Zi as E,Zs as D,Zt as O,_o as k,cn as A,es as j,fs as M,kc as N,ln as P,mo as ee,oi as te,on as ne,pn as F,qs as re,qt as I,rs as ie,sn as ae,sr as oe,zn as se}from"./ui-components-CLgu4Fon.js";import{G as L,H as ce,J as le,K as ue,Q as R,W as de,Y as fe,_ as pe,a as me,g as he,i as ge,j as _e,p as ve,q as z,r as ye,t as B,y as V}from"./ReportDefaultInspector-DXCs9PIk.js";var H=e(t(),1),U=n();function be(e,t){if(!t)return!0;let n=t.toLowerCase();return e.value.toLowerCase().includes(n)||e.label.toLowerCase().includes(n)||(e.group?.toLowerCase().includes(n)??!1)}function W({label:e,value:t,onCommit:n,options:r,placeholder:i=`Select…`,searchPlaceholder:a=`Search or type…`,emptyText:o=`No match — keep typing to use a custom value.`,disabled:c,loading:l,allowCustom:f=!0,mono:m,className:h}){let[g,S]=H.useState(!1),[C,w]=H.useState(``),T=r.find(e=>e.value===t),E=T?T.label:t||(l?`Loading…`:i),D=H.useMemo(()=>r.filter(e=>be(e,C)),[r,C]),O=H.useMemo(()=>{let e=[],t=new Map;for(let n of D){let r=n.group??``;t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return e.map(e=>({heading:e,items:t.get(e)}))},[D]),k=C.trim(),j=f&&!!k&&!r.some(e=>e.value===k),M=e=>{n(e),S(!1),w(``)},N=(0,U.jsxs)(ne,{open:g,onOpenChange:e=>{S(e),e||w(``)},children:[(0,U.jsx)(A,{asChild:!0,children:(0,U.jsxs)(d,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":g,disabled:c,className:s(`h-8 w-full justify-between px-2 text-sm font-normal`,h),children:[(0,U.jsx)(`span`,{className:s(`truncate`,m&&`font-mono`,!T&&!t&&`text-muted-foreground`),children:E}),(0,U.jsx)(v,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,U.jsx)(ae,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,U.jsxs)(_,{shouldFilter:!1,children:[(0,U.jsx)(b,{value:C,onValueChange:w,placeholder:a}),(0,U.jsxs)(y,{children:[!j&&D.length===0&&(0,U.jsx)(se,{children:o}),j&&(0,U.jsx)(u,{children:(0,U.jsx)(p,{value:`__custom__${k}`,onSelect:()=>M(k),children:(0,U.jsxs)(`span`,{className:`truncate`,children:[`Use `,(0,U.jsxs)(`span`,{className:`font-mono`,children:[`“`,k,`”`]})]})})}),O.map((e,n)=>(0,U.jsx)(u,{heading:e.heading||void 0,children:e.items.map(e=>(0,U.jsxs)(p,{value:e.value,onSelect:()=>M(e.value),children:[(0,U.jsx)(x,{className:s(`h-3.5 w-3.5`,e.value===t?`opacity-100`:`opacity-0`)}),(0,U.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,U.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,U.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${n}`))]})]})})]});return e?(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsx)(F,{className:`text-xs text-muted-foreground`,children:e}),N]}):N}var xe=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function G(e,t){if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=e.default;if(typeof t==`string`&&t)return t}return t}function Se(e){let t=e.reference??e.reference_to??e.referenceTo??e.reference_to_object;if(typeof t==`string`&&t)return t;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0];if(t&&typeof t==`object`){let e=t.object;if(typeof e==`string`&&e)return e}}function Ce(e){switch(e){case`lookup`:case`master_detail`:case`masterDetail`:case`master-detail`:return`lookup`;case`date`:case`datetime`:case`time`:return`date`;case`number`:case`currency`:case`percent`:case`int`:case`integer`:case`float`:case`double`:case`autonumber`:return`number`;case`boolean`:case`toggle`:return`boolean`;default:return`string`}}function K(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=G(e.label,t),r=_e(e.fields).entries.map(e=>({name:e.name,label:G(e.def.label,e.name),type:typeof e.def.type==`string`?e.def.type:void 0,def:e.def}));return{label:n,fields:r,relationships:r.filter(e=>e.type&&xe.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:Se(e.def)}))}}function q(e,t,n){let r=e,i=[];for(let e of t.split(`.`)){let t=r.relationships.find(t=>t.name===e);if(!t?.referenceTo)return;let a=n[t.referenceTo];if(!a)return;i.push(t.label),r=a}return{target:r,labels:i}}function we(e,t,n){let r=e.fields.map(t=>({value:t.name,label:t.label,type:t.type,group:e.label}));for(let i of t){let t=q(e,i,n);if(!t)continue;let a=[...t.labels,t.target.label].join(` → `);for(let e of t.target.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:a})}return r}function J(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>J(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t?!0:Object.values(n).some(e=>e&&typeof e==`object`&&J(e,t))}function Y(){let e=R(),[t,n]=H.useState({options:[],loading:!0});return H.useEffect(()=>{let t=!1;return n(e=>({...e,loading:!0})),e.list(`object`).then(e=>{t||n({options:(Array.isArray(e)?e:[]).map(e=>({name:typeof e.name==`string`?e.name:``,label:G(e.label,typeof e.name==`string`?e.name:``)})).filter(e=>!!e.name).sort((e,t)=>e.label.localeCompare(t.label)),loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function Te(e,t){let n=R(),r=t.join(`\0`),[i,a]=H.useState({relationships:[],fieldOptions:[],loading:!!e});return H.useEffect(()=>{if(!e){a({relationships:[],fieldOptions:[],loading:!1});return}let t=!1;return a(e=>({...e,loading:!0})),(async()=>{try{let i=await n.get(`object`,e);if(t)return;let o=K(i,e),s=r?r.split(`\0`):[],c={[e]:o},l=async e=>{if(c[e])return c[e];let t;try{t=K(await n.get(`object`,e),e)}catch{t=K(null,e)}return c[e]=t,t};for(let e of s){let t=o;for(let n of e.split(`.`)){let e=t.relationships.find(e=>e.name===n);if(!e?.referenceTo)break;t=await l(e.referenceTo)}}if(t)return;let u=[...o.relationships];for(let e of s){if(e.split(`.`).length>=3)continue;let t=q(o,e,c);if(t)for(let n of t.target.relationships)u.push({name:`${e}.${n.name}`,label:`${e}.${n.name}`,referenceTo:n.referenceTo})}a({relationships:u,fieldOptions:we(o,s,c),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function Ee(e){let t=R(),[n,r]=H.useState({reports:0,dashboards:0,loading:!!e});return H.useEffect(()=>{if(!e){r({reports:0,dashboards:0,loading:!1});return}let n=!1;return r(e=>({...e,loading:!0})),(async()=>{let[i,a]=await Promise.all([t.list(`report`).catch(()=>[]),t.list(`dashboard`).catch(()=>[])]);n||r({reports:(Array.isArray(i)?i:[]).filter(t=>J(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>J(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}var X={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:ee},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:S},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:w},line:{id:`line`,label:`Line chart`,category:`chart`,icon:D},area:{id:`area`,label:`Area chart`,category:`chart`,icon:o},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:re},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:j},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:g},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:m},table:{id:`table`,label:`Data table`,category:`data`,icon:te},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:ie},list:{id:`list`,label:`Record list`,category:`data`,icon:f},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:M}},De={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},Oe=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(X).filter(t=>t.category===e)})),ke=N;function Ae({onAdd:e,label:t=`Add widget`}){let[n,r]=H.useState(!1),[i,a]=H.useState(``),o=H.useRef(null),s=H.useRef(null);H.useEffect(()=>{if(!n){a(``);return}let e=e=>{o.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>s.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let l=H.useMemo(()=>{let e=i.trim().toLowerCase();return e?Oe.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):Oe},[i]);return(0,U.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,U.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:()=>r(e=>!e),children:[(0,U.jsx)(E,{className:`h-3 w-3`}),t]}),n&&(0,U.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,U.jsx)(c,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,U.jsx)(`input`,{ref:s,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search widgets…`,className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground`})]}),(0,U.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:l.length===0?(0,U.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):l.map(t=>(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:De[t.category]}),t.types.map(t=>(0,U.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{e(t.id),r(!1)},children:[(0,U.jsx)(X[t.id]?.icon??ke,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,U.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,U.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var je={io:`input`,unrepresentable:`any`},Me=new Set([`widgets`,`label`,`description`,`name`]),Z,Ne=!1;function Pe(){if(Z||Ne)return Z;try{Z=r(i,je)}catch(e){Ne=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return Z}var Q;function Fe(){if(Q)return Q;if(!(!a||typeof a!=`object`)){try{let e=JSON.parse(JSON.stringify(a));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!Me.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Q=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return Q}}var Ie=new Set([`name`,`label`,`description`,`widgets`]);function Le({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=H.useCallback(e=>V(e,r),[r]),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,u=H.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),f=e=>{let n=fe(`widget`,u.map(e=>e?.id).filter(Boolean)),r=X[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:ue(u,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},p=e=>{t({widgets:le(u,e,null)})},m=(e,n)=>{e!==n&&t({widgets:z(u,e,n)})},h=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[g,_]=H.useState(null),[v,y]=H.useState(null),{schema:b,form:x}=H.useMemo(()=>me({bundledSchema:Pe(),bundledForm:Fe(),serverSchema:a,excludeFields:Ie,sectionTitle:V(`engine.inspector.moreFields`,r)}),[a,r]);return(0,U.jsxs)(de,{kindLabel:o(`engine.inspector.dashboard.kind`),title:String(s||e.name||o(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:o(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,U.jsx)(L,{label:o(`engine.inspector.dashboard.label`),value:s,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,U.jsx)(L,{label:o(`engine.inspector.dashboard.description`),value:c,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,U.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(F,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,U.jsx)(oe,{variant:`outline`,className:`text-[10px]`,children:u.length})]}),u.length===0?(0,U.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.widgetsEmpty`)}):(0,U.jsx)(`div`,{className:`space-y-1`,children:u.map((e,t)=>{let r=X[e?.type]?.icon??ke;return(0,U.jsxs)(`div`,{draggable:!n,onDragStart:()=>_(t),onDragEnd:()=>{_(null),y(null)},onDragOver:e=>{e.preventDefault(),y(t)},onDrop:()=>{g!=null&&g!==t&&m(g,t),_(null),y(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(v===t&&g!==null&&g!==t?` border-primary`:``),children:[!n&&(0,U.jsx)(k,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,U.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,U.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>h(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,U.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,U.jsx)(d,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>p(t),title:o(`engine.inspector.dashboard.removeWidget`),"aria-label":o(`engine.inspector.dashboard.removeWidget`),children:(0,U.jsx)(l,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,U.jsx)(Ae,{onAdd:f,label:o(`engine.inspector.add.widget`)})]}),(0,U.jsx)(`div`,{className:`border-t pt-3`,children:b?(0,U.jsx)(ve,{schema:b,form:x,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,U.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var Re=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],ze=[`count`,`sum`,`avg`,`min`,`max`],Be=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function Ve(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function He({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){let s=Array.isArray(e.widgets)?e.widgets:[],c=t.kind===`widget`?t.id:void 0,u=c?Ve(e,c):null,f=u?.widget??{},p=typeof f.dataset==`string`?f.dataset:``,m=typeof f.object==`string`?f.object:``,g=Array.isArray(f.dimensions)?f.dimensions.filter(e=>typeof e==`string`):[],_=Array.isArray(f.values)?f.values.filter(e=>typeof e==`string`):[],v=ye(),y=ge(p||void 0,v),{options:b,loading:x}=Y(),{fields:S}=he(m||void 0),w=H.useMemo(()=>{let e=v.datasets.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return p&&!e.some(e=>e.value===p)&&e.push({value:p,label:p}),e},[v.datasets,p]),E=H.useMemo(()=>b.map(e=>({value:e.name,label:e.label})),[b]),D=H.useMemo(()=>S.map(e=>({value:e.name,label:e.label,hint:e.type})),[S]),k=H.useMemo(()=>y.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[y.measures]),A=H.useMemo(()=>y.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[y.dimensions]);if(t.kind!==`widget`)return(0,U.jsx)(Ue,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});if(!u)return(0,U.jsx)(Ue,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:j,index:M}=u;function N(e){let t=[...s];t[M]={...t[M],...e},n({widgets:t})}function ee(e){n({widgets:z(s,M,e)}),j.id&&i?.({kind:`widget`,id:j.id,label:j.title??void 0})}return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:V(`engine.inspector.widget.kind`,o)}),(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:j.title||t.label||`Widget ${M+1}`})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,U.jsx)(ce,{index:M,total:s.length,onMove:ee,upLabel:V(`engine.inspector.reorder.up`,o),downLabel:V(`engine.inspector.reorder.down`,o),disabled:a}),(0,U.jsx)(d,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:V(`engine.inspector.widget.close`,o),"aria-label":V(`engine.inspector.widget.close`,o),children:(0,U.jsx)(l,{className:`h-3.5 w-3.5`})})]})]}),(0,U.jsx)($,{id:`widget-title`,label:V(`engine.inspector.widget.title`,o),children:(0,U.jsx)(P,{id:`widget-title`,value:j.title??``,onChange:e=>N({title:e.target.value}),disabled:a})}),(0,U.jsx)($,{id:`widget-type`,label:V(`engine.inspector.widget.type`,o),children:(0,U.jsxs)(I,{value:j.type??`metric`,onValueChange:e=>N({type:e}),disabled:a,children:[(0,U.jsx)(C,{id:`widget-type`,children:(0,U.jsx)(O,{})}),(0,U.jsx)(h,{children:Re.map(e=>(0,U.jsx)(T,{value:e.value,children:e.label},e.value))})]})}),(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:V(`engine.inspector.widget.datasetSection`,o)}),(0,U.jsxs)($,{id:`widget-dataset`,label:V(`engine.inspector.widget.dataset`,o),children:[(0,U.jsx)(W,{value:p,onCommit:e=>N({dataset:e||void 0}),options:w,loading:v.loading,placeholder:V(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:V(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,U.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:V(`engine.inspector.widget.datasetHint`,o)})]}),p&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(B,{label:V(`engine.inspector.widget.dimensions`,o),emptyText:V(`engine.inspector.widget.dimensionsHint`,o),names:g,options:A,loading:y.loading,error:y.error,readOnly:a,onCommit:e=>N({dimensions:e})}),(0,U.jsx)(B,{label:V(`engine.inspector.widget.values`,o),emptyText:V(`engine.inspector.widget.valuesHint`,o),names:_,options:k,loading:y.loading,error:y.error,readOnly:a,onCommit:e=>N({values:e})})]})]}),(0,U.jsx)($,{id:`widget-object`,label:V(`engine.inspector.widget.object`,o),children:(0,U.jsx)(W,{value:j.object??``,onCommit:e=>N({object:e||void 0}),options:E,loading:x,placeholder:`Select an object…`,searchPlaceholder:`Search objects…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-value-field`,label:V(`engine.inspector.widget.valueField`,o),children:(0,U.jsx)(W,{value:j.valueField??``,onCommit:e=>N({valueField:e||void 0}),options:D,placeholder:j.object?`Select a field…`:`e.g. amount`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-category-field`,label:V(`engine.inspector.widget.categoryField`,o),children:(0,U.jsx)(W,{value:j.categoryField??``,onCommit:e=>N({categoryField:e||void 0}),options:D,placeholder:j.object?`Select a field…`:`e.g. status`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,U.jsx)($,{id:`widget-aggregate`,label:V(`engine.inspector.widget.aggregate`,o),children:(0,U.jsxs)(I,{value:j.aggregate??`count`,onValueChange:e=>N({aggregate:e}),disabled:a,children:[(0,U.jsx)(C,{id:`widget-aggregate`,children:(0,U.jsx)(O,{})}),(0,U.jsx)(h,{children:ze.map(e=>(0,U.jsx)(T,{value:e,children:e},e))})]})}),(0,U.jsx)($,{id:`widget-color`,label:V(`engine.inspector.widget.color`,o),children:(0,U.jsx)(pe,{value:j.colorVariant??`default`,onChange:e=>N({colorVariant:e}),disabled:a,options:Be.map(e=>({value:e}))})}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,U.jsx)($,{id:`widget-w`,label:V(`engine.inspector.widget.width`,o),children:(0,U.jsx)(P,{id:`widget-w`,type:`number`,min:1,value:j.layout?.w??1,onChange:e=>N({layout:{...j.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,U.jsx)($,{id:`widget-h`,label:V(`engine.inspector.widget.height`,o),children:(0,U.jsx)(P,{id:`widget-h`,type:`number`,min:1,value:j.layout?.h??1,onChange:e=>N({layout:{...j.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,U.jsx)(`div`,{className:`pt-2 border-t`,children:(0,U.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(M,1),n({widgets:t}),r()},children:V(`engine.inspector.widget.remove`,o)})})]})}function $({id:e,label:t,children:n}){return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsx)(F,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function Ue({message:e,onClose:t,locale:n}){return(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,U.jsx)(`p`,{children:e}),(0,U.jsx)(d,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:V(`engine.inspector.widget.close`,n)})]})}export{Ce as a,Y as c,X as i,W as l,Le as n,Te as o,Ae as r,Ee as s,He as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{j as r}from"./framework-BzwUcFJm.js";import{$i as i,Cr as a,Cs as o,Fs as s,Gt as c,Ht as l,Mr as u,Ms as d,Qt as f,Ui as p,Ut as m,Va as h,Vt as g,Wt as _,_s as v,_t as y,ar as b,ct as x,gt as S,ht as C,ir as w,ln as T,mt as E,nr as D,pn as O,pt as k,rr as A,sr as j,tr as M,vt as N,yt as P,zt as F}from"./ui-components-CLgu4Fon.js";import"./src-Ce8iWu_4.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:d,cls:`text-emerald-600 border-emerald-300`},completed:{icon:d,cls:`text-emerald-600 border-emerald-300`},failed:{icon:o,cls:`text-red-600 border-red-300`},error:{icon:o,cls:`text-red-600 border-red-300`},running:{icon:h,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:v,cls:`text-amber-600 border-amber-300`},skipped:{icon:s,cls:`text-muted-foreground`}}[e]??{icon:s,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(j,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(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 V({data:e}){return(0,L.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 H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,o]=(0,I.useState)(!0),[s,c]=(0,I.useState)(null),[l,d]=(0,I.useState)(``),[f,m]=(0,I.useState)(0),h=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){c(`meta.getItems is not available on this client`),o(!1);return}o(!0),c(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),!l&&r.length>0&&d(r[0].name)}catch(e){c(e?.message??String(e))}finally{o(!1)}},[e,l]);(0,I.useEffect)(()=>{h()},[h]);let g=(0,I.useMemo)(()=>t.find(e=>e.name===l)??null,[t,l]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(u,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.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,L.jsxs)(M,{children:[(0,L.jsx)(w,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(b,{className:`text-base`,children:`Flow`}),(0,L.jsx)(A,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(a,{variant:`outline`,size:`sm`,onClick:h,disabled:i,children:[(0,L.jsx)(p,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(D,{children:[i&&(0,L.jsx)(F,{className:`h-9 w-72`}),s&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!i&&!s&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!s&&t.length>0&&(0,L.jsx)(`select`,{value:l,onChange:e=>d(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,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),g&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:g.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:g.name,refreshKey:f})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[s,c]=(0,I.useState)({}),[l,u]=(0,I.useState)(!1),[f,p]=(0,I.useState)(null),[m,g]=(0,I.useState)(null);(0,I.useEffect)(()=>{c({}),p(null),g(null)},[t?.name]);let _=(e,t)=>c(n=>({...n,[e]:t}));return(0,L.jsxs)(M,{children:[(0,L.jsxs)(w,{className:`pb-3`,children:[(0,L.jsx)(b,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(A,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(D,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(O,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(j,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(P,{id:`var-${e.name}`,checked:s[e.name]===`true`,onCheckedChange:t=>_(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(x,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:s[e.name]??``,onChange:t=>_(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(T,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:s[e.name]??``,onChange:t=>_(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(a,{onClick:async()=>{if(!e?.automation?.execute){g(`automation.execute is not available on this client`);return}u(!0),g(null),p(null);try{let i={};for(let e of r){let t=s[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}p(await e.automation.execute(t.name,{params:i})),n?.()}catch(e){g(e?.message??String(e))}finally{u(!1)}},disabled:l,size:`sm`,children:[l?(0,L.jsx)(h,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(i,{className:`h-3.5 w-3.5 mr-2`}),l?`Running…`:`Run Flow`]})}),(f||m)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[m||f?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(o,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(d,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof f?.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono`,children:[f.durationMs,` ms`]})]}),m&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:m}),f&&(0,L.jsx)(V,{data:f})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,i]=(0,I.useState)([]),[o,s]=(0,I.useState)(!0),[u,d]=(0,I.useState)(null),[v,x]=(0,I.useState)(null),[T,O]=(0,I.useState)(null),[P,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){d(`automation.listRuns is not available on this client`),s(!1);return}s(!0),d(null);try{let n=await e.automation.listRuns(t,{limit:20});i(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){d(e?.message??String(e))}finally{s(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{x(n),O(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);O(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(M,{children:[(0,L.jsx)(w,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(b,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(A,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(a,{variant:`outline`,size:`sm`,onClick:W,disabled:o,children:[o?(0,L.jsx)(h,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(p,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(D,{children:[o&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(F,{className:`h-8 w-full`}),(0,L.jsx)(F,{className:`h-8 w-full`}),(0,L.jsx)(F,{className:`h-8 w-full`})]}),!o&&u&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:u}),!o&&!u&&r.length===0&&(0,L.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.`}),!o&&!u&&r.length>0&&(0,L.jsxs)(k,{children:[(0,L.jsx)(y,{children:(0,L.jsxs)(N,{children:[(0,L.jsx)(S,{children:`Run`}),(0,L.jsx)(S,{children:`Status`}),(0,L.jsx)(S,{children:`Started`}),(0,L.jsx)(S,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(E,{children:r.map(e=>(0,L.jsxs)(N,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(C,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(C,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(C,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(C,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(g,{open:!!v,onOpenChange:e=>{e||(x(null),O(null))},children:(0,L.jsxs)(l,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(_,{className:`p-4 border-b`,children:[(0,L.jsxs)(c,{className:`font-mono text-sm break-all`,children:[`Run `,v]}),(0,L.jsx)(m,{children:T&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:T.status}),typeof T.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono`,children:[T.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(T.startedAt)})]})})]}),(0,L.jsxs)(f,{className:`flex-1 p-4`,children:[P&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(F,{className:`h-16 w-full`}),(0,L.jsx)(F,{className:`h-16 w-full`}),(0,L.jsx)(F,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!P&&T&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(T.steps)&&T.steps.length>0?T.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(j,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(j,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:T})]})})]})]})})]})}export{H as FlowRunsPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,p as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{B as a,H as o,M as s,a as c,j as l}from"./framework-BzwUcFJm.js";import{G as u,H as d,K as f,Y as p,rs as m}from"./ui-components-CLgu4Fon.js";import"./MetadataProvider-DuoHqlCv.js";import{t as h}from"./RecordDetailView-DdNF49JU.js";import{l as g}from"./plugins-views-D-6k7FrC.js";var _=e(t(),1),v=`uf_`;function y(e){let t={};return e.forEach((e,n)=>{if(n.startsWith(v)&&e!==``){let r=n.slice(3);t[r]=e.split(`,`).map(e=>{try{return decodeURIComponent(e)}catch{return e}})}}),Object.keys(t).length>0?t:void 0}function b(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t)){let t=v+e;r&&r.length>0?n.set(t,r.map(e=>encodeURIComponent(String(e))).join(`,`)):n.delete(t)}return n}var x=r();function S(e){return Array.isArray(e?.columns)&&e.columns.length>0}function C(e,t){let n=e?.listViews||e?.list_views||{},r=(t?[n[`${e?.name}.${t}`],n[t],...t==="default"||t===`list`?[e?.list]:[]]:[e?.list,...Object.values(n)]).filter(Boolean);return r.find(S)??r[0]}var w=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]);function ee(e){if(Array.isArray(e?.compactLayout)&&e.compactLayout.length>0)return e.compactLayout.filter(t=>e.fields?.[t]);let t=e?.fields;return t&&typeof t==`object`?Object.entries(t).filter(([e,t])=>t&&!t.hidden&&!w.has(e)).map(([e])=>e).slice(0,6):[]}function T(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!w.has(e)&&t(e,n))?.[0]}var E=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),D=new Set([`date`,`datetime`,`time`]),O=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function k(e){let t=T(e,(e,t)=>E.has(t.type))??T(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function A(e){return T(e,(e,t)=>D.has(t.type))??T(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function j(e){let t=A(e);return t?{startDateField:t}:void 0}function M(e){let t=T(e,(e,t)=>O.has(t.type));return t?{coverField:t}:void 0}var N=new Set([`location`,`geo`,`geolocation`,`geopoint`,`point`]);function P(e){let t=T(e,(e,t)=>D.has(t.type)&&/start|begin|kickoff/i.test(e))??T(e,(e,t)=>D.has(t.type));if(!t)return;let n=T(e,(e,n)=>D.has(n.type)&&e!==t&&/end|due|finish|deadline|close/i.test(e))??T(e,(e,n)=>D.has(n.type)&&e!==t);if(!n)return;let r=T(e,(e,t)=>(t.type===`number`||t.type===`percent`)&&/progress|percent|complete/i.test(e));return{startDateField:t,endDateField:n,...r?{progressField:r}:{}}}function F(e){let t=T(e,(e,t)=>N.has(t.type))??T(e,e=>/location|address|geo|coords?|place|venue/i.test(e));return t?{locationField:t}:void 0}function I({page:e,className:t,onConfigChange:r,reserveEditAffordance:v}){let{t:w}=c(),{objects:T}=s(),E=l(),D=i(),[O,A]=n(),[N]=_.useState(()=>y(new URLSearchParams(window.location.search))),I=_.useCallback(e=>{A(t=>b(t,e),{replace:!0})},[A]),L=e?.interfaceConfig||{},R=_.useMemo(()=>(T||[]).find(e=>e.name===L.source),[T,L.source]),z=_.useMemo(()=>C(R,L.sourceView),[R,L.sourceView]),B=L.recordAction===`page`||L.recordAction===`modal`||L.recordAction===`none`?L.recordAction:`drawer`,V=_.useCallback(e=>`/apps/${window.location.pathname.split(`/`)[2]||``}/${L.source}/record/${encodeURIComponent(String(e))}`,[L.source]),H=a({navigation:{mode:B===`none`?`none`:B},objectName:L.source,onNavigate:e=>D(V(e))}),U=O.get(`recordId`),W=_.useCallback((e,t)=>{if(B===`none`)return;let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(V(n),`_blank`);return}if((B===`drawer`||B===`modal`)&&n!=null){A(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t});return}H.handleClick(e,t)},[B,V,H,A]),G=_.useCallback(()=>{A(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[A]);_.useEffect(()=>{U&&!H.isOpen?H.open({id:U}):!U&&H.isOpen&&H.close()},[U]);let K=R?.name,q=!!z&&!S(z),J=z?.name??(L.sourceView?`${L.source}.${L.sourceView}`:void 0),[Y,X]=_.useState(null);_.useEffect(()=>{let e=!1;if(X(null),!(!K||!L.source||!q||!J))return(async()=>{try{let t=E,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(L.source))?.[J]??null),!S(n)&&typeof t?.getView==`function`&&(n=await t.getView(L.source,J)),!e&&n&&typeof n==`object`&&X(n)}catch{}})(),()=>{e=!0}},[K,L.source,L.sourceView,q,J,E]);let Z=_.useMemo(()=>Y?{...z,...Y}:z,[z,Y]),te=JSON.stringify(Z??null),Q=_.useMemo(()=>{if(!R)return;let e=Z||{},t=L.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=L.userActions||{},a=e.kanban??(r.has(`kanban`)?k(R):void 0),o=e.calendar??(r.has(`calendar`)?j(R):void 0),s=e.timeline??(r.has(`timeline`)?j(R):void 0),c=e.gallery??(r.has(`gallery`)?M(R):void 0),l=e.gantt??(r.has(`gantt`)?P(R):void 0),u=e.options?.map??(r.has(`map`)?F(R):void 0),d=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(L.filterBy)?L.filterBy:[]],f=S(L)?L.columns:S(e)?e.columns:ee(R),p=Array.isArray(L.sort)&&L.sort.length?L.sort:e.sort;return{type:`list-view`,objectName:R.name,viewType:n[0]??e.type??`grid`,fields:f,...d.length?{filters:d}:{},...p?.length?{sort:p}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:l,...u||e.options?{options:{...e.options??{},...u?{map:u}:{}}}:{},userFilters:L.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:L.showRecordCount,addRecord:L.addRecord,showSearch:i.search!==!1,showSort:i.sort!==!1,showFilters:i.filter===!0,showDensity:i.rowHeight===!0,showHideFields:!1,showGroup:!1,showColor:!1,allowExport:!1,inlineEdit:i.editInline===!0}},[K,te,L]);if(!R||!Q)return(0,x.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,x.jsxs)(u,{children:[(0,x.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,x.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,x.jsx)(p,{children:w(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,x.jsx)(f,{children:w(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:L.source||`?`})})]})});let $=Array.isArray(L.buttons)&&L.buttons.length?L.buttons.map(e=>(R.actions||[]).find(t=>t?.name===e)).filter(Boolean).map(e=>({...e,locations:[`list_toolbar`]})):[];return(0,x.jsxs)(`div`,{className:t??`h-full flex flex-col`,"data-testid":`interface-list-page`,children:[(0,x.jsxs)(`div`,{className:`pl-4 pt-4 pb-2 shrink-0 flex items-start justify-between gap-3 ${v?`pr-12`:`pr-4`}`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h1`,{className:`text-lg font-semibold leading-tight`,children:typeof e.label==`string`?e.label:e.name}),typeof e.description==`string`&&e.description&&(0,x.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:e.description})]}),$.length>0&&(0,x.jsx)(`div`,{className:`shrink-0`,"data-testid":`interface-page-buttons`,children:(0,x.jsx)(o,{schema:{type:`action:bar`,location:`list_toolbar`,actions:$,size:`sm`,variant:`outline`}})})]}),(0,x.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,x.jsx)(g,{schema:Q,dataSource:E,userFilterSelections:N,onUserFilterSelectionsChange:I,onSortChange:r?e=>r({sort:e}):void 0,onColumnStateChange:r?e=>{e?.order?.length&&r({columns:e.order})}:void 0,onRowClick:B===`none`?void 0:W})}),H.isOverlay&&(0,x.jsx)(d,{...H,setIsOpen:e=>{e||G()},title:typeof e.label==`string`?e.label:L.source||`Record`,children:e=>(0,x.jsx)(h,{objectNameOverride:L.source,recordIdOverride:String(e?.id??e?._id??U??``),embedded:!0,dataSource:E,objects:T,onEdit:()=>{}})})]})}export{b as n,y as r,I as t};
@@ -1,9 +0,0 @@
1
- import{o as e,r as t,t as n}from"./rolldown-runtime-DAXXjFlN.js";import{_ as r,f as i,l as a,r as o,t as s,u as c}from"./vendor-react-slxo-5GC.js";import{f as l,m as u}from"./infrastructure-BySW-NB0.js";import{H as d,I as f,S as p,T as m,a as h,g,jt as _,m as v,tt as y,w as b}from"./framework-BzwUcFJm.js";import{Ac as x,Cr as S,E as C,Fc as w,G as ee,Gn as T,Hs as te,Ic as ne,Jn as re,Jo as E,Jt as D,K as ie,Kn as O,Ws as k,Xn as A,Xt as ae,Y as oe,Yn as se,Yt as ce,Zt as le,_r as ue,br as de,ct as fe,er as pe,gr as me,hr as he,ln as ge,ls as _e,mr as ve,pn as ye,qn as be,qo as xe,qt as Se,rs as Ce,vr as we,xr as j,yr as Te}from"./ui-components-CLgu4Fon.js";import{r as M}from"./vendor-ui-utils-C1OpMExs.js";import{t as Ee}from"./plugin-form-DGPdqA5u.js";import{i as De,n as Oe,o as ke,t as Ae}from"./useActionModal-BPkUp8XL.js";import{n as je}from"./utils-CFXe_XCU.js";import{n as Me,t as Ne}from"./MetadataInspector--jXw9q3_.js";import{c as Pe,i as Fe,n as Ie,r as Le,s as Re}from"./plugins-views-D-6k7FrC.js";import{t as ze}from"./ManagedByBadge-B_3CAxVP.js";import{t as Be}from"./skeletons-CRKtyrMr.js";var N=e(r(),1),P=s(),F=(0,N.createContext)(void 0);function Ve({children:e}){let[t,n]=(0,N.useState)(`home`),[r,i]=(0,N.useState)(),[a,o]=(0,N.useState)(),s=(0,N.useMemo)(()=>({context:t,setContext:n,currentAppName:r,setCurrentAppName:i,recordTitle:a,setRecordTitle:o}),[t,r,a]);return(0,P.jsx)(F.Provider,{value:s,children:e})}function I(){return(0,N.useContext)(F)||{context:`app`,setContext:()=>{},currentAppName:void 0,setCurrentAppName:()=>{},recordTitle:void 0,setRecordTitle:()=>{}}}function He(e){let{setRecordTitle:t}=I();(0,N.useEffect)(()=>(t(e),()=>t(void 0)),[e,t])}var Ue=n(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),L=n((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),R=n((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),We=n(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),Ge=n(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),Ke=n((e=>{var t=L().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),z=n((e=>{var t=L().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),qe=n((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),B=n((e=>{var t=R(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],r=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return r[(e-1)*4+0];case t.M:return r[(e-1)*4+1];case t.Q:return r[(e-1)*4+2];case t.H:return r[(e-1)*4+3];default:return}}})),V=n((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),Je=n((e=>{var t=V();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),H=n(((e,t)=>{var n=Je();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),Ye=n((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),Xe=n((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
2
- ]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^[0-9]+$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),U=n((e=>{var t=Ye(),n=Xe();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),W=n((e=>{var t=L(),n=B(),r=R(),i=U(),a=Ye(),o=7973,s=t.getBCHDigit(o);function c(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function l(e,t){return i.getCharCountIndicator(e,t)+4}function u(e,t){let n=0;return e.forEach(function(e){let r=l(e.mode,t);n+=r+e.getBitsLength()}),n}function d(t,n){for(let r=1;r<=40;r++)if(u(t,r)<=e.getCapacity(r,n,i.MIXED))return r}e.from=function(e,t){return a.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,r,o){if(!a.isValid(e))throw Error(`Invalid QR Code version`);o===void 0&&(o=i.BYTE);let s=(t.getSymbolTotalCodewords(e)-n.getTotalCodewordsCount(e,r))*8;if(o===i.MIXED)return s;let c=s-l(o,e);switch(o){case i.NUMERIC:return Math.floor(c/10*3);case i.ALPHANUMERIC:return Math.floor(c/11*2);case i.KANJI:return Math.floor(c/13);case i.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,i=r.from(t,r.M);if(Array.isArray(e)){if(e.length>1)return d(e,i);if(e.length===0)return 1;n=e[0]}else n=e;return c(n.mode,n.getLength(),i)},e.getEncodedBits=function(e){if(!a.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-s>=0;)n^=o<<t.getBCHDigit(n)-s;return e<<12|n}})),Ze=n((e=>{var t=L(),n=1335,r=21522,i=t.getBCHDigit(n);e.getEncodedBits=function(e,a){let o=e.bit<<3|a,s=o<<10;for(;t.getBCHDigit(s)-i>=0;)s^=n<<t.getBCHDigit(s)-i;return(o<<10|s)^r}})),Qe=n(((e,t)=>{var n=U();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),G=n(((e,t)=>{var n=U(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),K=n(((e,t)=>{var n=U();function r(e){this.mode=n.BYTE,typeof e==`string`?this.data=new TextEncoder().encode(e):this.data=new Uint8Array(e)}r.getBitsLength=function(e){return e*8},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=r})),$e=n(((e,t)=>{var n=U(),r=L();function i(e){this.mode=n.KANJI,this.data=e}i.getBitsLength=function(e){return e*13},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=r.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
3
- Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=i})),et=n(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e||={},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),q=n((e=>{var t=U(),n=Qe(),r=G(),i=K(),a=$e(),o=Xe(),s=L(),c=et();function l(e){return unescape(encodeURIComponent(e)).length}function u(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function d(e){let n=u(o.NUMERIC,t.NUMERIC,e),r=u(o.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return s.isKanjiModeEnabled()?(i=u(o.BYTE,t.BYTE,e),a=u(o.KANJI,t.KANJI,e)):(i=u(o.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function f(e,o){switch(o){case t.NUMERIC:return n.getBitsLength(e);case t.ALPHANUMERIC:return r.getBitsLength(e);case t.KANJI:return a.getBitsLength(e);case t.BYTE:return i.getBitsLength(e)}}function p(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function m(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:l(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:l(i.data)}])}}return n}function h(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=f(r[o].lastCount+l.length,l.mode)-f(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=f(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function g(e,o){let c,l=t.getBestModeForData(e);if(c=t.from(o,l),c!==t.BYTE&&c.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(c)+`.
4
- Suggested mode is: `+t.toString(l));switch(c===t.KANJI&&!s.isKanjiModeEnabled()&&(c=t.BYTE),c){case t.NUMERIC:return new n(e);case t.ALPHANUMERIC:return new r(e);case t.KANJI:return new a(e);case t.BYTE:return new i(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(g(t,null)):t.data&&e.push(g(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=h(m(d(t,s.isKanjiModeEnabled())),n),i=c.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(p(a))},e.rawSplit=function(t){return e.fromArray(d(t,s.isKanjiModeEnabled()))}})),tt=n((e=>{var t=L(),n=R(),r=We(),i=Ge(),a=Ke(),o=z(),s=qe(),c=B(),l=H(),u=W(),d=Ze(),f=U(),p=q();function m(e,t){let n=e.size,r=o.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function h(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function g(e,t){let n=a.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function _(e,t){let n=e.size,r=u.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function v(e,t,n){let r=e.size,i=d.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function y(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function b(e,n,i){let a=new r;i.forEach(function(t){a.put(t.mode.bit,4),a.put(t.getLength(),f.getCharCountIndicator(t.mode,e)),t.write(a)});let o=(t.getSymbolTotalCodewords(e)-c.getTotalCodewordsCount(e,n))*8;for(a.getLengthInBits()+4<=o&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(0);let s=(o-a.getLengthInBits())/8;for(let e=0;e<s;e++)a.put(e%2?17:236,8);return x(a,e,n)}function x(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-c.getTotalCodewordsCount(n,r),o=c.getBlocksCount(n,r),s=o-i%o,u=Math.floor(i/o),d=Math.floor(a/o),f=d+1,p=u-d,m=new l(p),h=0,g=Array(o),_=Array(o),v=0,y=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?d:f;g[e]=y.slice(h,h+t),_[e]=m.encode(g[e]),h+=t,v=Math.max(v,t)}let b=new Uint8Array(i),x=0,S,C;for(S=0;S<v;S++)for(C=0;C<o;C++)S<g[C].length&&(b[x++]=g[C][S]);for(S=0;S<p;S++)for(C=0;C<o;C++)b[x++]=_[C][S];return b}function S(e,n,r,a){let o;if(Array.isArray(e))o=p.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=p.rawSplit(e);t=u.getBestVersionForData(n,r)}o=p.fromString(e,t||40)}else throw Error(`Invalid data`);let c=u.getBestVersionForData(o,r);if(!c)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=c;else if(n<c)throw Error(`
5
- The chosen QR Code version cannot contain this amount of data.
6
- Minimum version required to store current data is: `+c+`.
7
- `);let l=b(n,r,o),d=new i(t.getSymbolSize(n));return m(d,n),h(d),g(d,n),v(d,r,0),n>=7&&_(d,n),y(d,l),isNaN(a)&&(a=s.getBestMask(d,v.bind(null,d,r))),s.applyMask(a,d),v(d,r,a),{modules:d,version:n,errorCorrectionLevel:r,maskPattern:a,segments:o}}e.create=function(e,r){if(e===void 0||e===``)throw Error(`No input text`);let i=n.M,a,o;return r!==void 0&&(i=n.from(r.errorCorrectionLevel,n.M),a=u.from(r.version),o=s.from(r.maskPattern),r.toSJISFunc&&t.setToSJISFunction(r.toSJISFunc)),S(e,a,i,o)}})),nt=n((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||={},e.color||={};let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),rt=n((e=>{var t=nt();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||={},t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||={};let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),it=n((e=>{var t=nt();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
8
- `;return typeof a==`function`&&a(null,p),p}})),J=n((e=>{var t=Ue(),n=tt(),r=rt(),i=it();function a(e,r,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!t())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=r,r=a=void 0):c===3&&(r.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=r,r=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=r,r=a=void 0):c===2&&!r.getContext&&(a=i,i=r,r=void 0),new Promise(function(t,o){try{t(e(n.create(i,a),r,a))}catch(e){o(e)}})}try{let t=n.create(i,a);o(null,e(t,r,a))}catch(e){o(e)}}e.create=n.create,e.toCanvas=a.bind(null,r.render),e.toDataURL=a.bind(null,r.renderToDataURL),e.toString=a.bind(null,function(e,t,n){return i.render(e,n)})}));function at(e){let{url:t,channel:n,autoReconnect:r=!0,reconnectInterval:i=1e3,maxReconnectAttempts:a=10,authToken:o}=e,[s,c]=(0,N.useState)(`disconnected`),[l,u]=(0,N.useState)(null),[d,f]=(0,N.useState)([]),[p,m]=(0,N.useState)(null),h=(0,N.useRef)(null),g=(0,N.useRef)(0),_=(0,N.useRef)(null),v=(0,N.useRef)(new Map),y=(0,N.useRef)([]),b=(0,N.useRef)(!0),x=(0,N.useRef)(!1),S=(0,N.useCallback)(()=>{_.current!==null&&(clearTimeout(_.current),_.current=null)},[]),C=(0,N.useCallback)(e=>{for(;y.current.length>0;){let t=y.current.shift(),r={type:t.type,channel:n,data:t.data,timestamp:new Date().toISOString()};e.send(JSON.stringify(r))}},[n]),w=(0,N.useCallback)(()=>{if(typeof WebSocket>`u`){m(Error(`WebSocket is not available in this environment`)),c(`error`);return}if(!t){m(Error(`WebSocket URL is required`)),c(`error`);return}try{let e=new URL(t);if(e.protocol!==`ws:`&&e.protocol!==`wss:`){m(Error(`WebSocket URL must use ws: or wss: protocol`)),c(`error`);return}}catch{m(Error(`Invalid WebSocket URL`)),c(`error`);return}h.current&&=(x.current=!0,h.current.close(),null),x.current=!1,c(`connecting`),m(null);let e=o?`${t}?token=${encodeURIComponent(o)}&channel=${encodeURIComponent(n)}`:`${t}?channel=${encodeURIComponent(n)}`,s;try{s=new WebSocket(e)}catch(e){if(!b.current)return;m(e instanceof Error?e:Error(`Failed to create WebSocket connection`)),c(`error`);return}h.current=s,s.onopen=()=>{b.current&&(c(`connected`),m(null),g.current=0,C(s))},s.onmessage=e=>{if(b.current)try{let t=JSON.parse(String(e.data));if(t.channel!==n)return;u(t),f(e=>[...e,t]);let r=v.current.get(t.type);r&&r.forEach(e=>e(t.data))}catch{}},s.onerror=()=>{b.current&&(m(Error(`WebSocket connection error`)),c(`error`))},s.onclose=()=>{if(b.current){if(h.current=null,x.current){c(`disconnected`);return}if(r&&g.current<a){c(`reconnecting`);let e=Math.min(i*2**g.current,3e4);g.current+=1,_.current=setTimeout(()=>{b.current&&w()},e)}else c(`disconnected`)}}},[t,n,o,r,i,a,C]),ee=(0,N.useCallback)(()=>{S(),x.current=!0,g.current=0,h.current&&=(h.current.close(),null),c(`disconnected`)},[S]),T=(0,N.useCallback)(()=>{S(),g.current=0,w()},[w,S]),te=(0,N.useCallback)((e,t)=>{let r=h.current;if(r&&r.readyState===WebSocket.OPEN){let i={type:e,channel:n,data:t,timestamp:new Date().toISOString()};r.send(JSON.stringify(i))}else y.current.push({type:e,data:t})},[n]),ne=(0,N.useCallback)((e,t)=>(v.current.has(e)||v.current.set(e,new Set),v.current.get(e).add(t),()=>{let n=v.current.get(e);n&&(n.delete(t),n.size===0&&v.current.delete(e))}),[]);return(0,N.useEffect)(()=>(b.current=!0,t&&w(),()=>{b.current=!1,S(),x.current=!0,h.current&&=(h.current.close(),null)}),[t,n,o]),{connectionState:s,isConnected:s===`connected`,lastMessage:l,messages:d,send:te,subscribe:ne,disconnect:ee,reconnect:T,error:p}}var ot=0;function st(){return ot+=1,`conflict-${Date.now()}-${ot}`}var ct=0;function lt(){return ct+=1,`ver-${Date.now()}-${ct}`}function ut(e,t,n){let[r,i]=(0,N.useState)([]),[a,o]=(0,N.useState)([]);return{versions:r,currentVersion:(0,N.useMemo)(()=>r.length===0?0:r[r.length-1].version,[r]),conflicts:a,hasConflicts:a.length>0,recordVersion:(0,N.useCallback)((n,r)=>{i(i=>{let a=i.length===0?1:i[i.length-1].version+1,o={id:lt(),version:a,timestamp:new Date().toISOString(),userId:e,userName:t,changes:n,message:r};return[...i,o]})},[e,t]),resolveConflict:(0,N.useCallback)((n,r,a)=>{o(o=>{let s=o.find(e=>e.id===n);if(!s)return o;let c;switch(r){case`local`:c=s.localValue;break;case`remote`:c=s.remoteValue;break;case`merge`:c=a??s.localValue;break}return i(n=>{let i=n.length===0?1:n[n.length-1].version+1,a={id:lt(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:{[s.field]:{before:s.baseValue,after:c}},message:`Resolved conflict on "${s.field}" using ${r} strategy`};return[...n,a]}),o.filter(e=>e.id!==n)})},[e,t]),resolveAllConflicts:(0,N.useCallback)(n=>{o(r=>{if(r.length===0)return r;let a={};for(let e of r)a[e.field]={before:e.baseValue,after:n===`local`?e.localValue:e.remoteValue};return i(r=>{let i=r.length===0?1:r[r.length-1].version+1,o={id:lt(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:a,message:`Resolved all conflicts using ${n} strategy`};return[...r,o]}),[]})},[e,t]),revertToVersion:(0,N.useCallback)(n=>{let a=r.findIndex(e=>e.id===n);if(a===-1)return null;let o={};for(let e=0;e<=a;e++){let t=r[e];for(let[e,n]of Object.entries(t.changes))o[e]=n.after}let s={},c={};for(let e of r)for(let[t,n]of Object.entries(e.changes))c[t]=n.after;for(let[e,t]of Object.entries(o))c[e]!==t&&(s[e]={before:c[e],after:t});return Object.keys(s).length>0&&i(n=>{let i=n.length===0?1:n[n.length-1].version+1,o={id:lt(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:s,message:`Reverted to version ${r[a].version}`};return[...n,o]}),o},[r,e,t]),compareVersions:(0,N.useCallback)((e,t)=>{let n=r.findIndex(t=>t.id===e),i=r.findIndex(e=>e.id===t);if(n===-1||i===-1)return null;let[a,o]=n<i?[n,i]:[i,n],s=e=>{let t={};for(let n=0;n<=e;n++)for(let[e,i]of Object.entries(r[n].changes))t[e]=i.after;return t},c=s(a),l=s(o),u=new Set([...Object.keys(c),...Object.keys(l)]),d={};for(let e of u){let t=c[e],n=l[e];t!==n&&(d[e]={before:t,after:n})}return d},[r]),addConflict:(0,N.useCallback)(e=>{let t={...e,id:st()};o(e=>[...e,t])},[]),clearHistory:(0,N.useCallback)(()=>{i([]),o([])},[])}}var dt={sm:24,md:32,lg:40},ft={active:`#22c55e`,idle:`#f59e0b`,away:`#94a3b8`};function pt(e){return e.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}function mt({users:e,maxVisible:t=5,size:n=`md`,showStatus:r=!0,className:i}){let a=dt[n],o=Math.round(a*.3),s=Math.round(a*.35),c=Math.max(8,Math.round(a*.28)),l=(0,N.useMemo)(()=>e.slice(0,t),[e,t]),u=Math.max(0,e.length-t),d={display:`inline-flex`,alignItems:`center`,flexDirection:`row-reverse`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`},f={width:`${a}px`,height:`${a}px`,borderRadius:`50%`,border:`2px solid #fff`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`${s}px`,fontWeight:600,color:`#fff`,position:`relative`,flexShrink:0,overflow:`hidden`,boxSizing:`border-box`},p={...f,backgroundColor:`#e2e8f0`,color:`#475569`,marginLeft:`-${o}px`},m={position:`absolute`,bottom:`-1px`,right:`-1px`,width:`${c}px`,height:`${c}px`,borderRadius:`50%`,border:`2px solid #fff`,boxSizing:`border-box`},h=(0,N.useMemo)(()=>[...l].reverse(),[l]);return N.createElement(`div`,{style:d,className:i,role:`group`,"aria-label":`${e.length} user${e.length===1?``:`s`} present`},u>0&&N.createElement(`div`,{key:`overflow`,style:p,title:`${u} more user${u===1?``:`s`}`},`+${u}`),h.map((e,t)=>N.createElement(`div`,{key:e.userId,style:{...f,backgroundColor:e.color,marginLeft:t>0||u>0?`-${o}px`:`0`},title:`${e.userName} (${e.status})`},e.avatar?N.createElement(`img`,{src:e.avatar,alt:e.userName,style:{width:`100%`,height:`100%`,objectFit:`cover`}}):pt(e.userName),r&&N.createElement(`span`,{style:{...m,backgroundColor:ft[e.status]}}))))}var ht=N.createContext({});function Y(){let e=N.useContext(ht),[t,n]=N.useState([]);return N.useEffect(()=>{if(!e.subscribeTenant){n([]);return}return e.subscribeTenant(e=>{n(Array.isArray(e)?e:[])})},[e]),t}function gt(e,t){let n=N.useContext(ht),[r,i]=N.useState([]);return N.useEffect(()=>{if(!n.subscribeRecord||!e||!t){i([]);return}return n.subscribeRecord({objectName:e,recordId:t},e=>{i(Array.isArray(e)?e:[])})},[n,e,t]),r}var _t={platform:{create:!0,import:!0,edit:!0,delete:!0,exportCsv:!0},config:{create:!0,import:!1,edit:!0,delete:!0,exportCsv:!0},system:{create:!1,import:!1,edit:!1,delete:!1,exportCsv:!0},"append-only":{create:!1,import:!1,edit:!1,delete:!1,exportCsv:!0},"better-auth":{create:!1,import:!1,edit:!1,delete:!1,exportCsv:!0}};function vt(e){let t=_t[e?.managedBy??`platform`]??_t.platform,n=e?.userActions??{};return{create:n.create??t.create,import:n.import??t.import,edit:n.edit??t.edit,delete:n.delete??t.delete,exportCsv:n.exportCsv??t.exportCsv}}var yt=new Set([`record:discussion`,`record:chatter`]);function bt(e){let t=new WeakSet,n=e=>{if(!e||typeof e!=`object`||t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.some(n);let r=e?.type;return typeof r==`string`&&yt.has(r)?!0:[e.children,e.items,e.body,e.components,e.properties?.children,e.properties?.items,e.regions].some(n)};return n(e)}function xt({state:e,onOpenChange:t}){let{t:n}=h(),r=()=>{e.resolve?.(!0),t(!1)},i=()=>{e.resolve?.(!1),t(!1)};return(0,P.jsx)(ve,{open:e.open,onOpenChange:e=>{e||i()},children:(0,P.jsxs)(ue,{children:[(0,P.jsxs)(de,{children:[(0,P.jsx)(j,{children:e.options?.title||n(`actionConfirm.title`)}),(0,P.jsx)(we,{children:e.message})]}),(0,P.jsxs)(Te,{children:[(0,P.jsx)(me,{onClick:i,children:e.options?.cancelText||n(`actionConfirm.cancel`)}),(0,P.jsx)(he,{onClick:r,children:e.options?.confirmText||n(`actionConfirm.confirm`)})]})]})})}function St({state:e,onOpenChange:t}){let{t:n,language:r}=h(),[i,a]=(0,N.useState)({}),[o,s]=(0,N.useState)({});(0,N.useEffect)(()=>{if(e.open){let t={};for(let n of e.params)n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);a(t),s({})}},[e.open,e.params]);let c=e=>e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)?e.length===0:!1,l=()=>{let n={};for(let t of e.params)t.required&&c(i[t.name])&&(n[t.name]=!0);if(Object.keys(n).length>0){s(n);return}e.resolve?.(i),t(!1)},u=()=>{e.resolve?.(null),t(!1)},d=(e,t)=>{a(n=>({...n,[e]:t})),s(t=>({...t,[e]:!1}))};return(0,P.jsx)(T,{open:e.open,onOpenChange:e=>{e||u()},children:(0,P.jsxs)(O,{children:[(0,P.jsxs)(se,{children:[(0,P.jsx)(A,{children:e.title||n(`actionDialog.title`)}),(0,P.jsx)(be,{children:e.description||n(`actionDialog.description`)})]}),(0,P.jsx)(`div`,{className:`grid gap-4 py-4`,children:e.params.map(e=>{let t={...e,label:w(e.label,r),helpText:e.helpText==null?e.helpText:w(e.helpText,r),options:e.options?.map(e=>({...e,label:w(e.label,r)}))};if(t.type===`boolean`||t.type===`checkbox`){let e=i[t.name]===!0;return(0,P.jsxs)(`div`,{className:`grid gap-1`,children:[(0,P.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,P.jsx)(pe,{id:t.name,checked:e,onCheckedChange:e=>d(t.name,e===!0),className:`mt-0.5`}),(0,P.jsxs)(ye,{htmlFor:t.name,className:`font-normal cursor-pointer`,children:[t.label,t.required&&(0,P.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]})]}),o[t.name]&&(0,P.jsx)(`p`,{className:`text-xs text-destructive ml-6`,children:n(`actionDialog.requiredError`,{label:t.label})}),t.helpText&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground ml-6`,children:t.helpText})]},t.name)}let a=t.type===`lookup`||t.type===`reference`;return(0,P.jsxs)(`div`,{className:`grid gap-2`,children:[(0,P.jsxs)(ye,{htmlFor:t.name,children:[t.label,t.required&&(0,P.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]}),t.type===`select`&&t.options?(0,P.jsxs)(Se,{value:i[t.name]??``,onValueChange:e=>d(t.name,e),children:[(0,P.jsx)(ae,{id:t.name,className:o[t.name]?`border-destructive`:``,children:(0,P.jsx)(le,{placeholder:t.placeholder||n(`actionDialog.selectPlaceholder`,{label:t.label})})}),(0,P.jsx)(D,{children:t.options.map(e=>(0,P.jsx)(ce,{value:e.value,children:e.label},e.value))})]}):a&&t.referenceTo?(0,P.jsx)(C,{value:i[t.name]??null,onChange:e=>d(t.name,e),field:{name:t.name,type:`lookup`,reference_to:t.referenceTo,display_field:t.displayField,id_field:t.idField,description_field:t.descriptionField,multiple:t.multiple,title_format:t.titleFormat,lookup_columns:t.lookupColumns,lookup_filters:t.lookupFilters,lookup_page_size:t.lookupPageSize,depends_on:t.dependsOn,placeholder:t.placeholder}}):t.type===`textarea`?(0,P.jsx)(fe,{id:t.name,value:i[t.name]??``,onChange:e=>d(t.name,e.target.value),placeholder:t.placeholder,className:o[t.name]?`border-destructive`:``}):t.type===`number`?(0,P.jsx)(ge,{id:t.name,type:`number`,value:i[t.name]??``,onChange:e=>d(t.name,e.target.value===``?void 0:e.target.valueAsNumber),placeholder:t.placeholder,className:o[t.name]?`border-destructive`:``}):(0,P.jsx)(ge,{id:t.name,type:[`email`,`url`,`date`,`datetime-local`,`time`,`password`].includes(t.type)?t.type:`text`,value:i[t.name]??``,onChange:e=>d(t.name,e.target.value),placeholder:t.placeholder||(a?n(`actionDialog.lookupPlaceholder`,{label:t.label}):void 0),className:o[t.name]?`border-destructive`:``}),o[t.name]&&(0,P.jsx)(`p`,{className:`text-xs text-destructive`,children:n(`actionDialog.requiredError`,{label:t.label})}),t.helpText&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.helpText}),a&&!t.helpText&&(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`actionDialog.lookupHelpText`)})]},t.name)})}),(0,P.jsxs)(re,{children:[(0,P.jsx)(S,{variant:`outline`,onClick:u,children:n(`actionDialog.cancel`)}),(0,P.jsx)(S,{onClick:l,children:n(`actionDialog.confirm`)})]})]})})}var Ct=J();function X(e,t){if(e!=null)return t.split(`.`).reduce((e,t)=>{if(e!=null)return e[t]},e)}function wt({state:e,onAcknowledge:t}){let{t:n}=h(),{spec:r,data:i}=e,a=(0,N.useMemo)(()=>r?.fields&&r.fields.length>0?r.fields:[{path:``,label:void 0,format:r?.format??`json`}],[r]);return(0,P.jsx)(T,{open:e.open,onOpenChange:e=>{},children:(0,P.jsxs)(O,{onPointerDownOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),className:`max-w-lg`,children:[(0,P.jsxs)(se,{children:[(0,P.jsx)(A,{children:r?.title||n(`actions.resultDialog.defaultTitle`)||`Save this value now`}),r?.description?(0,P.jsx)(be,{children:r.description}):null]}),(0,P.jsx)(`div`,{className:`space-y-4 py-2`,children:a.map((e,t)=>(0,P.jsx)(Tt,{field:e,value:e.path===``?i:X(i,e.path),defaultFormat:r?.format},`${e.path}-${t}`))}),(0,P.jsx)(re,{children:(0,P.jsx)(S,{onClick:t,children:r?.acknowledge||n(`actions.resultDialog.acknowledge`)||`I have saved this`})})]})})}function Tt({field:e,value:t,defaultFormat:n}){let r=e.format??n??`json`,i=e.label,a=r===`qrcode`&&typeof t!=`string`||r===`code-list`&&!Array.isArray(t)||(r===`secret`||r===`text`)&&typeof t!=`string`?`json`:r;return(0,P.jsxs)(`div`,{className:`space-y-1.5`,children:[i?(0,P.jsx)(`div`,{className:`text-sm font-medium text-foreground/80`,children:i}):null,a===`qrcode`?(0,P.jsx)(Dt,{value:t}):null,a===`code-list`?(0,P.jsx)(Q,{value:t}):null,a===`secret`?(0,P.jsx)(Ot,{value:t}):null,a===`text`?(0,P.jsx)(kt,{value:t}):null,a===`json`?(0,P.jsx)(At,{value:t}):null]})}function Et(e){let[t,n]=(0,N.useState)(!1);return(0,N.useEffect)(()=>{if(!t)return;let e=setTimeout(()=>n(!1),1500);return()=>clearTimeout(e)},[t]),{copy:async()=>{if(e!=null)try{await navigator.clipboard.writeText(e),n(!0)}catch{}},copied:t}}function Z({value:e,label:t}){let{copy:n,copied:r}=Et(e);return(0,P.jsxs)(S,{type:`button`,variant:`outline`,size:`sm`,onClick:n,children:[r?(0,P.jsx)(k,{className:`w-4 h-4`}):(0,P.jsx)(_e,{className:`w-4 h-4`}),t?(0,P.jsx)(`span`,{className:`ml-2`,children:t}):null]})}function Dt({value:e}){let[t,n]=(0,N.useState)(null);return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`flex justify-center rounded-md border bg-white p-3`,children:t?(0,P.jsx)(`span`,{className:`text-sm text-destructive`,children:t}):(0,P.jsx)(`canvas`,{ref:t=>{!t||!e||(0,Ct.toCanvas)(t,e,{width:200,margin:1},e=>{e&&n(e.message)})}})}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`code`,{className:`flex-1 truncate rounded bg-muted px-2 py-1 text-xs font-mono`,children:e}),(0,P.jsx)(Z,{value:e})]})]})}function Q({value:e}){let t=e.join(`
9
- `);return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`div`,{className:`rounded-md border bg-muted/40 p-2`,children:(0,P.jsx)(`ul`,{className:`space-y-1`,children:e.map((e,t)=>(0,P.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`code`,{className:`flex-1 rounded bg-background px-2 py-1 text-sm font-mono`,children:e}),(0,P.jsx)(Z,{value:e})]},`${t}-${e}`))})}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsx)(Z,{value:t,label:`Copy all`})})]})}function Ot({value:e}){let[t,n]=(0,N.useState)(!1);return(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`code`,{className:`flex-1 rounded bg-muted px-2 py-1 text-sm font-mono break-all`,children:t?e:e.replace(/./g,`•`)}),(0,P.jsx)(S,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(e=>!e),children:t?(0,P.jsx)(E,{className:`w-4 h-4`}):(0,P.jsx)(xe,{className:`w-4 h-4`})}),(0,P.jsx)(Z,{value:e})]})}function kt({value:e}){return(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,P.jsx)(`code`,{className:`flex-1 rounded bg-muted px-2 py-1 text-sm font-mono break-all`,children:e}),(0,P.jsx)(Z,{value:e})]})}function At({value:e}){let t=(0,N.useMemo)(()=>{try{return JSON.stringify(e,null,2)}catch{return String(e)}},[e]);return(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(`pre`,{className:`max-h-80 overflow-auto rounded-md border bg-muted/40 p-3 text-xs font-mono`,children:t}),(0,P.jsx)(`div`,{className:`flex justify-end`,children:(0,P.jsx)(Z,{value:t})})]})}function $(e){return e.kind===`object-form`&&!!e.objectName}function jt(e){let t={};for(let n of e.fields)n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function Mt({screen:e,values:t,onValueChange:n,dataSource:r,objects:i,objectForm:a,className:o}){if($(e)){let t=Array.isArray(i)?i.find(t=>t?.name===e.objectName):void 0,n=t?t.form?.subforms??t.formViews?.default?.subforms:void 0;return(0,P.jsx)(`div`,{className:x(`py-2`,o),children:r?(0,P.jsx)(Ee,{schema:{type:`object-form`,formType:`simple`,objectName:e.objectName,mode:e.mode===`edit`?`edit`:`create`,recordId:e.mode===`edit`?e.recordId:void 0,...e.defaults?{initialValues:e.defaults}:{},layout:`vertical`,subforms:n,onSuccess:a?.onSuccess,onCancel:a?.onCancel,showSubmit:a?.showSubmit??!0,showCancel:a?.showCancel??!0,submitText:a?.submitText??`Save & Continue`,cancelText:a?.cancelText??`Cancel`},dataSource:r},e.nodeId):(0,P.jsx)(`div`,{className:`text-sm text-destructive py-4`,children:a?.noDataSourceMessage??`This step renders an object form but no data source is available.`})})}return(0,P.jsx)(`div`,{className:x(`space-y-4 py-2`,o),children:e.fields.map(e=>(0,P.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,P.jsxs)(ye,{htmlFor:`ff-${e.name}`,className:`text-sm`,children:[e.label||e.name,e.required&&(0,P.jsx)(`span`,{className:`text-destructive`,children:` *`})]}),(0,P.jsx)(Nt,{field:e,value:t[e.name],onChange:t=>n(e.name,t)})]},e.name))})}function Nt({field:e,value:t,onChange:n}){let r=`ff-${e.name}`,i=(e.type||`text`).toLowerCase();if(Array.isArray(e.options)&&e.options.length>0)return(0,P.jsxs)(Se,{value:t==null?void 0:String(t),onValueChange:e=>n(e),children:[(0,P.jsx)(ae,{id:r,children:(0,P.jsx)(le,{placeholder:e.placeholder||`Select…`})}),(0,P.jsx)(D,{children:e.options.map((e,t)=>(0,P.jsx)(ce,{value:String(e.value),children:e.label},t))})]});if(i===`boolean`||i===`checkbox`)return(0,P.jsx)(pe,{id:r,checked:t===!0,onCheckedChange:e=>n(e===!0)});if(i===`textarea`||i===`markdown`)return(0,P.jsx)(fe,{id:r,value:t??``,placeholder:e.placeholder,onChange:e=>n(e.target.value)});let a=i===`number`||i===`currency`?`number`:i===`email`?`email`:i===`date`?`date`:`text`;return(0,P.jsx)(ge,{id:r,type:a,value:t??``,placeholder:e.placeholder,onChange:e=>n(a===`number`?e.target.value===``?void 0:Number(e.target.value):e.target.value)})}function Pt({state:e,authFetch:t,baseUrl:n,onClose:r,onComplete:i,dataSource:a,objects:o}){let[s,c]=(0,N.useState)(null),[l,u]=(0,N.useState)(``),[d,f]=(0,N.useState)(``),[p,m]=(0,N.useState)({}),[h,g]=(0,N.useState)(!1);if((0,N.useEffect)(()=>{e&&(c(e.screen),u(e.runId),f(e.flowName),m(jt(e.screen)))},[e]),!e||!s)return null;let _=(e,t)=>m(n=>({...n,[e]:t})),v=async e=>{let a=await t(`${n}/api/v1/automation/${encodeURIComponent(d)}/runs/${encodeURIComponent(l)}/resume`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({inputs:e})}),o=await a.json().catch(()=>null);if(!a.ok||o?.success===!1){M.error(o?.error||`Resume failed (HTTP ${a.status})`);return}let s=o?.data??{};if(s.success===!1||s.status===`failed`){M.error(s.errorMessage||s.error||`The flow failed to complete.`),r();return}s.status===`paused`&&s.screen?(c(s.screen),u(s.runId||l),m(jt(s.screen)),M.success(`Saved — next step`)):(M.success(s.successMessage||`Done`),i())},y=async()=>{let e=s.fields.filter(e=>e.required&&(p[e.name]===void 0||p[e.name]===``||p[e.name]===null));if(e.length){M.error(`Please fill: ${e.map(e=>e.label||e.name).join(`, `)}`);return}g(!0);try{await v(p)}catch(e){M.error(e.message)}finally{g(!1)}},b=async e=>{let t=e?.id??e?.data?.id??e?.record?.id,n=s.idVariable&&t!=null?{[s.idVariable]:t}:{};g(!0);try{await v(n)}catch(e){M.error(e.message)}finally{g(!1)}},x=$(s);return(0,P.jsx)(T,{open:!0,onOpenChange:e=>{!e&&!h&&r()},children:(0,P.jsxs)(O,{className:x?`sm:max-w-3xl max-h-[90vh] overflow-y-auto`:`sm:max-w-md`,children:[(0,P.jsxs)(se,{children:[(0,P.jsx)(A,{children:s.title||`Input`}),s.description&&(0,P.jsx)(be,{children:s.description})]}),(0,P.jsx)(Mt,{screen:s,values:p,onValueChange:_,dataSource:a,objects:o,objectForm:{onSuccess:b,onCancel:r,showSubmit:!0,showCancel:!0,submitText:`Save & Continue`,cancelText:`Cancel`}}),!x&&(0,P.jsxs)(re,{children:[(0,P.jsx)(S,{variant:`outline`,onClick:r,disabled:h,children:`Cancel`}),(0,P.jsx)(S,{onClick:y,disabled:h,children:h?`Submitting…`:`Submit`})]})]})})}function Ft(e,t,n,r){if(!(!Array.isArray(e)||e.length===0))return e.map(e=>{let i=typeof e==`string`?{label:e,value:e}:e;return{label:r?r(t,n,i.value,i.label):i.label,value:i.value}})}function It(e,t){let n=e.field??e.name,r=e.defaultFromRow&&t.row&&n!=null&&Object.prototype.hasOwnProperty.call(t.row,n)?t.row[n]:void 0;if(!e.field)return{name:e.name??``,label:e.label??e.name??``,type:e.type??`text`,required:e.required??!1,options:e.options,placeholder:e.placeholder,helpText:e.helpText,defaultValue:r??e.defaultValue};let i=e.objectOverride??t.objectName,a=t.objects.find(e=>e?.name===i)?.fields?.[e.field];if(!a)return{name:e.name??e.field,label:e.label??t.fieldLabel(i,e.field,e.field),type:e.type??`text`,required:e.required??!1,options:e.options,placeholder:e.placeholder,helpText:e.helpText,defaultValue:r??e.defaultValue};let o=e.type??a.type??`text`,s=e.options??Ft(a.options,i,e.field,t.fieldOptionLabel),c=e.label??t.fieldLabel(i,e.field,a.label??e.field),l=o===`lookup`||o===`reference`?{referenceTo:a.reference_to??a.reference,displayField:a.display_field??a.reference_field,idField:a.id_field,descriptionField:a.description_field,multiple:a.multiple,titleFormat:a.title_format,lookupColumns:a.lookup_columns,lookupFilters:a.lookup_filters,lookupPageSize:a.lookup_page_size,dependsOn:a.depends_on}:{};return{name:e.name??e.field,label:c,type:o,required:e.required??a.required??!1,options:s,placeholder:e.placeholder??a.placeholder,helpText:e.helpText??a.help??a.description,defaultValue:r??e.defaultValue??a.defaultValue,...l}}function Lt(e,t){return Array.isArray(e)?e.map(e=>It(e,t)):[]}var Rt=t({RecordDetailView:()=>Gt}),zt={id:`current-user`,name:`Demo User`},Bt=new Set([`created_at`,`created_by`,`updated_at`,`updated_by`]),Vt=new Set([`organization_id`,`tenant_id`,`is_deleted`,`deleted_at`]),Ht=[`description`,`notes`,`note`,`remark`,`remarks`,`comments`],Ut=new Set([`textarea`,`markdown`,`html`,`rich-text`,`json`,`code`]);function Wt(e,t){if(Ut.has(t?.type))return!0;let n=e.toLowerCase();return Ht.some(e=>n===e||n.endsWith(`_${e}`))}function Gt({dataSource:e,objects:t,onEdit:n,objectNameOverride:r,recordIdOverride:s,embedded:x}){let S=i(),C=S.appName,w=r??S.objectName,T=s??S.recordId,{showDebug:re}=Me(),{user:E}=l(),D=c(),O=a().state?.from,{t:k}=h(),{objectLabel:A,viewLabel:ae,sectionLabel:se,actionLabel:ce,actionConfirm:le,actionSuccess:ue,actionParamText:de,actionParamOptionLabel:fe,actionDescription:pe,fieldLabel:me,fieldOptionLabel:he}=ne(),{isFavorite:ge,toggleFavorite:_e,refreshLabel:ve}=De(),{addRecentItem:ye}=ke(),[be,xe]=(0,N.useState)(!0),[Se,we]=(0,N.useState)([]),[j,Te]=(0,N.useState)([]),[Ee,F]=(0,N.useState)(0),[Ve,I]=(0,N.useState)(null),[Ue,L]=(0,N.useState)({}),[R,We]=(0,N.useState)(null),[Ge,Ke]=(0,N.useState)(!1),[z,qe]=(0,N.useState)(),B=t.find(e=>e.name===w);He(x?void 0:z);let V=T,Je=gt(w,V),H=(0,N.useMemo)(()=>!w||!V?null:{id:`record:${w}:${V}`,label:z||V||``,href:`/apps/${C}/${w}/record/${V}`,type:`record`},[C,w,V,z]),Ye=H?ge(H.id):!1,Xe=(0,N.useCallback)(()=>{H&&_e(H)},[H,_e]),{page:U,slots:W}=v(w),Ze=(0,N.useMemo)(()=>{if(typeof window<`u`)try{let e=new URLSearchParams(window.location.search).get(`renderViaSchema`);if(e===`0`||e===`false`)return!1;if(e===`1`||e===`true`)return!0}catch{}return B?.detail?.renderViaSchema!==!1},[B]),Qe=(0,N.useMemo)(()=>U||!B||!Ze&&!W?null:Ie(B,W?{slots:W}:void 0),[Ze,U,W,B]),G=U||Qe,[K,$e]=(0,N.useState)(null),[et,q]=(0,N.useState)(`idle`);(0,N.useEffect)(()=>{let t=!1;if(!G||!V||!w||!e?.findOne){$e(null),q(`idle`);return}let n=_(B?.fields),r=n.length>0?{$expand:n}:void 0,i=()=>{q(`loading`),(r?e.findOne(w,V,r):e.findOne(w,V)).then(e=>{t||(e&&typeof e==`object`?($e(e),q(`loaded`)):($e(null),q(`missing`)))}).catch(()=>{t||($e(null),q(`missing`))})};i();let a=e=>{let t=e.detail||{};t.objectName!==w||String(t.recordId)!==String(V)||i()};return window.addEventListener(`objectui:record-changed`,a),()=>{t=!0,window.removeEventListener(`objectui:record-changed`,a)}},[G,w,V,e,B]),(0,N.useEffect)(()=>{if(!K||typeof K!=`object`||!B)return;let e=y(B,K);e&&e!==`Untitled`&&e!==z&&qe(e)},[K,B,z]),(0,N.useEffect)(()=>{if(!w||!V||!C||!z)return;let e=`record:${w}:${V}`;ye({id:e,label:z,href:`/apps/${C}/${w}/record/${V}`,type:`record`}),ve(e,z)},[C,w,V,z,ye,ve]);let[tt,nt]=(0,N.useState)({open:!1,message:``}),[rt,it]=(0,N.useState)({open:!1,params:[]}),[J,at]=(0,N.useState)({open:!1}),ot=(0,N.useCallback)((e,t)=>new Promise(n=>{at({open:!0,spec:e,data:t,resolve:n})}),[]),st=(0,N.useCallback)((e,t)=>new Promise(n=>{nt({open:!0,message:e,options:t,resolve:n})}),[]),ct=(0,N.useCallback)((e,n)=>new Promise(r=>{let i=Lt(e,{objectName:w||B?.name||``,objects:t||[],fieldLabel:me,fieldOptionLabel:he}),a=w||B?.name;it({open:!0,params:i.map(e=>({...e,label:de(a,n?.name,e.name,`label`,e.label)??e.label,placeholder:de(a,n?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:de(a,n?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(t=>({...t,label:fe(a,n?.name,e.name,t.value,t.label)})):e.options})),title:n?.label||n?.title,description:pe(a,n?.name,n?.description),resolve:r})}),[w,B,t,me,he,de,fe]),lt=g({dataSource:e,onUndo:()=>{F(e=>e+1),M.success(`Change undone`)}}),ut=(0,N.useCallback)((e,t)=>{if(t?.type===`error`){M.error(e);return}if(t?.undo){M.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{lt.undo()}}});return}M.success(e,{duration:t?.duration})},[lt]),dt=(0,N.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):D(e)},[D]),ft=(0,N.useCallback)(async t=>{try{let n=t.target||t.name,r={...t.params||{}};delete r._rowRecord,t.bodyExtra&&typeof t.bodyExtra==`object`&&Object.assign(r,t.bodyExtra);let i;switch(n){case`opportunity_change_stage`:await e.update(w,V,{stage:r.new_stage});break;case`opportunity_mark_won`:await e.update(w,V,{stage:`closed_won`});break;case`opportunity_mark_lost`:await e.update(w,V,{stage:`closed_lost`,loss_reason:r.loss_reason});break;default:if(Object.keys(r).length>0){if(t.undoable&&K&&w&&V){let e={};for(let t of Object.keys(r))e[t]=K[t]??null;i={id:`undo-${w}-${V}-${Date.now()}`,type:`update`,objectName:w,recordId:String(V),timestamp:Date.now(),description:t.label||`Undo ${w}`,undoData:e,redoData:{...r}}}await e.update(w,V,r)}break}let a=t.refreshAfter===!0;return(a||i)&&F(e=>e+1),{success:!0,reload:a,undo:i}}catch(e){return{success:!1,error:e.message}}},[e,w,V,K]),{modalHandler:pt,modalElement:ht}=Ae(e),Y=(0,N.useMemo)(()=>u(),[]),_t=(0,N.useCallback)(async e=>{let t=e.target||e.name;if(!t)return{success:!1,error:`No flow target provided for flow action`};try{let n=await Y(`/api/v1/automation/${encodeURIComponent(t)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:V,objectName:w,params:e.params??{}})}),r=await n.json().catch(()=>null);if(!n.ok||r&&r.success===!1)return{success:!1,error:r?.error||`Flow "${t}" failed (HTTP ${n.status})`};let i=r?.data??{};if(i.status===`paused`&&i.screen)return I({flowName:t,runId:i.runId,screen:i.screen}),{success:!0,silent:!0};let a=e.refreshAfter!==!1;return a&&F(e=>e+1),{success:!0,data:r?.data,reload:a}}catch(e){return{success:!1,error:e.message}}},[Y,V,w]),yt=(0,N.useRef)(new Set),Ct=(0,N.useCallback)(async e=>{let t=e.target||e.name;if(!t)return{success:!1,error:`No action target provided`};let n=e.params&&!Array.isArray(e.params)?e.params:{},r=`${t}:${V??``}`;if(yt.current.has(r))return{success:!1,error:`Action already in progress`};yt.current.add(r);let i=null;if(e.opensInNewTab)try{i=window.open(`about:blank`,`_blank`),i&&(i.document.write(`<!doctype html><meta charset="utf-8"><title>正在打开… Opening…</title><body style="margin:0;font-family:system-ui,sans-serif;display:flex;flex-direction:column;align-items:center;justify-content:center;height:100vh;gap:16px;color:#4b5563"><div style="width:28px;height:28px;border:3px solid #e5e7eb;border-top-color:#6366f1;border-radius:50%;animation:s .8s linear infinite"></div><div>正在为你打开环境…</div><style>@keyframes s{to{transform:rotate(360deg)}}</style></body>`),i.document.close())}catch{i=null}try{let r=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&r){if(V==null){if(i)try{i.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let t=`${window.location.origin}${r.replace(`{recordId}`,encodeURIComponent(String(V)))}`;if(i)try{i.location.href=t}catch{try{i.close()}catch{}window.location.href=t}else{let e=null;try{e=window.open(t,`_blank`)}catch{e=null}e||M(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(t,`_blank`)}catch{window.location.href=t}}},duration:1e4})}return e.refreshAfter===!0&&F(e=>e+1),{success:!0}}let a=e.objectName||w||`global`,o=await Y(`/api/v1/actions/${encodeURIComponent(a)}/${encodeURIComponent(t)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:V,params:n})}),s=await o.json().catch(()=>null),c=s?.data,l=c&&typeof c==`object`&&c.success===!1;if(!o.ok||s&&s.success===!1||l){let e=l&&c.error||s?.error||`Action "${t}" failed (HTTP ${o.status})`;if(i)try{i.close()}catch{}return M.error(e),{success:!1,error:e}}let u=e.refreshAfter!==!1;u&&F(e=>e+1);let d=s?.data;if(d&&typeof d==`object`&&typeof d.redirectUrl==`string`){let e=d.redirectUrl;if(i)try{i.location.href=e}catch{try{i.close()}catch{}window.location.href=e}else{let t=null;try{t=window.open(e,`_blank`)}catch{t=null}t||M(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(e,`_blank`)}catch{window.location.href=e}}},duration:1e4})}}else if(i)try{i.close()}catch{}return{success:!0,data:d,reload:u}}catch(e){if(i)try{i.close()}catch{}let t=e.message;return M.error(t),{success:!1,error:t}}finally{yt.current.delete(r)}},[Y,V,w]),X=Oe(w,V,E?.id),Tt=(0,N.useRef)(X);Tt.current=X;let Et=(0,N.useCallback)(async e=>{let t=e.target||e.name,n=e.params&&!Array.isArray(e.params)?e.params:{};try{if(t===`approve_request`)await Tt.current.approve({comment:n.comment});else if(t===`reject_request`)await Tt.current.reject({comment:n.comment});else return{success:!1,error:`Unknown approval target: ${t}`};return F(e=>e+1),{success:!0,reload:!0}}catch(e){return{success:!1,error:e?.message||String(e)}}},[]),Z=(0,N.useMemo)(()=>je(B,t),[B,t]);(0,N.useEffect)(()=>{if(G||!e||!V||Z.length===0)return;let t=!1;return Promise.all(Z.map(({childObject:t,referenceField:n})=>e.find(t,{$filter:{[n]:V}}).then(e=>({childObject:t,items:Array.isArray(e)?e:e?.data||[]})).catch(e=>(console.warn(`[RecordDetailView] Failed to fetch related ${t}:`,e),{childObject:t,items:[]})))).then(e=>{if(t)return;let n={};for(let{childObject:t,items:r}of e)n[t]=r;L(n)}),()=>{t=!0}},[e,V,Z,B,G]);let Dt=(0,N.useMemo)(()=>!B||B.name===`sys_audit_log`||B.enable?.trackHistory!==!0?!1:t.some(e=>e.name===`sys_audit_log`),[B,t]);(0,N.useEffect)(()=>{if(!e||!V||!B||!Dt){We(null);return}let t=!1;return Ke(!0),e.find(`sys_audit_log`,{$filter:{record_id:V,object_name:B.name},$orderby:{created_at:`desc`},$top:50,$select:[`id`,`created_at`,`action`,`user_id`,`old_value`,`new_value`]}).then(async n=>{if(t)return;let r=Array.isArray(n)?n:n?.data||[],i=Array.from(new Set(r.map(e=>e?.user_id).filter(e=>typeof e==`string`&&e.length>0))),a=new Map;if(i.length>0)try{let t=await e.find(`sys_user`,{$filter:{id:{$in:i}},$top:i.length,$select:[`id`,`name`,`email`,`image`]}),n=Array.isArray(t)?t:t?.data||[];a=new Map(n.map(e=>[e.id,{name:e.name||e.email||null,image:e.image||null}]))}catch(e){console.warn(`[RecordDetailView] Failed to resolve audit user names:`,e)}let o={};for(let[e,t]of Object.entries(B.fields||{}))t?.label&&(o[e]=t.label);let s=e=>{if(!e)return null;if(typeof e==`object`)return e;if(typeof e==`string`)try{return JSON.parse(e)}catch{return null}return null};We(r.map(e=>{let t=e?.user_id?a.get(e.user_id):void 0,n=s(e?.old_value)||{},r=s(e?.new_value)||{},i=new Set([...Object.keys(n),...Object.keys(r)]),c=Array.from(i).filter(e=>JSON.stringify(n[e])!==JSON.stringify(r[e])).map(e=>({field:e,label:o[e]||e,from:n[e],to:r[e]}));return{...e,user_name:t?.name??null,user_avatar:t?.image??null,changes:c.length>0?c:void 0}}))}).catch(e=>{t||(console.warn(`[RecordDetailView] Failed to fetch sys_audit_log:`,e),We([]))}).finally(()=>{t||Ke(!1)}),()=>{t=!0}},[e,V,B,Dt]),(0,N.useEffect)(()=>{if(!e)return;let t=!1,n=E?[{id:String(E.id),label:E.name||E.email||String(E.id),avatarUrl:E.image||void 0}]:[];return(async()=>{try{let r=await e.find(`sys_user`,{$top:50,$select:[`id`,`name`,`email`,`image`]});if(t)return;let i=(Array.isArray(r)?r:r?.data||[]).map(e=>({id:String(e.id),label:e.name||e.email||String(e.id),avatarUrl:e.image||void 0})).filter(e=>e.label),a=new Set(n.map(e=>e.id)),o=[...n,...i.filter(e=>!a.has(e.id))];Te(o.length>0?o:n)}catch{if(t)return;Te(n)}})(),()=>{t=!0}},[e,E?.id,E?.name,E?.email]);let Q=(0,N.useMemo)(()=>E?{id:E.id,name:E.name,avatar:E.image}:zt,[E?.id,E?.name,E?.image]);(0,N.useEffect)(()=>{if(!e||!w||!V)return;let t=`${w}:${V}`,n=e=>{if(!e)return;let t;if(typeof e==`string`)try{t=JSON.parse(e)}catch{return}else typeof e==`object`&&(t=e);if(t)return Object.entries(t).map(([e,t])=>({emoji:e,count:Array.isArray(t)?t.length:0,reacted:Array.isArray(t)&&t.includes(Q.id)}))};e.find(`sys_comment`,{$filter:{thread_id:t},$orderby:{created_at:`asc`}}).then(e=>{if(!e?.data?.length)return;let t=e.data.map(e=>({id:e.id,type:`comment`,actor:e.author_name??k(`detail.unknownUser`,{defaultValue:`Unknown`}),actorAvatarUrl:e.author_avatar_url??void 0,body:e.body??``,createdAt:e.created_at,updatedAt:e.updated_at,parentId:e.parent_id??void 0,reactions:n(e.reactions)}));we(e=>{let n=new Map;for(let r of[...e,...t])n.set(String(r.id),r);return Array.from(n.values()).sort((e,t)=>(e.createdAt?Date.parse(e.createdAt):0)-(t.createdAt?Date.parse(t.createdAt):0))})}).catch(()=>{});let r={created:`field_change`,updated:`field_change`,deleted:`field_change`,assigned:`field_change`,shared:`field_change`,system:`system`,completed:`task`,commented:void 0,mentioned:void 0,login:void 0,logout:void 0};e.find(`sys_activity`,{$filter:{object_name:w,record_id:V},$orderby:{timestamp:`asc`},$top:200}).then(e=>{if(!e?.data?.length)return;let t=[];for(let n of e.data){let e=r[n.type];if(!e)continue;let i=n.timestamp;(!i||i===`NOW()`||Number.isNaN(Date.parse(i)))&&(i=n.created_at),t.push({id:n.id,type:e,actor:n.actor_name??k(`detail.systemActor`,{defaultValue:`System`}),actorAvatarUrl:n.actor_avatar_url??void 0,body:n.summary??``,createdAt:i,sourceObject:n.source_object??void 0,sourceId:n.source_id??void 0})}t.length&&we(e=>{let n=new Map;for(let r of[...e,...t])n.set(String(r.id),r);return Array.from(n.values()).sort((e,t)=>(e.createdAt?Date.parse(e.createdAt):0)-(t.createdAt?Date.parse(t.createdAt):0))})}).catch(()=>{})},[e,w,V,Q]);let Ot=(0,N.useCallback)(async t=>{let n={id:crypto.randomUUID(),type:`comment`,actor:Q.name,actorAvatarUrl:`avatar`in Q?Q.avatar:void 0,body:t,createdAt:new Date().toISOString()};if(we(e=>[...e,n]),e){let r=`${w}:${V}`,i=Fe(t,j);e.create(`sys_comment`,{id:n.id,thread_id:r,author_id:Q.id,author_name:Q.name,author_avatar_url:`avatar`in Q?Q.avatar:void 0,body:t,mentions:JSON.stringify(i),created_at:n.createdAt}).catch(()=>{})}},[Q,e,w,V,j]),kt=(0,N.useCallback)(async(t,n)=>{let r={id:crypto.randomUUID(),type:`comment`,actor:Q.name,actorAvatarUrl:`avatar`in Q?Q.avatar:void 0,body:n,createdAt:new Date().toISOString(),parentId:t};if(we(e=>[...e,r].map(e=>e.id===t?{...e,replyCount:(e.replyCount??0)+1}:e)),e){let i=`${w}:${V}`,a=Fe(n,j);e.create(`sys_comment`,{id:r.id,thread_id:i,author_id:Q.id,author_name:Q.name,author_avatar_url:`avatar`in Q?Q.avatar:void 0,body:n,mentions:JSON.stringify(a),created_at:r.createdAt,parent_id:t}).catch(()=>{})}},[Q,e,w,V,j]),At=(0,N.useCallback)((t,n)=>{we(r=>r.map(r=>{if(r.id!==t)return r;let i=[...r.reactions??[]],a=i.findIndex(e=>e.emoji===n);if(a>=0){let e=i[a];e.reacted?e.count<=1?i.splice(a,1):i[a]={...e,count:e.count-1,reacted:!1}:i[a]={...e,count:e.count+1,reacted:!0}}else i.push({emoji:n,count:1,reacted:!0});let o={...r,reactions:i};if(e){let n=Q.id,r={};for(let e of i){let t=[];for(e.reacted&&t.push(n);t.length<e.count;)t.push(`__other__`);r[e.emoji]=t}e.update(`sys_comment`,String(t),{reactions:JSON.stringify(r)}).catch(()=>{})}return o}))},[Q.id,e]);(0,N.useEffect)(()=>{xe(!0),queueMicrotask(()=>xe(!1))},[w,T]);let $=(0,N.useMemo)(()=>{if(!B)return{type:`detail-view`};let n=B.primaryField||Object.keys(B.fields||{}).find(e=>e===`name`||e===`title`),r=B.detail?.sections??B.views?.form?.sections,i=r&&r.length>0?r.map(e=>({title:e.name?se(B.name,e.name,e.title||e.name):e.title,collapsible:e.collapsible,defaultCollapsed:e.defaultCollapsed,fields:(e.fields||[]).filter(e=>{let t=typeof e==`string`?e:e.name;return!B.fields?.[t]?.hidden}).map(e=>{let t=typeof e==`string`?e:e.name,n=B.fields[t];if(!n)return console.warn(`[RecordDetailView] Field "${t}" not found in ${B.name} definition`),{name:t,label:t};let r=n.reference_to||n.reference;return{name:t,label:n.label||t,type:n.type||`text`,...n.options&&{options:n.options},...r&&{reference_to:r},...n.reference_field&&{reference_field:n.reference_field},...n.currency&&{currency:n.currency}}})})):(()=>{let e=e=>{let t=B.fields[e],n=t.reference_to||t.reference;return{name:e,label:t.label||e,type:t.type||`text`,...t.options&&{options:t.options},...n&&{reference_to:n},...t.reference_field&&{reference_field:t.reference_field},...t.currency&&{currency:t.currency}}},t=t=>{let n=t.filter(e=>!Wt(e,B.fields[e])),r=t.filter(e=>Wt(e,B.fields[e]));return r.length===0||n.length===0?[{showBorder:!1,fields:t.map(e)}]:[{showBorder:!1,fields:n.map(e)},{name:`details`,title:se(B.name,`details`,k(`detail.sectionMoreDetails`,`More details`)),collapsible:!0,defaultCollapsed:!1,showBorder:!0,fields:r.map(e)}]},n=Le(B);return n?n.flatMap(e=>e.name?[{...e,title:se(B.name,e.name,e.title),showBorder:!0}]:t(e.fields.map(e=>e.name))):t(Object.keys(B.fields||{}).filter(e=>!Bt.has(e)&&!Vt.has(e)&&!B.fields[e]?.hidden))})(),a=(()=>{let e=new Set,t=(B.actions||[]).filter(t=>t.locations?.includes(`record_header`)?t.name?e.has(t.name)?!1:(e.add(t.name),!0):!0:!1).map(e=>({...e,label:ce(B.name,e.name,e.label||e.name),...e.confirmText!==void 0&&{confirmText:le(B.name,e.name,e.confirmText)},...e.successMessage!==void 0&&{successMessage:ue(B.name,e.name,e.successMessage)}}));if(X.available&&X.canDecide){let e={name:`comment`,label:k(`approvals.comment`,{defaultValue:`Comment (optional)`}),type:`text`,multiline:!0};t.push({name:`approve_request`,type:`approval`,target:`approve_request`,label:k(`approvals.approve`,{defaultValue:`Approve`}),icon:`check`,variant:`default`,locations:[`record_header`],refreshAfter:!0,collectParams:[e],successMessage:k(`approvals.approveSuccess`,{defaultValue:`Approved`})}),t.push({name:`reject_request`,type:`approval`,target:`reject_request`,label:k(`approvals.reject`,{defaultValue:`Reject`}),icon:`x`,variant:`destructive`,locations:[`record_header`],refreshAfter:!0,confirmText:k(`approvals.rejectConfirm`,{defaultValue:`Reject this approval request?`}),collectParams:[e],successMessage:k(`approvals.rejectSuccess`,{defaultValue:`Rejected`})})}return t})(),o=B.detail?.highlightFields??B.views?.detail?.highlightFields??[],s=(Array.isArray(o)?o:[]).map(e=>{let t=typeof e==`string`?e:e?.name;if(!t)return null;if(typeof e==`object`&&e.label)return e;let n=B.fields?.[t];return{name:t,label:n?.label||t,...n?.type?{type:n.type}:{}}}).filter(e=>!!e),c=B.detail?.sectionGroups??B.views?.detail?.sectionGroups??B.views?.form?.sectionGroups,l=C?`/apps/${C}`:``,u=Z.map(({childObject:n,childLabel:r,referenceField:i,title:a,columns:o})=>{let s=t.find(e=>e.name===n),c=V||``,u=a||(s?A({name:s.name,label:s.label||r}):r),d=()=>{let e=new URLSearchParams({[i]:c}).toString();return`${l}/${n}/new${e?`?${e}`:``}`},f=()=>{let e=new URLSearchParams({[`filter[${i}]`]:c}).toString();return`${l}/${n}${e?`?${e}`:``}`},p=e=>{let t=e?.id||e?._id;return t?`${l}/${n}/record/${encodeURIComponent(String(t))}/edit`:null},m=e=>{let t=e?.id||e?._id;return t?`${l}/${n}/record/${encodeURIComponent(String(t))}`:null},h=l?()=>D(d()):void 0,g=l?()=>D(f()):void 0,_=l?e=>{let t=m(e);t&&D(t)}:void 0,v=l?e=>{let t=p(e);t&&D(t)}:void 0,y=e&&c?async t=>{let r=t?.id||t?._id;if(r)try{await e.delete(n,r),M.success(k(`detail.deleteSuccess`,{defaultValue:`Deleted`})),L(e=>({...e,[n]:(e[n]||[]).filter(e=>(e.id||e._id)!==r)}))}catch(e){M.error(e?.message||k(`detail.deleteError`,{defaultValue:`Delete failed`}))}}:void 0;return{title:u,type:`table`,api:n,data:Ue[n]||[],referenceField:i,...Array.isArray(o)&&o.length>0?{columns:o}:{},icon:s?.icon,displayField:s?.displayNameField||(Array.isArray(s?.compactLayout)?s.compactLayout[0]:void 0),onNew:h,onViewAll:g,onRowClick:_,onRowEdit:v,onRowDelete:y}}),d=vt(B);return{type:`detail-view`,objectName:B.name,resourceId:V,showBack:!x,onBack:`history`,showEdit:d.edit,title:B.label,primaryField:n,sections:i,autoTabs:!0,autoDiscoverRelated:!0,...Dt&&{history:{entries:R??[],loading:Ge&&R===null}},...u.length>0&&{related:u},...s.length>0&&{highlightFields:s},...c&&c.length>0&&{sectionGroups:c},...a.length>0&&{actions:[{type:`action:bar`,location:`record_header`,actions:a}]}}},[B?.name,V,Ue,Ee,C,D,e,k,A,t,Dt,R,Ge,X.available,X.canDecide,X.pendingRequest,X.latestRequest,x]);if(be)return(0,P.jsx)(Be,{});if(!B)return(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,P.jsxs)(ee,{children:[(0,P.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,P.jsx)(Ce,{className:`h-6 w-6 text-muted-foreground`})}),(0,P.jsx)(oe,{children:k(`empty.objectNotFound`)}),(0,P.jsx)(ie,{children:k(`empty.objectNotFoundDescription`,{name:w})})]})});if(G&&et===`missing`)return(0,P.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,P.jsxs)(ee,{children:[(0,P.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,P.jsx)(Ce,{className:`h-6 w-6 text-muted-foreground`})}),(0,P.jsx)(oe,{children:k(`empty.recordNotFound`,{defaultValue:`Record not found`})}),(0,P.jsx)(ie,{children:k(`empty.recordNotFoundDescription`,{defaultValue:`The record you are looking for does not exist or may have been deleted.`})})]})});if(G){let r=G?.disableDiscussion===!0,i=bt(G),a=!r&&!i,s=(()=>{let e=$.actions;if(!Array.isArray(e))return[];let t=e.find(e=>Array.isArray(e?.actions))?.actions??e;return Array.isArray(t)?t:[]})(),c=(()=>{let t=vt(B),r=[];return t.edit&&(r.push({name:`sys_inline_edit`,label:k(`detail.editFieldsInline`,{defaultValue:`Edit fields`}),type:`script`,locations:[`record_header`],variant:`outline`,onClick:()=>{window.dispatchEvent(new CustomEvent(`objectui:record:inline-edit-toggle`,{detail:{recordId:V,objectName:w}}))}}),r.push({name:`sys_edit`,label:k(`detail.edit`,{defaultValue:`Edit`}),type:`script`,locations:[`record_header`],variant:`default`,onClick:()=>n({id:V})})),r.push({name:`sys_share`,label:k(`detail.share`,{defaultValue:`Share`}),type:`script`,locations:[`record_header`],variant:`outline`,onClick:async()=>{try{if(navigator.share){await navigator.share({title:document.title,url:window.location.href});return}}catch{return}try{await navigator.clipboard.writeText(window.location.href),M.success(k(`detail.linkCopied`,{defaultValue:`Link copied`}))}catch(e){M.error(k(`detail.linkCopyFailed`,{defaultValue:`Failed to copy link`})+(e?.message?`: ${e.message}`:``))}}}),t.delete&&r.push({name:`sys_delete`,label:k(`detail.delete`,{defaultValue:`Delete`}),type:`script`,locations:[`record_header`],variant:`destructive`,onClick:async()=>{let t=k(`detail.deleteConfirmation`,{defaultValue:`Are you sure you want to delete this record?`});if(window.confirm(t))try{await e.delete(w,V),M.success(k(`detail.deleted`,{defaultValue:`Record deleted`})),D(`${C?`/apps/${C}`:``}/${w}`,{replace:!0})}catch(e){M.error(e?.message||`Delete failed`)}}}),r})(),l=s.length>0?s:void 0,u=Array.isArray($.related)?$.related.filter(e=>e?.api&&e?.referenceField).map(e=>({title:e.title,objectName:e.api,relationshipField:e.referenceField,...Array.isArray(e.columns)?{columns:e.columns}:{},...typeof e.pageSize==`number`?{limit:e.pageSize}:{},...e.icon?{icon:e.icon}:{}})):void 0,h=$.history?{entries:$.history.entries??[],loading:!!$.history.loading,emptyText:$.history.emptyText}:void 0,g=U?G:Ie(B,{sections:$.sections,highlightFields:Array.isArray($.highlightFields)?$.highlightFields.map(e=>typeof e==`string`?e:e?.name).filter(e=>!!e):void 0,headerActions:l,related:u,history:h,showReferenceRail:B?.detail?.showReferenceRail===!0||void 0,hideReferenceRail:B?.detail?.hideReferenceRail===!0||void 0,hideRelatedTab:B?.detail?.hideRelatedTab===!0||void 0,relatedLayout:B?.detail?.relatedLayout===`tabs`?`tabs`:void 0,...W?{slots:W}:{}});return(0,P.jsxs)(`div`,{className:`h-full bg-background overflow-hidden flex flex-col relative`,children:[(0,P.jsxs)(`div`,{className:`absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2`,children:[Je.length>0&&(0,P.jsx)(mt,{users:Je,size:`sm`,maxVisible:3,showStatus:!0}),(0,P.jsx)(ze,{managedBy:B?.managedBy})]}),(0,P.jsx)(m,{objectName:w,recordId:V,data:K,objectSchema:B,dataSource:e,embedded:x,headerSystemActions:c,isFavorite:Ye,onToggleFavorite:H?Xe:void 0,children:(0,P.jsx)(b,{children:(0,P.jsx)(p,{items:Se,onAddComment:Ot,onAddReply:kt,onToggleReaction:At,mentionSuggestions:j,children:(0,P.jsxs)(f,{context:{record:K||{},objectName:w,user:Q},onConfirm:st,onToast:ut,onNavigate:dt,onParamCollection:ct,onResultDialog:ot,onModal:pt,handlers:{api:ft,flow:_t,script:Ct,approval:Et},children:[(0,P.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-row`,children:[(0,P.jsxs)(`div`,{className:`flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48`,children:[O?.pathname&&O?.label&&(0,P.jsxs)(o,{to:O.pathname,className:`inline-flex items-center gap-1 mb-3 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,P.jsx)(te,{className:`h-4 w-4`}),(0,P.jsx)(`span`,{children:O.label})]}),(0,P.jsx)(d,{schema:g}),a&&(0,P.jsx)(`div`,{className:`mt-6`,children:(0,P.jsx)(Re,{config:{position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:Se,onAddComment:Ot,onAddReply:kt,onToggleReaction:At,mentionSuggestions:j})})]}),(0,P.jsx)(Ne,{open:re,sections:[{title:`Page Schema`,data:g}]})]}),ht]})})})}),(0,P.jsx)(xt,{state:tt,onOpenChange:e=>{e||nt(e=>({...e,open:!1}))}}),(0,P.jsx)(St,{state:rt,onOpenChange:e=>{e||it(e=>({...e,open:!1}))}}),(0,P.jsx)(wt,{state:J,onAcknowledge:()=>{J.resolve?.(),at({open:!1})}}),(0,P.jsx)(Pt,{state:Ve,authFetch:Y,baseUrl:``,dataSource:e,objects:t,onClose:()=>I(null),onComplete:()=>{I(null),F(e=>e+1)}})]})}return(0,P.jsxs)(`div`,{className:`h-full bg-background overflow-hidden flex flex-col relative`,children:[(0,P.jsxs)(`div`,{className:`absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2`,children:[Je.length>0&&(0,P.jsx)(mt,{users:Je,size:`sm`,maxVisible:3,showStatus:!0}),(0,P.jsx)(ze,{managedBy:B?.managedBy})]}),(0,P.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-row`,children:[(0,P.jsx)(`div`,{className:`flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48`,children:(0,P.jsx)(`div`,{className:`mx-auto w-full max-w-[1400px]`,children:(0,P.jsxs)(f,{context:{record:{},objectName:w,user:Q},onConfirm:st,onToast:ut,onNavigate:dt,onParamCollection:ct,onResultDialog:ot,onModal:pt,handlers:{api:ft,flow:_t,script:Ct,approval:Et},children:[(0,P.jsx)(Pe,{schema:$,dataSource:e,objectLabel:A({name:B.name,label:B.label}),isFavorite:Ye,onToggleFavorite:H?Xe:void 0,onDataLoaded:e=>{if(!e||typeof e!=`object`)return;let t=y(B,e);t&&t!==z&&t!==`Untitled`&&qe(t)},onEdit:()=>{n({id:V})},discussionSlot:(0,P.jsx)(Re,{config:{position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:Se,onAddComment:Ot,onAddReply:kt,onToggleReaction:At})},Ee),ht]})})}),(0,P.jsx)(Ne,{open:re,sections:[{title:`View Schema`,data:$}]})]}),(0,P.jsx)(xt,{state:tt,onOpenChange:e=>{e||nt(e=>({...e,open:!1}))}}),(0,P.jsx)(St,{state:rt,onOpenChange:e=>{e||it(e=>({...e,open:!1}))}}),(0,P.jsx)(wt,{state:J,onAcknowledge:()=>{J.resolve?.(),at({open:!1})}}),(0,P.jsx)(Pt,{state:Ve,authFetch:Y,baseUrl:``,dataSource:e,objects:t,onClose:()=>I(null),onComplete:()=>{I(null),F(e=>e+1)}})]})}export{Ve as _,Mt as a,wt as c,vt as d,Y as f,J as g,at as h,Pt as i,St as l,ut as m,Rt as n,jt as o,mt as p,Lt as r,$ as s,Gt as t,xt as u,I as v};