@objectstack/console 10.2.0 → 11.0.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 (112) hide show
  1. package/dist/assets/{AdapterProvider-CJjaoZJR.js → AdapterProvider-BieqtbDy.js} +1 -1
  2. package/dist/assets/{AiPendingActionsPage-B4OLmiXS.js → AiPendingActionsPage-_rod9OeO.js} +1 -1
  3. package/dist/assets/ApiConsolePage-WCI3DIIi.js +1 -0
  4. package/dist/assets/{AppDocsIndex-ChEbT5sV.js → AppDocsIndex-0yBeTLFW.js} +1 -1
  5. package/dist/assets/AppManagementPage-jXBjId07.js +1 -0
  6. package/dist/assets/ApprovalsInboxPage-BYHBBA9y.js +1 -0
  7. package/dist/assets/{AuditLogPage-BtNmxWyG.js → AuditLogPage-CO0HOjCA.js} +1 -1
  8. package/dist/assets/{ComponentNavView-naLkSvjF.js → ComponentNavView-DmByVW8F.js} +1 -1
  9. package/dist/assets/ConsoleFloatingChatbot-C_BlXoV1.js +1 -0
  10. package/dist/assets/DashboardView-Cs-MC_5A.js +1 -0
  11. package/dist/assets/DashboardWidgetInspector-ce9fT5XA.js +1 -0
  12. package/dist/assets/{DeveloperHubPage-COHQrdbV.js → DeveloperHubPage-DN8UdQMr.js} +1 -1
  13. package/dist/assets/ExpressionProvider-CT3sX7xF.js +1 -0
  14. package/dist/assets/FlowRunsPage-DPj0zPLk.js +1 -0
  15. package/dist/assets/{IntegrationsPage-Bu6X6rLQ.js → IntegrationsPage-CqLzZMOK.js} +2 -2
  16. package/dist/assets/{InterfaceListPage-Cfv6Lkis.js → InterfaceListPage-GcApvEz0.js} +1 -1
  17. package/dist/assets/{ManagedByBadge-DDil8sjK.js → ManagedByBadge-5eJy46Si.js} +1 -1
  18. package/dist/assets/{MarketplaceAccessDenied-C3bv4Vmg.js → MarketplaceAccessDenied-BGBYYv_M.js} +1 -1
  19. package/dist/assets/{MarketplaceInstalledPage-C-saIRJu.js → MarketplaceInstalledPage-Fa8EY_5o.js} +1 -1
  20. package/dist/assets/{MarketplacePackagePage-CcpJSBrF.js → MarketplacePackagePage-DC6zA893.js} +2 -2
  21. package/dist/assets/MarketplacePage-nv-oKrlO.js +1 -0
  22. package/dist/assets/{MetadataInspector-D9KL7Kgi.js → MetadataInspector-XbWYccBm.js} +1 -1
  23. package/dist/assets/{MetadataProvider-BO_KcC86.js → MetadataProvider-fKK6GbWD.js} +1 -1
  24. package/dist/assets/PageView-C9b2DYFF.js +1 -0
  25. package/dist/assets/ProfilePage-D7Ie0WN7.js +1 -0
  26. package/dist/assets/PublicFormsPage-BaKsA3Eo.js +1 -0
  27. package/dist/assets/RecordDetailView-CfCIFeA9.js +9 -0
  28. package/dist/assets/{RecordFormPage-BYeWa90w.js → RecordFormPage-Bkn_bUyo.js} +1 -1
  29. package/dist/assets/ReportDefaultInspector-CoxrLLKh.js +11 -0
  30. package/dist/assets/{ReportView-uPqsauzE.js → ReportView-Gq01PZlc.js} +1 -1
  31. package/dist/assets/{SearchResultsPage-DraOSIqg.js → SearchResultsPage-C3SyFv3R.js} +1 -1
  32. package/dist/assets/{SettingsHub-CzOLpvoR.js → SettingsHub-BLCpGzj-.js} +1 -1
  33. package/dist/assets/{SettingsView-BJnPeWpq.js → SettingsView-Cd6iNy3t.js} +1 -1
  34. package/dist/assets/{SystemHubPage-CeKubn-w.js → SystemHubPage-DBdBlyat.js} +1 -1
  35. package/dist/assets/{data-adapter-QvY0S7Jg.js → data-adapter-C8ELgvKP.js} +1 -1
  36. package/dist/assets/exceljs.min-HZhgX9lC.js +28 -0
  37. package/dist/assets/framework-CQlIjbCT.js +35 -0
  38. package/dist/assets/{highlighted-body-OFNGDK62-DH1qH6jn.js → highlighted-body-OFNGDK62-02fX_5a1.js} +1 -1
  39. package/dist/assets/index-Vh0-yrfs.js +2 -0
  40. package/dist/assets/index-_u4ypVlX.css +2 -0
  41. package/dist/assets/infrastructure-BtLHjSlJ.js +3 -0
  42. package/dist/assets/{marketplaceApi-DL8PegzV.js → marketplaceApi-D36MnuCE.js} +1 -1
  43. package/dist/assets/mermaid-GHXKKRXX-BeAYGylq.js +1 -0
  44. package/dist/assets/metadata-admin-mBijR3yo.js +22 -0
  45. package/dist/assets/plugin-calendar-BdTHA4Ee.js +1 -0
  46. package/dist/assets/plugin-charts-DoMMZZk8.js +7 -0
  47. package/dist/assets/plugin-chatbot-CumNGrh8.js +120 -0
  48. package/dist/assets/plugin-dashboard-Bl7wuG9f.js +6 -0
  49. package/dist/assets/plugin-form-hyYQoCHc.js +1 -0
  50. package/dist/assets/plugin-gantt-BsnXplf2.js +93 -0
  51. package/dist/assets/plugin-grid-DvI8i3CO.js +6 -0
  52. package/dist/assets/plugin-kanban-DmKa19Zc.js +1 -0
  53. package/dist/assets/plugin-map-CIN-oBC5.js +1 -0
  54. package/dist/assets/{plugin-markdown-Fz2pgiZT.js → plugin-markdown-DU8O5B7L.js} +1 -1
  55. package/dist/assets/plugin-report-JWTVyA2R.js +59 -0
  56. package/dist/assets/{plugin-timeline-BEk5SlxQ.js → plugin-timeline-BMM7P_hx.js} +1 -1
  57. package/dist/assets/plugin-tree-CErRKxCG.js +1 -0
  58. package/dist/assets/plugin-view-BMfFD77p.js +1 -0
  59. package/dist/assets/plugins-views-iYrs182B.js +4 -0
  60. package/dist/assets/recordFormNavigation-CXt3jCB4.js +1 -0
  61. package/dist/assets/{skeletons-DZWz9Ill.js → skeletons-k9g6qZSy.js} +1 -1
  62. package/dist/assets/{src-CpvBTq6C.js → src-BcFufHSl.js} +1 -1
  63. package/dist/assets/src-Dnw5qGGv.js +2 -0
  64. package/dist/assets/types-DXihP4sI.js +1 -0
  65. package/dist/assets/ui-components-CgiD1ql5.js +42 -0
  66. package/dist/assets/ui-layout-C9ykUXmg.js +1 -0
  67. package/dist/assets/useActionModal-DJG5Babl.js +1 -0
  68. package/dist/assets/{useOpenRecordList-CwVRoKH4.js → useOpenRecordList-D-g511Jw.js} +1 -1
  69. package/dist/assets/{useReconcileOnError-BXVpquqp.js → useReconcileOnError-QYVPx52o.js} +1 -1
  70. package/dist/assets/utils-6HhVlFkm.js +1 -0
  71. package/dist/index.html +4 -4
  72. package/package.json +1 -1
  73. package/LICENSE.apache +0 -202
  74. package/dist/assets/ApiConsolePage-D9A9ewr3.js +0 -1
  75. package/dist/assets/AppManagementPage-DwyKF7UE.js +0 -1
  76. package/dist/assets/ApprovalsInboxPage-Ca5Bb0JN.js +0 -1
  77. package/dist/assets/ConsoleFloatingChatbot-1MfhDZaK.js +0 -1
  78. package/dist/assets/DashboardView-Ccnc4ERO.js +0 -1
  79. package/dist/assets/DashboardWidgetInspector-DQvlAqdm.js +0 -1
  80. package/dist/assets/ExpressionProvider-C2XzKImE.js +0 -1
  81. package/dist/assets/FlowRunsPage-DIO45X3A.js +0 -1
  82. package/dist/assets/MarketplacePage-B0zIXkwO.js +0 -1
  83. package/dist/assets/PageView-gzbH9RTq.js +0 -1
  84. package/dist/assets/ProfilePage-BXz0C-TJ.js +0 -1
  85. package/dist/assets/PublicFormsPage-D5-EASU8.js +0 -1
  86. package/dist/assets/RecordDetailView-ANMXqsUj.js +0 -9
  87. package/dist/assets/ReportDefaultInspector-B6X1lhzs.js +0 -7
  88. package/dist/assets/framework-CsYa1Kaj.js +0 -34
  89. package/dist/assets/index-Bx77jcFN.js +0 -4
  90. package/dist/assets/index-CYLGNLiD.css +0 -2
  91. package/dist/assets/infrastructure-BsIvKvpW.js +0 -3
  92. package/dist/assets/mermaid-GHXKKRXX-DlOIGBXr.js +0 -1
  93. package/dist/assets/metadata-admin--twLAcNF.js +0 -21
  94. package/dist/assets/plugin-calendar-HZM7PnuZ.js +0 -1
  95. package/dist/assets/plugin-charts-CHVu5fbZ.js +0 -7
  96. package/dist/assets/plugin-chatbot-B25XBELF.js +0 -120
  97. package/dist/assets/plugin-dashboard-C8TbFk_D.js +0 -6
  98. package/dist/assets/plugin-form-sm04IEZv.js +0 -1
  99. package/dist/assets/plugin-gantt-BAbv_iPP.js +0 -93
  100. package/dist/assets/plugin-grid-pjPmzTDb.js +0 -6
  101. package/dist/assets/plugin-kanban-CFOumo0N.js +0 -1
  102. package/dist/assets/plugin-map-DD4Y0TfP.js +0 -1
  103. package/dist/assets/plugin-report-DidhEKAB.js +0 -59
  104. package/dist/assets/plugin-tree-uFJca_YQ.js +0 -1
  105. package/dist/assets/plugin-view-CDxJidrj.js +0 -1
  106. package/dist/assets/plugins-views-BpKTWXXa.js +0 -4
  107. package/dist/assets/src-ZyouQodC.js +0 -2
  108. package/dist/assets/types-IRCvjK2K.js +0 -1
  109. package/dist/assets/ui-components-DXl7VfQF.js +0 -42
  110. package/dist/assets/ui-layout-BwKCXo1Z.js +0 -1
  111. package/dist/assets/useActionModal-CYfSmVlP.js +0 -1
  112. package/dist/assets/utils-29quoGQV.js +0 -1
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,r,t as i}from"./vendor-react-ClIa1CJA.js";import{d as a,f as ee}from"./infrastructure-BsIvKvpW.js";import{i as te}from"./framework-CsYa1Kaj.js";import{As as ne,Bo as re,Bt as ie,Ci as ae,Cr as oe,Ft as se,H as ce,Ht as o,Ii as le,It as ue,Jn as de,Lr as fe,Lt as pe,Mr as me,Mt as s,Ns as he,Pt as ge,R as _e,Rt as ve,Si as ye,Ut as be,Vt as xe,Wt as Se,Yn as Ce,Zo as we,ar as Te,at as Ee,cr as c,cs as De,ct as l,dc as Oe,dr as u,dt as ke,er as Ae,es as je,fr as d,gr as f,gs as Me,hr as Ne,ir as Pe,it as Fe,js as Ie,li as Le,lr as p,lt as m,mr as h,nc as Re,nn as ze,nt as Be,on as Ve,ot as He,pr as g,ps as Ue,qn as We,rt as Ge,sr as _,st as Ke,tt as qe,ur as v,ut as Je,vc as y,ws as Ye,xs as Xe,z as Ze,zt as Qe}from"./ui-components-DXl7VfQF.js";import{r as b}from"./vendor-ui-utils-C92Fl7BT.js";var x=e(t(),1),$e=`${``.replace(/\/$/,``)}/api/v1`;async function S(e,t){let n=await fetch(`${$e}${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 C={listProcesses(e={}){let t=new URLSearchParams;e.object&&t.set(`object`,e.object),e.activeOnly&&t.set(`activeOnly`,`true`);let n=t.toString();return S(`/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 S(`/approvals/requests${r?`?${r}`:``}`)},async getRequest(e){return{data:await S(`/approvals/requests/${encodeURIComponent(e)}`)}},listActions(e){return S(`/approvals/requests/${encodeURIComponent(e)}/actions`)},async approve(e,t){let n=await S(`/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 S(`/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 S(`/approvals/requests/${encodeURIComponent(e)}/recall`,{method:`POST`,body:JSON.stringify(t)})).request,finalized:!0}},async reassign(e,t){return{data:(await S(`/approvals/requests/${encodeURIComponent(e)}/reassign`,{method:`POST`,body:JSON.stringify(t)})).request}},async remind(e,t={}){let n=await S(`/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 S(`/approvals/requests/${encodeURIComponent(e)}/request-info`,{method:`POST`,body:JSON.stringify(t)})).request}},async sendBack(e,t){let n=await S(`/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 S(`/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 S(`/approvals/requests/${encodeURIComponent(e)}/comment`,{method:`POST`,body:JSON.stringify(t)})).request}},async submit(e){return S(`/approvals/requests`,{method:`POST`,body:JSON.stringify(e)})}};function et(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 w=i(),tt=50,nt={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 rt(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function T(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 E(e){return e&&String(e).replace(/^flow:/,``).trim().split(/[_\-\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)||`—`}function it(e){return e.process_label||E(e.process_name)}function at(e){return e.step_label?e.step_label:e.current_step?E(e.current_step):null}function ot(e){return e.submitter_name||T(e.submitter_id)}function st(e,t){return t.pending_approver_names?.[e]||T(e)}function ct(e){return e.object_label||e.object_name}function D(e){return e.submitted_at||e.created_at||void 0}function O(e){let t=D(e);if(!t)return null;let n=Date.parse(t);return Number.isNaN(n)?null:(Date.now()-n)/36e5}function lt(e){if(e.status!==`pending`)return`text-muted-foreground`;let t=O(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 ut(e){let t=Math.max(1,Math.round(Math.abs(e)/36e5));return t<48?`${t}h`:`${Math.round(t/24)}d`}var k=new Set([`id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`organization_id`]);function A(e){return e.split(`_`).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(` `)}function j(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 dt=/^[A-Za-z0-9_-]{15,}$/;function ft(e,t,n=6){if(!e||typeof e!=`object`||Array.isArray(e))return[];let r=[];for(let[i,a]of Object.entries(e)){if(k.has(i)||a==null||typeof a==`object`||String(a).trim()===``)continue;let e=t?.[i];if(!(!e&&typeof a==`string`&&dt.test(a.trim())&&!/^\d+$/.test(a.trim()))&&(r.push([A(i),e??j(i,a)]),r.length>=n))break}return r}function pt(){let{t:e,language:t}=te(),{user:i}=ee(),$e=a(),{appName:S}=n(),E=(0,x.useMemo)(()=>et(i),[i]),O=(0,x.useCallback)((t,n,r)=>String(e(`approvalsInbox.${t}`,{defaultValue:n,...r})),[e]),k=(0,x.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 O(`justNow`,`just now`);let i=Math.round(r/60);if(i<60)return O(`minutesAgo`,`{{count}}m ago`,{count:i});let a=Math.round(i/60);if(a<24)return O(`hoursAgo`,`{{count}}h ago`,{count:a});let ee=Math.round(a/24);if(ee<30)return O(`daysAgo`,`{{count}}d ago`,{count:ee});try{return new Date(e).toLocaleDateString(t)}catch{return e}},[O,t]),A=(0,x.useCallback)(e=>{switch(e){case`pending`:return O(`statusPending`,`Pending`);case`approved`:return O(`statusApproved`,`Approved`);case`rejected`:return O(`statusRejected`,`Rejected`);case`recalled`:return O(`statusRecalled`,`Recalled`);case`returned`:return O(`statusReturned`,`Returned for revision`);default:return e}},[O]),j=(0,x.useCallback)((e,t)=>{let n=e?.code??``,r=e?.status??0;return n===`NOT_IMPLEMENTED`||r===501?O(`recallUnavailable`,`Recall is not available on this deployment.`):n===`THROTTLED`||r===429?O(`remindThrottled`,`A reminder was sent recently — try again later.`):r===404?O(`requestGone`,`This request no longer exists. Refresh the list.`):n===`FORBIDDEN`||r===403?O(`notAllowed`,`You are not allowed to perform this action.`):n===`INVALID_STATE`||r===409?O(`alreadyDecided`,`This request was already decided. Refresh the list.`):e?.message||t},[O]);function dt({status:e}){return(0,w.jsx)(Ae,{variant:`outline`,className:y(`font-medium`,nt[e]??``),children:A(e)})}let pt=(0,x.useCallback)(e=>`/apps/${S||`setup`}/${encodeURIComponent(e.object_name)}/record/${encodeURIComponent(e.record_id)}`,[S]),[M,mt]=(0,x.useState)(`pending`),[N,ht]=(0,x.useState)([]),[gt,_t]=(0,x.useState)(!1),[vt,yt]=(0,x.useState)(!1),[bt,xt]=(0,x.useState)(null),[St,Ct]=(0,x.useState)(null),[wt,Tt]=(0,x.useState)(0),[P,Et]=(0,x.useState)(null),[F,Dt]=(0,x.useState)(null),[Ot,kt]=(0,x.useState)([]),[At,jt]=(0,x.useState)(!1),[I,L]=(0,x.useState)(``),[R,Mt]=(0,x.useState)(``),[z,Nt]=(0,x.useState)(null),[B,Pt]=(0,x.useState)(``),[Ft,It]=(0,x.useState)(``),[Lt,Rt]=(0,x.useState)(`all`),[zt,Bt]=(0,x.useState)(`all`),[V,Vt]=(0,x.useState)(`all`),[H,Ht]=(0,x.useState)(new Set),[Ut,Wt]=(0,x.useState)(!1),[U,Gt]=(0,x.useState)(null),[Kt,qt]=(0,x.useState)(null),[Jt,Yt]=(0,x.useState)(!1),[Xt,Zt]=(0,x.useState)(``),[Qt,$t]=(0,x.useState)(!1),[en,tn]=(0,x.useState)(``),[nn,rn]=(0,x.useState)(!1),[an,on]=(0,x.useState)(``),[sn,cn]=(0,x.useState)(!1),[ln,un]=(0,x.useState)(``),[W,G]=(0,x.useState)(!1),[dn,fn]=(0,x.useState)([]),[pn,mn]=(0,x.useState)(-1);(0,x.useEffect)(()=>{if(M===`pending`)return;let e=window.setTimeout(()=>It(B),350);return()=>window.clearTimeout(e)},[B,M]);let K=(0,x.useCallback)(async()=>{_t(!0),Ct(null);try{let e=[];if(M===`pending`)e=E.length?(await C.listRequests({status:`pending`,approverId:E})).data:[],Tt(e.length),xt(null);else{let t={q:Ft||void 0,status:V===`all`?void 0:V,limit:tt,offset:0};if(M===`submitted`){let n=i?.id;if(n){let r=await C.listRequests({submitterId:n,...t});e=r.data,xt(r.total??r.data.length)}else e=[],xt(0)}else{let n=await C.listRequests(t);e=n.data,xt(n.total??n.data.length)}E.length&&C.listRequests({status:`pending`,approverId:E}).then(e=>Tt(e.data.length)).catch(()=>{})}e.sort((e,t)=>(D(t)||``).localeCompare(D(e)||``)),ht(e)}catch(e){Ct(e?.message||String(e)),ht([])}finally{_t(!1)}},[M,E,i?.id,Ft,V]);(0,x.useEffect)(()=>{K()},[K]);let hn=(0,x.useCallback)(async()=>{if(!(M===`pending`||vt)){yt(!0);try{let e=await C.listRequests({submitterId:M===`submitted`?i?.id??void 0:void 0,q:Ft||void 0,status:V===`all`?void 0:V,limit:tt,offset:N.length});ht(t=>{let n=new Set(t.map(e=>e.id));return[...t,...e.data.filter(e=>!n.has(e.id))]}),e.total!=null&&xt(e.total)}catch(e){b.error(j(e,O(`loadFailed`,`Failed to load request`)))}finally{yt(!1)}}},[M,vt,i?.id,Ft,V,N.length,j,O]),q=(0,x.useCallback)(async e=>{Et(e),jt(!0),L(``),Mt(``);try{let[t,n]=await Promise.all([C.getRequest(e),C.listActions(e)]);Dt(t.data),kt(n.data)}catch(e){b.error(j(e,O(`loadFailed`,`Failed to load request`))),Dt(null),kt([])}finally{jt(!1)}},[j,O]),gn=()=>{Et(null),Dt(null),kt([]),L(``),Mt(``)},J=(0,x.useCallback)(e=>{if(R.trim())return R.trim();if(!e)return i?.id||``;let t=new Set(e.pending_approvers||[]);for(let e of E)if(t.has(e))return e;return i?.id||``},[R,E,i?.id]),Y=(0,x.useCallback)(()=>{E.length&&C.listRequests({status:`pending`,approverId:E}).then(e=>Tt(e.data.length)).catch(()=>{})},[E]),_n=(0,x.useCallback)(async e=>{if(!F)return;let t=e===`recall`&&i?.id||J(F);if(!t){b.error(O(`noActor`,`Cannot determine the acting identity`));return}Nt(e);try{let n={actor_id:t,comment:I.trim()||void 0},r=await(e===`approve`?C.approve:e===`reject`?C.reject:C.recall)(F.id,n);if(b.success(e===`approve`?r.finalized?O(`approvedFinal`,`Approved`):O(`approvedWaiting`,`Approved — waiting on the remaining approvers`):e===`reject`?O(`rejectedToast`,`Rejected`):O(`recalledToast`,`Request recalled`)),L(``),e!==`recall`&&M===`pending`){let e=Rn.current,t=e.findIndex(e=>e.id===F.id),n=e[t+1]??e[t-1];K(),n&&n.id!==F.id?q(n.id):gn();return}let[i,a]=await Promise.all([C.getRequest(F.id),C.listActions(F.id)]);Dt(i.data),kt(a.data),K()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{Nt(null)}},[F,J,I,K,i?.id,j,O,M,q]),X=(0,x.useCallback)(async e=>{let[t,n]=await Promise.all([C.getRequest(e),C.listActions(e)]);Dt(t.data),kt(n.data),K()},[K]),vn=(0,x.useCallback)(async()=>{if(!(!F||!Xt.trim())){G(!0);try{await C.reassign(F.id,{actor_id:J(F),to:Xt.trim(),comment:I.trim()||void 0}),b.success(O(`reassignSuccess`,`Handed to {{to}}`,{to:Xt.trim()})),Yt(!1),Zt(``),L(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,Xt,I,J,X,Y,j,O]),yn=(0,x.useCallback)(async()=>{if(F){G(!0);try{let e=await C.remind(F.id,{actor_id:i?.id});b.success(O(`remindSuccess`,`Reminder sent to {{count}} approver(s)`,{count:e.notified})),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,i?.id,X,j,O]),bn=(0,x.useCallback)(async()=>{if(!(!F||!en.trim())){G(!0);try{await C.requestInfo(F.id,{actor_id:J(F),comment:en.trim()}),b.success(O(`requestInfoSent`,`Sent back to the requester for more information`)),$t(!1),tn(``),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,en,J,X,j,O]),xn=(0,x.useCallback)(async()=>{if(F){G(!0);try{let e=await C.sendBack(F.id,{actor_id:J(F),comment:an.trim()||void 0});b.success(e.autoRejected?O(`sendBackAutoRejected`,`Revision limit reached — the request was auto-rejected`):O(`sendBackSuccess`,`Sent back for revision — the requester can now edit and resubmit`)),rn(!1),on(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,an,J,X,Y,j,O]),Sn=(0,x.useCallback)(async()=>{if(F){cn(!0);try{await C.resubmit(F.id,{actor_id:i?.id,comment:I.trim()||void 0}),b.success(O(`resubmitSuccess`,`Resubmitted — a new approval round has opened`)),L(``),await X(F.id),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{cn(!1)}}},[F,I,i?.id,X,Y,j,O]),Cn=(0,x.useCallback)(async()=>{if(!(!F||!ln.trim())){G(!0);try{await C.comment(F.id,{actor_id:i?.id,comment:ln.trim()}),un(``),await X(F.id)}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{G(!1)}}},[F,ln,i?.id,X,j,O]),wn=(0,x.useCallback)(async()=>{if(!dn.length)try{let e=``.replace(/\/$/,``);fn(((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{}},[dn.length,i?.id]),Tn=(0,x.useMemo)(()=>{if(!F||F.status!==`pending`)return!1;let e=new Set(F.pending_approvers||[]);return E.some(t=>e.has(t))||R.trim().length>0},[F,E,R]),En=(0,x.useMemo)(()=>!F||F.status!==`pending`?!1:F.submitter_id===i?.id||R.trim().length>0,[F,i?.id,R]),Dn=(0,x.useMemo)(()=>!F||F.status!==`returned`?!1:F.submitter_id===i?.id||R.trim().length>0,[F,i?.id,R]),On=(0,x.useMemo)(()=>{let e=new Set;for(let t of N)e.add(it(t));return Array.from(e).sort()},[N]),kn=(0,x.useMemo)(()=>{let e=new Set;for(let t of N)t.object_name&&e.add(t.object_name);return Array.from(e).sort()},[N]),Z=(0,x.useMemo)(()=>{let e=B.trim().toLowerCase();return N.filter(t=>Lt!==`all`&&it(t)!==Lt||zt!==`all`&&t.object_name!==zt||V!==`all`&&t.status!==V?!1:M!==`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))},[N,B,Lt,zt,V,M]),An=(0,x.useMemo)(()=>P?Z.findIndex(e=>e.id===P):-1,[Z,P]);(0,x.useEffect)(()=>{if(H.size===0)return;let e=new Set(Z.map(e=>e.id)),t=!1,n=new Set;for(let r of H)e.has(r)?n.add(r):t=!0;t&&Ht(n)},[Z,H]),(0,x.useEffect)(()=>{pn>=Z.length&&mn(Z.length-1)},[Z.length,pn]);let Q=(0,x.useCallback)(e=>{if(e.status!==`pending`)return!1;let t=new Set(E);return(e.pending_approvers||[]).some(e=>t.has(e))},[E]),$=(0,x.useMemo)(()=>Z.filter(e=>H.has(e.id)&&Q(e)),[Z,H,Q]),jn=Z.filter(e=>e.status===`pending`),Mn=jn.length>0&&jn.every(e=>H.has(e.id)),Nn=(0,x.useCallback)(()=>{Ht(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,x.useCallback)(e=>{Ht(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Fn=(0,x.useCallback)(async e=>{let t=$;if(t.length===0)return;Wt(!0);let n=0,r=[];for(let a of t){let t=new Set(a.pending_approvers||[]),ee=E.find(e=>t.has(e))||i?.id||``;try{await(e===`approve`?C.approve:C.reject)(a.id,{actor_id:ee}),n++}catch{r.push(a.record_title||T(a.record_id))}}if(Wt(!1),Ht(new Set),r.length===0)b.success(e===`approve`?O(`bulkApproved`,`Approved {{count}} requests`,{count:n}):O(`bulkRejected`,`Rejected {{count}} requests`,{count:n}));else{let e=r.slice(0,3).join(`, `);b.error(O(`bulkPartial`,`{{ok}} succeeded, {{fail}} failed: {{which}}`,{ok:n,fail:r.length,which:e+(r.length>3?`…`:``)}))}K(),Y()},[$,E,i?.id,K,Y,O]),In=(0,x.useCallback)(async e=>{if(!Q(e)||Kt)return;let t=new Set(e.pending_approvers||[]),n=E.find(e=>t.has(e))||i?.id||``;qt(e.id);try{let t=await C.approve(e.id,{actor_id:n});b.success(t.finalized?O(`inlineApproved`,`Approved "{{title}}"`,{title:e.record_title||T(e.record_id)}):O(`approvedWaiting`,`Approved — waiting on the remaining approvers`)),K(),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{qt(null)}},[Q,Kt,E,i?.id,K,Y,j,O]),Ln=(0,x.useCallback)(async()=>{let e=U;if(!e)return;let t=new Set(e.pending_approvers||[]),n=E.find(e=>t.has(e))||i?.id||``;qt(e.id),Gt(null);try{await C.reject(e.id,{actor_id:n}),b.success(O(`inlineRejected`,`Rejected "{{title}}"`,{title:e.record_title||T(e.record_id)})),K(),Y()}catch(e){b.error(j(e,O(`actionFailed`,`Action failed`)))}finally{qt(null)}},[U,E,i?.id,K,Y,j,O]),Rn=(0,x.useRef)(Z);Rn.current=Z;let zn=(0,x.useRef)(pn);zn.current=pn,(0,x.useEffect)(()=>{let e=e=>{if(P||U)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(),mn(Math.min(i+1,r.length-1))):e.key===`k`||e.key===`ArrowUp`?(e.preventDefault(),mn(Math.max(i-1,0))):e.key===`Enter`&&i>=0&&r[i]?(e.preventDefault(),q(r[i].id)):(e.key===`x`||e.key===` `)&&i>=0&&r[i]&&M===`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(),Gt(r[i]))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P,U,M,q,Pn,In,Q]),(0,x.useEffect)(()=>{if(!P)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===P);if(i<0)return;let a=e.key===`ArrowLeft`?r[i-1]:r[i+1];a&&(e.preventDefault(),q(a.id))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[P,q]);let Bn=!!B||Lt!==`all`||zt!==`all`||V!==`all`,Vn=e=>{mt(e),Vt(`all`),Rt(`all`),Bt(`all`),Pt(``),mn(-1)};function Hn({r:e}){return(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`font-medium truncate`,children:it(e)}),(0,w.jsxs)(`div`,{className:`text-xs text-muted-foreground truncate`,children:[at(e)||`—`,(e.round??1)>1&&(0,w.jsx)(`span`,{className:`ml-1.5 text-violet-600 dark:text-violet-400`,children:O(`roundChip`,`Round {{n}}`,{n:e.round})})]})]})}function Un({r:e}){return(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(r,{to:pt(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,w.jsx)(`span`,{className:`truncate`,children:e.record_title||T(e.record_id)}),(0,w.jsx)(re,{className:`h-3 w-3 shrink-0 text-muted-foreground`})]}),(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground truncate`,children:ct(e)})]})}function Wn({r:e}){if(!Q(e))return null;let t=Kt===e.id;return(0,w.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,w.jsx)(f,{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":O(`approve`,`Approve`),children:(0,w.jsx)(Xe,{className:`h-4 w-4`})}),(0,w.jsx)(f,{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:()=>Gt(e),"aria-label":O(`reject`,`Reject`),children:(0,w.jsx)(Ue,{className:`h-4 w-4`})})]})}return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-6xl`,children:[(0,w.jsxs)(`header`,{className:`flex flex-col sm:flex-row sm:items-center sm:justify-between gap-2`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsxs)(`h1`,{className:`text-2xl font-semibold flex items-center gap-2`,children:[(0,w.jsx)(Le,{className:`h-6 w-6`}),O(`title`,`Approvals Inbox`)]}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:O(`subtitle`,`Review and act on approval requests.`)})]}),(0,w.jsxs)(f,{variant:`outline`,size:`sm`,onClick:K,disabled:gt,className:`self-start sm:self-auto`,children:[(0,w.jsx)(le,{className:`h-4 w-4 mr-2 ${gt?`animate-spin`:``}`}),O(`refresh`,`Refresh`)]})]}),St&&(0,w.jsxs)(Pe,{variant:`destructive`,children:[(0,w.jsx)(Ye,{className:`h-4 w-4`}),(0,w.jsx)(Te,{children:St})]}),(0,w.jsxs)(Be,{value:M,onValueChange:Vn,children:[(0,w.jsxs)(Fe,{children:[(0,w.jsxs)(Ee,{value:`pending`,children:[O(`tabMyPending`,`My Pending`),wt>0&&(0,w.jsx)(Ae,{variant:`secondary`,className:`ml-2`,children:wt})]}),(0,w.jsx)(Ee,{value:`submitted`,children:O(`tabSubmitted`,`Submitted by me`)}),(0,w.jsx)(Ee,{value:`all`,children:O(`tabAll`,`All`)})]}),(0,w.jsxs)(Ge,{value:M,className:`mt-4 space-y-3`,children:[!gt&&(N.length>0||M!==`pending`&&(Ft||V!==`all`))&&(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative flex-1 min-w-[200px] max-w-sm`,children:[(0,w.jsx)(ae,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,w.jsx)(ze,{value:B,onChange:e=>Pt(e.target.value),placeholder:O(`searchPlaceholder`,`Search record, process, requester…`),className:`pl-8 h-8 text-sm`}),B&&(0,w.jsx)(`button`,{type:`button`,onClick:()=>Pt(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,"aria-label":O(`clearSearch`,`Clear search`),children:(0,w.jsx)(oe,{className:`h-3.5 w-3.5`})})]}),M!==`pending`&&(0,w.jsxs)(ie,{value:V,onValueChange:Vt,children:[(0,w.jsx)(be,{className:`h-8 w-auto min-w-[130px] text-sm`,children:(0,w.jsx)(Se,{placeholder:O(`statusFilter`,`Status`)})}),(0,w.jsxs)(xe,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allStatuses`,`All statuses`)}),(0,w.jsx)(o,{value:`pending`,children:A(`pending`)}),(0,w.jsx)(o,{value:`approved`,children:A(`approved`)}),(0,w.jsx)(o,{value:`rejected`,children:A(`rejected`)}),(0,w.jsx)(o,{value:`recalled`,children:A(`recalled`)}),(0,w.jsx)(o,{value:`returned`,children:A(`returned`)})]})]}),On.length>1&&(0,w.jsxs)(ie,{value:Lt,onValueChange:Rt,children:[(0,w.jsx)(be,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,w.jsx)(Se,{placeholder:O(`processFilter`,`Process`)})}),(0,w.jsxs)(xe,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allProcesses`,`All processes`)}),On.map(e=>(0,w.jsx)(o,{value:e,children:e},e))]})]}),kn.length>1&&(0,w.jsxs)(ie,{value:zt,onValueChange:Bt,children:[(0,w.jsx)(be,{className:`h-8 w-auto min-w-[140px] text-sm`,children:(0,w.jsx)(Se,{placeholder:O(`objectFilter`,`Object`)})}),(0,w.jsxs)(xe,{children:[(0,w.jsx)(o,{value:`all`,children:O(`allObjects`,`All objects`)}),kn.map(e=>(0,w.jsx)(o,{value:e,children:e},e))]})]}),Bn&&(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`filterCount`,`{{shown}} of {{total}}`,{shown:Z.length,total:N.length})})]}),M===`pending`&&H.size>0&&(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 rounded-md border bg-accent/30 text-sm`,children:[(0,w.jsxs)(`span`,{children:[(0,w.jsx)(`strong`,{children:H.size}),` `,O(`selected`,`selected`),$.length!==H.size&&(0,w.jsx)(`span`,{className:`text-muted-foreground ml-1`,children:O(`actionableCount`,`({{count}} actionable)`,{count:$.length})})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,disabled:Ut||$.length===0,children:[(0,w.jsx)(Xe,{className:`h-3.5 w-3.5 mr-1`}),O(`approveN`,`Approve {{count}}`,{count:$.length||``})]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`bulkApproveTitle`,`Approve {{count}} requests?`,{count:$.length})}),(0,w.jsx)(u,{children:O(`bulkApproveBody`,`Each request is approved with your identity and its flow continues down the approve branch.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>Fn(`approve`),children:O(`approveN`,`Approve {{count}}`,{count:$.length})})]})]})]}),(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:Ut||$.length===0,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,w.jsx)(Ue,{className:`h-3.5 w-3.5 mr-1`}),O(`rejectN`,`Reject {{count}}`,{count:$.length||``})]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`bulkRejectTitle`,`Reject {{count}} requests?`,{count:$.length})}),(0,w.jsx)(u,{children:O(`bulkRejectBody`,`This rejects the selected requests and notifies their submitters.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>Fn(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`rejectN`,`Reject {{count}}`,{count:$.length})})]})]})]}),(0,w.jsx)(f,{size:`sm`,variant:`ghost`,onClick:()=>Ht(new Set),disabled:Ut,children:O(`clear`,`Clear`)})]})]}),gt?(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(s,{className:`h-10 w-full`}),(0,w.jsx)(s,{className:`h-10 w-full`}),(0,w.jsx)(s,{className:`h-10 w-full`})]}):N.length===0?(0,w.jsx)(`div`,{className:`flex items-center justify-center min-h-[240px] rounded-md border border-dashed`,children:(0,w.jsxs)(_e,{children:[(0,w.jsx)(ce,{children:O(`emptyTitle`,`No requests`)}),(0,w.jsx)(Ze,{children:M===`pending`?O(`emptyPending`,`You're all caught up — nothing is waiting on you.`):O(`emptyOther`,`Nothing here yet.`)}),M===`pending`&&(0,w.jsx)(f,{variant:`link`,size:`sm`,className:`mt-1`,onClick:()=>Vn(`all`),children:O(`emptyViewAll`,`Browse all requests`)})]})}):Z.length===0?(0,w.jsx)(`div`,{className:`flex items-center justify-center min-h-[160px] rounded-md border border-dashed text-sm text-muted-foreground`,children:O(`noMatches`,`No matches for current filters.`)}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(de,{className:`hidden md:block`,children:(0,w.jsx)(Ce,{className:`p-0`,children:(0,w.jsxs)(He,{children:[(0,w.jsx)(Je,{children:(0,w.jsxs)(ke,{children:[M===`pending`&&(0,w.jsx)(m,{className:`w-10`,children:(0,w.jsx)(We,{checked:Mn,onCheckedChange:Nn,"aria-label":O(`selectAll`,`Select all`),disabled:jn.length===0})}),(0,w.jsx)(m,{children:O(`colRequest`,`Request`)}),(0,w.jsx)(m,{children:O(`colRecord`,`Record`)}),(0,w.jsx)(m,{children:O(`colRequester`,`Requester`)}),(0,w.jsx)(m,{children:O(`colStatus`,`Status`)}),(0,w.jsx)(m,{children:O(`colWaiting`,`Submitted`)}),(0,w.jsx)(m,{className:`w-20`,"aria-label":O(`colActions`,`Actions`)})]})}),(0,w.jsx)(Ke,{children:Z.map((e,t)=>(0,w.jsxs)(ke,{className:y(`group cursor-pointer hover:bg-accent/50`,pn===t&&`ring-2 ring-inset ring-ring bg-accent/30`),onClick:()=>{mn(t),q(e.id)},children:[M===`pending`&&(0,w.jsx)(l,{className:`w-10`,onClick:e=>e.stopPropagation(),children:(0,w.jsx)(We,{checked:H.has(e.id),onCheckedChange:()=>Pn(e.id),disabled:e.status!==`pending`,"aria-label":O(`selectRow`,`Select request`)})}),(0,w.jsx)(l,{children:(0,w.jsx)(Hn,{r:e})}),(0,w.jsx)(l,{children:(0,w.jsx)(Un,{r:e})}),(0,w.jsx)(l,{children:(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm`,children:[(0,w.jsx)(me,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,w.jsx)(`span`,{className:`truncate`,title:e.submitter_id||``,children:ot(e)})]})}),(0,w.jsx)(l,{children:(0,w.jsx)(dt,{status:e.status})}),(0,w.jsxs)(l,{className:y(`text-xs whitespace-nowrap`,lt(e)),title:rt(D(e)),children:[(0,w.jsx)(De,{className:`h-3 w-3 inline mr-1`}),k(D(e)),e.status===`pending`&&e.sla_due_at&&(0,w.jsx)(`div`,{className:y(`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()?O(`slaOverdue`,`SLA overdue {{dur}}`,{dur:ut(Date.now()-Date.parse(e.sla_due_at))}):O(`slaRemaining`,`SLA {{dur}} left`,{dur:ut(Date.parse(e.sla_due_at)-Date.now())})})]}),(0,w.jsx)(l,{className:`w-20`,children:(0,w.jsx)(Wn,{r:e})})]},e.id))})]})})}),(0,w.jsx)(`div`,{className:`md:hidden space-y-2`,children:Z.map(e=>(0,w.jsx)(de,{className:`cursor-pointer active:bg-accent/50`,onClick:()=>void q(e.id),children:(0,w.jsxs)(Ce,{className:`p-3 space-y-1.5`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,w.jsx)(`div`,{className:`font-medium text-sm truncate`,children:it(e)}),(0,w.jsx)(dt,{status:e.status})]}),(0,w.jsxs)(`div`,{className:`text-sm truncate`,children:[e.record_title||T(e.record_id),(0,w.jsx)(`span`,{className:`text-muted-foreground text-xs ml-1.5`,children:ct(e)})]}),(0,w.jsxs)(`div`,{className:`flex items-center justify-between text-xs text-muted-foreground`,children:[(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1 truncate`,children:[(0,w.jsx)(me,{className:`h-3 w-3`}),ot(e)]}),(0,w.jsxs)(`span`,{className:y(`inline-flex items-center gap-1 whitespace-nowrap`,lt(e)),children:[(0,w.jsx)(De,{className:`h-3 w-3`}),k(D(e))]})]}),Q(e)&&(0,w.jsxs)(`div`,{className:`flex gap-2 pt-1`,onClick:e=>e.stopPropagation(),children:[(0,w.jsxs)(f,{size:`sm`,className:`h-7 flex-1`,disabled:Kt===e.id,onClick:()=>void In(e),children:[(0,w.jsx)(Xe,{className:`h-3.5 w-3.5 mr-1`}),O(`approve`,`Approve`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,className:`h-7 flex-1 border-destructive text-destructive`,disabled:Kt===e.id,onClick:()=>Gt(e),children:[(0,w.jsx)(Ue,{className:`h-3.5 w-3.5 mr-1`}),O(`reject`,`Reject`)]})]})]})},e.id))}),M!==`pending`&&bt!=null&&(0,w.jsxs)(`div`,{className:`flex items-center justify-center gap-3 py-1`,children:[(0,w.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`loadedOf`,`Loaded {{loaded}} of {{total}}`,{loaded:N.length,total:bt})}),N.length<bt&&(0,w.jsx)(f,{size:`sm`,variant:`outline`,disabled:vt,onClick:()=>void hn(),children:vt?O(`loadingMore`,`Loading…`):O(`loadMore`,`Load more`)})]}),(0,w.jsx)(`div`,{className:`hidden md:block text-[11px] text-muted-foreground`,children:O(`keyboardHint`,`Keyboard: j/k move · Enter open · x select · a approve · r reject`)})]})]})]}),(0,w.jsx)(_,{open:Jt,onOpenChange:e=>{e||(Yt(!1),Zt(``))},children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`reassignTitle`,`Hand this approval to someone else?`)}),(0,w.jsx)(u,{children:O(`reassignBody`,`Your approver slot moves to the person you pick — they are notified and can act immediately.`)})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Ve,{htmlFor:`reassign-to`,className:`text-xs`,children:O(`reassignTo`,`New approver`)}),(0,w.jsx)(ze,{id:`reassign-to`,list:`reassign-user-options`,value:Xt,onChange:e=>Zt(e.target.value),placeholder:O(`reassignToPlaceholder`,`Pick a user or type an email / role:<name>`),className:`mt-1`}),(0,w.jsx)(`datalist`,{id:`reassign-user-options`,children:dn.map(e=>(0,w.jsx)(`option`,{value:e.email,children:e.name},e.email))})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{disabled:!Xt.trim()||W,onClick:()=>void vn(),children:O(`reassignBtn`,`Reassign`)})]})]})}),(0,w.jsx)(_,{open:Qt,onOpenChange:e=>{e||($t(!1),tn(``))},children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`requestInfoTitle`,`Ask the requester for more information?`)}),(0,w.jsx)(u,{children:O(`requestInfoBody`,`The request stays pending; the requester is notified and can reply on the thread.`)})]}),(0,w.jsx)(qe,{value:en,onChange:e=>tn(e.target.value),rows:3,placeholder:O(`requestInfoPlaceholder`,`What do you need from the requester?`)}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{disabled:!en.trim()||W,onClick:()=>void bn(),children:O(`requestInfoBtn`,`Request info`)})]})]})}),(0,w.jsx)(_,{open:nn,onOpenChange:e=>{e||(rn(!1),on(``))},children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`sendBackTitle`,`Send this request back for revision?`)}),(0,w.jsx)(u,{children:O(`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,w.jsx)(qe,{value:an,onChange:e=>on(e.target.value),rows:3,placeholder:O(`sendBackPlaceholder`,`What needs to be fixed before this can be approved?`)}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{disabled:W,onClick:()=>void xn(),children:O(`sendBackBtn`,`Send back`)})]})]})}),(0,w.jsx)(_,{open:!!U,onOpenChange:e=>!e&&Gt(null),children:(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`rejectOneTitle`,`Reject "{{title}}"?`,{title:U?U.record_title||T(U.record_id):``})}),(0,w.jsx)(u,{children:O(`rejectOneBody`,`This rejects the request and notifies the submitter.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>void Ln(),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`reject`,`Reject`)})]})]})}),(0,w.jsx)(ge,{open:!!P,onOpenChange:e=>!e&&gn(),children:(0,w.jsxs)(se,{className:`w-full sm:max-w-xl overflow-y-auto`,children:[(0,w.jsxs)(pe,{children:[(0,w.jsx)(ve,{children:F?it(F):O(`drawerTitle`,`Approval Request`)}),(0,w.jsx)(ue,{children:F?at(F)||ct(F):``})]}),F&&An>=0&&Z.length>1&&(0,w.jsxs)(`div`,{className:`flex items-center justify-between mt-2 text-xs text-muted-foreground`,children:[(0,w.jsxs)(f,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:An<=0,onClick:()=>{let e=Z[An-1];e&&q(e.id)},children:[(0,w.jsx)(Ie,{className:`h-4 w-4 mr-0.5`}),O(`prevRequest`,`Previous`)]}),(0,w.jsx)(`span`,{children:O(`positionOf`,`{{index}} of {{total}}`,{index:An+1,total:Z.length})}),(0,w.jsxs)(f,{variant:`ghost`,size:`sm`,className:`h-7 px-2`,disabled:An>=Z.length-1,onClick:()=>{let e=Z[An+1];e&&q(e.id)},children:[O(`nextRequest`,`Next`),(0,w.jsx)(ne,{className:`h-4 w-4 ml-0.5`})]})]}),At?(0,w.jsxs)(`div`,{className:`space-y-2 mt-6`,children:[(0,w.jsx)(s,{className:`h-6 w-3/4`}),(0,w.jsx)(s,{className:`h-6 w-1/2`}),(0,w.jsx)(s,{className:`h-20 w-full`})]}):F?(0,w.jsxs)(`div`,{className:`space-y-4 mt-6`,children:[(0,w.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-muted-foreground`,children:[(0,w.jsx)(dt,{status:F.status}),(F.round??1)>1&&(0,w.jsx)(Ae,{variant:`outline`,className:`text-[10px] border-violet-200 text-violet-700 dark:border-violet-500/30 dark:text-violet-400`,children:O(`roundChip`,`Round {{n}}`,{n:F.round})}),(0,w.jsxs)(`span`,{className:`inline-flex items-center gap-1`,title:rt(D(F)),children:[(0,w.jsx)(De,{className:`h-3 w-3`}),O(`submittedAgo`,`Submitted {{when}}`,{when:k(D(F))})]}),F.completed_at&&(0,w.jsxs)(`span`,{children:[`· `,O(`completedAt`,`Completed {{when}}`,{when:k(F.completed_at)})]}),F.status===`pending`&&F.sla_due_at&&(0,w.jsx)(Ae,{variant:`outline`,className:y(`text-[10px]`,Date.parse(F.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(F.sla_due_at)<Date.now()?O(`slaOverdue`,`SLA overdue {{dur}}`,{dur:ut(Date.now()-Date.parse(F.sla_due_at))}):O(`slaRemaining`,`SLA {{dur}} left`,{dur:ut(Date.parse(F.sla_due_at)-Date.now())})})]}),(0,w.jsx)(de,{children:(0,w.jsxs)(Ce,{className:`p-4 space-y-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsxs)(r,{to:pt(F),className:`text-base font-semibold hover:underline inline-flex items-center gap-1.5`,children:[(0,w.jsx)(`span`,{className:`truncate`,children:F.record_title||T(F.record_id)}),(0,w.jsx)(re,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:ct(F)})]}),(0,w.jsx)(`div`,{className:`text-right text-xs text-muted-foreground shrink-0`,children:(0,w.jsxs)(`div`,{className:`inline-flex items-center gap-1`,children:[(0,w.jsx)(me,{className:`h-3 w-3`}),(0,w.jsx)(`span`,{title:F.submitter_id||``,children:ot(F)})]})})]}),ft(F.payload,F.payload_display).length>0&&(0,w.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-sm border-t pt-3`,children:ft(F.payload,F.payload_display).map(([e,t])=>(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e}),(0,w.jsx)(`div`,{className:`truncate`,title:t,children:t})]},e))}),F.status===`pending`&&(F.pending_approvers||[]).length>0&&(0,w.jsxs)(`div`,{className:`border-t pt-3`,children:[(0,w.jsx)(`div`,{className:`text-[11px] text-muted-foreground mb-1`,children:O(`waitingOn`,`Waiting on`)}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:(F.pending_approvers||[]).map((e,t)=>(0,w.jsx)(Ae,{variant:`outline`,className:`text-[11px]`,title:e,children:st(e,F)},t))})]})]})}),(F.flow_steps?.length??0)>1&&(0,w.jsx)(`div`,{className:`flex items-center px-1`,"aria-label":O(`stepProgress`,`Approval steps`),children:F.flow_steps.map((e,t)=>(0,w.jsxs)(x.Fragment,{children:[t>0&&(0,w.jsx)(`div`,{className:y(`h-px flex-1 mx-2`,e.state===`done`||e.state===`current`?`bg-emerald-300 dark:bg-emerald-700`:`bg-border`)}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,w.jsx)(`span`,{className:y(`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,w.jsx)(he,{className:`h-3 w-3`}):t+1}),(0,w.jsx)(`span`,{className:y(`text-xs`,e.state===`current`?`font-medium`:`text-muted-foreground`),children:e.label})]})]},e.id))}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold mb-3`,children:O(`history`,`Activity`)}),Ot.length===0?(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O(`noActions`,`No actions yet.`)}):(0,w.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:Ot.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`?O(`systemSlaActor`,`System (SLA)`):e.actor_name??(e.actor_id&&e.actor_id===F.submitter_id?ot(F):T(e.actor_id)),r=e.action===`submit`?O(`actSubmit`,`Submitted`):e.action===`approve`?O(`actApprove`,`Approved`):e.action===`reject`?O(`actReject`,`Rejected`):e.action===`recall`?O(`actRecall`,`Recalled`):e.action===`reassign`?O(`actReassign`,`Reassigned`):e.action===`remind`?O(`actRemind`,`Reminder sent`):e.action===`request_info`?O(`actRequestInfo`,`Requested more info`):e.action===`comment`?O(`actComment`,`Commented`):e.action===`escalate`?O(`actEscalate`,`SLA escalated`):e.action===`revise`?O(`actRevise`,`Sent back for revision`):e.action===`resubmit`?O(`actResubmit`,`Resubmitted`):e.action;return(0,w.jsxs)(`li`,{className:`relative text-xs`,children:[(0,w.jsx)(`span`,{className:`absolute -left-[18px] top-1 h-3 w-3 rounded-full ring-2 ring-background ${t}`,"aria-hidden":!0}),(0,w.jsxs)(`div`,{className:`flex items-baseline gap-1.5 flex-wrap`,children:[(0,w.jsx)(`span`,{className:`font-medium`,children:r}),(0,w.jsx)(`span`,{className:`text-muted-foreground`,children:`·`}),(0,w.jsx)(`span`,{title:e.actor_id||``,children:n}),(0,w.jsx)(`span`,{className:`ml-auto text-muted-foreground text-[10px]`,title:rt(e.created_at),children:k(e.created_at)})]}),e.comment&&(0,w.jsxs)(`div`,{className:`text-muted-foreground italic mt-0.5`,children:[`"`,e.comment,`"`]})]},e.id)})}),F.status===`pending`&&(Tn||En)&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 mt-3`,children:[(0,w.jsx)(ze,{value:ln,onChange:e=>un(e.target.value),onKeyDown:e=>{e.key===`Enter`&&ln.trim()&&(e.preventDefault(),Cn())},placeholder:O(`replyPlaceholder`,`Reply on this request…`),className:`h-8 text-sm`}),(0,w.jsx)(f,{size:`sm`,variant:`outline`,className:`h-8 px-2 shrink-0`,disabled:!ln.trim()||W,onClick:()=>void Cn(),children:(0,w.jsx)(ye,{className:`h-3.5 w-3.5`})})]})]}),F.payload!=null&&(0,w.jsxs)(`details`,{className:`group`,children:[(0,w.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:O(`rawData`,`Raw data (JSON)`)}),(0,w.jsxs)(`div`,{className:`mt-2`,children:[(0,w.jsx)(`div`,{className:`flex justify-end`,children:(0,w.jsxs)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(F.payload,null,2)),b.success(O(`copied`,`Copied`))}catch{b.error(O(`copyFailed`,`Copy failed`))}},className:`text-[10px] text-muted-foreground hover:text-foreground inline-flex items-center gap-1`,children:[(0,w.jsx)(je,{className:`h-3 w-3`}),O(`copy`,`Copy`)]})}),(0,w.jsx)(`pre`,{className:`text-[11px] bg-muted/50 rounded p-2 overflow-auto max-h-48 mt-1`,children:JSON.stringify(F.payload,null,2)})]})]}),F.status===`pending`&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Qe,{}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[$e&&(0,w.jsxs)(`details`,{className:`group`,children:[(0,w.jsx)(`summary`,{className:`cursor-pointer text-xs text-muted-foreground hover:text-foreground select-none`,children:O(`overrideActor`,`Act as another identity (admin)`)}),(0,w.jsxs)(`div`,{className:`mt-2`,children:[(0,w.jsx)(Ve,{htmlFor:`actor-override`,className:`text-xs`,children:O(`actor`,`Actor`)}),(0,w.jsx)(`input`,{id:`actor-override`,type:`text`,value:R,onChange:e=>Mt(e.target.value),placeholder:`${O(`auto`,`Auto`)}: ${J(F)||`—`}`,className:`w-full mt-1 px-3 py-2 text-sm border rounded-md bg-background`}),(0,w.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:O(`overrideHint`,`e.g. role:sales_manager. Leave blank to use the auto-detected identity.`)})]})]}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Ve,{htmlFor:`comment`,className:`text-xs`,children:O(`comment`,`Comment (optional)`)}),(0,w.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mt-1.5`,children:[O(`quickPhrase1`,`Approved — meets requirements.`),O(`quickPhrase2`,`Approved with conditions — please monitor execution.`),O(`quickPhrase3`,`Please add supporting material and resubmit.`)].map(e=>(0,w.jsx)(`button`,{type:`button`,onClick:()=>L(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,w.jsx)(qe,{id:`comment`,value:I,onChange:e=>L(e.target.value),rows:2,className:`mt-1`})]}),(0,w.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,w.jsxs)(f,{size:`sm`,onClick:()=>_n(`approve`),disabled:!Tn||z!==null,children:[(0,w.jsx)(Xe,{className:`h-4 w-4 mr-1`}),z===`approve`?O(`approving`,`Approving…`):O(`approve`,`Approve`)]}),(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:!Tn||z!==null,className:`border-destructive text-destructive hover:bg-destructive hover:text-destructive-foreground`,children:[(0,w.jsx)(Ue,{className:`h-4 w-4 mr-1`}),z===`reject`?O(`rejecting`,`Rejecting…`):O(`reject`,`Reject`)]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`rejectTitle`,`Reject this request?`)}),(0,w.jsx)(u,{children:O(`rejectBody`,`This marks the request as rejected and notifies the submitter.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>_n(`reject`),className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,children:O(`reject`,`Reject`)})]})]})]}),Tn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,className:`border-violet-300 text-violet-700 hover:bg-violet-50 dark:text-violet-400`,onClick:()=>rn(!0),children:[(0,w.jsx)(we,{className:`h-4 w-4 mr-1`}),O(`sendBackBtn`,`Send back`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,className:`border-amber-300 text-amber-700 hover:bg-amber-50 dark:text-amber-400`,onClick:()=>$t(!0),children:[(0,w.jsx)(Me,{className:`h-4 w-4 mr-1`}),O(`requestInfoBtn`,`Request info`)]}),(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null||W,onClick:()=>{wn(),Yt(!0)},children:[(0,w.jsx)(Oe,{className:`h-4 w-4 mr-1`}),O(`reassignBtn`,`Reassign`)]})]}),En&&(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:W,onClick:()=>void yn(),children:[(0,w.jsx)(Re,{className:`h-4 w-4 mr-1`}),O(`remindBtn`,`Send reminder`)]}),En&&(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:z!==null,children:[(0,w.jsx)(fe,{className:`h-4 w-4 mr-1`}),z===`recall`?O(`recalling`,`Recalling…`):O(`recall`,`Recall`)]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`recallTitle`,`Recall this request?`)}),(0,w.jsx)(u,{children:O(`recallBody`,`This withdraws your request. Approvers can no longer act on it, and the record is unlocked.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>_n(`recall`),children:O(`recall`,`Recall`)})]})]})]})]}),!Tn&&(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:En?O(`whyDisabledSubmitter`,`You submitted this request, so you can recall it — but only the assigned approvers can approve or reject.`):O(`whyDisabled`,`Only the assigned approvers can act on this request. It is waiting on: {{who}}.`,{who:(F.pending_approvers||[]).map(e=>st(e,F)).join(`, `)||`—`})})]})]}),Dn&&(0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(Qe,{}),(0,w.jsxs)(`div`,{className:`space-y-3`,children:[(0,w.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:O(`returnedHint`,`An approver sent this back to you. The record is unlocked — fix the data, then resubmit to start a new approval round.`)}),(0,w.jsxs)(`div`,{children:[(0,w.jsx)(Ve,{htmlFor:`resubmit-comment`,className:`text-xs`,children:O(`comment`,`Comment (optional)`)}),(0,w.jsx)(qe,{id:`resubmit-comment`,value:I,onChange:e=>L(e.target.value),rows:2,className:`mt-1`,placeholder:O(`resubmitPlaceholder`,`What did you change?`)})]}),(0,w.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,w.jsx)(f,{asChild:!0,size:`sm`,variant:`outline`,children:(0,w.jsxs)(r,{to:pt(F),children:[(0,w.jsx)(re,{className:`h-4 w-4 mr-1`}),O(`editRecordBtn`,`Edit record`)]})}),(0,w.jsxs)(f,{size:`sm`,disabled:sn,onClick:()=>void Sn(),children:[(0,w.jsx)(le,{className:y(`h-4 w-4 mr-1`,sn&&`animate-spin`)}),sn?O(`resubmitting`,`Resubmitting…`):O(`resubmitBtn`,`Resubmit`)]}),(0,w.jsxs)(_,{children:[(0,w.jsx)(Ne,{asChild:!0,children:(0,w.jsxs)(f,{size:`sm`,variant:`outline`,disabled:sn,children:[(0,w.jsx)(fe,{className:`h-4 w-4 mr-1`}),O(`recall`,`Recall`)]})}),(0,w.jsxs)(v,{children:[(0,w.jsxs)(g,{children:[(0,w.jsx)(h,{children:O(`abandonTitle`,`Abandon this revision?`)}),(0,w.jsx)(u,{children:O(`abandonBody`,`This withdraws the request instead of resubmitting it. The approval ends here.`)})]}),(0,w.jsxs)(d,{children:[(0,w.jsx)(p,{children:O(`cancel`,`Cancel`)}),(0,w.jsx)(c,{onClick:()=>_n(`recall`),children:O(`recall`,`Recall`)})]})]})]})]})]})]})]}):null]})})]})}export{pt as ApprovalsInboxPage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{i as a}from"./framework-CsYa1Kaj.js";import{Bt as o,Ht as s,Ut as c,Vt as l,Wt as u,gr as d,oi as f,w as p,yi as m}from"./ui-components-DXl7VfQF.js";import{r as h}from"./vendor-ui-utils-C92Fl7BT.js";import{i as g,s as _,t as v}from"./assistantBus-BMrg1uLy.js";import{a as y,n as b,o as x,s as ee,t as te}from"./useReconcileOnError-BXVpquqp.js";import{S,a as ne,d as C,p as w,r as re,t as ie,u as T,v as E}from"./plugin-chatbot-B25XBELF.js";import{b as D,n as O}from"./marketplaceApi-DL8PegzV.js";var k=e(t(),1),A=r(),j={ask:{zh:`智能助手`,en:`Assistant`},build:{zh:`构建助手`,en:`Build assistant`}};function M(e,t,n){let r=t?j[w(t)]:void 0;return r?e?r.zh:r.en:n}function ae(e,t,n,r,i){let a=(e??``).toLowerCase().startsWith(`zh`),o=M(a,n,r),s=i.slice(0,2).map(e=>e.label||e.name);if(a){let e=[s[0]?`查询最近创建的${s[0]}`:`帮我查询最近的数据`,s[0]?`统计${s[0]}的总数量`:`统计各对象的记录数量`,s[1]?`${s[1]}有哪些字段?`:`当前应用里有哪些数据对象?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`你好,我是${o}`,emptyDescription:`随时帮你查询和分析「${t}」中的数据。试试下面的问题,或直接输入你的需求。`,clear:`清空对话`,sendHint:`发送`,agentActivity:`执行过程`,toolCompleted:`已完成`,toolRunning:`运行中`,toolAwaitingApproval:`等待确认`,toolFailed:`失败`,toolDetailsHidden:`已隐藏工具参数和原始结果,仅保留过程摘要。`,copy:`复制`,copied:`已复制`,regenerate:`重新生成`,model:`模型`,submit:`发送`,uploadFiles:`上传文件`,stopResponse:`停止生成`,trace:`调试 trace`,viewTrace:`查看调试 trace`},placeholder:`向${o}提问…`,loadingPlaceholder:`正在加载助手…`,title:`${t} 智能助手`,newChat:`开启新对话`,share:`分享对话`,reviewDraft:e=>`查看 ${e} 项变更`,publishDrafts:`发布`,published:`已发布`,nextSteps:`下一步`,planTitle:`方案预览`,planQuestions:`搭建前请确认`,planAssumptions:`假设`,planApproveHint:`回复以确认或调整该方案。`,planApprove:`开始搭建`,planAdjust:`调整方案`,planApproveMessage:`就按这个方案搭建吧。`,planApproveDefaultsMessage:`就按你的合理假设直接搭建,未决问题用默认即可。`,planAnswer:(e,t)=>`关于「${e}」,我选择「${t}」。`,publishOk:`已发布,对象已生效。`,publishFailed:`发布失败`,seedWarn:`已发布,但部分示例数据未能载入。`,openBuiltApp:`打开应用`,suggestions:e}}let c=[s[0]?`Show the latest ${s[0]}`:`Show my most recent records`,s[0]?`How many ${s[0]} are there?`:`Count records by status`,s[1]?`What fields does ${s[1]} have?`:`What data can I work with here?`].filter(Boolean);return{agentLabel:o,labels:{emptyTitle:`Hi, I'm ${o}`,emptyDescription:`I can help you query and analyze your ${t} data. Try a prompt below, or just type your question.`,clear:`Clear`,sendHint:`to send`,agentActivity:`Agent activity`,toolCompleted:`Completed`,toolRunning:`Running`,toolAwaitingApproval:`Awaiting approval`,toolFailed:`Failed`,toolDetailsHidden:`Tool inputs and raw results are hidden in this view.`,copy:`Copy`,copied:`Copied`,regenerate:`Regenerate`,model:`Model`,submit:`Submit`,uploadFiles:`Upload files`,stopResponse:`Stop response`,trace:`trace`,viewTrace:`View trace`},placeholder:`Ask ${o}...`,loadingPlaceholder:`Loading assistant...`,title:`${t} Assistant`,newChat:`New chat`,share:`Share conversation`,reviewDraft:e=>`Review ${e} change${e===1?``:`s`}`,publishDrafts:`Publish`,published:`Published`,nextSteps:`What's next`,planTitle:`Proposed plan`,planQuestions:`Confirm before building`,planAssumptions:`Assumptions`,planApproveHint:`Reply to approve or adjust this plan.`,planApprove:`Build it`,planAdjust:`Adjust`,planApproveMessage:`Looks good — build it as proposed.`,planApproveDefaultsMessage:`Build it with your best assumptions; use sensible defaults for the open questions.`,planAnswer:(e,t)=>`For "${e}", go with: ${t}.`,publishOk:`Published — objects are now live.`,publishFailed:`Publish failed`,seedWarn:`Published, but some sample data failed to load.`,openBuiltApp:`Open app`,suggestions:c}}var N=`/api/v1/ai`;function P(e){if(e)return e.replace(/\/$/,``);let t={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},n=t.VITE_AI_BASE_URL;return n?n.replace(/\/$/,``):`${(t.VITE_SERVER_URL??``).replace(/\/$/,``)}${N}`}function oe(e,t){if(!e||e.type!==`object`)return null;let n=e.label||e.name||`this object`;return(t??``).toLowerCase().startsWith(`zh`)?[`为「${n}」补充字段`,`为「${n}」建议校验规则`,`添加一个状态选项字段`]:[`Add fields to ${n}`,`Suggest validations for ${n}`,`Add a status picklist field`]}var F=new Set([`view`,`record`,`page`,`dashboard`,`design`,`report`,`metadata`]);function I(e){try{return decodeURIComponent(e)}catch{return e}}function se(e,t){let n=e.split(`/`).filter(Boolean),r=n.indexOf(`apps`);if(r===-1||n.length<r+3)return{};let i=I(n[r+2]);if(F.has(i)||!t.some(e=>e.name===i))return{};let a=n[r+3]?I(n[r+3]):void 0,o=a&&a!==`new`?a:void 0;return{objectName:i,...o?{recordId:o}:{}}}function L({appLabel:e,appName:t,objects:r,agents:x,agentsLoading:C,activeAgent:w,onAgentChange:T,showAgentPicker:j,chatApi:M,apiBase:N,defaultOpen:P=!1,conversationId:F,initialMessages:I}){let{language:L}=a(),R=i(),z=n(),B=k.useMemo(()=>se(z.pathname,r),[z.pathname,r]),{editor:V}=_(),H=k.useMemo(()=>!I||I.length===0?[]:S(I),[I]),U=k.useMemo(()=>x.find(e=>e.name===w)?.label??w??e,[x,w,e]),W=k.useMemo(()=>ae(L,e,w,U,r),[L,e,w,U,r]),G=k.useMemo(()=>oe(V,L),[V,L]),{errorSuppressed:ce,handleChatError:le,setMessagesRef:ue,resetSuppression:K}=te({chatApi:M,conversationId:F}),{messages:q,isLoading:J,error:de,sendMessage:Y,stop:fe,reload:pe,clear:X,setMessages:Z}=E({api:M,conversationId:F,onError:le,body:{context:{activeApp:e,appName:t,objects:r.map(e=>({name:e.name,label:e.label})),agentName:w,autoPublishAiBuilds:D().features.autoPublishAiBuilds,...B.objectName?{objectName:B.objectName}:{},...B.recordId?{recordId:B.recordId}:{},...V?{editing:V}:{}}},initialMessages:H,autoResponse:!M,autoResponseText:r.length>0?`I can help you work with ${r.map(e=>e.label||e.name).join(`, `)}. What would you like to do?`:`Thanks for your message! I'm here to help you navigate and manage your data.`,autoResponseDelay:600});k.useEffect(()=>{ue.current=Z},[Z]),k.useEffect(()=>{ee(F,y(q))},[F,q]);let Q=ie({messages:q,apiBase:N,continueConversation:e=>{K(),Y(e)}}),me=j&&x.length>1?(0,A.jsxs)(o,{value:w,onValueChange:T,disabled:C,children:[(0,A.jsx)(c,{className:`h-7 w-[180px] text-xs`,"data-testid":`floating-chatbot-agent-picker`,children:(0,A.jsx)(u,{placeholder:`Choose agent...`})}),(0,A.jsx)(l,{align:`end`,children:x.map(e=>(0,A.jsxs)(s,{value:e.name,className:`text-xs`,children:[(0,A.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,A.jsx)(`span`,{className:`block text-muted-foreground text-[10px] truncate max-w-[220px]`,children:e.description}):null]},e.name))})]}):null,[he,$]=k.useState(!1),ge=k.useMemo(()=>N.replace(/\/v1\/ai$/,``).replace(/\/ai$/,``)||`/api`,[N]),_e=(0,A.jsxs)(A.Fragment,{children:[q.length>0?(0,A.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":W.newChat,title:W.newChat,"data-testid":`floating-chatbot-new`,onClick:X,children:(0,A.jsx)(f,{className:`h-4 w-4`})}):null,F?(0,A.jsx)(d,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":W.share,title:W.share,"data-testid":`floating-chatbot-share`,onClick:()=>$(!0),children:(0,A.jsx)(m,{className:`h-4 w-4`})}):null]});return(0,A.jsxs)(A.Fragment,{children:[(0,A.jsx)(re,{onUpgrade:()=>window.open(O(),`_blank`,`noopener,noreferrer`),floatingConfig:{position:`bottom-right`,defaultOpen:P,panelWidth:420,panelHeight:560,title:W.title,triggerSize:56},headerExtra:me,headerActions:_e,messages:q,labels:W.labels,showAvatars:!0,hideClearBar:!0,assistantAvatarFallback:W.agentLabel,suggestions:q.length===0?G??W.suggestions:void 0,placeholder:w?W.placeholder:C?W.loadingPlaceholder:W.placeholder,onSendMessage:e=>{K(),Y(e)},onClear:X,onStop:J?fe:void 0,onReload:pe,isLoading:J,error:ce?void 0:de,enableMarkdown:!0,onToolApprove:Q.decide,toolDecisions:Q.decisions,toolApproveLabel:`Approve & run`,toolDenyLabel:`Reject`,toolDenyReason:`Operator rejected from chat`,onReviewDraft:e=>{e[0]&&g(e[0])},toolReviewLabel:W.reviewDraft,onOpenBuiltApp:e=>R(`/apps/${encodeURIComponent(e)}`),openBuiltAppLabel:W.openBuiltApp,onPreviewDraftApp:(e,t)=>R(t?.materialized?`/apps/${encodeURIComponent(e)}`:`/apps/${encodeURIComponent(e)}?preview=draft`),onDraftArtifacts:e=>{for(let t of e)v(t)},fetchPendingDraftCount:b,onPublishDrafts:async e=>{try{let t=await fetch(`/api/v1/packages/${encodeURIComponent(e)}/publish-drafts`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:`{}`}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error?.message||`HTTP ${t.status}`);let r=n?.data?.failedCount??n?.failedCount??0;if(r)throw Error(String(r));let i=n?.data?.seedApplied??n?.seedApplied;i&&i.success===!1?h.warning(W.seedWarn,{description:i.error??(Array.isArray(i.errors)&&i.errors.length?String(i.errors[0]):void 0)}):h.success(W.publishOk);let a=(n?.data?.published??n?.published??[]).find(e=>e?.type===`app`&&e?.name);return a?.name&&R(`/apps/${encodeURIComponent(a.name)}`),{ok:!0,health:ne(n)}}catch(e){return h.error(W.publishFailed,{description:e instanceof Error?e.message:void 0}),!1}},publishDraftsLabel:W.publishDrafts,nextStepsLabel:W.nextSteps,planTitleLabel:W.planTitle,planQuestionsLabel:W.planQuestions,planAssumptionsLabel:W.planAssumptions,planApproveHintLabel:W.planApproveHint,planApproveLabel:W.planApprove,planAdjustLabel:W.planAdjust,planApproveMessage:W.planApproveMessage,planApproveDefaultsMessage:W.planApproveDefaultsMessage,planAnswerMessage:W.planAnswer,publishedLabel:W.published,autoPublishDrafts:D().features.autoPublishAiBuilds}),F&&(0,A.jsx)(p,{open:he,onOpenChange:$,objectName:`ai_conversations`,recordId:F,recordLabel:`this conversation`,apiBase:ge})]})}function R({appLabel:e,appName:t,objects:n,apiBase:r,defaultAgent:i,showAgentPicker:a,defaultOpen:o=!1,userId:s}){let c=k.useMemo(()=>P(r),[r]),l={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},u=l.VITE_AI_DEFAULT_AGENT,d=a??l.VITE_AI_SHOW_AGENT_PICKER===`true`,{agents:f,isLoading:p,error:m}=C({apiBase:c}),[h,g]=k.useState(void 0);k.useEffect(()=>{if(!h&&f.length>0){let e=T(f,i??u);e&&g(e)}},[f,h,i,u]);let _=h?`${c}/agents/${encodeURIComponent(h)}/chat`:void 0,{conversationId:v,initialMessages:y}=x({userId:h?s:void 0,scope:h,apiBase:c});return(0,A.jsx)(L,{appLabel:e,appName:t,objects:n,agents:f,agentsLoading:p,agentsError:m,activeAgent:h,onAgentChange:g,showAgentPicker:d,chatApi:_,apiBase:c,defaultOpen:o,conversationId:v,initialMessages:y},`${_??`local`}:${v??`pending`}`)}export{R as default};
@@ -1 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i}from"./vendor-react-ClIa1CJA.js";import{f as a}from"./infrastructure-BsIvKvpW.js";import{A as o,f as s,i as c,k as l}from"./framework-CsYa1Kaj.js";import{$r as u,Bn as d,Bs as f,Cr as p,Ga as m,H as h,Hn as g,Hr as _,Is as v,R as y,Rn as b,Ua as x,Un as S,Vn as C,Vs as w,Wi as T,Zi as E,fc as D,gr as O,wc as ee,z as k,zn as te,zr as A}from"./ui-components-DXl7VfQF.js";import{r as j}from"./vendor-ui-utils-C92Fl7BT.js";import"./AdapterProvider-CJjaoZJR.js";import{n as ne}from"./plugin-form-sm04IEZv.js";import"./MetadataProvider-BO_KcC86.js";import{r as re}from"./ExpressionProvider-C2XzKImE.js";import{Z as ie,v as M}from"./ReportDefaultInspector-B6X1lhzs.js";import{n as N}from"./utils-29quoGQV.js";import{n as ae,r as oe,t as se}from"./MetadataInspector-D9KL7Kgi.js";import{n as P,t as F}from"./DashboardWidgetInspector-DQvlAqdm.js";import{i as ce,n as I,t as le}from"./useOpenRecordList-CwVRoKH4.js";import{n as ue}from"./skeletons-DZWz9Ill.js";import{n as de}from"./plugin-dashboard-C8TbFk_D.js";var L=e(n(),1),R=i();function fe({open:e,onClose:t,schema:n,selectedWidgetId:r,onSelectWidget:i,onSave:a,onChange:o,onRemoveWidget:s,name:l,metadataClient:u,onAfterChange:d}){let{t:f}=c(),m=(0,L.useMemo)(()=>M(),[]),[h,g]=(0,L.useState)(!1),[v,y]=(0,L.useState)(0),b=(0,L.useCallback)(e=>{g(!0),o({...n??{},...e})},[n,o]),x=(0,L.useCallback)(e=>{o(e),g(!1)},[o]),S=(0,L.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),C=Array.isArray(n?.widgets)?n.widgets:[],w=r?C.find(e=>e?.id===r):null;if(!e)return null;let T=typeof n?.name==`string`?n.name:``,E=w?f(`widget.editor.title`,{defaultValue:`Edit widget`}):f(`dashboard.editor.title`,{defaultValue:`Edit dashboard`});return(0,R.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":E,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[w&&(0,R.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>i(null),className:`h-7 w-7 p-0`,"aria-label":f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),title:f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),"data-testid":`dashboard-config-back`,children:(0,R.jsx)(D,{className:`h-4 w-4`})}),(0,R.jsx)(`div`,{className:`text-sm font-medium truncate`,children:E})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&s&&(0,R.jsx)(O,{variant:`ghost`,size:`sm`,onClick:()=>s(r),className:`h-7 w-7 p-0 text-destructive hover:text-destructive`,"aria-label":f(`widget.editor.delete`,{defaultValue:`Delete widget`}),title:f(`widget.editor.delete`,{defaultValue:`Delete widget`}),"data-testid":`widget-delete-button`,children:(0,R.jsx)(_,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(O,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":f(`common.close`,{defaultValue:`Close`}),"data-testid":`dashboard-config-close`,children:(0,R.jsx)(p,{className:`h-4 w-4`})})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:w?(0,R.jsx)(F,{type:`dashboard`,name:T,draft:n??{},selection:{kind:`widget`,id:r},onPatch:b,onClearSelection:()=>i(null),onSelectionChange:S,readOnly:!1,locale:m}):(0,R.jsx)(P,{type:`dashboard`,name:T,draft:n??{},onPatch:b,onSelectionChange:S,readOnly:!1,locale:m})}),(0,R.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,R.jsx)(I,{type:`dashboard`,name:l||T||void 0,metadataClient:u,dirty:h,onResume:x,savedSignal:v,onAfterChange:d}),(0,R.jsx)(O,{size:`sm`,onClick:()=>{a(n??{}),g(!1),y(e=>e+1)},"data-testid":`dashboard-config-save`,children:f(`common.save`,{defaultValue:`Save`})})]})]})}var z=t({DashboardView:()=>U}),B=[{type:`metric`,label:`KPI Metric`,Icon:A},{type:`bar`,label:`Bar Chart`,Icon:w},{type:`line`,label:`Line Chart`,Icon:f},{type:`pie`,label:`Pie Chart`,Icon:v},{type:`table`,label:`Table`,Icon:u},{type:`pivot`,label:`Pivot`,Icon:x}],V=0;function H(){return V+=1,`widget_${Date.now()}_${V}`}function pe(e){return!e.widgets?.length||!e.widgets.some(e=>!e.id)?e:{...e,widgets:e.widgets.map(e=>e.id?e:{...e,id:H()})}}function me(e){let t=B.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function U({dataSource:e}){let t=le(),{dashboardName:n}=r(),{showDebug:i}=ae(),u=l(),f=ie(),{t:p}=c(),{dashboardLabel:_,dashboardDescription:v}=ee(),{user:x}=a(),w=x?.role===`admin`,[D,A]=(0,L.useState)(!0),[M,P]=(0,L.useState)(!1),[F,I]=(0,L.useState)(null),[z,V]=(0,L.useState)(null),U=(0,L.useCallback)(e=>{V(t=>(t&&t.resolve(e),null))},[]),he=(0,L.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;V({schema:n,resolve:t})}),[]),ge=(0,L.useMemo)(()=>({export_dashboard_pdf:async()=>{j.info(p(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return j.error(p(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(j.info(p(`dashboardActions.forecastSoon`)),{success:!0})}),[p]);(0,L.useEffect)(()=>{A(!0),J(null),P(!1),I(null),queueMicrotask(()=>A(!1))},[n]);let{dashboards:_e,objects:W,refresh:G}=o(),{app:ve}=re(),K=oe(_e,n,ve?._packageId),[q,J]=(0,L.useState)(null);(0,L.useEffect)(()=>{M||J(null)},[K]);let Y=(0,L.useCallback)(async e=>{try{f&&await ce(`dashboard`,n,e,{metadataClient:f}),G().catch(()=>{})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[DashboardView] Auto-save failed:`,e),j.error(`Failed to save dashboard: ${t}`)}},[f,n,G]),ye=(0,L.useCallback)(()=>{J(pe(K)),P(!0)},[K]),be=(0,L.useCallback)(()=>{P(!1),I(null)},[]),X=(0,L.useCallback)(e=>{if(!q)return;let t=H(),n={id:t,title:me(e),type:e,layout:{x:0,y:q.widgets?.length??0,w:q.columns??2,h:1}},r={...q,widgets:[...q.widgets||[],n]};J(r),Y(r),I(t)},[q,Y]),xe=(0,L.useCallback)(e=>{if(!q)return;let t={...q,widgets:q.widgets.filter(t=>t.id!==e)};J(t),Y(t),F===e&&I(null)},[q,F,Y]),Se=(0,L.useCallback)(e=>{let t=q||K;if(!t)return;let n={...t,widgets:e};J(n),Y(n)},[q,K,Y]),Ce=(q||K)??null,Z=(0,L.useMemo)(()=>new Set((W||[]).map(e=>e?.name).filter(Boolean)),[W]),Q=q||K,$=(0,L.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 D?(0,R.jsx)(ue,{}):K?(0,R.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,R.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,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=N(($||K).title,p),t=N(K.label,p),n=_({name:K.name,label:t});return(0,R.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:e||n||K.name})})(),(()=>{let e=($||K).description??K.description,t=v({name:K.name,description:N(e,p)});return t?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]}),(0,R.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:[M&&(0,R.jsx)(`div`,{className:`flex items-center gap-1 mr-2`,role:`toolbar`,"aria-label":`Add widgets`,"data-testid":`dashboard-widget-toolbar`,children:B.map(({type:e,label:t,Icon:n})=>(0,R.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>X(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,R.jsx)(T,{className:`h-3 w-3`}),(0,R.jsx)(n,{className:`h-3 w-3`})]},e))}),w&&(0,R.jsxs)(`button`,{type:`button`,onClick:ye,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,R.jsx)(E,{className:`h-3.5 w-3.5`}),p(`common.edit`,{defaultValue:`Edit`})]})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,R.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,R.jsx)(s,{value:{openRecordList:t},children:(0,R.jsx)(de,{schema:$,dataSource:e,designMode:M,selectedWidgetId:F,onWidgetClick:I,onWidgetsReorder:Se,modalHandler:he,scriptHandlers:ge,hideHeaderText:!0})})}),(0,R.jsx)(fe,{open:M&&w,onClose:be,schema:Ce,selectedWidgetId:F,onSelectWidget:I,onSave:Y,onChange:J,onRemoveWidget:xe,name:n,metadataClient:f,onAfterChange:()=>G().catch(()=>{})}),(0,R.jsx)(se,{open:i,sections:[{title:`Dashboard Configuration`,data:$}]})]}),z&&z.schema?.objectName?(0,R.jsx)(ne,{schema:{type:`object-form`,formType:`modal`,objectName:z.schema.objectName,mode:z.schema.mode||`create`,recordId:z.schema.recordId,title:z.schema.title,description:z.schema.description,fields:z.schema.fields,open:!0,onOpenChange:e=>{e||U({success:!1})},onSuccess:e=>{U({success:!0,reload:!0,data:e})},onCancel:()=>{U({success:!1})},showSubmit:!0,showCancel:!0},dataSource:u}):z?(0,R.jsx)(b,{open:!0,onOpenChange:e=>{e||U({success:!1})},children:(0,R.jsxs)(te,{children:[(0,R.jsxs)(g,{children:[(0,R.jsx)(S,{children:z.schema?.title||p(`actionDialog.defaultActionTitle`)}),z.schema?.description&&(0,R.jsx)(d,{children:z.schema.description})]}),(0,R.jsxs)(C,{children:[(0,R.jsx)(O,{variant:`outline`,onClick:()=>U({success:!1}),children:p(`actionDialog.cancel`)}),(0,R.jsx)(O,{onClick:()=>U({success:!0}),children:p(`actionDialog.ok`)})]})]})}):null]}):(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,R.jsxs)(y,{children:[(0,R.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,R.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,R.jsx)(h,{children:p(`empty.dashboardNotFound`)}),(0,R.jsx)(k,{children:p(`empty.dashboardNotFoundDescription`,{name:n})})]})})}export{z as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{R as r,l as i,m as a}from"./vendor-objectstack-C1teU2a6.js";import{$r as o,$t as s,An as c,Bs as l,Bt as u,Ci as d,Cr as f,Es as p,Fa as m,Fn as h,Fs as g,Go as _,Hs as v,Ht as y,In as b,Is as x,Jo as S,Mn as ee,Nn as C,Ns as w,Pn as te,Rs as T,Ut as E,Vr as D,Vt as O,Wi as k,Wt as A,_c as j,ao as M,co as ne,en as re,er as ie,gr as N,is as ae,nn as P,on as F,tn as oe,vc as I,zs as se}from"./ui-components-DXl7VfQF.js";import{G as ce,J as le,K as ue,U as de,V as fe,W as L,Z as R,_ as pe,a as me,g as he,i as ge,j as _e,p as ve,q as ye,r as be,t as xe,y as z}from"./ReportDefaultInspector-B6X1lhzs.js";var B=e(t(),1),V=n();function Se(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 H({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:l,loading:u,allowCustom:d=!0,mono:f,className:m}){let[g,_]=B.useState(!1),[v,y]=B.useState(``),x=r.find(e=>e.value===t),S=x?x.label:t||(u?`Loading…`:i),T=B.useMemo(()=>r.filter(e=>Se(e,v)),[r,v]),E=B.useMemo(()=>{let e=[],t=new Map;for(let n of T){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)}))},[T]),D=v.trim(),O=d&&!!D&&!r.some(e=>e.value===D),k=e=>{n(e),_(!1),y(``)},A=(0,V.jsxs)(s,{open:g,onOpenChange:e=>{_(e),e||y(``)},children:[(0,V.jsx)(oe,{asChild:!0,children:(0,V.jsxs)(N,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":g,disabled:l,className:I(`h-8 w-full justify-between px-2 text-sm font-normal`,m),children:[(0,V.jsx)(`span`,{className:I(`truncate`,f&&`font-mono`,!x&&!t&&`text-muted-foreground`),children:S}),(0,V.jsx)(p,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,V.jsx)(re,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,V.jsxs)(c,{shouldFilter:!1,children:[(0,V.jsx)(te,{value:v,onValueChange:y,placeholder:a}),(0,V.jsxs)(b,{children:[!O&&T.length===0&&(0,V.jsx)(ee,{children:o}),O&&(0,V.jsx)(C,{children:(0,V.jsx)(h,{value:`__custom__${D}`,onSelect:()=>k(D),children:(0,V.jsxs)(`span`,{className:`truncate`,children:[`Use `,(0,V.jsxs)(`span`,{className:`font-mono`,children:[`“`,D,`”`]})]})})}),E.map((e,n)=>(0,V.jsx)(C,{heading:e.heading||void 0,children:e.items.map(e=>(0,V.jsxs)(h,{value:e.value,onSelect:()=>k(e.value),children:[(0,V.jsx)(w,{className:I(`h-3.5 w-3.5`,e.value===t?`opacity-100`:`opacity-0`)}),(0,V.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,V.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,V.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${n}`))]})]})})]});return e?(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(F,{className:`text-xs text-muted-foreground`,children:e}),A]}):A}var Ce=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function U(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 we(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 Te(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 W(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=U(e.label,t),r=_e(e.fields).entries.map(e=>({name:e.name,label:U(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&&Ce.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:we(e.def)}))}}function Ee(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=e.relationships.find(e=>e.name===i),a=t?.referenceTo?n[t.referenceTo]:void 0;if(!a)continue;let o=`${t.label} → ${a.label}`;for(let e of a.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:o})}return r}function G(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>G(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t?!0:Object.values(n).some(e=>e&&typeof e==`object`&&G(e,t))}function K(){let e=R(),[t,n]=B.useState({options:[],loading:!0});return B.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:U(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 De(e,t){let n=R(),r=t.join(`\0`),[i,a]=B.useState({relationships:[],fieldOptions:[],loading:!!e});return B.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=W(i,e),s=new Set;for(let e of r?r.split(`\0`):[]){let t=o.relationships.find(t=>t.name===e);t?.referenceTo&&s.add(t.referenceTo)}let c=await Promise.all([...s].map(async e=>{try{return[e,W(await n.get(`object`,e),e)]}catch{return[e,W(null,e)]}}));if(t)return;let l=Object.fromEntries(c),u=r?r.split(`\0`):[];a({relationships:o.relationships,fieldOptions:Ee(o,u,l),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function Oe(e){let t=R(),[n,r]=B.useState({reports:0,dashboards:0,loading:!!e});return B.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=>G(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>G(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}var q={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:M},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:se},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:T},line:{id:`line`,label:`Line chart`,category:`chart`,icon:l},area:{id:`area`,label:`Area chart`,category:`chart`,icon:v},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:x},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:_},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:g},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:D},table:{id:`table`,label:`Data table`,category:`data`,icon:o},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:S},list:{id:`list`,label:`Record list`,category:`data`,icon:m},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:ae}},ke={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},J=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(q).filter(t=>t.category===e)})),Y=j;function X({onAdd:e,label:t=`Add widget`}){let[n,r]=B.useState(!1),[i,a]=B.useState(``),o=B.useRef(null),s=B.useRef(null);B.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 c=B.useMemo(()=>{let e=i.trim().toLowerCase();return e?J.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):J},[i]);return(0,V.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,V.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,V.jsx)(k,{className:`h-3 w-3`}),t]}),n&&(0,V.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,V.jsx)(d,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,V.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,V.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,V.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):c.map(t=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:ke[t.category]}),t.types.map(t=>(0,V.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,V.jsx)(q[t.id]?.icon??Y,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,V.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,V.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var Ae={io:`input`,unrepresentable:`any`},je=new Set([`widgets`,`label`,`description`,`name`]),Z,Me=!1;function Ne(){if(Z||Me)return Z;try{Z=r(i,Ae)}catch(e){Me=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return Z}var Q;function Pe(){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!je.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 Fe=new Set([`name`,`label`,`description`,`widgets`]);function Ie({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=B.useCallback(e=>z(e,r),[r]),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,l=B.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),u=e=>{let n=le(`widget`,l.map(e=>e?.id).filter(Boolean)),r=q[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:ce(l,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},d=e=>{t({widgets:ye(l,e,null)})},p=(e,n)=>{e!==n&&t({widgets:ue(l,e,n)})},m=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[h,g]=B.useState(null),[_,v]=B.useState(null),{schema:y,form:b}=B.useMemo(()=>me({bundledSchema:Ne(),bundledForm:Pe(),serverSchema:a,excludeFields:Fe,sectionTitle:z(`engine.inspector.moreFields`,r)}),[a,r]);return(0,V.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,V.jsx)(L,{label:o(`engine.inspector.dashboard.label`),value:s,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,V.jsx)(L,{label:o(`engine.inspector.dashboard.description`),value:c,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,V.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(F,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,V.jsx)(ie,{variant:`outline`,className:`text-[10px]`,children:l.length})]}),l.length===0?(0,V.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,V.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let r=q[e?.type]?.icon??Y;return(0,V.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{h!=null&&h!==t&&p(h,t),g(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&h!==null&&h!==t?` border-primary`:``),children:[!n&&(0,V.jsx)(ne,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,V.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>m(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,V.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,V.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>d(t),title:o(`engine.inspector.dashboard.removeWidget`),"aria-label":o(`engine.inspector.dashboard.removeWidget`),children:(0,V.jsx)(f,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,V.jsx)(X,{onAdd:u,label:o(`engine.inspector.add.widget`)})]}),(0,V.jsx)(`div`,{className:`border-t pt-3`,children:y?(0,V.jsx)(ve,{schema:y,form:b,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,V.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var Le=[{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`}],Re=[`count`,`sum`,`avg`,`min`,`max`],ze=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function Be(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 Ve({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,l=c?Be(e,c):null,d=l?.widget??{},p=typeof d.dataset==`string`?d.dataset:``,m=typeof d.object==`string`?d.object:``,h=Array.isArray(d.dimensions)?d.dimensions.filter(e=>typeof e==`string`):[],g=Array.isArray(d.values)?d.values.filter(e=>typeof e==`string`):[],_=be(),v=ge(p||void 0,_),{options:b,loading:x}=K(),{fields:S}=he(m||void 0),ee=B.useMemo(()=>{let e=_.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},[_.datasets,p]),C=B.useMemo(()=>b.map(e=>({value:e.name,label:e.label})),[b]),w=B.useMemo(()=>S.map(e=>({value:e.name,label:e.label,hint:e.type})),[S]),te=B.useMemo(()=>v.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[v.measures]),T=B.useMemo(()=>v.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[v.dimensions]);if(t.kind!==`widget`)return(0,V.jsx)(He,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});if(!l)return(0,V.jsx)(He,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:D,index:k}=l;function j(e){let t=[...s];t[k]={...t[k],...e},n({widgets:t})}function M(e){n({widgets:ue(s,k,e)}),D.id&&i?.({kind:`widget`,id:D.id,label:D.title??void 0})}return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:z(`engine.inspector.widget.kind`,o)}),(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:D.title||t.label||`Widget ${k+1}`})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,V.jsx)(fe,{index:k,total:s.length,onMove:M,upLabel:z(`engine.inspector.reorder.up`,o),downLabel:z(`engine.inspector.reorder.down`,o),disabled:a}),(0,V.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:z(`engine.inspector.widget.close`,o),"aria-label":z(`engine.inspector.widget.close`,o),children:(0,V.jsx)(f,{className:`h-3.5 w-3.5`})})]})]}),(0,V.jsx)($,{id:`widget-title`,label:z(`engine.inspector.widget.title`,o),children:(0,V.jsx)(P,{id:`widget-title`,value:D.title??``,onChange:e=>j({title:e.target.value}),disabled:a})}),(0,V.jsx)($,{id:`widget-type`,label:z(`engine.inspector.widget.type`,o),children:(0,V.jsxs)(u,{value:D.type??`metric`,onValueChange:e=>j({type:e}),disabled:a,children:[(0,V.jsx)(E,{id:`widget-type`,children:(0,V.jsx)(A,{})}),(0,V.jsx)(O,{children:Le.map(e=>(0,V.jsx)(y,{value:e.value,children:e.label},e.value))})]})}),(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,V.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:z(`engine.inspector.widget.datasetSection`,o)}),(0,V.jsxs)($,{id:`widget-dataset`,label:z(`engine.inspector.widget.dataset`,o),children:[(0,V.jsx)(H,{value:p,onCommit:e=>j({dataset:e||void 0}),options:ee,loading:_.loading,placeholder:z(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:z(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,V.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:z(`engine.inspector.widget.datasetHint`,o)})]}),p&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xe,{label:z(`engine.inspector.widget.dimensions`,o),emptyText:z(`engine.inspector.widget.dimensionsHint`,o),names:h,options:T,loading:v.loading,error:v.error,readOnly:a,onCommit:e=>j({dimensions:e})}),(0,V.jsx)(xe,{label:z(`engine.inspector.widget.values`,o),emptyText:z(`engine.inspector.widget.valuesHint`,o),names:g,options:te,loading:v.loading,error:v.error,readOnly:a,onCommit:e=>j({values:e})})]})]}),(0,V.jsx)($,{id:`widget-object`,label:z(`engine.inspector.widget.object`,o),children:(0,V.jsx)(H,{value:D.object??``,onCommit:e=>j({object:e||void 0}),options:C,loading:x,placeholder:`Select an object…`,searchPlaceholder:`Search objects…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-value-field`,label:z(`engine.inspector.widget.valueField`,o),children:(0,V.jsx)(H,{value:D.valueField??``,onCommit:e=>j({valueField:e||void 0}),options:w,placeholder:D.object?`Select a field…`:`e.g. amount`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-category-field`,label:z(`engine.inspector.widget.categoryField`,o),children:(0,V.jsx)(H,{value:D.categoryField??``,onCommit:e=>j({categoryField:e||void 0}),options:w,placeholder:D.object?`Select a field…`:`e.g. status`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-aggregate`,label:z(`engine.inspector.widget.aggregate`,o),children:(0,V.jsxs)(u,{value:D.aggregate??`count`,onValueChange:e=>j({aggregate:e}),disabled:a,children:[(0,V.jsx)(E,{id:`widget-aggregate`,children:(0,V.jsx)(A,{})}),(0,V.jsx)(O,{children:Re.map(e=>(0,V.jsx)(y,{value:e,children:e},e))})]})}),(0,V.jsx)($,{id:`widget-color`,label:z(`engine.inspector.widget.color`,o),children:(0,V.jsx)(pe,{value:D.colorVariant??`default`,onChange:e=>j({colorVariant:e}),disabled:a,options:ze.map(e=>({value:e}))})}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsx)($,{id:`widget-w`,label:z(`engine.inspector.widget.width`,o),children:(0,V.jsx)(P,{id:`widget-w`,type:`number`,min:1,value:D.layout?.w??1,onChange:e=>j({layout:{...D.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,V.jsx)($,{id:`widget-h`,label:z(`engine.inspector.widget.height`,o),children:(0,V.jsx)(P,{id:`widget-h`,type:`number`,min:1,value:D.layout?.h??1,onChange:e=>j({layout:{...D.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,V.jsx)(`div`,{className:`pt-2 border-t`,children:(0,V.jsx)(N,{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(k,1),n({widgets:t}),r()},children:z(`engine.inspector.widget.remove`,o)})})]})}function $({id:e,label:t,children:n}){return(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(F,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function He({message:e,onClose:t,locale:n}){return(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,V.jsx)(`p`,{children:e}),(0,V.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:z(`engine.inspector.widget.close`,n)})]})}export{Te as a,K as c,q as i,H as l,Ie as n,De as o,X as r,Oe as s,Ve as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{W as r,yt as i}from"./framework-CsYa1Kaj.js";var a=e(t(),1),o=n(),s=(0,a.createContext)(null);function c({children:e,user:t={},app:n={},data:c={},features:l={}}){let u=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l,evaluator:new i({user:t,app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}};return{...e,evaluator:new i(e)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{k as r}from"./framework-CsYa1Kaj.js";import{Ft as i,Gt as a,Ii as o,It as s,Jn as c,Ki as l,Lt as u,Mt as d,Pa as f,Pt as p,Qn as m,Rt as h,Tr as g,Xn as _,Yn as v,Zn as y,cs as b,ct as x,dt as S,er as C,ft as w,gr as T,lt as E,nn as D,on as O,ot as k,ps as A,st as j,tt as M,ut as N,ws as P,xs as F}from"./ui-components-DXl7VfQF.js";import"./src-ZyouQodC.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:F,cls:`text-emerald-600 border-emerald-300`},completed:{icon:F,cls:`text-emerald-600 border-emerald-300`},failed:{icon:A,cls:`text-red-600 border-red-300`},error:{icon:A,cls:`text-red-600 border-red-300`},running:{icon:f,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:b,cls:`text-amber-600 border-amber-300`},skipped:{icon:P,cls:`text-muted-foreground`}}[e]??{icon:P,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(C,{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,a]=(0,I.useState)(!0),[s,l]=(0,I.useState)(null),[u,f]=(0,I.useState)(``),[p,h]=(0,I.useState)(0),b=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),a(!1);return}a(!0),l(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),!u&&r.length>0&&f(r[0].name)}catch(e){l(e?.message??String(e))}finally{a(!1)}},[e,u]);(0,I.useEffect)(()=>{b()},[b]);let x=(0,I.useMemo)(()=>t.find(e=>e.name===u)??null,[t,u]);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)(g,{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)(c,{children:[(0,L.jsx)(y,{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)(m,{className:`text-base`,children:`Flow`}),(0,L.jsx)(_,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(T,{variant:`outline`,size:`sm`,onClick:b,disabled:i,children:[(0,L.jsx)(o,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(v,{children:[i&&(0,L.jsx)(d,{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:u,onChange:e=>f(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))})]})]}),x&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:x.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:x.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[i,a]=(0,I.useState)({}),[o,s]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[p,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{a({}),d(null),h(null)},[t?.name]);let g=(e,t)=>a(n=>({...n,[e]:t}));return(0,L.jsxs)(c,{children:[(0,L.jsxs)(y,{className:`pb-3`,children:[(0,L.jsx)(m,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(_,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(v,{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)(C,{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)(w,{id:`var-${e.name}`,checked:i[e.name]===`true`,onCheckedChange:t=>g(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(M,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(D,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(T,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}s(!0),h(null),d(null);try{let a={};for(let e of r){let t=i[e.name];t!==void 0&&(a[e.name]=B(t,e.type))}d(await e.automation.execute(t.name,{params:a})),n?.()}catch(e){h(e?.message??String(e))}finally{s(!1)}},disabled:o,size:`sm`,children:[o?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(l,{className:`h-3.5 w-3.5 mr-2`}),o?`Running…`:`Run Flow`]})}),(u||p)&&(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:[p||u?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(F,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof u?.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono`,children:[u.durationMs,` ms`]})]}),p&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:p}),u&&(0,L.jsx)(V,{data:u})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,l]=(0,I.useState)([]),[g,b]=(0,I.useState)(!0),[w,D]=(0,I.useState)(null),[O,A]=(0,I.useState)(null),[M,P]=(0,I.useState)(null),[F,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`),b(!1);return}b(!0),D(null);try{let n=await e.automation.listRuns(t,{limit:20});l(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){D(e?.message??String(e))}finally{b(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{A(n),P(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);P(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(c,{children:[(0,L.jsx)(y,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(m,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(_,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(T,{variant:`outline`,size:`sm`,onClick:W,disabled:g,children:[g?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(o,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(v,{children:[g&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(d,{className:`h-8 w-full`}),(0,L.jsx)(d,{className:`h-8 w-full`}),(0,L.jsx)(d,{className:`h-8 w-full`})]}),!g&&w&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:w}),!g&&!w&&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.`}),!g&&!w&&r.length>0&&(0,L.jsxs)(k,{children:[(0,L.jsx)(N,{children:(0,L.jsxs)(S,{children:[(0,L.jsx)(E,{children:`Run`}),(0,L.jsx)(E,{children:`Status`}),(0,L.jsx)(E,{children:`Started`}),(0,L.jsx)(E,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(j,{children:r.map(e=>(0,L.jsxs)(S,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(x,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(x,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(x,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(x,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(p,{open:!!O,onOpenChange:e=>{e||(A(null),P(null))},children:(0,L.jsxs)(i,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(u,{className:`p-4 border-b`,children:[(0,L.jsxs)(h,{className:`font-mono text-sm break-all`,children:[`Run `,O]}),(0,L.jsx)(s,{children:M&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:M.status}),typeof M.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono`,children:[M.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(M.startedAt)})]})})]}),(0,L.jsxs)(a,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(d,{className:`h-16 w-full`}),(0,L.jsx)(d,{className:`h-16 w-full`}),(0,L.jsx)(d,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&M&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(M.steps)&&M.steps.length>0?M.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)(C,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(C,{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:M})]})})]})]})})]})}export{H as FlowRunsPage};
@@ -1 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-ClIa1CJA.js";import{d as o}from"./infrastructure-BsIvKvpW.js";import{i as s}from"./framework-CsYa1Kaj.js";import{Ci as ee,Jn as c,Li as l,Mt as u,Qn as d,Xn as f,Yn as p,Zn as m,da as h,er as g,gr as _,nn as v,ti as y,ws as te,xi as ne,xs as b}from"./ui-components-DXl7VfQF.js";import{n as re}from"./assistantBus-BMrg1uLy.js";import{a as x,b as ie,d as ae,f as S,l as C,o as oe,u as se}from"./marketplaceApi-DL8PegzV.js";import{n as w,t as T}from"./usePackageL10n-DIEe85Ot.js";import{t as ce}from"./MarketplaceAccessDenied-C3bv4Vmg.js";var E=t({MarketplacePage:()=>A}),D=e(n(),1),O=i();function k(){let{language:e,t}=s();return n=>{if(!n)return``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=Math.floor((Date.now()-r.getTime())/864e5);if(i<1)return t(`marketplace.relativeTime.today`);try{let t=new Intl.RelativeTimeFormat(e||`en`,{numeric:`auto`});return i<30?t.format(-i,`day`):i<365?t.format(-Math.floor(i/30),`month`):t.format(-Math.floor(i/365),`year`)}catch{return i<30?t(`marketplace.relativeTime.daysAgo`,{count:i}):i<365?t(`marketplace.relativeTime.monthsAgo`,{count:Math.floor(i/30)}):t(`marketplace.relativeTime.yearsAgo`,{count:Math.floor(i/365)})}}}function A(){let e=a(),{appName:t}=r(),n=o(),{t:i,language:E}=s(),A=k(),j=t?`/apps/${t}`:``,[M,N]=(0,D.useState)([]),[P,F]=(0,D.useState)(!0),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(``),[H,U]=(0,D.useState)([]),[W,le]=(0,D.useState)([]),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(null),[Y,ue]=(0,D.useState)(new Set),de=(0,D.useMemo)(()=>{let e=new Map;for(let t of H)e.set(t.manifestId,t);return e},[H]),X=async()=>{F(!0),L(null);try{let[e,t,n,r]=await Promise.all([ae({limit:100}),se(),S(),C()]);N(e.items??[]),U(t),le(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);ue(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,D.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{ie().features.installLocal?await x({packageId:e.manifest_id||e.id,versionId:`latest`}):await oe({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:i(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X(),re()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,D.useMemo)(()=>{let e=new Set;for(let t of M)t.category&&e.add(t.category);return Array.from(e).sort()},[M]),Q=e=>{let t=`marketplace.category.${e}`,n=i(t,{defaultValue:e});return n===t?e:n},$=(0,D.useMemo)(()=>{let e=R.trim().toLowerCase();return M.filter(t=>{if(B&&t.category!==B)return!1;if(!e)return!0;let n=T(t,E);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,E]);return n?(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(y,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.title`)})]}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:i(`marketplace.subtitle`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,O.jsx)(ne,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?i(`marketplace.installedCount`,{count:H.length}):i(`marketplace.installed`)]}),(0,O.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,O.jsx)(l,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(ee,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,O.jsx)(v,{value:R,onChange:e=>z(e.target.value),placeholder:i(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":i(`marketplace.searchAria`)})]}),Z.length>0&&(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,O.jsx)(_,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:i(`marketplace.all`)}),Z.map(e=>(0,O.jsx)(_,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,O.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,O.jsx)(te,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`font-medium text-destructive`,children:i(`marketplace.load.failed`)}),(0,O.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:i(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,O.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(y,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,O.jsx)(g,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,O.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${q.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:q.text}),(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:W.map(e=>{let t=Y.has(e.manifest_id);return(0,O.jsxs)(c,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(d,{className:`text-base truncate`,children:e.display_name}),(0,O.jsx)(f,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,O.jsx)(g,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,O.jsxs)(p,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||i(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,O.jsxs)(g,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(h,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,O.jsx)(`div`,{className:`ml-auto`,children:t?(0,O.jsxs)(g,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,O.jsx)(_,{size:`sm`,onClick:()=>void fe(e),disabled:G===e.id,children:G===e.id?i(`marketplace.org.installing`,{defaultValue:`Installing…`}):i(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,O.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,O.jsxs)(c,{children:[(0,O.jsxs)(m,{className:`pb-2`,children:[(0,O.jsx)(u,{className:`h-10 w-10 rounded-lg mb-2`}),(0,O.jsx)(u,{className:`h-5 w-3/4`}),(0,O.jsx)(u,{className:`h-4 w-1/2 mt-1`})]}),(0,O.jsx)(p,{children:(0,O.jsx)(u,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,O.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?i(`marketplace.noApprovedYet`):i(`marketplace.noMatchFilters`)}):(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:$.map(t=>{let n=de.get(t.manifest_id),r=T(t,E);return(0,O.jsxs)(c,{className:`cursor-pointer transition-colors hover:bg-accent/50 flex flex-col`,onClick:()=>e(`${j}/system/marketplace/${t.id}`),role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(`${j}/system/marketplace/${t.id}`))},"data-testid":`marketplace-card-${t.manifest_id}`,children:[(0,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(d,{className:`text-base truncate`,children:r.displayName}),(0,O.jsx)(f,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,O.jsx)(g,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,O.jsxs)(p,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||i(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,O.jsxs)(g,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,O.jsxs)(g,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(h,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,O.jsx)(g,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,O.jsx)(ce,{})}export{E as t};
@@ -1 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,l as i,p as a,t as o,u as s}from"./vendor-react-ClIa1CJA.js";import{f as c,m as l}from"./infrastructure-BsIvKvpW.js";import{A as u,F as d,H as f,N as p,i as m,k as h}from"./framework-CsYa1Kaj.js";import{Do as g,H as _,R as v,Zi as y,wc as b,z as x}from"./ui-components-DXl7VfQF.js";import{r as S}from"./vendor-ui-utils-C92Fl7BT.js";import"./MetadataProvider-BO_KcC86.js";import{r as C}from"./ExpressionProvider-C2XzKImE.js";import{a as w,i as T,o as E,r as D,s as O}from"./RecordDetailView-ANMXqsUj.js";import{n as k,r as A,t as j}from"./MetadataInspector-D9KL7Kgi.js";import{t as M}from"./InterfaceListPage-Cfv6Lkis.js";var N=e(n(),1),P=o(),F={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function I(e){let{dataSource:t,objects:n,objectName:r,onRefresh:i}=e,a=s(),{user:o,activeOrganization:u}=c(),{fieldLabel:f,fieldOptionLabel:p,actionParamText:m,actionParamOptionLabel:h,actionDescription:g}=b(),_=(0,N.useMemo)(()=>r?n?.find(e=>e.name===r):void 0,[n,r]),v=r||_?.name,y=(0,N.useCallback)(()=>{i?.()},[i]),x=d({dataSource:t,onUndo:()=>{y(),S.success(`Change undone`)}}),[C,k]=(0,N.useState)({open:!1,message:``}),[A,j]=(0,N.useState)({open:!1,params:[]}),[M,I]=(0,N.useState)({open:!1}),[L,R]=(0,N.useState)(null),z=(0,N.useRef)(new Set),B=(0,N.useCallback)((e,t)=>new Promise(n=>{I({open:!0,spec:e,data:t,resolve:n})}),[]),V=(0,N.useCallback)((e,t)=>new Promise(n=>{k({open:!0,message:e,options:t,resolve:n})}),[]),H=(0,N.useCallback)((e,t)=>new Promise(i=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=D(e,{objectName:r||_?.name||``,objects:n||[],fieldLabel:f,fieldOptionLabel:p,row:a}),s=r||_?.name;j({open:!0,params:o.map(e=>({...e,label:m(s,t?.name,e.name,`label`,e.label)??e.label,placeholder:m(s,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:m(s,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:h(s,t?.name,e.name,n.value,n.label)})):e.options})),title:t?.label||t?.title,description:g(s,t?.name,t?.description),resolve:i})}),[r,_,n,f,p,m,h]),U=o?{id:o.id,name:o.name,avatar:o.image,isPlatformAdmin:o?.isPlatformAdmin??!1}:F,W=(0,N.useCallback)((e,t)=>{if(t?.type===`error`){S.error(e);return}if(t?.undo){S.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{x.undo()}}});return}S.success(e,{duration:t?.duration})},[x]),G=(0,N.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):a(e)},[a]),K=(0,N.useMemo)(()=>l(),[]),q=(0,N.useCallback)(async e=>{try{let n=e.target||e.name,r=e.params||{},i=typeof n==`string`?n:``;if(i.startsWith(`/`)||/^https?:\/\//i.test(i)){let t={...r},n=t._rowRecord;delete t._rowRecord;let a=i;n&&/\{[a-z_][a-z0-9_]*\}/i.test(a)&&(a=a.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let r=n[t];return r==null?``:encodeURIComponent(String(r))}));let o=a.startsWith(`http`)?a:`${a}`,s=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,c=s?{[s]:t}:{...t};if(n&&e.recordIdParam){let t=n[e.recordIdField||`id`];t!=null&&(c[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(a)&&!c.organizationId&&u?.id&&(c.organizationId=u.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(c,e.bodyExtra);let l=(e.method||`POST`).toUpperCase(),d={method:l,headers:{"Content-Type":`application/json`},credentials:`include`};l!==`GET`&&l!==`DELETE`&&(d.body=JSON.stringify(c));let f=await K(o,d);if(!f.ok){let e=`HTTP ${f.status}`;try{let t=await f.json();e=t?.error||t?.message||e}catch{}return{success:!1,error:e}}let p=await f.json().catch(()=>({}));return e.refreshAfter!==!1&&y(),{success:!0,data:p,reload:e.refreshAfter!==!1}}let a=e.objectName||v,o=r._rowRecord,s={...r};delete s._rowRecord;let c=s.recordId??o?.[e.recordIdField||`id`];delete s.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(s,e.bodyExtra),a&&typeof t?.execute==`function`?await t.execute(a,n,s):a&&c&&Object.keys(s).length>0&&typeof t?.update==`function`&&await t.update(a,c,s);let l;if(e.undoable&&a&&c&&o&&Object.keys(s).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(s))t[e]=o[e]??null;l={id:`undo-${a}-${c}-${Date.now()}`,type:`update`,objectName:a,recordId:String(c),timestamp:Date.now(),description:e.label||`Undo ${a}`,undoData:t,redoData:{...s}}}let d=e.refreshAfter!==!1;return d&&y(),{success:!0,reload:d,undo:l}}catch(e){return{success:!1,error:e.message}}},[t,v,K,u,y]),J=(0,N.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No flow target provided for flow action`};try{let r={...e.params||{}},i=r._rowRecord;delete r._rowRecord;let a=r.recordId??i?.id;if(a==null){let e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)a=e[0]?.id;else if(e.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`}}a!=null&&r.recordId==null&&(r.recordId=a);let o=await K(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||v,params:r})}),s=await o.json().catch(()=>null);if(!o.ok||s&&s.success===!1)return{success:!1,error:s?.error||`Flow "${n}" failed (HTTP ${o.status})`};let c=s?.data??{};if(c.status===`paused`&&c.screen)return R({flowName:n,runId:c.runId,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&y(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[K,v,y]),Y=(0,N.useCallback)(async(e,t)=>{let n=e.target||e.name;if(!n)return{success:!1,error:`No action target provided`};let r=e.params&&!Array.isArray(e.params)?{...e.params}:{},i=r._rowRecord;delete r._rowRecord;let a=e.recordIdField||`id`,o=r.recordId??i?.[a];if(o==null){let e=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(e.length===1)o=e[0]?.[a];else if(e.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`}}let s=`${n}:${o??``}`;if(z.current.has(s))return{success:!1,error:`Action already in progress`};z.current.add(s);let c=null;if(e.opensInNewTab)try{c=window.open(`about:blank`,`_blank`),c&&(c.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>`),c.document.close())}catch{c=null}try{let t=typeof e.newTabUrl==`string`?e.newTabUrl:``;if(e.opensInNewTab&&t){if(o==null){if(c)try{c.close()}catch{}return{success:!1,error:`This action runs on a single record — no record id available.`}}let n=`${window.location.origin}${t.replace(`{recordId}`,encodeURIComponent(String(o)))}`;if(c)try{c.location.href=n}catch{try{c.close()}catch{}window.location.href=n}else{let e=null;try{e=window.open(n,`_blank`)}catch{e=null}e||S(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&y(),{success:!0}}let i=e.objectName||v||`global`,a=await K(`/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(n)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:o,params:r})}),s=await a.json().catch(()=>null);if(!a.ok||s&&s.success===!1){let e=s?.error||`Action "${n}" failed (HTTP ${a.status})`;if(c)try{c.close()}catch{}return S.error(e),{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&y();let u=s?.data,d=u&&typeof u==`object`&&typeof u.redirectUrl==`string`?u.redirectUrl:null;if(d)if(c)try{c.location.href=d}catch{try{c.close()}catch{}window.location.href=d}else{let e=null;try{e=window.open(d,`_blank`)}catch{e=null}e||S(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(d,`_blank`)}catch{window.location.href=d}}},duration:1e4})}else if(c)try{c.close()}catch{}return{success:!0,data:u,reload:l}}catch(e){if(c)try{c.close()}catch{}let t=e.message;return S.error(t),{success:!1,error:t}}finally{z.current.delete(s)}},[K,v,y]);return{confirmHandler:V,toastHandler:W,navigateHandler:G,paramCollectionHandler:H,resultDialogHandler:B,apiHandler:q,flowHandler:J,serverActionHandler:Y,authFetch:K,actionProviderProps:(0,N.useMemo)(()=>({context:{...r?{objectName:r}:{},user:U,apiBase:``,activeOrganization:u?{id:u.id,slug:u.slug,name:u.name}:null},onConfirm:V,onToast:W,onNavigate:G,onParamCollection:H,onResultDialog:B,handlers:{api:q,flow:J,script:Y,modal:Y}}),[r,U,u,V,W,G,H,B,q,J,Y]),dialogs:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(O,{state:C,onOpenChange:e=>{e||k({open:!1,message:``})}}),(0,P.jsx)(E,{state:A,onOpenChange:e=>{e||j({open:!1,params:[]})}}),(0,P.jsx)(w,{state:M,onAcknowledge:()=>{M.resolve?.(),I({open:!1})}}),(0,P.jsx)(T,{state:L,authFetch:K,baseUrl:``,dataSource:t,objects:n,onClose:()=>R(null),onComplete:()=>{R(null),y()}})]})}}function L({children:e,...t}){let n=I(t);return(0,P.jsxs)(p,{...n.actionProviderProps,children:[e,n.dialogs]})}var R=t({PageView:()=>z});function z(){let{t:e}=m(),{pageName:t}=r(),[n]=a(),{showDebug:o}=k(),l=s(),d=i(),{user:p}=c(),b=p?.role===`admin`,{pages:S,objects:w}=u(),{app:T}=C(),E=h(),[D,O]=(0,N.useState)(0),F=A(S,t,T?._packageId);if(!F)return(0,P.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,P.jsxs)(v,{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)(g,{className:`h-6 w-6 text-muted-foreground`})}),(0,P.jsx)(_,{children:e(`empty.pageNotFound`)}),(0,P.jsx)(x,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})});let I=Object.fromEntries(n.entries()),R=d.pathname.match(/\/apps\/([^/]+)/)?.[1],z=b&&!!R&&!!t;return(0,P.jsx)(L,{dataSource:E,objects:w,onRefresh:()=>O(e=>e+1),children:(0,P.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,P.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[z&&(0,P.jsx)(`button`,{type:`button`,onClick:()=>{z&&l(`/apps/${R}/metadata/page/${encodeURIComponent(t)}`)},className:`absolute right-3 top-3 z-30 inline-flex h-7 w-7 items-center justify-center rounded-md border border-input bg-background/90 text-muted-foreground shadow-sm backdrop-blur hover:bg-accent hover:text-accent-foreground`,"data-testid":`page-edit-in-studio-button`,title:e(`common.editInStudio`,{defaultValue:`Edit in studio`}),"aria-label":e(`common.editInStudio`,{defaultValue:`Edit in studio`}),children:(0,P.jsx)(y,{className:`h-3.5 w-3.5`})}),F.interfaceConfig?.source?(0,P.jsx)(M,{page:F,reserveEditAffordance:z},D):(0,P.jsx)(f,{schema:{...F,type:F.type||`page`,context:{...F.context,params:I,refreshKey:D}}},D)]}),(0,P.jsx)(j,{open:o,sections:[{title:`Page Configuration`,data:F}]})]})})}export{I as n,R as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{f as r,o as i}from"./infrastructure-BsIvKvpW.js";import{Cr as a,Jn as o,Mr as s,Na as c,Pa as l,Pr as u,Qn as d,Xn as f,Yn as p,Zn as m,ar as h,b as g,er as _,gr as v,ir as y,nn as b,nr as x,on as S,rr as C,tr as w,ws as T,xs as E}from"./ui-components-DXl7VfQF.js";var D=e(t(),1),O=n();function k(){let{user:e,updateUser:t,isLoading:n,changePassword:c,setInitialPassword:k,hasLocalPassword:j}=r(),{upload:M}=g(),[N,P]=(0,D.useState)(e?.name??``),[F,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(null),z=(0,D.useRef)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null);return(0,D.useEffect)(()=>{P(e?.name??``)},[e?.name]),e?(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Profile`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage your account settings`})]}),(0,O.jsx)(o,{children:(0,O.jsxs)(p,{className:`pt-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(w,{className:`h-16 w-16`,children:[(0,O.jsx)(C,{src:e.image??void 0,alt:e.name??`User`}),(0,O.jsx)(x,{className:`text-lg bg-primary text-primary-foreground`,children:i(e)})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:e.name??`User`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:e.email}),(0,O.jsx)(_,{variant:`secondary`,className:`mt-1`,children:e.role??`member`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0`,children:[(0,O.jsx)(`input`,{ref:z,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];if(z.current&&(z.current.value=``),n){V(!0),U(null);try{await t({image:(await M(n)).url})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},"data-testid":`profile-avatar-file`}),(0,O.jsxs)(v,{type:`button`,variant:`outline`,size:`sm`,disabled:B,onClick:()=>z.current?.click(),"data-testid":`profile-avatar-upload-btn`,children:[B?(0,O.jsx)(l,{className:`mr-2 h-4 w-4 animate-spin`}):(0,O.jsx)(u,{className:`mr-2 h-4 w-4`}),e.image?`Replace`:`Upload`]}),e.image&&(0,O.jsxs)(v,{type:`button`,variant:`ghost`,size:`sm`,disabled:B,onClick:async()=>{V(!0),U(null);try{await t({image:null})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}},"data-testid":`profile-avatar-remove-btn`,children:[(0,O.jsx)(a,{className:`mr-2 h-4 w-4`}),`Remove`]})]})]}),H&&(0,O.jsxs)(y,{variant:`destructive`,className:`mt-4`,children:[(0,O.jsx)(T,{className:`h-4 w-4`}),(0,O.jsx)(h,{children:H})]})]})}),(0,O.jsxs)(o,{children:[(0,O.jsxs)(m,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(s,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(d,{className:`text-base sm:text-lg`,children:`Personal Information`})]}),(0,O.jsx)(f,{children:`Update your name and view account details`})]}),(0,O.jsx)(p,{children:(0,O.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),R(null),I(!1);try{await t({name:N}),I(!0)}catch(e){R(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[L&&(0,O.jsxs)(y,{variant:`destructive`,children:[(0,O.jsx)(T,{className:`h-4 w-4`}),(0,O.jsx)(h,{children:L})]}),F&&(0,O.jsxs)(y,{children:[(0,O.jsx)(E,{className:`h-4 w-4 text-green-600`}),(0,O.jsx)(h,{className:`text-green-800 dark:text-green-400`,children:`Profile updated successfully.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(S,{htmlFor:`profile-name`,children:`Name`}),(0,O.jsx)(b,{id:`profile-name`,type:`text`,value:N,onChange:e=>P(e.target.value),required:!0,"aria-required":`true`,disabled:n})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(S,{htmlFor:`profile-email`,children:`Email`}),(0,O.jsx)(b,{id:`profile-email`,type:`email`,value:e.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Email cannot be changed.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(S,{children:`Role`}),(0,O.jsx)(b,{type:`text`,value:e.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,O.jsx)(v,{type:`submit`,disabled:n,className:`w-full sm:w-auto`,children:n?`Saving…`:`Save Changes`})]})})]}),(0,O.jsx)(A,{changePassword:c,setInitialPassword:k,hasLocalPassword:j})]}):null}function A({changePassword:e,setInitialPassword:t,hasLocalPassword:n,highlight:r,onPasswordSet:i}){let[a,s]=(0,D.useState)(null),[l,u]=(0,D.useState)(``),[g,_]=(0,D.useState)(``),[x,C]=(0,D.useState)(``),[w,k]=(0,D.useState)(!1),[A,j]=(0,D.useState)(null),[M,N]=(0,D.useState)(null);(0,D.useEffect)(()=>{let e=!1;return n().then(t=>{e||s(t)}).catch(()=>{e||s(!1)}),()=>{e=!0}},[n]);let P=()=>{u(``),_(``),C(``)},F=async n=>{if(n.preventDefault(),j(null),N(null),g.length<8){j(`Password must be at least 8 characters`);return}if(g!==x){j(`Passwords do not match`);return}k(!0);try{if(a){if(!l){j(`Enter your current password`),k(!1);return}await e(l,g),N(`Password changed.`)}else await t(g),N(`Local password set. You can now sign in with email and password on this environment.`),s(!0),i?.();P()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},I=a===null;return(0,O.jsxs)(o,{className:r?`ring-2 ring-amber-300 dark:ring-amber-700`:void 0,children:[(0,O.jsxs)(m,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(c,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(d,{className:`text-base sm:text-lg`,children:a?`Change Password`:`Set Local Password`})]}),(0,O.jsx)(f,{children:a?`Update the password you use to sign in to this environment.`:`You signed in via single sign-on. Set a local password to also sign in with email and password on this environment.`})]}),(0,O.jsx)(p,{children:(0,O.jsxs)(`form`,{onSubmit:F,className:`space-y-4 max-w-md`,children:[a&&(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(S,{htmlFor:`current-password`,children:`Current password`}),(0,O.jsx)(b,{id:`current-password`,type:`password`,autoComplete:`current-password`,value:l,onChange:e=>u(e.target.value),disabled:w||I,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(S,{htmlFor:`new-password`,children:a?`New password`:`Password`}),(0,O.jsx)(b,{id:`new-password`,type:`password`,autoComplete:`new-password`,value:g,onChange:e=>_(e.target.value),disabled:w||I,minLength:8,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(S,{htmlFor:`confirm-password`,children:`Confirm password`}),(0,O.jsx)(b,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,value:x,onChange:e=>C(e.target.value),disabled:w||I,minLength:8,required:!0})]}),A&&(0,O.jsxs)(y,{variant:`destructive`,children:[(0,O.jsx)(T,{className:`h-4 w-4`}),(0,O.jsx)(h,{children:A})]}),M&&(0,O.jsxs)(y,{children:[(0,O.jsx)(E,{className:`h-4 w-4`}),(0,O.jsx)(h,{children:M})]}),(0,O.jsx)(v,{type:`submit`,disabled:w||I,className:`w-full sm:w-auto`,children:w?`Saving…`:a?`Change password`:`Set password`})]})})]})}export{k as ProfilePage};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{k as r}from"./framework-CsYa1Kaj.js";import{Bn as i,Bo as a,Hn as o,Ii as ee,Jn as te,Qn as ne,Rn as s,Un as c,Va as l,Vn as u,Wi as re,Xn as ie,Yn as ae,Zn as oe,bi as se,ct as d,dt as f,er as ce,es as le,gr as p,is as ue,lt as m,nn as h,on as g,ot as de,st as fe,ut as pe,zi as me,zn as _}from"./ui-components-DXl7VfQF.js";import{r as v}from"./vendor-ui-utils-C92Fl7BT.js";import"./src-ZyouQodC.js";var y=e(t(),1),b=n();function x(e){return e?e.replace(/^\/+/,``).match(/^forms\/([^/?#]+)/i)?.[1]??null:null}function S(e){return e.trim().toLowerCase().replace(/[^a-z0-9-_]+/g,`-`).replace(/^-+|-+$/g,``)}function C(){let e=r()?.getClient?.(),[t,n]=(0,y.useState)([]),[C,he]=(0,y.useState)([]),[w,T]=(0,y.useState)(!0),[E,D]=(0,y.useState)(null),[ge,O]=(0,y.useState)(!1),[k,A]=(0,y.useState)(``),[j,M]=(0,y.useState)(``),[N,P]=(0,y.useState)(!1),[_e,F]=(0,y.useState)(!1),[I,L]=(0,y.useState)(null),[R,z]=(0,y.useState)(``),[B,V]=(0,y.useState)(`thank-you`),[H,U]=(0,y.useState)(``),[W,G]=(0,y.useState)(``),[K,q]=(0,y.useState)(``),[J,Y]=(0,y.useState)(!1),X=async()=>{if(!e?.meta?.getItems){D(`meta.getItems is not available on this client`),T(!1);return}T(!0),D(null);try{let t=await e.meta.getItems(`view`),r=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[],i=[],a=[];for(let e of r){let t=e?.spec??e;if(!(t?.sections||t?.groups||t?.form||t?.type===`simple`||t?.type===`tabbed`||t?.type===`wizard`||t?.viewType===`form`))continue;let n=t?.sharing,r=n?.publicLink,o=x(r);n?.allowAnonymous&&o&&r?i.push({name:t?.name??e?.name,label:t?.label,object:t?.object,slug:o,publicLink:r,updatedAt:e?.updatedAt??e?.updated_at,spec:t}):a.push({name:t?.name??e?.name,label:t?.label,object:t?.object,spec:t})}n(i),he(a)}catch(e){D(e?.message??String(e))}finally{T(!1)}};(0,y.useEffect)(()=>{X()},[]);let ve=typeof window<`u`?window.location.origin:``,Z=e=>`${ve}/console/f/${e}`,ye=e=>`<iframe src="${Z(e)}" width="100%" height="640" frameborder="0" style="border:0;"></iframe>`,be=e=>`<iframe\n src={\`${Z(e)}\`}\n title="Public form"\n style={{ width: '100%', height: 640, border: 0 }}\n/>`,Q=async(e,t)=>{try{await navigator.clipboard.writeText(t),v.success(`Copied ${e}`)}catch{v.error(`Clipboard unavailable`)}},xe=async()=>{if(!k||!j)return;let t=C.find(e=>e.name===k);if(!t)return;let n=S(j);if(!n){v.error(`Invalid slug`);return}let r={...t.spec,sharing:{...t.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${n}`}};P(!0);try{await e.meta.saveItem(`view`,t.name,r),v.success(`Published ${t.name}`),O(!1),A(``),M(``),await X()}catch(e){v.error(`Publish failed: ${e?.message??e}`)}finally{P(!1)}},Se=e=>{L(e),z(e.slug);let t=e.spec?.submitBehavior;V(t?.kind??`thank-you`),U(t?.title??``),G(t?.message??``),q(t?.url??``),F(!0)},Ce=async()=>{if(!I)return;let t=S(R);if(!t){v.error(`Invalid slug`);return}let n;switch(B){case`thank-you`:n={kind:`thank-you`},H&&(n.title=H),W&&(n.message=W);break;case`redirect`:if(!K){v.error(`Redirect URL is required`);return}n={kind:`redirect`,url:K};break;case`continue`:case`next-record`:n={kind:B};break}let r={...I.spec,sharing:{...I.spec.sharing??{},enabled:!0,allowAnonymous:!0,publicLink:`/forms/${t}`},submitBehavior:n};Y(!0);try{await e.meta.saveItem(`view`,I.name,r),v.success(`Saved ${I.name}`),F(!1),L(null),await X()}catch(e){v.error(`Save failed: ${e?.message??e}`)}finally{Y(!1)}},$=t.length>0;return(0,b.jsxs)(`div`,{className:`flex flex-1 flex-col gap-4 p-4 md:p-6 overflow-auto`,children:[(0,b.jsxs)(te,{children:[(0,b.jsxs)(oe,{className:`flex flex-row items-start justify-between gap-4 space-y-0`,children:[(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(ne,{className:`flex items-center gap-2`,children:[(0,b.jsx)(me,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(ie,{children:`Forms anyone can fill out — no login required. Publish a form to get a shareable link; submissions land directly in the bound object.`})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsxs)(p,{variant:`default`,size:`sm`,onClick:()=>O(!0),disabled:C.length===0,title:C.length===0?`No non-public FormViews available`:`Publish a FormView`,children:[(0,b.jsx)(re,{className:`h-3.5 w-3.5`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Publish form…`})]}),(0,b.jsxs)(p,{variant:`outline`,size:`sm`,onClick:X,disabled:w,children:[(0,b.jsx)(ee,{className:`h-3.5 w-3.5 ${w?`animate-spin`:``}`}),(0,b.jsx)(`span`,{className:`ml-1.5`,children:`Refresh`})]})]})]}),(0,b.jsxs)(ae,{children:[E&&(0,b.jsx)(`div`,{className:`mb-3 rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:E}),!w&&!$&&(0,b.jsxs)(`div`,{className:`rounded-md border border-dashed p-6 text-center text-sm text-muted-foreground`,children:[(0,b.jsx)(`p`,{className:`font-medium text-foreground`,children:`No public forms yet`}),(0,b.jsxs)(`p`,{className:`mt-1`,children:[`Click `,(0,b.jsx)(`strong`,{children:`Publish form…`}),` above to share an existing form, or build a new one in Views & Apps and mark it public.`]})]}),$&&(0,b.jsxs)(de,{children:[(0,b.jsx)(pe,{children:(0,b.jsxs)(f,{children:[(0,b.jsx)(m,{children:`Name`}),(0,b.jsx)(m,{children:`Object`}),(0,b.jsx)(m,{children:`Slug`}),(0,b.jsx)(m,{children:`Public URL`}),(0,b.jsx)(m,{className:`text-right`,children:`Actions`})]})}),(0,b.jsx)(fe,{children:t.map(e=>{let t=Z(e.slug);return(0,b.jsxs)(f,{children:[(0,b.jsx)(d,{children:(0,b.jsxs)(`div`,{className:`flex flex-col`,children:[(0,b.jsx)(`span`,{className:`font-medium`,children:e.label??e.name}),(0,b.jsx)(`code`,{className:`text-xs text-muted-foreground`,children:e.name})]})}),(0,b.jsx)(d,{children:e.object?(0,b.jsx)(ce,{variant:`secondary`,children:e.object}):(0,b.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})}),(0,b.jsx)(d,{children:(0,b.jsx)(`code`,{className:`text-xs`,children:e.slug})}),(0,b.jsx)(d,{children:(0,b.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-primary underline-offset-2 hover:underline`,children:[t,(0,b.jsx)(a,{className:`h-3 w-3`})]})}),(0,b.jsx)(d,{className:`text-right`,children:(0,b.jsxs)(`div`,{className:`inline-flex gap-1`,children:[(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Copy URL`,onClick:()=>Q(`URL`,t),children:(0,b.jsx)(l,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Copy <iframe> embed`,onClick:()=>Q(`iframe snippet`,ye(e.slug)),children:(0,b.jsx)(ue,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Copy React snippet`,onClick:()=>Q(`React snippet`,be(e.slug)),children:(0,b.jsx)(le,{className:`h-3.5 w-3.5`})}),(0,b.jsx)(p,{variant:`ghost`,size:`sm`,title:`Edit sharing & post-submit behavior`,onClick:()=>Se(e),children:(0,b.jsx)(se,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(s,{open:ge,onOpenChange:O,children:(0,b.jsxs)(_,{className:`sm:max-w-md`,children:[(0,b.jsxs)(o,{children:[(0,b.jsx)(c,{children:`Publish a FormView`}),(0,b.jsxs)(i,{children:[`Pick an existing FormView and turn it into a public form by enabling `,(0,b.jsx)(`code`,{className:`text-xs`,children:`sharing.allowAnonymous`}),` `,`and setting `,(0,b.jsx)(`code`,{className:`text-xs`,children:`publicLink`}),`.`]})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`publish-view`,children:`FormView`}),(0,b.jsxs)(`select`,{id:`publish-view`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:k,onChange:e=>A(e.target.value),children:[(0,b.jsx)(`option`,{value:``,children:`— Select a FormView —`}),C.map(e=>(0,b.jsxs)(`option`,{value:e.name,children:[e.label??e.name,` (`,e.name,`) `,e.object?`· ${e.object}`:``]},e.name))]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`publish-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(h,{id:`publish-slug`,placeholder:`contact-us`,value:j,onChange:e=>M(e.target.value)})]}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Lowercase letters, digits, dashes and underscores only.`})]})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(p,{variant:`ghost`,onClick:()=>O(!1),disabled:N,children:`Cancel`}),(0,b.jsx)(p,{onClick:xe,disabled:N||!k||!j,children:N?`Publishing…`:`Publish`})]})]})}),(0,b.jsx)(s,{open:_e,onOpenChange:F,children:(0,b.jsxs)(_,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(o,{children:[(0,b.jsx)(c,{children:I?`Edit ${I.label??I.name}`:`Edit form`}),(0,b.jsx)(i,{children:`Configure the public URL and what happens after submit.`})]}),(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-slug`,children:`URL slug`}),(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap`,children:`/console/f/`}),(0,b.jsx)(h,{id:`edit-slug`,value:R,onChange:e=>z(e.target.value)})]})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-behavior`,children:`After submit`}),(0,b.jsxs)(`select`,{id:`edit-behavior`,className:`flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm`,value:B,onChange:e=>V(e.target.value),children:[(0,b.jsx)(`option`,{value:`thank-you`,children:`Show a thank-you panel`}),(0,b.jsx)(`option`,{value:`redirect`,children:`Redirect to a URL`}),(0,b.jsx)(`option`,{value:`continue`,children:`Reset for another response`}),(0,b.jsx)(`option`,{value:`next-record`,children:`Advance to next record (internal queues)`})]})]}),B===`thank-you`&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-tytitle`,children:`Title`}),(0,b.jsx)(h,{id:`edit-tytitle`,placeholder:`Thanks!`,value:H,onChange:e=>U(e.target.value)})]}),(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-tymsg`,children:`Message`}),(0,b.jsx)(h,{id:`edit-tymsg`,placeholder:`Your submission has been received.`,value:W,onChange:e=>G(e.target.value)})]})]}),B===`redirect`&&(0,b.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,b.jsx)(g,{htmlFor:`edit-url`,children:`Redirect URL`}),(0,b.jsx)(h,{id:`edit-url`,type:`url`,placeholder:`https://example.com/thanks`,value:K,onChange:e=>q(e.target.value)})]})]}),(0,b.jsxs)(u,{children:[(0,b.jsx)(p,{variant:`ghost`,onClick:()=>F(!1),disabled:J,children:`Cancel`}),(0,b.jsx)(p,{onClick:Ce,disabled:J||!R,children:J?`Saving…`:`Save`})]})]})})]})}export{C as PublicFormsPage};
@@ -1,9 +0,0 @@
1
- import{o as e,r as t,t as n}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as r,f as i,l as a,r as o,t as s,u as c}from"./vendor-react-ClIa1CJA.js";import{f as l,m as u}from"./infrastructure-BsIvKvpW.js";import{E as d,F as f,H as p,N as m,_ as h,g,i as _,m as v,xt as y}from"./framework-CsYa1Kaj.js";import{Bn as b,Bt as x,Cc as S,H as C,Hn as w,Ht as T,Jo as ee,Ns as te,R as ne,Rn as E,Ro as D,Un as O,Ut as k,Vn as re,Vt as ie,Wt as ae,cr as oe,dr as se,es as ce,fr as le,gr as A,js as ue,lr as de,mr as fe,nn as pe,on as me,pr as he,qn as ge,sr as _e,tt as ve,ur as ye,wc as be,x as xe,z as Se,zn as j,zo as M}from"./ui-components-DXl7VfQF.js";import{r as N}from"./vendor-ui-utils-C92Fl7BT.js";import{t as Ce}from"./plugin-form-sm04IEZv.js";import{i as we,n as Te,o as Ee,t as De}from"./useActionModal-CYfSmVlP.js";import{r as Oe,t as ke}from"./utils-29quoGQV.js";import{n as Ae,t as je}from"./MetadataInspector-D9KL7Kgi.js";import{n as Me,o as Ne,r as Pe,s as Fe}from"./plugins-views-BpKTWXXa.js";import{t as Ie}from"./ManagedByBadge-DDil8sjK.js";import{t as Le}from"./skeletons-DZWz9Ill.js";var P=e(r(),1),F=s(),Re=(0,P.createContext)(void 0);function I({children:e}){let[t,n]=(0,P.useState)(`home`),[r,i]=(0,P.useState)(),[a,o]=(0,P.useState)(),s=(0,P.useMemo)(()=>({context:t,setContext:n,currentAppName:r,setCurrentAppName:i,recordTitle:a,setRecordTitle:o}),[t,r,a]);return(0,F.jsx)(Re.Provider,{value:s,children:e})}function ze(){return(0,P.useContext)(Re)||{context:`app`,setContext:()=>{},currentAppName:void 0,setCurrentAppName:()=>{},recordTitle:void 0,setRecordTitle:()=>{}}}function Be(e){let{setRecordTitle:t}=ze();(0,P.useEffect)(()=>(t(e),()=>t(void 0)),[e,t])}function L(e){let{url:t,channel:n,autoReconnect:r=!0,reconnectInterval:i=1e3,maxReconnectAttempts:a=10,authToken:o}=e,[s,c]=(0,P.useState)(`disconnected`),[l,u]=(0,P.useState)(null),[d,f]=(0,P.useState)([]),[p,m]=(0,P.useState)(null),h=(0,P.useRef)(null),g=(0,P.useRef)(0),_=(0,P.useRef)(null),v=(0,P.useRef)(new Map),y=(0,P.useRef)([]),b=(0,P.useRef)(!0),x=(0,P.useRef)(!1),S=(0,P.useCallback)(()=>{_.current!==null&&(clearTimeout(_.current),_.current=null)},[]),C=(0,P.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,P.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]),T=(0,P.useCallback)(()=>{S(),x.current=!0,g.current=0,h.current&&=(h.current.close(),null),c(`disconnected`)},[S]),ee=(0,P.useCallback)(()=>{S(),g.current=0,w()},[w,S]),te=(0,P.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,P.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,P.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:T,reconnect:ee,error:p}}var Ve=0;function He(){return Ve+=1,`conflict-${Date.now()}-${Ve}`}var Ue=0;function R(){return Ue+=1,`ver-${Date.now()}-${Ue}`}function We(e,t,n){let[r,i]=(0,P.useState)([]),[a,o]=(0,P.useState)([]);return{versions:r,currentVersion:(0,P.useMemo)(()=>r.length===0?0:r[r.length-1].version,[r]),conflicts:a,hasConflicts:a.length>0,recordVersion:(0,P.useCallback)((n,r)=>{i(i=>{let a=i.length===0?1:i[i.length-1].version+1,o={id:R(),version:a,timestamp:new Date().toISOString(),userId:e,userName:t,changes:n,message:r};return[...i,o]})},[e,t]),resolveConflict:(0,P.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:R(),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,P.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:R(),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,P.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:R(),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,P.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,P.useCallback)(e=>{let t={...e,id:He()};o(e=>[...e,t])},[]),clearHistory:(0,P.useCallback)(()=>{i([]),o([])},[])}}var Ge={sm:24,md:32,lg:40},z={active:`#22c55e`,idle:`#f59e0b`,away:`#94a3b8`};function Ke(e){return e.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}function qe({users:e,maxVisible:t=5,size:n=`md`,showStatus:r=!0,className:i}){let a=Ge[n],o=Math.round(a*.3),s=Math.round(a*.35),c=Math.max(8,Math.round(a*.28)),l=(0,P.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,P.useMemo)(()=>[...l].reverse(),[l]);return P.createElement(`div`,{style:d,className:i,role:`group`,"aria-label":`${e.length} user${e.length===1?``:`s`} present`},u>0&&P.createElement(`div`,{key:`overflow`,style:p,title:`${u} more user${u===1?``:`s`}`},`+${u}`),h.map((e,t)=>P.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?P.createElement(`img`,{src:e.avatar,alt:e.userName,style:{width:`100%`,height:`100%`,objectFit:`cover`}}):Ke(e.userName),r&&P.createElement(`span`,{style:{...m,backgroundColor:z[e.status]}}))))}var B=P.createContext({});function V(){let e=P.useContext(B),[t,n]=P.useState([]);return P.useEffect(()=>{if(!e.subscribeTenant){n([]);return}return e.subscribeTenant(e=>{n(Array.isArray(e)?e:[])})},[e]),t}function Je(e,t){let n=P.useContext(B),[r,i]=P.useState([]);return P.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 Ye={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 Xe(e){let t=Ye[e?.managedBy??`platform`]??Ye.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 H=new Set([`record:discussion`,`record:chatter`]);function Ze(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`&&H.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 Qe({state:e,onOpenChange:t}){let{t:n}=_(),r=()=>{e.resolve?.(!0),t(!1)},i=()=>{e.resolve?.(!1),t(!1)};return(0,F.jsx)(_e,{open:e.open,onOpenChange:e=>{e||i()},children:(0,F.jsxs)(ye,{children:[(0,F.jsxs)(he,{children:[(0,F.jsx)(fe,{children:e.options?.title||n(`actionConfirm.title`)}),(0,F.jsx)(se,{children:e.message})]}),(0,F.jsxs)(le,{children:[(0,F.jsx)(de,{onClick:i,children:e.options?.cancelText||n(`actionConfirm.cancel`)}),(0,F.jsx)(oe,{onClick:r,children:e.options?.confirmText||n(`actionConfirm.confirm`)})]})]})})}function $e({state:e,onOpenChange:t}){let{t:n,language:r}=_(),[i,a]=(0,P.useState)({}),[o,s]=(0,P.useState)({});(0,P.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,F.jsx)(E,{open:e.open,onOpenChange:e=>{e||u()},children:(0,F.jsxs)(j,{children:[(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:e.title||n(`actionDialog.title`)}),(0,F.jsx)(b,{children:e.description||n(`actionDialog.description`)})]}),(0,F.jsx)(`div`,{className:`grid gap-4 py-4`,children:e.params.map(e=>{let t={...e,label:S(e.label,r),helpText:e.helpText==null?e.helpText:S(e.helpText,r),options:e.options?.map(e=>({...e,label:S(e.label,r)}))};if(t.type===`boolean`||t.type===`checkbox`){let e=i[t.name]===!0;return(0,F.jsxs)(`div`,{className:`grid gap-1`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,F.jsx)(ge,{id:t.name,checked:e,onCheckedChange:e=>d(t.name,e===!0),className:`mt-0.5`}),(0,F.jsxs)(me,{htmlFor:t.name,className:`font-normal cursor-pointer`,children:[t.label,t.required&&(0,F.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]})]}),o[t.name]&&(0,F.jsx)(`p`,{className:`text-xs text-destructive ml-6`,children:n(`actionDialog.requiredError`,{label:t.label})}),t.helpText&&(0,F.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,F.jsxs)(`div`,{className:`grid gap-2`,children:[(0,F.jsxs)(me,{htmlFor:t.name,children:[t.label,t.required&&(0,F.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]}),t.type===`select`&&t.options?(0,F.jsxs)(x,{value:i[t.name]??``,onValueChange:e=>d(t.name,e),children:[(0,F.jsx)(k,{id:t.name,className:o[t.name]?`border-destructive`:``,children:(0,F.jsx)(ae,{placeholder:t.placeholder||n(`actionDialog.selectPlaceholder`,{label:t.label})})}),(0,F.jsx)(ie,{children:t.options.map(e=>(0,F.jsx)(T,{value:e.value,children:e.label},e.value))})]}):a&&t.referenceTo?(0,F.jsx)(xe,{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,F.jsx)(ve,{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,F.jsx)(pe,{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,F.jsx)(pe,{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,F.jsx)(`p`,{className:`text-xs text-destructive`,children:n(`actionDialog.requiredError`,{label:t.label})}),t.helpText&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.helpText}),a&&!t.helpText&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`actionDialog.lookupHelpText`)})]},t.name)})}),(0,F.jsxs)(re,{children:[(0,F.jsx)(A,{variant:`outline`,onClick:u,children:n(`actionDialog.cancel`)}),(0,F.jsx)(A,{onClick:l,children:n(`actionDialog.confirm`)})]})]})})}var et=n(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),U=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)}})),W=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}}})),G=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})),tt=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})),nt=n((e=>{var t=U().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}})),K=n((e=>{var t=U().getSymbolSize,n=7;e.getPositions=function(e){let r=t(e);return[[0,0],[r-n,0],[0,r-n]]}})),q=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}})),rt=n((e=>{var t=W(),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}}})),it=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]]}})),at=n((e=>{var t=it();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}})),ot=n(((e,t)=>{var n=at();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})),st=n((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),ct=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)}})),J=n((e=>{var t=st(),n=ct();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}}})),lt=n((e=>{var t=U(),n=rt(),r=W(),i=J(),a=st(),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}})),ut=n((e=>{var t=U(),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}})),dt=n(((e,t)=>{var n=J();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})),ft=n(((e,t)=>{var n=J(),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})),pt=n(((e,t)=>{var n=J();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})),mt=n(((e,t)=>{var n=J(),r=U();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})),ht=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)})),gt=n((e=>{var t=J(),n=dt(),r=ft(),i=pt(),a=mt(),o=ct(),s=U(),c=ht();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()))}})),_t=n((e=>{var t=U(),n=W(),r=G(),i=tt(),a=nt(),o=K(),s=q(),c=rt(),l=ot(),u=lt(),d=ut(),f=J(),p=gt();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)}})),vt=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}}})),yt=n((e=>{var t=vt();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)}})),Y=n((e=>{var t=vt();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}})),bt=n((e=>{var t=et(),n=_t(),r=yt(),i=Y();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 xt(e,t){if(e!=null)return t.split(`.`).reduce((e,t)=>{if(e!=null)return e[t]},e)}function St({state:e,onAcknowledge:t}){let{t:n}=_(),{spec:r,data:i}=e,a=(0,P.useMemo)(()=>r?.fields&&r.fields.length>0?r.fields:[{path:``,label:void 0,format:r?.format??`json`}],[r]);return(0,F.jsx)(E,{open:e.open,onOpenChange:e=>{},children:(0,F.jsxs)(j,{onPointerDownOutside:e=>e.preventDefault(),onEscapeKeyDown:e=>e.preventDefault(),className:`max-w-lg`,children:[(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:r?.title||n(`actions.resultDialog.defaultTitle`)||`Save this value now`}),r?.description?(0,F.jsx)(b,{children:r.description}):null]}),(0,F.jsx)(`div`,{className:`space-y-4 py-2`,children:a.map((e,t)=>(0,F.jsx)(Ct,{field:e,value:e.path===``?i:xt(i,e.path),defaultFormat:r?.format},`${e.path}-${t}`))}),(0,F.jsx)(re,{children:(0,F.jsx)(A,{onClick:t,children:r?.acknowledge||n(`actions.resultDialog.acknowledge`)||`I have saved this`})})]})})}function Ct({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,F.jsxs)(`div`,{className:`space-y-1.5`,children:[i?(0,F.jsx)(`div`,{className:`text-sm font-medium text-foreground/80`,children:i}):null,a===`qrcode`?(0,F.jsx)(wt,{value:t}):null,a===`code-list`?(0,F.jsx)(Tt,{value:t}):null,a===`secret`?(0,F.jsx)(Et,{value:t}):null,a===`text`?(0,F.jsx)(Q,{value:t}):null,a===`json`?(0,F.jsx)(Dt,{value:t}):null]})}function X(e){let[t,n]=(0,P.useState)(!1);return(0,P.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}=X(e);return(0,F.jsxs)(A,{type:`button`,variant:`outline`,size:`sm`,onClick:n,children:[r?(0,F.jsx)(te,{className:`w-4 h-4`}):(0,F.jsx)(ce,{className:`w-4 h-4`}),t?(0,F.jsx)(`span`,{className:`ml-2`,children:t}):null]})}function wt({value:e}){let[t,n]=(0,P.useState)(null);return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`div`,{className:`flex justify-center rounded-md border bg-white p-3`,children:t?(0,F.jsx)(`span`,{className:`text-sm text-destructive`,children:t}):(0,F.jsx)(`canvas`,{ref:t=>{!t||!e||(0,bt.toCanvas)(t,e,{width:200,margin:1},e=>{e&&n(e.message)})}})}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`code`,{className:`flex-1 truncate rounded bg-muted px-2 py-1 text-xs font-mono`,children:e}),(0,F.jsx)(Z,{value:e})]})]})}function Tt({value:e}){let t=e.join(`
9
- `);return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`div`,{className:`rounded-md border bg-muted/40 p-2`,children:(0,F.jsx)(`ul`,{className:`space-y-1`,children:e.map((e,t)=>(0,F.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`code`,{className:`flex-1 rounded bg-background px-2 py-1 text-sm font-mono`,children:e}),(0,F.jsx)(Z,{value:e})]},`${t}-${e}`))})}),(0,F.jsx)(`div`,{className:`flex justify-end`,children:(0,F.jsx)(Z,{value:t,label:`Copy all`})})]})}function Et({value:e}){let[t,n]=(0,P.useState)(!1);return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.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,F.jsx)(A,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(e=>!e),children:t?(0,F.jsx)(M,{className:`w-4 h-4`}):(0,F.jsx)(D,{className:`w-4 h-4`})}),(0,F.jsx)(Z,{value:e})]})}function Q({value:e}){return(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`code`,{className:`flex-1 rounded bg-muted px-2 py-1 text-sm font-mono break-all`,children:e}),(0,F.jsx)(Z,{value:e})]})}function Dt({value:e}){let t=(0,P.useMemo)(()=>{try{return JSON.stringify(e,null,2)}catch{return String(e)}},[e]);return(0,F.jsxs)(`div`,{className:`space-y-2`,children:[(0,F.jsx)(`pre`,{className:`max-h-80 overflow-auto rounded-md border bg-muted/40 p-3 text-xs font-mono`,children:t}),(0,F.jsx)(`div`,{className:`flex justify-end`,children:(0,F.jsx)(Z,{value:t})})]})}function Ot(e){let t={};for(let n of e.fields)n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);return t}function kt({state:e,authFetch:t,baseUrl:n,onClose:r,onComplete:i,dataSource:a,objects:o}){let[s,c]=(0,P.useState)(null),[l,u]=(0,P.useState)(``),[d,f]=(0,P.useState)(``),[p,m]=(0,P.useState)({}),[h,g]=(0,P.useState)(!1);if((0,P.useEffect)(()=>{e&&(c(e.screen),u(e.runId),f(e.flowName),m(Ot(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){N.error(o?.error||`Resume failed (HTTP ${a.status})`);return}let s=o?.data??{};if(s.success===!1||s.status===`failed`){N.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(Ot(s.screen)),N.success(`Saved — next step`)):(N.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){N.error(`Please fill: ${e.map(e=>e.label||e.name).join(`, `)}`);return}g(!0);try{await v(p)}catch(e){N.error(e.message)}finally{g(!1)}},x=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){N.error(e.message)}finally{g(!1)}},S=s.kind===`object-form`&&!!s.objectName,C=S&&Array.isArray(o)?o.find(e=>e?.name===s.objectName):void 0,T=C?C.form?.subforms??C.formViews?.default?.subforms:void 0;return(0,F.jsx)(E,{open:!0,onOpenChange:e=>{!e&&!h&&r()},children:(0,F.jsxs)(j,{className:S?`sm:max-w-3xl max-h-[90vh] overflow-y-auto`:`sm:max-w-md`,children:[(0,F.jsxs)(w,{children:[(0,F.jsx)(O,{children:s.title||`Input`}),s.description&&(0,F.jsx)(b,{children:s.description})]}),S?(0,F.jsx)(`div`,{className:`py-2`,children:a?(0,F.jsx)(Ce,{schema:{type:`object-form`,formType:`simple`,objectName:s.objectName,mode:s.mode===`edit`?`edit`:`create`,recordId:s.mode===`edit`?s.recordId:void 0,...s.defaults?{initialValues:s.defaults}:{},layout:`vertical`,subforms:T,onSuccess:x,onCancel:r,showSubmit:!0,showCancel:!0,submitText:`Save & Continue`,cancelText:`Cancel`},dataSource:a},s.nodeId):(0,F.jsx)(`div`,{className:`text-sm text-destructive py-4`,children:`This step renders an object form but no data source is available.`})}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`space-y-4 py-2`,children:s.fields.map(e=>(0,F.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,F.jsxs)(me,{htmlFor:`ff-${e.name}`,className:`text-sm`,children:[e.label||e.name,e.required&&(0,F.jsx)(`span`,{className:`text-destructive`,children:` *`})]}),(0,F.jsx)(At,{field:e,value:p[e.name],onChange:t=>_(e.name,t)})]},e.name))}),(0,F.jsxs)(re,{children:[(0,F.jsx)(A,{variant:`outline`,onClick:r,disabled:h,children:`Cancel`}),(0,F.jsx)(A,{onClick:y,disabled:h,children:h?`Submitting…`:`Submit`})]})]})]})})}function At({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,F.jsxs)(x,{value:t==null?void 0:String(t),onValueChange:e=>n(e),children:[(0,F.jsx)(k,{id:r,children:(0,F.jsx)(ae,{placeholder:e.placeholder||`Select…`})}),(0,F.jsx)(ie,{children:e.options.map((e,t)=>(0,F.jsx)(T,{value:String(e.value),children:e.label},t))})]});if(i===`boolean`||i===`checkbox`)return(0,F.jsx)(ge,{id:r,checked:t===!0,onCheckedChange:e=>n(e===!0)});if(i===`textarea`||i===`markdown`)return(0,F.jsx)(ve,{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,F.jsx)(pe,{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 $(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 jt(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??$(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 Mt(e,t){return Array.isArray(e)?e.map(e=>jt(e,t)):[]}var Nt=t({RecordDetailView:()=>Bt}),Pt={id:`current-user`,name:`Demo User`},Ft=new Set([`created_at`,`created_by`,`updated_at`,`updated_by`]),It=new Set([`organization_id`,`tenant_id`,`is_deleted`,`deleted_at`]),Lt=[`description`,`notes`,`note`,`remark`,`remarks`,`comments`],Rt=new Set([`textarea`,`markdown`,`html`,`rich-text`,`json`,`code`]);function zt(e,t){if(Rt.has(t?.type))return!0;let n=e.toLowerCase();return Lt.some(e=>n===e||n.endsWith(`_${e}`))}function Bt({dataSource:e,objects:t,onEdit:n,objectNameOverride:r,recordIdOverride:s,embedded:b}){let x=i(),S=x.appName,w=r??x.objectName,T=s??x.recordId,{showDebug:te}=Ae(),{user:E}=l(),D=c(),O=a().state?.from,{t:k}=_(),{objectLabel:re,viewLabel:ie,sectionLabel:ae,actionLabel:oe,actionConfirm:se,actionSuccess:ce,actionParamText:le,actionParamOptionLabel:A,actionDescription:de,fieldLabel:fe,fieldOptionLabel:pe}=be(),{isFavorite:me,toggleFavorite:he,refreshLabel:ge}=we(),{addRecentItem:_e}=Ee(),[ve,ye]=(0,P.useState)(!0),[xe,j]=(0,P.useState)([]),[M,Ce]=(0,P.useState)([]),[Re,I]=(0,P.useState)(0),[ze,L]=(0,P.useState)(null),[Ve,He]=(0,P.useState)({}),[Ue,R]=(0,P.useState)(null),[We,Ge]=(0,P.useState)(!1),[z,Ke]=(0,P.useState)(),B=t.find(e=>e.name===w);Be(b?void 0:z);let V=T,Ye=Je(w,V),H=(0,P.useMemo)(()=>!w||!V?null:{id:`record:${w}:${V}`,label:z||V||``,href:`/apps/${S}/${w}/record/${V}`,type:`record`},[S,w,V,z]),et=H?me(H.id):!1,U=(0,P.useCallback)(()=>{H&&he(H)},[H,he]),{page:W,slots:G}=d(w),tt=(0,P.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]),nt=(0,P.useMemo)(()=>W||!B||!tt&&!G?null:Me(B,G?{slots:G}:void 0),[tt,W,G,B]),K=W||nt,[q,rt]=(0,P.useState)(null),[it,at]=(0,P.useState)(`idle`);(0,P.useEffect)(()=>{let t=!1;if(!K||!V||!w||!e?.findOne){rt(null),at(`idle`);return}let n=y(B?.fields),r=n.length>0?{$expand:n}:void 0,i=()=>{at(`loading`),(r?e.findOne(w,V,r):e.findOne(w,V)).then(e=>{t||(e&&typeof e==`object`?(rt(e),at(`loaded`)):(rt(null),at(`missing`)))}).catch(()=>{t||(rt(null),at(`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)}},[K,w,V,e,B]),(0,P.useEffect)(()=>{if(!q||typeof q!=`object`||!B)return;let e=ke(B,q);e&&e!==`Untitled`&&e!==z&&Ke(e)},[q,B,z]),(0,P.useEffect)(()=>{if(!w||!V||!S||!z)return;let e=`record:${w}:${V}`;_e({id:e,label:z,href:`/apps/${S}/${w}/record/${V}`,type:`record`}),ge(e,z)},[S,w,V,z,_e,ge]);let[ot,st]=(0,P.useState)({open:!1,message:``}),[ct,J]=(0,P.useState)({open:!1,params:[]}),[lt,ut]=(0,P.useState)({open:!1}),dt=(0,P.useCallback)((e,t)=>new Promise(n=>{ut({open:!0,spec:e,data:t,resolve:n})}),[]),ft=(0,P.useCallback)((e,t)=>new Promise(n=>{st({open:!0,message:e,options:t,resolve:n})}),[]),pt=(0,P.useCallback)((e,n)=>new Promise(r=>{let i=Mt(e,{objectName:w||B?.name||``,objects:t||[],fieldLabel:fe,fieldOptionLabel:pe}),a=w||B?.name;J({open:!0,params:i.map(e=>({...e,label:le(a,n?.name,e.name,`label`,e.label)??e.label,placeholder:le(a,n?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:le(a,n?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(t=>({...t,label:A(a,n?.name,e.name,t.value,t.label)})):e.options})),title:n?.label||n?.title,description:de(a,n?.name,n?.description),resolve:r})}),[w,B,t,fe,pe,le,A]),mt=f({dataSource:e,onUndo:()=>{I(e=>e+1),N.success(`Change undone`)}}),ht=(0,P.useCallback)((e,t)=>{if(t?.type===`error`){N.error(e);return}if(t?.undo){N.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{mt.undo()}}});return}N.success(e,{duration:t?.duration})},[mt]),gt=(0,P.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):D(e)},[D]),_t=(0,P.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&&q&&w&&V){let e={};for(let t of Object.keys(r))e[t]=q[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)&&I(e=>e+1),{success:!0,reload:a,undo:i}}catch(e){return{success:!1,error:e.message}}},[e,w,V,q]),{modalHandler:vt,modalElement:yt}=De(e),Y=(0,P.useMemo)(()=>u(),[]),bt=(0,P.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 L({flowName:t,runId:i.runId,screen:i.screen}),{success:!0,silent:!0};let a=e.refreshAfter!==!1;return a&&I(e=>e+1),{success:!0,data:r?.data,reload:a}}catch(e){return{success:!1,error:e.message}}},[Y,V,w]),xt=(0,P.useRef)(new Set),Ct=(0,P.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(xt.current.has(r))return{success:!1,error:`Action already in progress`};xt.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||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(t,`_blank`)}catch{window.location.href=t}}},duration:1e4})}return e.refreshAfter===!0&&I(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 N.error(e),{success:!1,error:e}}let u=e.refreshAfter!==!1;u&&I(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||N(`浏览器拦截了弹窗 / 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 N.error(t),{success:!1,error:t}}finally{xt.current.delete(r)}},[Y,V,w]),X=Te(w,V,E?.id),Z=(0,P.useRef)(X);Z.current=X;let wt=(0,P.useCallback)(async e=>{let t=e.target||e.name,n=e.params&&!Array.isArray(e.params)?e.params:{};try{if(t===`approve_request`)await Z.current.approve({comment:n.comment});else if(t===`reject_request`)await Z.current.reject({comment:n.comment});else return{success:!1,error:`Unknown approval target: ${t}`};return I(e=>e+1),{success:!0,reload:!0}}catch(e){return{success:!1,error:e?.message||String(e)}}},[]),Tt=(0,P.useMemo)(()=>Oe(B,t),[B,t]);(0,P.useEffect)(()=>{if(K||!e||!V||Tt.length===0)return;let t=!1;return Promise.all(Tt.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;He(n)}),()=>{t=!0}},[e,V,Tt,B,K]);let Et=(0,P.useMemo)(()=>!B||B.name===`sys_audit_log`||B.enable?.trackHistory!==!0?!1:t.some(e=>e.name===`sys_audit_log`),[B,t]);(0,P.useEffect)(()=>{if(!e||!V||!B||!Et){R(null);return}let t=!1;return Ge(!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};R(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),R([]))}).finally(()=>{t||Ge(!1)}),()=>{t=!0}},[e,V,B,Et]),(0,P.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))];Ce(o.length>0?o:n)}catch{if(t)return;Ce(n)}})(),()=>{t=!0}},[e,E?.id,E?.name,E?.email]);let Q=(0,P.useMemo)(()=>E?{id:E.id,name:E.name,avatar:E.image}:Pt,[E?.id,E?.name,E?.image]);(0,P.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)}));j(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&&j(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 Dt=(0,P.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(j(e=>[...e,n]),e){let r=`${w}:${V}`,i=Pe(t,M);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,M]),Ot=(0,P.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(j(e=>[...e,r].map(e=>e.id===t?{...e,replyCount:(e.replyCount??0)+1}:e)),e){let i=`${w}:${V}`,a=Pe(n,M);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,M]),At=(0,P.useCallback)((t,n)=>{j(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,P.useEffect)(()=>{ye(!0),queueMicrotask(()=>ye(!1))},[w,T]);let $=(0,P.useMemo)(()=>{if(!B)return{type:`detail-view`};let n=B.primaryField||Object.keys(B.fields||{}).find(e=>e===`name`||e===`title`),r=B.views?.form?.sections,i=r&&r.length>0?r.map(e=>({title:e.name?ae(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=Object.keys(B.fields||{}).filter(e=>!Ft.has(e)&&!It.has(e)&&!B.fields[e]?.hidden),t=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}}},n=e.filter(e=>!zt(e,B.fields[e])),r=e.filter(e=>zt(e,B.fields[e]));return r.length===0||n.length===0?[{showBorder:!1,fields:e.map(t)}]:[{showBorder:!1,fields:n.map(t)},{name:`details`,title:ae(B.name,`details`,k(`detail.sectionMoreDetails`,`More details`)),collapsible:!0,defaultCollapsed:!1,showBorder:!0,fields:r.map(t)}]})(),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:oe(B.name,e.name,e.label||e.name),...e.confirmText!==void 0&&{confirmText:se(B.name,e.name,e.confirmText)},...e.successMessage!==void 0&&{successMessage:ce(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.views?.detail?.highlightFields??[],s=B.views?.detail?.sectionGroups??B.views?.form?.sectionGroups,c=S?`/apps/${S}`:``,l=Tt.map(({childObject:n,childLabel:r,referenceField:i,title:a,columns:o})=>{let s=t.find(e=>e.name===n),l=V||``,u=a||(s?re({name:s.name,label:s.label||r}):r),d=()=>{let e=new URLSearchParams({[i]:l}).toString();return`${c}/${n}/new${e?`?${e}`:``}`},f=()=>{let e=new URLSearchParams({[`filter[${i}]`]:l}).toString();return`${c}/${n}${e?`?${e}`:``}`},p=e=>{let t=e?.id||e?._id;return t?`${c}/${n}/record/${encodeURIComponent(String(t))}/edit`:null},m=e=>{let t=e?.id||e?._id;return t?`${c}/${n}/record/${encodeURIComponent(String(t))}`:null},h=c?()=>D(d()):void 0,g=c?()=>D(f()):void 0,_=c?e=>{let t=m(e);t&&D(t)}:void 0,v=c?e=>{let t=p(e);t&&D(t)}:void 0,y=e&&l?async t=>{let r=t?.id||t?._id;if(r)try{await e.delete(n,r),N.success(k(`detail.deleteSuccess`,{defaultValue:`Deleted`})),He(e=>({...e,[n]:(e[n]||[]).filter(e=>(e.id||e._id)!==r)}))}catch(e){N.error(e?.message||k(`detail.deleteError`,{defaultValue:`Delete failed`}))}}:void 0;return{title:u,type:`table`,api:n,data:Ve[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}}),u=Xe(B);return{type:`detail-view`,objectName:B.name,resourceId:V,showBack:!b,onBack:`history`,showEdit:u.edit,title:B.label,primaryField:n,sections:i,autoTabs:!0,autoDiscoverRelated:!0,...Et&&{history:{entries:Ue??[],loading:We&&Ue===null}},...l.length>0&&{related:l},...o.length>0&&{highlightFields:o},...s&&s.length>0&&{sectionGroups:s},...a.length>0&&{actions:[{type:`action:bar`,location:`record_header`,actions:a}]}}},[B?.name,V,Ve,Re,S,D,e,k,re,t,Et,Ue,We,X.available,X.canDecide,X.pendingRequest,X.latestRequest,b]);if(ve)return(0,F.jsx)(Le,{});if(!B)return(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,F.jsxs)(ne,{children:[(0,F.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,F.jsx)(ee,{className:`h-6 w-6 text-muted-foreground`})}),(0,F.jsx)(C,{children:k(`empty.objectNotFound`)}),(0,F.jsx)(Se,{children:k(`empty.objectNotFoundDescription`,{name:w})})]})});if(K&&it===`missing`)return(0,F.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,F.jsxs)(ne,{children:[(0,F.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,F.jsx)(ee,{className:`h-6 w-6 text-muted-foreground`})}),(0,F.jsx)(C,{children:k(`empty.recordNotFound`,{defaultValue:`Record not found`})}),(0,F.jsx)(Se,{children:k(`empty.recordNotFoundDescription`,{defaultValue:`The record you are looking for does not exist or may have been deleted.`})})]})});if(K){let r=K?.disableDiscussion===!0,i=Ze(K),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=Xe(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),N.success(k(`detail.linkCopied`,{defaultValue:`Link copied`}))}catch(e){N.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),N.success(k(`detail.deleted`,{defaultValue:`Record deleted`})),D(`${S?`/apps/${S}`:``}/${w}`,{replace:!0})}catch(e){N.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,d=$.history?{entries:$.history.entries??[],loading:!!$.history.loading,emptyText:$.history.emptyText}:void 0,f=W?K:Me(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:d,showReferenceRail:B?.detail?.showReferenceRail===!0||void 0,hideReferenceRail:B?.detail?.hideReferenceRail===!0||void 0,hideRelatedTab:B?.detail?.hideRelatedTab===!0||void 0,...G?{slots:G}:{}});return(0,F.jsxs)(`div`,{className:`h-full bg-background overflow-hidden flex flex-col relative`,children:[(0,F.jsxs)(`div`,{className:`absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2`,children:[Ye.length>0&&(0,F.jsx)(qe,{users:Ye,size:`sm`,maxVisible:3,showStatus:!0}),(0,F.jsx)(Ie,{managedBy:B?.managedBy})]}),(0,F.jsx)(h,{objectName:w,recordId:V,data:q,objectSchema:B,dataSource:e,embedded:b,headerSystemActions:c,isFavorite:et,onToggleFavorite:H?U:void 0,children:(0,F.jsx)(g,{children:(0,F.jsx)(v,{items:xe,onAddComment:Dt,onAddReply:Ot,onToggleReaction:At,mentionSuggestions:M,children:(0,F.jsxs)(m,{context:{record:q||{},objectName:w,user:Q},onConfirm:ft,onToast:ht,onNavigate:gt,onParamCollection:pt,onResultDialog:dt,onModal:vt,handlers:{api:_t,flow:bt,script:Ct,approval:wt},children:[(0,F.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-row`,children:[(0,F.jsxs)(`div`,{className:`flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48`,children:[O?.pathname&&O?.label&&(0,F.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,F.jsx)(ue,{className:`h-4 w-4`}),(0,F.jsx)(`span`,{children:O.label})]}),(0,F.jsx)(p,{schema:f}),a&&(0,F.jsx)(`div`,{className:`mt-6`,children:(0,F.jsx)(Ne,{config:{position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:xe,onAddComment:Dt,onAddReply:Ot,onToggleReaction:At,mentionSuggestions:M})})]}),(0,F.jsx)(je,{open:te,sections:[{title:`Page Schema`,data:f}]})]}),yt]})})})}),(0,F.jsx)(Qe,{state:ot,onOpenChange:e=>{e||st(e=>({...e,open:!1}))}}),(0,F.jsx)($e,{state:ct,onOpenChange:e=>{e||J(e=>({...e,open:!1}))}}),(0,F.jsx)(St,{state:lt,onAcknowledge:()=>{lt.resolve?.(),ut({open:!1})}}),(0,F.jsx)(kt,{state:ze,authFetch:Y,baseUrl:``,dataSource:e,objects:t,onClose:()=>L(null),onComplete:()=>{L(null),I(e=>e+1)}})]})}return(0,F.jsxs)(`div`,{className:`h-full bg-background overflow-hidden flex flex-col relative`,children:[(0,F.jsxs)(`div`,{className:`absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2`,children:[Ye.length>0&&(0,F.jsx)(qe,{users:Ye,size:`sm`,maxVisible:3,showStatus:!0}),(0,F.jsx)(Ie,{managedBy:B?.managedBy})]}),(0,F.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-row`,children:[(0,F.jsx)(`div`,{className:`flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48`,children:(0,F.jsx)(`div`,{className:`mx-auto w-full max-w-[1400px]`,children:(0,F.jsxs)(m,{context:{record:{},objectName:w,user:Q},onConfirm:ft,onToast:ht,onNavigate:gt,onParamCollection:pt,onResultDialog:dt,onModal:vt,handlers:{api:_t,flow:bt,script:Ct,approval:wt},children:[(0,F.jsx)(Fe,{schema:$,dataSource:e,objectLabel:re({name:B.name,label:B.label}),isFavorite:et,onToggleFavorite:H?U:void 0,onDataLoaded:e=>{if(!e||typeof e!=`object`)return;let t=ke(B,e);t&&t!==z&&t!==`Untitled`&&Ke(t)},onEdit:()=>{n({id:V})},discussionSlot:(0,F.jsx)(Ne,{config:{position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:xe,onAddComment:Dt,onAddReply:Ot,onToggleReaction:At})},Re),yt]})})}),(0,F.jsx)(je,{open:te,sections:[{title:`View Schema`,data:$}]})]}),(0,F.jsx)(Qe,{state:ot,onOpenChange:e=>{e||st(e=>({...e,open:!1}))}}),(0,F.jsx)($e,{state:ct,onOpenChange:e=>{e||J(e=>({...e,open:!1}))}}),(0,F.jsx)(St,{state:lt,onAcknowledge:()=>{lt.resolve?.(),ut({open:!1})}}),(0,F.jsx)(kt,{state:ze,authFetch:Y,baseUrl:``,dataSource:e,objects:t,onClose:()=>L(null),onComplete:()=>{L(null),I(e=>e+1)}})]})}export{St as a,Xe as c,We as d,L as f,kt as i,V as l,ze as m,Nt as n,$e as o,I as p,Mt as r,Qe as s,Bt as t,qe as u};