@objectstack/console 9.8.0 → 9.9.1

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 (94) hide show
  1. package/dist/assets/{AdapterProvider-CGofnJBf.js → AdapterProvider-DJb3ZVmJ.js} +1 -1
  2. package/dist/assets/{AiPendingActionsPage-CaJCvm5D.js → AiPendingActionsPage-BI-QQNee.js} +1 -1
  3. package/dist/assets/ApiConsolePage-B6QExly9.js +1 -0
  4. package/dist/assets/AppDocsIndex-S-ilhz4W.js +1 -0
  5. package/dist/assets/AppManagementPage-JgLQ-wXj.js +1 -0
  6. package/dist/assets/{ApprovalsInboxPage-BbvtY-xj.js → ApprovalsInboxPage-CAyznoRP.js} +1 -1
  7. package/dist/assets/{AuditLogPage-ffz9xeHl.js → AuditLogPage-BeEqEy4g.js} +1 -1
  8. package/dist/assets/ComponentNavView-DmALsugj.js +1 -0
  9. package/dist/assets/ConsoleFloatingChatbot-D13eK4M8.js +1 -0
  10. package/dist/assets/{DashboardView-CsknMwAh.js → DashboardView-P--eXDC-.js} +1 -1
  11. package/dist/assets/{DashboardWidgetInspector-DSLIsQS9.js → DashboardWidgetInspector-VPDtQEP_.js} +1 -1
  12. package/dist/assets/{DeveloperHubPage-DZyjalsK.js → DeveloperHubPage-DbQwi1EV.js} +1 -1
  13. package/dist/assets/{ExpressionProvider-wi1dJ2tN.js → ExpressionProvider-DKFCgLsJ.js} +1 -1
  14. package/dist/assets/FlowRunsPage-CCS9xNVc.js +1 -0
  15. package/dist/assets/{IntegrationsPage-Dfl35fAT.js → IntegrationsPage-DU_wvj4-.js} +2 -2
  16. package/dist/assets/{InterfaceListPage-DAJiEE0k.js → InterfaceListPage-B3jzgT27.js} +1 -1
  17. package/dist/assets/{ManagedByBadge-BAL_PuGz.js → ManagedByBadge-Difq_L_A.js} +1 -1
  18. package/dist/assets/{MarketplaceAccessDenied-BBUl4uOo.js → MarketplaceAccessDenied-CXUE33gy.js} +1 -1
  19. package/dist/assets/{MarketplaceInstalledPage-CaN54GxZ.js → MarketplaceInstalledPage-CBfcARvX.js} +1 -1
  20. package/dist/assets/{MarketplacePackagePage-SKgqOj7g.js → MarketplacePackagePage-DOZgrTZo.js} +2 -2
  21. package/dist/assets/{MarketplacePage-CoigR7d_.js → MarketplacePage-BT-WkhAG.js} +1 -1
  22. package/dist/assets/{MetadataInspector-BGWYqUse.js → MetadataInspector-BRICMLXW.js} +1 -1
  23. package/dist/assets/{MetadataProvider-_6IU7cWK.js → MetadataProvider-Bja7m8Gt.js} +1 -1
  24. package/dist/assets/PageView-My4nP5w4.js +1 -0
  25. package/dist/assets/{ProfilePage-C11r_2xN.js → ProfilePage-BAtKSxuK.js} +1 -1
  26. package/dist/assets/PublicFormsPage-CcRFrTQC.js +1 -0
  27. package/dist/assets/RecordDetailView-CMIRy42W.js +1 -0
  28. package/dist/assets/{RecordFormPage-1zrrumdr.js → RecordFormPage-BUfFijzM.js} +1 -1
  29. package/dist/assets/{ReportDefaultInspector--SQsifZI.js → ReportDefaultInspector-C8gR3RMr.js} +1 -1
  30. package/dist/assets/{ReportView-q3jNGyaI.js → ReportView-DSrtPxzA.js} +1 -1
  31. package/dist/assets/{RuntimeDraftBar-DaYAgW5v.js → RuntimeDraftBar-B2fJIAhv.js} +1 -1
  32. package/dist/assets/{SearchResultsPage-BRnB7VD4.js → SearchResultsPage-C7i-b3gn.js} +1 -1
  33. package/dist/assets/{SettingsHub-CUCcntU9.js → SettingsHub-BLEC_8Ao.js} +1 -1
  34. package/dist/assets/{SettingsView-DRjJrXF9.js → SettingsView-BEjR60F6.js} +1 -1
  35. package/dist/assets/SystemHubPage-DWGnZfF0.js +1 -0
  36. package/dist/assets/componentRegistry-ByxoJqMW.js +1 -0
  37. package/dist/assets/{data-adapter-CzKUUIgi.js → data-adapter-CCidkDs3.js} +1 -1
  38. package/dist/assets/framework-BLEk-ou3.js +34 -0
  39. package/dist/assets/{highlighted-body-OFNGDK62-JYK0hMjr.js → highlighted-body-OFNGDK62-DiT7C6XW.js} +1 -1
  40. package/dist/assets/index-BgnAjV6_.js +4 -0
  41. package/dist/assets/index-CJe1zUD0.css +2 -0
  42. package/dist/assets/{mergeServerFields-CM4cY1zR.js → mergeServerFields-zZ2r6yTA.js} +2 -2
  43. package/dist/assets/mermaid-GHXKKRXX-CK-9EMhD.js +1 -0
  44. package/dist/assets/metadata-admin-BgoJzjrj.js +19 -0
  45. package/dist/assets/{plugin-calendar-DCCbdIpj.js → plugin-calendar-DQC9zdKq.js} +1 -1
  46. package/dist/assets/{plugin-charts-Do3qrshN.js → plugin-charts-AMObsZz3.js} +1 -1
  47. package/dist/assets/plugin-chatbot-Ch8YIyYL.js +120 -0
  48. package/dist/assets/plugin-dashboard-C7fxXXeO.js +5 -0
  49. package/dist/assets/plugin-form-DXCdD2d-.js +1 -0
  50. package/dist/assets/plugin-gantt-BHmpu6VX.js +23 -0
  51. package/dist/assets/plugin-grid-boi_rkH3.js +6 -0
  52. package/dist/assets/{plugin-kanban-CYKs5Fuv.js → plugin-kanban-DOsTOpJz.js} +1 -1
  53. package/dist/assets/{plugin-map-DuGG00x5.js → plugin-map-Bid9UXOR.js} +1 -1
  54. package/dist/assets/{plugin-markdown-Du1ajwhj.js → plugin-markdown-BUQOG31j.js} +13 -1
  55. package/dist/assets/{plugin-report-D0COS83c.js → plugin-report-FxG9jOvy.js} +1 -1
  56. package/dist/assets/plugin-timeline-DDrFKEb8.js +1 -0
  57. package/dist/assets/plugin-view-D58aYgqA.js +1 -0
  58. package/dist/assets/plugins-views-DUKPQNs8.js +4 -0
  59. package/dist/assets/resolveActionParams-xmwfLvud.js +9 -0
  60. package/dist/assets/{skeletons-Cdt8ttDk.js → skeletons-B_SNEnMn.js} +1 -1
  61. package/dist/assets/src-DXFkWHTV.js +2 -0
  62. package/dist/assets/{src-BPf-hjw2.js → src-DbxuLwqh.js} +1 -1
  63. package/dist/assets/{types-DjNzBgbB.js → types-CosU35As.js} +1 -1
  64. package/dist/assets/ui-components-CrPYFyEM.js +42 -0
  65. package/dist/assets/{ui-layout-D19iPz4K.js → ui-layout-DAWxaQvy.js} +1 -1
  66. package/dist/assets/{useActionModal-BKaoxO40.js → useActionModal-DsVCm46J.js} +1 -1
  67. package/dist/assets/useReconcileOnError-D6sIYKrb.js +1 -0
  68. package/dist/index.html +4 -4
  69. package/package.json +1 -1
  70. package/dist/assets/ApiConsolePage-DGCgQ6RS.js +0 -1
  71. package/dist/assets/AppDocsIndex-B_hZ36LW.js +0 -1
  72. package/dist/assets/AppManagementPage-DN-u3YQP.js +0 -1
  73. package/dist/assets/ComponentNavView-B6LSKpd-.js +0 -1
  74. package/dist/assets/ConsoleFloatingChatbot-CsiQ_KDu.js +0 -1
  75. package/dist/assets/FlowRunsPage-DcT6ntvZ.js +0 -1
  76. package/dist/assets/PageView-CxOhEFic.js +0 -1
  77. package/dist/assets/PublicFormsPage-N0Wofan4.js +0 -1
  78. package/dist/assets/RecordDetailView-Bh6I2k3c.js +0 -1
  79. package/dist/assets/SystemHubPage-_i5E_SOC.js +0 -1
  80. package/dist/assets/framework-DLckRGJs.js +0 -34
  81. package/dist/assets/index-DGuFGryh.css +0 -2
  82. package/dist/assets/index-JrHkY-wh.js +0 -4
  83. package/dist/assets/mermaid-GHXKKRXX-Bg8PoWKD.js +0 -1
  84. package/dist/assets/metadata-admin-B5WWi7HS.js +0 -19
  85. package/dist/assets/plugin-chatbot-DF5LNhQ2.js +0 -120
  86. package/dist/assets/plugin-dashboard-BQ3awX8y.js +0 -5
  87. package/dist/assets/plugin-form-FmgnWzcl.js +0 -1
  88. package/dist/assets/plugin-gantt-CWw13thv.js +0 -23
  89. package/dist/assets/plugin-grid-Cd-2qFJP.js +0 -6
  90. package/dist/assets/plugin-timeline-BBYlrrgQ.js +0 -1
  91. package/dist/assets/plugin-view-BhoDHK4P.js +0 -1
  92. package/dist/assets/plugins-views-gs7PYt1Y.js +0 -4
  93. package/dist/assets/resolveActionParams-DjRjW-gD.js +0 -9
  94. package/dist/assets/ui-components-B2CBE2Rs.js +0 -42
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,r,t as i}from"./vendor-react-DR370ovB.js";import{$n as a,Co as o,Cs as s,Ct as c,Et as l,Gn as u,Ki as d,St as f,Tt as p,Un as m,Wn as h,Z as g,_t as _,dc as v,io as y,ni as b,qi as x,vt as S,wt as C,xt as w,yt as T,zt as E}from"./ui-components-B2CBE2Rs.js";import{_ as D,c as O,d as k,g as A,h as j,n as M,o as N,p as P,s as F,t as I,u as L}from"./vendor-dndkit-DMFEUxSy.js";var R=e(t(),1),z=i();function B(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return{h:s*360,s:c*100,l:l*100}}function V(e){let t=B(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function H(e){let t=B(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function U(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return`0 0% 100%`;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},r=n(parseInt(t[1],16)),i=n(parseInt(t[2],16)),a=n(parseInt(t[3],16));return .2126*r+.7152*i+.0722*a>.6?`222 47% 11%`:`0 0% 100%`}function W(e,t){(0,R.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=V(e.primaryColor),i=H(e.primaryColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t||a),n.style.setProperty(`--primary`,a),n.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:U(e.primaryColor)),n.style.setProperty(`--ring`,a),n.style.setProperty(`--sidebar-primary`,a),n.style.setProperty(`--sidebar-ring`,a))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let t=V(e.accentColor),i=H(e.accentColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t||a),n.style.setProperty(`--accent`,a),n.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:U(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{a.disconnect(),n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function G({sidebar:e,navbar:t,children:n,className:r,defaultOpen:i=!0,branding:a}){return W(a,a?.title),(0,z.jsxs)(l,{defaultOpen:i,className:`!flex-col h-svh overflow-hidden`,children:[(0,z.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:t}),(0,z.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,z.jsx)(w,{className:`min-w-0`,children:(0,z.jsx)(`main`,{className:v(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,r),children:n})})]})]})}function K(e){return e?g(e):o}function q(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function J(e,t,n,r,i,a,o){let s=q(e.label,n);if(typeof e.label!=`string`)return s;if(e.type===`object`&&e.objectName){if(e.viewName)return a?a(e.objectName,e.viewName,s):s;if(t)return t(e.objectName,s)}return r&&e.type===`dashboard`&&e.dashboardName?r(e.dashboardName,s):i&&e.type===`group`&&e.id?i(e.id,s):o&&e.id?o(e.id,s):s}var ee=e=>!(e===!1||e===`false`),Y=()=>!0,X=()=>!0,te=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function Z(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(te,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}function Q(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=Z(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}return{href:e.viewName?`${r}/view/${e.viewName}`:r,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null)if(typeof i==`string`){let r=Z(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i));let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(!(t===`type`||t===`name`)&&r!=null)if(typeof r==`string`){let i=Z(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r));let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}function ne(e,t,n){if(t===`#`)return!1;if(n===t)return!0;let r=e.componentRef;return r&&r.split(`:`)[1]===`directory`?!1:e.type===`object`&&e.objectName?!(e.viewName||!n.startsWith(`${t}/`)||n.slice(t.length+1).startsWith(`view/`)):n.startsWith(`${t}/`)}function re(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=re(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return q(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var ie=5;function ae({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,enableReorder:c,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h}){let{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=N({id:e.id,disabled:!c});return(0,z.jsx)(`div`,{ref:v,style:{transform:D.Transform.toString(y),transition:b,opacity:x?.5:void 0,zIndex:x?10:void 0},...g,children:(0,z.jsx)($,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,dragListeners:c?_:void 0,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h})})}function $({item:e,basePath:t,evalVis:i,checkPerm:o,checkCap:l,onAction:g,enablePinning:v,onPinToggle:b,dragListeners:w,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N}){let P=n(),F=(()=>{let t=e.expanded;if(typeof t==`boolean`)return t;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),I=e.type===`group`?e.children?.length??0:0,[L,B]=(0,R.useState)(R.useMemo(()=>{if(e.type!==`group`)return!1;let n=e=>{if(!e)return!1;for(let r of e){if(r.type===`group`){if(n(r.children))return!0;continue}let{href:e}=Q(r,t,N);if(ne(r,e,P.pathname))return!0}return!1};return n(e.children)},[e,t,P.pathname])?!0:F??!(I>=8));if(!i(e.visible)||e.requiredPermissions?.length&&!o(e.requiredPermissions))return null;let V=e.requiresObject,H=e.requiresService;if(V&&!l(`object`,V)||H&&!l(`service`,H))return null;if(e.type===`separator`)return(0,z.jsx)(E,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,z.jsx)(m,{open:L,onOpenChange:B,children:(0,z.jsxs)(_,{children:[(0,z.jsx)(T,{asChild:!0,children:(0,z.jsxs)(u,{className:`flex w-full items-center justify-between`,children:[J(e,D,M,O,k,A,j),(0,z.jsx)(s,{className:`ml-auto h-4 w-4 transition-transform ${L?`rotate-90`:``}`})]})}),(0,z.jsx)(h,{children:(0,z.jsx)(S,{children:(0,z.jsx)(f,{children:n.map(e=>(0,z.jsx)($,{item:e,basePath:t,evalVis:i,checkPerm:o,checkCap:l,onAction:g,enablePinning:v,onPinToggle:b,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N},e.id))})})})]})})}if(e.type===`action`){let n=K(e.icon),r=q(e.label,M);return(0,z.jsxs)(p,{children:[w&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...w,children:(0,z.jsx)(y,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(C,{tooltip:r,onClick:()=>g?.(e),children:[(0,z.jsx)(n,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:r}),e.badge!=null&&(0,z.jsx)(a,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),v&&b&&(0,z.jsx)(c,{showOnHover:!0,onClick:()=>b(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${r}`:`Pin ${r}`,name:r}):e.pinned?`Unpin ${r}`:`Pin ${r}`,children:e.pinned?(0,z.jsx)(x,{className:`h-3.5 w-3.5`}):(0,z.jsx)(d,{className:`h-3.5 w-3.5`})})]})}let U=K(e.icon),{href:W,external:G}=Q(e,t,N),ee=ne(e,W,P.pathname),Y=J(e,D,M,O,k,A,j),X=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:Y}),e.badge!=null&&(0,z.jsx)(a,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,z.jsxs)(p,{children:[w&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...w,children:(0,z.jsx)(y,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(C,{asChild:!0,isActive:ee,tooltip:Y,children:G?(0,z.jsx)(`a`,{href:W,target:`_blank`,rel:`noopener noreferrer`,children:X}):(0,z.jsx)(r,{to:W,children:X})}),v&&b&&(0,z.jsx)(c,{showOnHover:!0,onClick:()=>b(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${Y}`:`Pin ${Y}`,name:Y}):e.pinned?`Unpin ${Y}`:`Pin ${Y}`,children:e.pinned?(0,z.jsx)(x,{className:`h-3.5 w-3.5`}):(0,z.jsx)(d,{className:`h-3.5 w-3.5`})})]})}function oe({items:e,basePath:t=``,evaluateVisibility:n=ee,checkPermission:r=Y,checkCapability:i=X,onAction:a,searchQuery:o,enablePinning:s,onPinToggle:c,enableReorder:l,onReorder:u,resolveObjectLabel:d,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:v,templateContext:y}){let x=(0,R.useMemo)(()=>o?re(e,o):e,[e,o]),C=(0,R.useMemo)(()=>se(x),[x]),w=x.slice().sort((e,t)=>(e.order??0)-(t.order??0)),E=A(j(k,{activationConstraint:{distance:ie}}),j(L)),D=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!u)return;let r=w.findIndex(e=>e.id===t.id),i=w.findIndex(e=>e.id===n.id);r===-1||i===-1||u(M(w,r,i).map((e,t)=>({...e,order:t})))},N={basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,resolveObjectLabel:d,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:v,templateContext:y},B=w.some(e=>e.type===`group`),V=C.length>0&&s?(0,z.jsxs)(_,{children:[(0,z.jsxs)(T,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(b,{className:`h-3.5 w-3.5`}),v?v(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,z.jsx)(S,{children:(0,z.jsx)(f,{children:C.map(e=>(0,z.jsx)($,{item:e,...N},`fav-${e.id}`))})})]}):null;if(!B){let e=w.filter(e=>e.type!==`group`).map(e=>e.id);return(0,z.jsxs)(z.Fragment,{children:[V,(0,z.jsx)(_,{children:(0,z.jsx)(S,{children:l?(0,z.jsx)(O,{sensors:E,collisionDetection:P,onDragEnd:D,children:(0,z.jsx)(I,{items:e,strategy:F,children:(0,z.jsx)(f,{children:w.map(e=>(0,z.jsx)(ae,{item:e,enableReorder:l,...N},e.id))})})}):(0,z.jsx)(f,{children:w.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})})]})}let H=[],U=[],W=e=>{if(U.length===0)return;let t=U;U=[],H.push((0,z.jsx)(_,{children:(0,z.jsx)(S,{children:(0,z.jsx)(f,{children:t.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})},e))};return w.forEach((e,t)=>{e.type===`group`?(W(`leaf-${t}`),H.push((0,z.jsx)($,{item:e,...N},e.id))):U.push(e)}),W(`leaf-end`),(0,z.jsxs)(z.Fragment,{children:[V,H]})}function se(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...se(n.children));return t}export{Q as n,G as r,oe as t};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,l as n,r,t as i}from"./vendor-react-DR370ovB.js";import{$n as a,Co as o,Ct as s,Et as c,Gn as l,Ki as u,St as d,Ts as f,Tt as p,Un as m,Wn as h,Z as g,_t as _,io as v,ni as y,pc as b,qi as x,vt as S,wt as C,xt as w,yt as T,zt as E}from"./ui-components-CrPYFyEM.js";import{_ as D,c as O,d as k,g as A,h as j,n as M,o as N,p as P,s as F,t as I,u as L}from"./vendor-dndkit-DMFEUxSy.js";var R=e(t(),1),z=i();function B(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return null;let n=parseInt(t[1],16)/255,r=parseInt(t[2],16)/255,i=parseInt(t[3],16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=0,c=0,l=(a+o)/2;if(a!==o){let e=a-o;switch(c=l>.5?e/(2-a-o):e/(a+o),a){case n:s=((r-i)/e+(r<i?6:0))/6;break;case r:s=((i-n)/e+2)/6;break;case i:s=((n-r)/e+4)/6;break}}return{h:s*360,s:c*100,l:l*100}}function V(e){let t=B(e);return t?`${Math.round(t.h)} ${Math.round(t.s)}% ${Math.round(t.l)}%`:null}function H(e){let t=B(e);if(!t)return null;let n=Math.max(t.l,65),r=t.s>80?Math.max(t.s-10,70):t.s;return`${Math.round(t.h)} ${Math.round(r)}% ${Math.round(n)}%`}function U(e){let t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(!t)return`0 0% 100%`;let n=e=>{let t=e/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},r=n(parseInt(t[1],16)),i=n(parseInt(t[2],16)),a=n(parseInt(t[3],16));return .2126*r+.7152*i+.0722*a>.6?`222 47% 11%`:`0 0% 100%`}function W(e,t){(0,R.useEffect)(()=>{let n=document.documentElement,r=()=>n.classList.contains(`dark`),i=()=>{if(e?.primaryColor){let t=V(e.primaryColor),i=H(e.primaryColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-primary`,e.primaryColor),n.style.setProperty(`--brand-primary-hsl`,t||a),n.style.setProperty(`--primary`,a),n.style.setProperty(`--primary-foreground`,r()?`222 47% 11%`:U(e.primaryColor)),n.style.setProperty(`--ring`,a),n.style.setProperty(`--sidebar-primary`,a),n.style.setProperty(`--sidebar-ring`,a))}else n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`);if(e?.accentColor){let t=V(e.accentColor),i=H(e.accentColor),a=r()&&i||t;a&&(n.style.setProperty(`--brand-accent`,e.accentColor),n.style.setProperty(`--brand-accent-hsl`,t||a),n.style.setProperty(`--accent`,a),n.style.setProperty(`--accent-foreground`,r()?`222 47% 11%`:U(e.accentColor)))}else n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)};i();let a=new MutationObserver(e=>{for(let t of e)if(t.type===`attributes`&&t.attributeName===`class`){i();break}});if(a.observe(n,{attributes:!0,attributeFilter:[`class`]}),e?.favicon){let t=document.querySelector(`#favicon`)||document.querySelector(`link[rel="icon"]`);t&&(t.href=e.favicon)}return t&&(document.title=t),()=>{a.disconnect(),n.style.removeProperty(`--brand-primary`),n.style.removeProperty(`--brand-primary-hsl`),n.style.removeProperty(`--brand-accent`),n.style.removeProperty(`--brand-accent-hsl`),n.style.removeProperty(`--primary`),n.style.removeProperty(`--primary-foreground`),n.style.removeProperty(`--ring`),n.style.removeProperty(`--sidebar-primary`),n.style.removeProperty(`--sidebar-ring`),n.style.removeProperty(`--accent`),n.style.removeProperty(`--accent-foreground`)}},[e?.primaryColor,e?.accentColor,e?.favicon,t])}function G({sidebar:e,navbar:t,children:n,className:r,defaultOpen:i=!0,branding:a}){return W(a,a?.title),(0,z.jsxs)(c,{defaultOpen:i,className:`!flex-col h-svh overflow-hidden`,children:[(0,z.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:t}),(0,z.jsxs)(`div`,{className:`flex flex-1 min-h-0 w-full`,children:[e,(0,z.jsx)(w,{className:`min-w-0`,children:(0,z.jsx)(`main`,{className:b(`flex-1 min-w-0 overflow-auto p-3 sm:p-4 md:p-6 pb-20 sm:pb-4 md:pb-6`,r),children:n})})]})]})}function K(e){return e?g(e):o}function q(e,t){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}function J(e,t,n,r,i,a,o){let s=q(e.label,n);if(typeof e.label!=`string`)return s;if(e.type===`object`&&e.objectName){if(e.viewName)return a?a(e.objectName,e.viewName,s):s;if(t)return t(e.objectName,s)}return r&&e.type===`dashboard`&&e.dashboardName?r(e.dashboardName,s):i&&e.type===`group`&&e.id?i(e.id,s):o&&e.id?o(e.id,s):s}var ee=e=>!(e===!1||e===`false`),Y=()=>!0,X=()=>!0,te=/\{(current_user_id|current_org_id|[a-z][a-z0-9_]*)\}/g;function Z(e,t){if(!e.includes(`{`))return e;let n=!1,r=e.replace(te,(e,r)=>{let i;return i=r===`current_user_id`?t?.currentUserId:r===`current_org_id`?t?.currentOrgId:t?.contextValues?.[r],i||(n=!0,``)});return n?null:r}function Q(e,t,n){switch(e.type){case`object`:{let r=`${t}/${e.objectName??``}`,i=e.recordId;if(i){let t=Z(i,n);if(t){let n=`${r}/record/${encodeURIComponent(t)}`;return{href:e.recordMode===`edit`?`${n}/edit`:n,external:!1}}}return{href:e.viewName?`${r}/view/${e.viewName}`:r,external:!1}}case`dashboard`:return{href:e.dashboardName?`${t}/dashboard/${e.dashboardName}`:`#`,external:!1};case`page`:{if(!e.pageName)return{href:`#`,external:!1};let r=e.params,i=`${t}/page/${e.pageName}`;if(r&&typeof r==`object`){let e=new URLSearchParams;for(let[t,i]of Object.entries(r))if(i!=null)if(typeof i==`string`){let r=Z(i,n);r!==null&&e.set(t,r)}else e.set(t,JSON.stringify(i));let t=e.toString();t&&(i+=`?${t}`)}return{href:i,external:!1}}case`report`:return{href:e.reportName?`${t}/report/${e.reportName}`:`#`,external:!1};case`url`:return{href:e.url??`#`,external:e.target===`_blank`};case`component`:{let r=e.componentRef;if(!r)return{href:`#`,external:!1};let i=r.split(`:`).filter(Boolean);if(i.length===0)return{href:`#`,external:!1};let a=e.params;if(i[0]===`metadata`){let e=i[1],r=a&&typeof a.type==`string`?a.type:void 0,o=a&&typeof a.name==`string`?a.name:void 0,s=``;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,r]of Object.entries(a))if(!(t===`type`||t===`name`)&&r!=null)if(typeof r==`string`){let i=Z(r,n);i&&e.set(t,i)}else e.set(t,JSON.stringify(r));let t=e.toString();t&&(s=`?${t}`)}return e===`directory`||!e?{href:`${t}/metadata${s}`,external:!1}:e===`resource`&&r?{href:`${t}/metadata${o?`/${encodeURIComponent(r)}/${encodeURIComponent(o)}`:`/${encodeURIComponent(r)}`}${s}`,external:!1}:{href:`${t}/metadata${s}`,external:!1}}let o=`${t}/component/${i.join(`/`)}`;if(a&&typeof a==`object`){let e=new URLSearchParams;for(let[t,n]of Object.entries(a))n!=null&&e.set(t,typeof n==`string`?n:JSON.stringify(n));let t=e.toString();t&&(o+=`?${t}`)}return{href:o,external:!1}}default:return{href:`#`,external:!1}}}function ne(e,t,n){if(t===`#`)return!1;if(n===t)return!0;let r=e.componentRef;return r&&r.split(`:`)[1]===`directory`?!1:e.type===`object`&&e.objectName?!(e.viewName||!n.startsWith(`${t}/`)||n.slice(t.length+1).startsWith(`view/`)):n.startsWith(`${t}/`)}function re(e,t){if(!t.trim())return e;let n=t.toLowerCase().trim();return e.reduce((e,r)=>{if(r.type===`separator`)return e;if(r.type===`group`&&r.children?.length){let n=re(r.children,t);return n.length>0&&e.push({...r,children:n}),e}return q(r.label).toLowerCase().includes(n)&&e.push(r),e},[])}var ie=5;function ae({item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,enableReorder:c,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h}){let{attributes:g,listeners:_,setNodeRef:v,transform:y,transition:b,isDragging:x}=N({id:e.id,disabled:!c});return(0,z.jsx)(`div`,{ref:v,style:{transform:D.Transform.toString(y),transition:b,opacity:x?.5:void 0,zIndex:x?10:void 0},...g,children:(0,z.jsx)($,{item:e,basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:o,onPinToggle:s,dragListeners:c?_:void 0,resolveObjectLabel:l,resolveDashboardLabel:u,resolveGroupLabel:d,resolveViewLabel:f,resolveItemLabel:p,t:m,templateContext:h})})}function $({item:e,basePath:t,evalVis:i,checkPerm:o,checkCap:c,onAction:g,enablePinning:y,onPinToggle:b,dragListeners:w,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N}){let P=n(),F=(()=>{let t=e.expanded;if(typeof t==`boolean`)return t;if(typeof e.defaultOpen==`boolean`)return e.defaultOpen})(),I=e.type===`group`?e.children?.length??0:0,[L,B]=(0,R.useState)(R.useMemo(()=>{if(e.type!==`group`)return!1;let n=e=>{if(!e)return!1;for(let r of e){if(r.type===`group`){if(n(r.children))return!0;continue}let{href:e}=Q(r,t,N);if(ne(r,e,P.pathname))return!0}return!1};return n(e.children)},[e,t,P.pathname])?!0:F??!(I>=8));if(!i(e.visible)||e.requiredPermissions?.length&&!o(e.requiredPermissions))return null;let V=e.requiresObject,H=e.requiresService;if(V&&!c(`object`,V)||H&&!c(`service`,H))return null;if(e.type===`separator`)return(0,z.jsx)(E,{className:`my-2`});if(e.type===`group`){let n=(e.children??[]).slice().sort((e,t)=>(e.order??0)-(t.order??0));return(0,z.jsx)(m,{open:L,onOpenChange:B,children:(0,z.jsxs)(_,{children:[(0,z.jsx)(T,{asChild:!0,children:(0,z.jsxs)(l,{className:`flex w-full items-center justify-between`,children:[J(e,D,M,O,k,A,j),(0,z.jsx)(f,{className:`ml-auto h-4 w-4 transition-transform ${L?`rotate-90`:``}`})]})}),(0,z.jsx)(h,{children:(0,z.jsx)(S,{children:(0,z.jsx)(d,{children:n.map(e=>(0,z.jsx)($,{item:e,basePath:t,evalVis:i,checkPerm:o,checkCap:c,onAction:g,enablePinning:y,onPinToggle:b,resolveObjectLabel:D,resolveDashboardLabel:O,resolveGroupLabel:k,resolveViewLabel:A,resolveItemLabel:j,t:M,templateContext:N},e.id))})})})]})})}if(e.type===`action`){let n=K(e.icon),r=q(e.label,M);return(0,z.jsxs)(p,{children:[w&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...w,children:(0,z.jsx)(v,{className:`h-3.5 w-3.5`})}),(0,z.jsxs)(C,{tooltip:r,onClick:()=>g?.(e),children:[(0,z.jsx)(n,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:r}),e.badge!=null&&(0,z.jsx)(a,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]}),y&&b&&(0,z.jsx)(s,{showOnHover:!0,onClick:()=>b(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${r}`:`Pin ${r}`,name:r}):e.pinned?`Unpin ${r}`:`Pin ${r}`,children:e.pinned?(0,z.jsx)(x,{className:`h-3.5 w-3.5`}):(0,z.jsx)(u,{className:`h-3.5 w-3.5`})})]})}let U=K(e.icon),{href:W,external:G}=Q(e,t,N),ee=ne(e,W,P.pathname),Y=J(e,D,M,O,k,A,j),X=(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(U,{className:`h-4 w-4`}),(0,z.jsx)(`span`,{children:Y}),e.badge!=null&&(0,z.jsx)(a,{variant:e.badgeVariant??`default`,className:`ml-auto text-[10px] px-1.5 py-0`,children:e.badge})]});return(0,z.jsxs)(p,{children:[w&&(0,z.jsx)(`span`,{className:`absolute left-0.5 top-1/2 -translate-y-1/2 cursor-grab text-muted-foreground`,"aria-label":M?M(`console.nav.dragToReorder`,{defaultValue:`Drag to reorder`}):`Drag to reorder`,...w,children:(0,z.jsx)(v,{className:`h-3.5 w-3.5`})}),(0,z.jsx)(C,{asChild:!0,isActive:ee,tooltip:Y,children:G?(0,z.jsx)(`a`,{href:W,target:`_blank`,rel:`noopener noreferrer`,children:X}):(0,z.jsx)(r,{to:W,children:X})}),y&&b&&(0,z.jsx)(s,{showOnHover:!0,onClick:()=>b(e.id,!e.pinned,e,t),"aria-label":M?M(e.pinned?`console.nav.unpinItem`:`console.nav.pinItem`,{defaultValue:e.pinned?`Unpin ${Y}`:`Pin ${Y}`,name:Y}):e.pinned?`Unpin ${Y}`:`Pin ${Y}`,children:e.pinned?(0,z.jsx)(x,{className:`h-3.5 w-3.5`}):(0,z.jsx)(u,{className:`h-3.5 w-3.5`})})]})}function oe({items:e,basePath:t=``,evaluateVisibility:n=ee,checkPermission:r=Y,checkCapability:i=X,onAction:a,searchQuery:o,enablePinning:s,onPinToggle:c,enableReorder:l,onReorder:u,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:v,templateContext:b}){let x=(0,R.useMemo)(()=>o?re(e,o):e,[e,o]),C=(0,R.useMemo)(()=>se(x),[x]),w=x.slice().sort((e,t)=>(e.order??0)-(t.order??0)),E=A(j(k,{activationConstraint:{distance:ie}}),j(L)),D=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!u)return;let r=w.findIndex(e=>e.id===t.id),i=w.findIndex(e=>e.id===n.id);r===-1||i===-1||u(M(w,r,i).map((e,t)=>({...e,order:t})))},N={basePath:t,evalVis:n,checkPerm:r,checkCap:i,onAction:a,enablePinning:s,onPinToggle:c,resolveObjectLabel:f,resolveDashboardLabel:p,resolveGroupLabel:m,resolveViewLabel:h,resolveItemLabel:g,t:v,templateContext:b},B=w.some(e=>e.type===`group`),V=C.length>0&&s?(0,z.jsxs)(_,{children:[(0,z.jsxs)(T,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(y,{className:`h-3.5 w-3.5`}),v?v(`console.nav.favorites`,{defaultValue:`Favorites`}):`Favorites`]}),(0,z.jsx)(S,{children:(0,z.jsx)(d,{children:C.map(e=>(0,z.jsx)($,{item:e,...N},`fav-${e.id}`))})})]}):null;if(!B){let e=w.filter(e=>e.type!==`group`).map(e=>e.id);return(0,z.jsxs)(z.Fragment,{children:[V,(0,z.jsx)(_,{children:(0,z.jsx)(S,{children:l?(0,z.jsx)(O,{sensors:E,collisionDetection:P,onDragEnd:D,children:(0,z.jsx)(I,{items:e,strategy:F,children:(0,z.jsx)(d,{children:w.map(e=>(0,z.jsx)(ae,{item:e,enableReorder:l,...N},e.id))})})}):(0,z.jsx)(d,{children:w.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})})]})}let H=[],U=[],W=e=>{if(U.length===0)return;let t=U;U=[],H.push((0,z.jsx)(_,{children:(0,z.jsx)(S,{children:(0,z.jsx)(d,{children:t.map(e=>(0,z.jsx)($,{item:e,...N},e.id))})})},e))};return w.forEach((e,t)=>{e.type===`group`?(W(`leaf-${t}`),H.push((0,z.jsx)($,{item:e,...N},e.id))):U.push(e)}),W(`leaf-end`),(0,z.jsxs)(z.Fragment,{children:[V,H]})}function se(e){let t=[];for(let n of e)n.pinned&&n.type!==`group`&&n.type!==`separator`&&t.push(n),n.children?.length&&t.push(...se(n.children));return t}export{Q as n,G as r,oe as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{f as r}from"./infrastructure-CJNwTVno.js";import{B as i}from"./framework-DLckRGJs.js";import{Ft as a,Hn as o,It as s,Ln as c,Lt as l,Pt as u,Rn as d,Rt as f,Vn as p,_n as m,bn as h,dc as g,hr as _,vn as v,xn as y,yn as b,zn as x}from"./ui-components-B2CBE2Rs.js";import{n as S}from"./plugin-form-FmgnWzcl.js";import{a as C,c as w,i as T,s as E}from"./RecentItemsProvider-B76qldBH.js";var D=e(t(),1),O=n(),k=`objectui-favorites`,A=`objectui-nav-pins`,j=20,M=20;function N(e){let t=0,n=0,r=!1;for(let i of e)i.type===`nav`?(n++,n>M&&(r=!0)):(t++,t>j&&(r=!0));if(!r)return e;let i=[],a=0,o=0;for(let t of e)t.type===`nav`?o<M&&(i.push(t),o++):a<j&&(i.push(t),a++);return i}function P(e){try{let t=localStorage.getItem(C(k,e));return t?JSON.parse(t):[]}catch{return[]}}function F(e,t){try{localStorage.setItem(C(k,t),JSON.stringify(e))}catch{}}function I(e){let t;try{t=localStorage.getItem(A)}catch{return{migrated:e,didMigrate:!1}}if(!t)return{migrated:e,didMigrate:!1};let n=[];try{let e=JSON.parse(t);Array.isArray(e)&&(n=e.filter(e=>typeof e==`string`))}catch{}try{localStorage.removeItem(A)}catch{}if(n.length===0)return{migrated:e,didMigrate:!1};let r=new Set(e.filter(e=>e.type===`nav`&&e.navId).map(e=>e.navId)),i=new Date().toISOString(),a=[];for(let e of n)r.has(e)||a.push({id:`nav:${e}`,label:e,href:``,type:`nav`,navId:e,pinned:!0,favoritedAt:i});return a.length===0?{migrated:e,didMigrate:!0}:{migrated:[...e,...a],didMigrate:!0}}var L=(0,D.createContext)(null);function R({children:e}){let{user:t}=r(),n=t?.id??null,i=w(`favorites`),[a,o]=(0,D.useState)(()=>P(n));(0,D.useEffect)(()=>{o(P(n))},[n]),E(C(k,n),e=>{o(Array.isArray(e)?N(e.filter(e=>e&&typeof e.id==`string`)):[])});let s=(0,D.useRef)(0);(0,D.useEffect)(()=>{if(!i)return;let e=++s.current,t=!1;return(async()=>{try{let r=await i.load();if(t||e!==s.current)return;let a=N((Array.isArray(r)?r:[]).filter(e=>e&&typeof e.id==`string`)),l=P(n),u=new Set(a.filter(e=>e.type===`nav`&&e.navId).map(e=>e.navId)),d=l.filter(e=>e.type===`nav`&&e.navId&&!u.has(e.navId)),f=a,p=!1;d.length>0&&(f=N([...a,...d]),p=!0);let{migrated:m,didMigrate:h}=I(f);h&&(f=N(m),p=!0),o(f),F(f,n),p&&c.schedule(f)}catch{}})(),()=>{t=!0}},[i,n]),(0,D.useEffect)(()=>{i||o(e=>{let{migrated:t,didMigrate:r}=I(e);if(!r)return e;let i=N(t);return F(i,n),i})},[i,n]);let c=(0,D.useMemo)(()=>T(async e=>{i&&await i.save(e)},500),[i]);(0,D.useEffect)(()=>()=>{c.flush()},[c]);let l=(0,D.useCallback)(e=>{F(e,n),i&&c.schedule(e)},[n,i,c]),u=(0,D.useCallback)(e=>{o(t=>{if(t.some(t=>t.id===e.id))return t;let n=N([{...e,favoritedAt:new Date().toISOString()},...t]);return l(n),n})},[l]),d=(0,D.useCallback)(e=>{o(t=>{let n=t.filter(t=>t.id!==e);return l(n),n})},[l]),f=(0,D.useCallback)(e=>{o(t=>{let n=t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):N([{...e,favoritedAt:new Date().toISOString()},...t]);return l(n),n})},[l]),p=(0,D.useCallback)(()=>{o([]),l([])},[l]),m=(0,D.useCallback)((e,t)=>{!e||!t||o(n=>{let r=!1,i=n.map(n=>n.id===e&&n.label!==t?(r=!0,{...n,label:t}):n);return r?(l(i),i):n})},[l]),h=(0,D.useCallback)((e,t)=>{o(n=>{let r=!1,i=n.map(n=>n.id!==e||!!n.pinned===t?n:(r=!0,{...n,pinned:t}));return r?(l(i),i):n})},[l]),g=(0,D.useMemo)(()=>{let e=new Set;for(let t of a)t.pinned&&t.type===`nav`&&t.navId&&e.add(t.navId);return{favorites:a,addFavorite:u,removeFavorite:d,toggleFavorite:f,isFavorite:e=>a.some(t=>t.id===e),clearFavorites:p,refreshLabel:m,setPinned:h,isPinned:e=>a.some(t=>t.id===e&&!!t.pinned),pinnedNavIds:e}},[a,u,d,f,p,m,h]);return(0,O.jsx)(L.Provider,{value:g,children:e})}function z(){return(0,D.useContext)(L)||{favorites:[],addFavorite:()=>{},removeFavorite:()=>{},toggleFavorite:()=>{},isFavorite:()=>!1,clearFavorites:()=>{},refreshLabel:()=>{},setPinned:()=>{},isPinned:()=>!1,pinnedNavIds:new Set}}function B(){return`${``.replace(/\/$/,``)}/api/v1`}async function V(e,t){let n=await fetch(`${B()}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=Error(r?.error||`HTTP ${n.status}`);throw e.code=r?.code??`HTTP_${n.status}`,e.status=n.status,e}return r}function H(e,t,n){let[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(!0),[s,c]=(0,D.useState)([]),l=(0,D.useRef)(!1),u=(0,D.useCallback)(async()=>{if(!(!e||!t)&&!l.current){i(!0);try{c((await V(`/approvals/requests?object=${encodeURIComponent(e)}&recordId=${encodeURIComponent(t)}`))?.data??[]),o(!0)}catch(e){(e?.status===404||e?.status===501)&&(l.current=!0,o(!1))}finally{i(!1)}}},[e,t]);(0,D.useEffect)(()=>{if(!e||!t){c([]);return}u()},[e,t,u]);let d=(0,D.useMemo)(()=>s.find(e=>e.status===`pending`)??null,[s]),f=(0,D.useMemo)(()=>s.length===0?null:[...s].sort((e,t)=>{let n=e.submitted_at||e.completed_at||``;return(t.submitted_at||t.completed_at||``).localeCompare(n)})[0]??null,[s]),p=!!d&&!!n&&(d.pending_approvers??[]).includes(n),m=(0,D.useCallback)(async(e,t)=>{if(!d)throw Error(`No pending request`);let r=await V(`/approvals/requests/${encodeURIComponent(d.id)}/${e}`,{method:`POST`,body:JSON.stringify({...n?{actorId:n}:{},...t?.comment?{comment:t.comment}:{}})});return await u(),r?.request},[d,n,u]);return{loading:r,available:a,pendingRequest:d,latestRequest:f,canDecide:p,approve:(0,D.useCallback)(e=>m(`approve`,e),[m]),reject:(0,D.useCallback)(e=>m(`reject`,e),[m]),refresh:u}}var U={sm:`sm:max-w-sm`,default:`sm:max-w-lg`,lg:`sm:max-w-2xl`,xl:`sm:max-w-5xl`,full:`sm:max-w-[95vw] sm:w-full`},W={lg:`sm:max-w-2xl`,xl:`sm:max-w-3xl`,full:`sm:max-w-[95vw]`};function G(e){if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);return t?{objectName:t[2],mode:t[1]===`edit`||t[1]===`update`?`edit`:`create`}:{objectName:e,mode:`create`}}return e&&typeof e==`object`?e.type&&!e.content&&!e.objectName&&!e.placement?{content:e}:e:{}}function K(e){let[t,n]=(0,D.useState)(null),r=(0,D.useCallback)(e=>{n(t=>(t?.resolve(e),null))},[]),C=(0,D.useCallback)(e=>new Promise(t=>{n({d:G(e),resolve:t})}),[]),w=null;if(t){let n=t.d,C=e=>{e||r({success:!1})};if(n.objectName&&!n.content)w=(0,O.jsx)(S,{schema:{type:`object-form`,formType:`modal`,objectName:n.objectName,mode:n.mode||`create`,recordId:n.recordId,title:n.title,description:n.description,fields:n.fields,modalSize:n.size,open:!0,onOpenChange:C,onSuccess:e=>r({success:!0,reload:!0,data:e}),onCancel:()=>r({success:!1}),showSubmit:!0,showCancel:!0},dataSource:e});else{let e=n.placement||`center`,t=n.content?(0,O.jsx)(i,{schema:n.content}):n.description?(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}):null;w=e===`side`?(0,O.jsx)(u,{open:!0,onOpenChange:C,children:(0,O.jsxs)(a,{side:n.side||`right`,className:g(`w-full overflow-y-auto`,W[n.size||`default`]),children:[n.title&&(0,O.jsxs)(l,{children:[(0,O.jsx)(f,{children:n.title}),n.description&&(0,O.jsx)(s,{children:n.description})]}),(0,O.jsx)(`div`,{className:`py-3`,children:t})]})}):e===`bottom`?(0,O.jsx)(m,{open:!0,onOpenChange:C,children:(0,O.jsxs)(v,{children:[n.title&&(0,O.jsxs)(h,{children:[(0,O.jsx)(y,{children:n.title}),n.description&&(0,O.jsx)(b,{children:n.description})]}),(0,O.jsx)(`div`,{className:`max-h-[75vh] overflow-y-auto px-4 pb-6`,children:t})]})}):(0,O.jsx)(c,{open:!0,onOpenChange:C,children:(0,O.jsxs)(d,{className:g(e===`fullscreen`?`h-[95vh] w-full max-w-[98vw] overflow-y-auto`:U[n.size||`default`]),children:[n.title&&(0,O.jsxs)(p,{children:[(0,O.jsx)(o,{children:n.title}),n.description&&(0,O.jsx)(x,{children:n.description})]}),(0,O.jsx)(`div`,{children:t}),!n.content&&(0,O.jsx)(`div`,{className:`flex justify-end`,children:(0,O.jsx)(_,{onClick:()=>r({success:!0}),children:`OK`})})]})})}}return{modalHandler:C,modalElement:w,closeModal:r}}export{z as i,H as n,R as r,K as t};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{f as r}from"./infrastructure-CJNwTVno.js";import{B as i}from"./framework-BLEk-ou3.js";import{Ft as a,Hn as o,It as s,Ln as c,Lt as l,Pt as u,Rn as d,Rt as f,Vn as p,_n as m,bn as h,hr as g,pc as _,vn as v,xn as y,yn as b,zn as x}from"./ui-components-CrPYFyEM.js";import{n as S}from"./plugin-form-DXCdD2d-.js";import{a as C,c as w,i as T,s as E}from"./RecentItemsProvider-B76qldBH.js";var D=e(t(),1),O=n(),k=`objectui-favorites`,A=`objectui-nav-pins`,j=20,M=20;function N(e){let t=0,n=0,r=!1;for(let i of e)i.type===`nav`?(n++,n>M&&(r=!0)):(t++,t>j&&(r=!0));if(!r)return e;let i=[],a=0,o=0;for(let t of e)t.type===`nav`?o<M&&(i.push(t),o++):a<j&&(i.push(t),a++);return i}function P(e){try{let t=localStorage.getItem(C(k,e));return t?JSON.parse(t):[]}catch{return[]}}function F(e,t){try{localStorage.setItem(C(k,t),JSON.stringify(e))}catch{}}function I(e){let t;try{t=localStorage.getItem(A)}catch{return{migrated:e,didMigrate:!1}}if(!t)return{migrated:e,didMigrate:!1};let n=[];try{let e=JSON.parse(t);Array.isArray(e)&&(n=e.filter(e=>typeof e==`string`))}catch{}try{localStorage.removeItem(A)}catch{}if(n.length===0)return{migrated:e,didMigrate:!1};let r=new Set(e.filter(e=>e.type===`nav`&&e.navId).map(e=>e.navId)),i=new Date().toISOString(),a=[];for(let e of n)r.has(e)||a.push({id:`nav:${e}`,label:e,href:``,type:`nav`,navId:e,pinned:!0,favoritedAt:i});return a.length===0?{migrated:e,didMigrate:!0}:{migrated:[...e,...a],didMigrate:!0}}var L=(0,D.createContext)(null);function R({children:e}){let{user:t}=r(),n=t?.id??null,i=w(`favorites`),[a,o]=(0,D.useState)(()=>P(n));(0,D.useEffect)(()=>{o(P(n))},[n]),E(C(k,n),e=>{o(Array.isArray(e)?N(e.filter(e=>e&&typeof e.id==`string`)):[])});let s=(0,D.useRef)(0);(0,D.useEffect)(()=>{if(!i)return;let e=++s.current,t=!1;return(async()=>{try{let r=await i.load();if(t||e!==s.current)return;let a=N((Array.isArray(r)?r:[]).filter(e=>e&&typeof e.id==`string`)),l=P(n),u=new Set(a.filter(e=>e.type===`nav`&&e.navId).map(e=>e.navId)),d=l.filter(e=>e.type===`nav`&&e.navId&&!u.has(e.navId)),f=a,p=!1;d.length>0&&(f=N([...a,...d]),p=!0);let{migrated:m,didMigrate:h}=I(f);h&&(f=N(m),p=!0),o(f),F(f,n),p&&c.schedule(f)}catch{}})(),()=>{t=!0}},[i,n]),(0,D.useEffect)(()=>{i||o(e=>{let{migrated:t,didMigrate:r}=I(e);if(!r)return e;let i=N(t);return F(i,n),i})},[i,n]);let c=(0,D.useMemo)(()=>T(async e=>{i&&await i.save(e)},500),[i]);(0,D.useEffect)(()=>()=>{c.flush()},[c]);let l=(0,D.useCallback)(e=>{F(e,n),i&&c.schedule(e)},[n,i,c]),u=(0,D.useCallback)(e=>{o(t=>{if(t.some(t=>t.id===e.id))return t;let n=N([{...e,favoritedAt:new Date().toISOString()},...t]);return l(n),n})},[l]),d=(0,D.useCallback)(e=>{o(t=>{let n=t.filter(t=>t.id!==e);return l(n),n})},[l]),f=(0,D.useCallback)(e=>{o(t=>{let n=t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):N([{...e,favoritedAt:new Date().toISOString()},...t]);return l(n),n})},[l]),p=(0,D.useCallback)(()=>{o([]),l([])},[l]),m=(0,D.useCallback)((e,t)=>{!e||!t||o(n=>{let r=!1,i=n.map(n=>n.id===e&&n.label!==t?(r=!0,{...n,label:t}):n);return r?(l(i),i):n})},[l]),h=(0,D.useCallback)((e,t)=>{o(n=>{let r=!1,i=n.map(n=>n.id!==e||!!n.pinned===t?n:(r=!0,{...n,pinned:t}));return r?(l(i),i):n})},[l]),g=(0,D.useMemo)(()=>{let e=new Set;for(let t of a)t.pinned&&t.type===`nav`&&t.navId&&e.add(t.navId);return{favorites:a,addFavorite:u,removeFavorite:d,toggleFavorite:f,isFavorite:e=>a.some(t=>t.id===e),clearFavorites:p,refreshLabel:m,setPinned:h,isPinned:e=>a.some(t=>t.id===e&&!!t.pinned),pinnedNavIds:e}},[a,u,d,f,p,m,h]);return(0,O.jsx)(L.Provider,{value:g,children:e})}function z(){return(0,D.useContext)(L)||{favorites:[],addFavorite:()=>{},removeFavorite:()=>{},toggleFavorite:()=>{},isFavorite:()=>!1,clearFavorites:()=>{},refreshLabel:()=>{},setPinned:()=>{},isPinned:()=>!1,pinnedNavIds:new Set}}function B(){return`${``.replace(/\/$/,``)}/api/v1`}async function V(e,t){let n=await fetch(`${B()}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers||{}},...t}),r=null;try{r=await n.json()}catch{}if(!n.ok){let e=Error(r?.error||`HTTP ${n.status}`);throw e.code=r?.code??`HTTP_${n.status}`,e.status=n.status,e}return r}function H(e,t,n){let[r,i]=(0,D.useState)(!1),[a,o]=(0,D.useState)(!0),[s,c]=(0,D.useState)([]),l=(0,D.useRef)(!1),u=(0,D.useCallback)(async()=>{if(!(!e||!t)&&!l.current){i(!0);try{c((await V(`/approvals/requests?object=${encodeURIComponent(e)}&recordId=${encodeURIComponent(t)}`))?.data??[]),o(!0)}catch(e){(e?.status===404||e?.status===501)&&(l.current=!0,o(!1))}finally{i(!1)}}},[e,t]);(0,D.useEffect)(()=>{if(!e||!t){c([]);return}u()},[e,t,u]);let d=(0,D.useMemo)(()=>s.find(e=>e.status===`pending`)??null,[s]),f=(0,D.useMemo)(()=>s.length===0?null:[...s].sort((e,t)=>{let n=e.submitted_at||e.completed_at||``;return(t.submitted_at||t.completed_at||``).localeCompare(n)})[0]??null,[s]),p=!!d&&!!n&&(d.pending_approvers??[]).includes(n),m=(0,D.useCallback)(async(e,t)=>{if(!d)throw Error(`No pending request`);let r=await V(`/approvals/requests/${encodeURIComponent(d.id)}/${e}`,{method:`POST`,body:JSON.stringify({...n?{actorId:n}:{},...t?.comment?{comment:t.comment}:{}})});return await u(),r?.request},[d,n,u]);return{loading:r,available:a,pendingRequest:d,latestRequest:f,canDecide:p,approve:(0,D.useCallback)(e=>m(`approve`,e),[m]),reject:(0,D.useCallback)(e=>m(`reject`,e),[m]),refresh:u}}var U={sm:`sm:max-w-sm`,default:`sm:max-w-lg`,lg:`sm:max-w-2xl`,xl:`sm:max-w-5xl`,full:`sm:max-w-[95vw] sm:w-full`},W={lg:`sm:max-w-2xl`,xl:`sm:max-w-3xl`,full:`sm:max-w-[95vw]`};function G(e){if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);return t?{objectName:t[2],mode:t[1]===`edit`||t[1]===`update`?`edit`:`create`}:{objectName:e,mode:`create`}}return e&&typeof e==`object`?e.type&&!e.content&&!e.objectName&&!e.placement?{content:e}:e:{}}function K(e){let[t,n]=(0,D.useState)(null),r=(0,D.useCallback)(e=>{n(t=>(t?.resolve(e),null))},[]),C=(0,D.useCallback)(e=>new Promise(t=>{n({d:G(e),resolve:t})}),[]),w=null;if(t){let n=t.d,C=e=>{e||r({success:!1})};if(n.objectName&&!n.content)w=(0,O.jsx)(S,{schema:{type:`object-form`,formType:`modal`,objectName:n.objectName,mode:n.mode||`create`,recordId:n.recordId,title:n.title,description:n.description,fields:n.fields,modalSize:n.size,open:!0,onOpenChange:C,onSuccess:e=>r({success:!0,reload:!0,data:e}),onCancel:()=>r({success:!1}),showSubmit:!0,showCancel:!0},dataSource:e});else{let e=n.placement||`center`,t=n.content?(0,O.jsx)(i,{schema:n.content}):n.description?(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description}):null;w=e===`side`?(0,O.jsx)(u,{open:!0,onOpenChange:C,children:(0,O.jsxs)(a,{side:n.side||`right`,className:_(`w-full overflow-y-auto`,W[n.size||`default`]),children:[n.title&&(0,O.jsxs)(l,{children:[(0,O.jsx)(f,{children:n.title}),n.description&&(0,O.jsx)(s,{children:n.description})]}),(0,O.jsx)(`div`,{className:`py-3`,children:t})]})}):e===`bottom`?(0,O.jsx)(m,{open:!0,onOpenChange:C,children:(0,O.jsxs)(v,{children:[n.title&&(0,O.jsxs)(h,{children:[(0,O.jsx)(y,{children:n.title}),n.description&&(0,O.jsx)(b,{children:n.description})]}),(0,O.jsx)(`div`,{className:`max-h-[75vh] overflow-y-auto px-4 pb-6`,children:t})]})}):(0,O.jsx)(c,{open:!0,onOpenChange:C,children:(0,O.jsxs)(d,{className:_(e===`fullscreen`?`h-[95vh] w-full max-w-[98vw] overflow-y-auto`:U[n.size||`default`]),children:[n.title&&(0,O.jsxs)(p,{children:[(0,O.jsx)(o,{children:n.title}),n.description&&(0,O.jsx)(x,{children:n.description})]}),(0,O.jsx)(`div`,{children:t}),!n.content&&(0,O.jsx)(`div`,{className:`flex justify-end`,children:(0,O.jsx)(g,{onClick:()=>r({success:!0}),children:`OK`})})]})})}}return{modalHandler:C,modalElement:w,closeModal:r}}export{z as i,H as n,R as r,K as t};
@@ -0,0 +1 @@
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,u as r}from"./vendor-react-DR370ovB.js";import{I as i,T as a,r as o,w as s}from"./framework-BLEk-ou3.js";import{Dt as c}from"./ui-components-CrPYFyEM.js";import{r as l}from"./vendor-ui-utils-rQOI1gAo.js";import"./AdapterProvider-DJb3ZVmJ.js";import{u}from"./MetadataProvider-Bja7m8Gt.js";import{n as d}from"./RecentItemsProvider-B76qldBH.js";import{i as f}from"./useActionModal-DsVCm46J.js";import{n as p}from"./ui-layout-DAWxaQvy.js";import{n as m}from"./appRoute-D5vwtoc_.js";var h=e(t(),1);function g({objectName:e,objectLabel:t,dataSource:a,onEdit:s,onRefresh:c,onConfirm:u,onToast:d}){let f=r(),{appName:p}=n(),{t:m}=o(),g=`/apps/${p}`,{execute:_,loading:v,error:y,runner:b}=i({context:{objectName:e,objectLabel:t||e,baseUrl:g},onConfirm:u,onToast:d});return(0,h.useEffect)(()=>{b.registerHandler(`create`,async()=>(s?.(null),{success:!0})),b.registerHandler(`delete`,async n=>{let r=Array.isArray(n.params?.records)?n.params.records.filter(e=>e?.id!=null):null;if(r&&r.length>1){let n=await Promise.allSettled(r.map(t=>a.delete(e,t.id))),i=n.filter(e=>e.status===`rejected`).length,o=n.length-i;return c?.(),i===0?(l.success(m(`objectActions.bulkDeleteSuccess`,{count:o,label:t||e,defaultValue:`Deleted ${o} ${t||e} records`})),{success:!0,reload:!0}):(l.error(m(`objectActions.bulkDeletePartial`,{succeeded:o,failed:i,defaultValue:`${o} deleted, ${i} failed`})),{success:!1,error:`${i} failed`})}let i=n.params?.recordId??n.params?.record?.id??r?.[0]?.id??n.recordId;if(!i)return{success:!1,error:m(`objectActions.noRecordId`)};try{return await a.delete(e,i),c?.(),l.success(m(`objectActions.deleteSuccess`,{label:t||e})),{success:!0,reload:!0}}catch(n){return l.error(m(`objectActions.deleteFailed`,{label:t||e}),{description:n.message}),{success:!1,error:n.message}}}),b.registerHandler(`navigate`,async e=>{let t=e.params?.url||e.url;return t&&f(t.startsWith(`/`)?t:`${g}/${t}`),{success:!0}}),b.registerHandler(`refresh`,async()=>(c?.(),{success:!0,reload:!0}))},[b,e,a,s,c,f,g,m,t]),{execute:_,create:(0,h.useCallback)(()=>{s?.(null)},[s]),deleteRecord:(0,h.useCallback)(async e=>_({type:`delete`,confirmText:m(`objectActions.deleteConfirm`),params:{recordId:e}}),[_,m]),navigateToView:(0,h.useCallback)(t=>{f(`${g}/${e}/view/${t}`)},[f,g,e]),navigateToRecord:(0,h.useCallback)(t=>{f(`${g}/${e}/record/${encodeURIComponent(t)}`)},[f,g,e]),loading:v,error:y}}var _=20;function v(e,t=``){let{href:n,external:r}=p(e,t);return r?n:!n||n===`#`?``:n}function y(e){return`nav:${e}`}function b(){let{favorites:e,addFavorite:t,removeFavorite:n,setPinned:r,pinnedNavIds:i}=f(),a=(0,h.useCallback)((e,i,a,o)=>{let s=y(e);i?(a&&t({id:s,label:a.label,href:v(a,o??``),type:`nav`,navId:e,pinned:!0}),r(s,!0)):n(s)},[t,n,r]),o=(0,h.useCallback)(e=>i.has(e),[i]),s=(0,h.useCallback)(e=>{if(i.size===0){let t=!1;for(let n of e)if(n.pinned){t=!0;break}if(!t)return e}let t=0,n=e=>e.map(e=>{let r=i.has(e.id)&&t<_;r&&t++;let a=e.children?.length?n(e.children):e.children;return r!==(e.pinned??!1)||a!==e.children?{...e,pinned:r,children:a}:e});return n(e)},[i]),c=(0,h.useCallback)(()=>{for(let t of e)t.type===`nav`&&n(t.id)},[e,n]);return{pinnedIds:(0,h.useMemo)(()=>Array.from(i),[i]),togglePin:a,isPinned:o,applyPins:s,clearPins:c}}var x=768,S=1024;function C(){let{setOpen:e,isMobile:t}=c(),n=(0,h.useRef)(e);(0,h.useEffect)(()=>{n.current=e},[e]),(0,h.useEffect)(()=>{if(t)return;let e=!1;function r(){let t=window.innerWidth,r=t>=x&&t<S;r&&!e&&n.current(!1),e=r}return r(),window.addEventListener(`resize`,r),()=>window.removeEventListener(`resize`,r)},[t])}function w(e,t){return{name:e.name,label:e.label,pluralLabel:e.pluralLabel,description:e.description,icon:e.icon,group:e.group,sortOrder:e.sortOrder,enabled:e.enabled,fields:t,relationships:e.relationships}}function T(e){return{name:e.name,label:e.label,type:e.type,group:e.group,description:e.description,required:e.required,unique:e.unique,readonly:e.readonly,hidden:e.hidden,defaultValue:e.defaultValue,placeholder:e.placeholder,options:e.options,externalId:e.externalId,trackHistory:e.trackHistory,indexed:e.indexed,referenceTo:e.referenceTo,formula:e.formula,sortOrder:e.sortOrder}}var E=class{adapter;constructor(e){this.adapter=e}async getItems(e){let t=await this.adapter.getClient().meta.getItems(e);return t&&typeof t==`object`&&`items`in t&&Array.isArray(t.items)?t.items:[]}async saveMetadataItem(e,t,n){await this.adapter.getClient().meta.saveItem(e,t,n),this.adapter.invalidateCache(`${e}:${t}`)}async deleteMetadataItem(e,t){await this.adapter.getClient().meta.saveItem(e,t,{name:t,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`${e}:${t}`)}async saveObject(e,t){let n=this.adapter.getClient(),r=w(e,t);await n.meta.saveItem(`object`,e.name,r),this.adapter.invalidateCache(`object:${e.name}`)}async deleteObject(e){await this.adapter.getClient().meta.saveItem(`object`,e,{name:e,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`object:${e}`)}async saveFields(e,t){let n=this.adapter.getClient(),r={};try{let t=await n.meta.getItem(`object`,e);r=t?.item??t??{}}catch{}let i={...r,name:e,fields:t.map(T)};await n.meta.saveItem(`object`,e,i),this.adapter.invalidateCache(`object:${e}`)}static diffObjects(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,object:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,object:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,object:t}}return null}static diffFields(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,field:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,field:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,field:t}}return null}};function ee(){let e=s();return(0,h.useMemo)(()=>e?new E(e):null,[e])}var te=0;function D(e=`nav`){return`${e}_${Date.now()}_${++te}`}function O(e,t){return[...e,t]}function k(e,t,n){return e.filter(e=>!(e.type===t&&(t===`page`&&e.pageName===n||t===`dashboard`&&e.dashboardName===n))).map(e=>e.children&&e.children.length>0?{...e,children:k(e.children,t,n)}:e)}function A(e,t,n,r){return e.map(e=>{let i=e;return t===`page`&&e.type===`page`&&e.pageName===n?i={...e,pageName:r}:t===`dashboard`&&e.type===`dashboard`&&e.dashboardName===n&&(i={...e,dashboardName:r}),i.children&&i.children.length>0?{...i,children:A(i.children,t,n,r)}:i})}function j(e,t){return e.length===t.length?e===t?!0:JSON.stringify(e)===JSON.stringify(t):!1}function M(e){return typeof e==`string`&&e.startsWith(`sys_`)}function N(e){if(!e||typeof e!=`object`)return!1;let t=e;return t._packageId!=null||t._provenance===`package`?!0:M(t.name)}function P(e){if(!e||typeof e!=`object`)return!1;let t=e,n=t._lock??t.protection?.lock;return n!==`full`&&n!==`no-overlay`}function ne(){let e=s(),{apps:t,refresh:n}=a(),{t:r}=o(),i=(0,h.useRef)(e);i.current=e;let c=(0,h.useRef)(n);c.current=n;let u=(0,h.useCallback)(async(e,t)=>{let n=i.current?.getClient();n&&await n.meta.saveItem(`app`,e,t),await c.current?.()},[]),d=(0,h.useCallback)(e=>m(t,e),[t]),f=(0,h.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=O(a,{id:D(`nav_page`),type:`page`,label:n||t,pageName:t,icon:`FileText`}),s={...i,navigation:o};try{await u(e,s),l.success(r(`navigationSync.addedPage`,{name:n||t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await u(e,{...i,navigation:a}),l.info(r(`navigationSync.undone`))}catch{l.error(r(`navigationSync.undoFailed`))}}}})}catch{l.error(r(`navigationSync.updateFailed`))}},[d,u,r]),p=(0,h.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=O(a,{id:D(`nav_dash`),type:`dashboard`,label:n||t,dashboardName:t,icon:`LayoutDashboard`}),s={...i,navigation:o};try{await u(e,s),l.success(r(`navigationSync.addedDashboard`,{name:n||t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await u(e,{...i,navigation:a}),l.info(r(`navigationSync.undone`))}catch{l.error(r(`navigationSync.undoFailed`))}}}})}catch{l.error(r(`navigationSync.updateFailed`))}},[d,u,r]),g=(0,h.useCallback)(async(e,t)=>{let n=d(e);if(!n)return;let i=n.navigation??[],a=k(i,`page`,t);if(j(a,i))return;let o={...n,navigation:a};try{await u(e,o),l.success(r(`navigationSync.removedPage`,{name:t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await u(e,{...n,navigation:i}),l.info(r(`navigationSync.undone`))}catch{l.error(r(`navigationSync.undoFailed`))}}}})}catch{l.error(r(`navigationSync.updateFailed`))}},[d,u,r]),_=(0,h.useCallback)(async(e,t)=>{let n=d(e);if(!n)return;let i=n.navigation??[],a=k(i,`dashboard`,t);if(j(a,i))return;let o={...n,navigation:a};try{await u(e,o),l.success(r(`navigationSync.removedDashboard`,{name:t}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await u(e,{...n,navigation:i}),l.info(r(`navigationSync.undone`))}catch{l.error(r(`navigationSync.undoFailed`))}}}})}catch{l.error(r(`navigationSync.updateFailed`))}},[d,u,r]),v=(0,h.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=A(a,`page`,t,n);if(j(o,a))return;let s={...i,navigation:o};try{await u(e,s),l.success(r(`navigationSync.renamedPage`,{oldName:t,newName:n}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await u(e,{...i,navigation:a}),l.info(r(`navigationSync.undone`))}catch{l.error(r(`navigationSync.undoFailed`))}}}})}catch{l.error(r(`navigationSync.updateFailed`))}},[d,u,r]),y=(0,h.useCallback)(async(e,t,n)=>{let i=d(e);if(!i)return;let a=i.navigation??[],o=A(a,`dashboard`,t,n);if(j(o,a))return;let s={...i,navigation:o};try{await u(e,s),l.success(r(`navigationSync.renamedDashboard`,{oldName:t,newName:n}),{action:{label:r(`navigationSync.undoLabel`),onClick:async()=>{try{await u(e,{...i,navigation:a}),l.info(r(`navigationSync.undone`))}catch{l.error(r(`navigationSync.undoFailed`))}}}})}catch{l.error(r(`navigationSync.updateFailed`))}},[d,u,r]),b=e=>e&&typeof e==`object`&&`name`in e?e.name:void 0;return{syncPageCreated:f,syncDashboardCreated:p,syncPageDeleted:g,syncDashboardDeleted:_,syncPageRenamed:v,syncDashboardRenamed:y,syncPageCreatedAllApps:(0,h.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!P(r)||await f(t,e,n)}},[t,f]),syncDashboardCreatedAllApps:(0,h.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!P(r)||await p(t,e,n)}},[t,p]),syncPageDeletedAllApps:(0,h.useCallback)(async e=>{for(let n of t){let t=b(n);!t||!P(n)||await g(t,e)}},[t,g]),syncDashboardDeletedAllApps:(0,h.useCallback)(async e=>{for(let n of t){let t=b(n);!t||!P(n)||await _(t,e)}},[t,_]),syncPageRenamedAllApps:(0,h.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!P(r)||await v(t,e,n)}},[t,v]),syncDashboardRenamedAllApps:(0,h.useCallback)(async(e,n)=>{for(let r of t){let t=b(r);!t||!P(r)||await y(t,e,n)}},[t,y])}}function re(){let{pages:e,dashboards:t,apps:n,getTypeStatus:r}=a(),i=s(),o=(0,h.useRef)(i);o.current=i;let c=u(),{syncPageCreated:l,syncDashboardCreated:d,syncPageDeleted:f,syncDashboardDeleted:p}=ne(),m=(0,h.useRef)(null),g=(0,h.useRef)(null),_=(0,h.useRef)(0),v=(0,h.useRef)(!1),y=e=>e&&typeof e==`object`&&`name`in e?e.name:void 0;return(0,h.useEffect)(()=>{if(v.current)return;if(c){m.current=null,g.current=null;return}if(r&&(r(`page`)!==`ready`||r(`dashboard`)!==`ready`))return;let i=e=>new Set(e.filter(e=>!N(e)).map(e=>e?.name).filter(e=>typeof e==`string`&&e.length>0)),a=i(e??[]),o=i(t??[]),s=m.current,u=g.current;if(s===null||u===null){m.current=a,g.current=o;return}let h=[...a].filter(e=>!s.has(e)),b=[...s].filter(e=>!a.has(e)),x=[...o].filter(e=>!u.has(e)),S=[...u].filter(e=>!o.has(e));if(h.length===0&&b.length===0&&x.length===0&&S.length===0){m.current=a,g.current=o;return}let C=++_.current;v.current=!0;let w=!1;return(async()=>{try{for(let e of n){if(w||_.current!==C)break;let t=y(e);if(!(!t||!P(e))){for(let e of h){if(w)break;await l(t,e)}for(let e of b){if(w)break;await f(t,e)}for(let e of x){if(w)break;await d(t,e)}for(let e of S){if(w)break;await p(t,e)}}}}finally{_.current===C&&(m.current=a,g.current=o,v.current=!1)}})(),()=>{w=!0}},[e,t,n,c,r,l,d,f,p]),null}var F=new Set([`view`,`record`,`page`,`dashboard`,`design`,`report`]);function I(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function L(e){try{return decodeURIComponent(e)}catch{return e}}function R({pathname:e,appName:t,objects:n=[],basePathSegment:r=`apps`,disabled:i=!1}){let{addRecentItem:a}=d(),o=(0,h.useRef)(n);o.current=n,(0,h.useEffect)(()=>{if(i||!t)return;let n=e.split(`/`).filter(Boolean);if(n[0]!==r||n[1]!==t)return;let s=n[2],c=n[3],l=`/${r}/${t}`;if(s===`metadata`){let e=n[3],t=n[4];e&&t&&t!==`new`&&a({id:`metadata:${e}:${L(t)}`,label:L(t),href:`${l}/metadata/${e}/${t}`,type:`metadata`});return}if(s&&!F.has(s)){let e=o.current.find(e=>e.name===s);e&&a({id:`object:${e.name}`,label:e.label||e.name,href:`${l}/${e.name}`,type:`object`});return}if(c)switch(s){case`dashboard`:a({id:`dashboard:${c}`,label:I(c),href:`${l}/dashboard/${c}`,type:`dashboard`});break;case`page`:a({id:`page:${c}`,label:I(c),href:`${l}/page/${c}`,type:`page`});break;case`report`:a({id:`report:${c}`,label:I(c),href:`${l}/report/${c}`,type:`report`});break;default:break}},[e,t,r,i])}var z=`objectstack:ai-chat-conversation-id`,B=`objectstack:ai-chat-messages`;function V(e,t){return t?`${z}:${e}:${t}`:`${z}:${e}`}function H(e){try{return localStorage.getItem(e)??void 0}catch{return}}function U(e,t){try{t?localStorage.setItem(e,t):localStorage.removeItem(e)}catch{}}function W(e){return`${B}:${e}`}function G(e){try{let t=localStorage.getItem(W(e));if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>!!e&&typeof e==`object`&&typeof e.id==`string`&&(e.role===`user`||e.role===`assistant`||e.role===`system`)&&Array.isArray(e.parts)):[]}catch{return[]}}function K(e,t){if(e)try{if(t.length===0){localStorage.removeItem(W(e));return}localStorage.setItem(W(e),JSON.stringify(t))}catch{}}function q(e){return e.map(e=>{let t=[];if(e.content&&t.push({type:`text`,text:e.content}),e.role===`assistant`)for(let n of e.toolInvocations??[])t.push({type:`tool-${n.toolName}`,toolCallId:n.toolCallId,toolName:n.toolName,state:n.state??(n.errorText?`output-error`:`output-available`),...n.errorText?{errorText:n.errorText}:{}});if(t.length!==0)return{id:e.id,role:e.role,parts:t}}).filter(e=>!!e)}function J(e){return typeof e==`string`?e?[{type:`text`,text:e}]:[]:Array.isArray(e)?e.map(e=>{if(typeof e==`string`)return e?{type:`text`,text:e}:void 0;if(e&&typeof e==`object`&&`type`in e&&typeof e.type==`string`)return e;if(e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`)return{type:`text`,text:e.text}}).filter(e=>!!e):e&&typeof e==`object`&&`parts`in e&&Array.isArray(e.parts)?J(e.parts):[]}function ie(e,t){for(let n of J(e)){let e=typeof n.toolCallId==`string`?n.toolCallId:void 0;if(!e)continue;let r=t.get(e);if(!r)continue;let i=n.output??n.result;if(i===void 0)continue;r.output=i;let a=n.errorText;r.state=n.isError||typeof a==`string`?`output-error`:`output-available`,typeof a==`string`&&(r.errorText=a)}}function Y(e){if(!e)return[];let t=[],n=new Map;return e.forEach((e,r)=>{let i=e.role;if(i===`tool`){ie(e.content,n);return}if(i!==`user`&&i!==`assistant`&&i!==`system`)return;let a=J(e.content);if(a.length!==0){if(i===`assistant`)for(let e of a){let t=typeof e.toolCallId==`string`?e.toolCallId:void 0;t&&(e.type===`tool-call`||e.type.startsWith(`tool-`))&&n.set(t,e)}t.push({id:e.id??`msg-${r}`,role:i,parts:a})}}),t}async function X(e,t){let n=await fetch(`${e}/conversations/${encodeURIComponent(t)}`,{credentials:`include`});if(n.status===404||n.status===403)return null;if(!n.ok)throw Error(`GET conversation failed: ${n.status}`);return await n.json()}async function Z(e){let t=await fetch(`${e}/conversations`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`},body:`{}`});if(!t.ok)throw Error(`POST conversation failed: ${t.status}`);return await t.json()}async function ae(e,t){await fetch(`${e}/conversations/${encodeURIComponent(t)}`,{method:`DELETE`,credentials:`include`}).catch(()=>{})}function oe(e){let{userId:t,scope:n,apiBase:r,activeId:i,forceNew:a}=e,[o,s]=(0,h.useState)(void 0),[c,l]=(0,h.useState)([]),[u,d]=(0,h.useState)(!!t),f=(0,h.useRef)(!0),p=(0,h.useRef)(void 0);return(0,h.useEffect)(()=>(f.current=!0,()=>{f.current=!1}),[]),(0,h.useEffect)(()=>{if(!t){s(void 0),l([]),d(!1),p.current=void 0;return}if(!i&&!a&&p.current===t&&o)return;let e=!1,c=V(t,n);return!i&&a&&(s(void 0),l([])),d(!0),(async()=>{try{if(i){let n=await X(r,i);if(e)return;if(n){U(c,n.id),s(n.id);let e=Y(n.messages);l(e.length>0?e:G(n.id)),p.current=t;return}U(c,void 0),K(i,[])}else if(!a){let n=H(c);if(n){let i=await X(r,n);if(e)return;if(i){s(i.id);let e=Y(i.messages);l(e.length>0?e:G(i.id)),p.current=t;return}U(c,void 0),K(n,[])}}let n=await Z(r);if(e)return;U(c,n.id),s(n.id),l(Y(n.messages)),p.current=t}catch{e||(s(void 0),l([]))}finally{e||d(!1)}})(),()=>{e=!0}},[t,n,r,i,a]),{conversationId:o,initialMessages:c,isLoading:u,reset:(0,h.useCallback)(async()=>{if(!t)return;let e=V(t,n);d(!0);try{o&&await ae(r,o),K(o,[]),U(e,void 0);let t=await Z(r);if(U(e,t.id),K(t.id,[]),!f.current)return;s(t.id),l([])}catch{f.current&&(s(void 0),l([]))}finally{f.current&&d(!1)}},[o,t,n,r])}}var se=new Set([`new chat`,`new conversation`,`untitled`,`新对话`]);function ce(e){let t=e?.trim().toLowerCase();return!t||se.has(t)}function le(e){let t=e.messages;if(!t||t.length===0)return;for(let e=t.length-1;e>=0;e--){let n=t[e];if(n.role===`user`){let e=Q(n.content);if(e)return e}}let n=t[t.length-1];return Q(n?.content)}function Q(e){if(typeof e==`string`)return e.slice(0,140);if(e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`)return e.text.slice(0,140);if(e&&typeof e==`object`&&`parts`in e&&Array.isArray(e.parts))return Q(e.parts);if(Array.isArray(e)){let t=e.map(e=>typeof e==`string`?e:e&&typeof e==`object`&&`text`in e&&typeof e.text==`string`?e.text:``).join(``);return t?t.slice(0,140):void 0}}function $(e){let t=e.title?.trim(),n=le(e)??Q(e.preview);return{id:e.id,title:ce(t)?void 0:t,agentId:e.agentId,createdAt:e.createdAt,updatedAt:e.updatedAt,preview:n}}async function ue(e,t){let n=await fetch(`${e}/conversations/${encodeURIComponent(t)}`,{credentials:`include`});if(!n.ok)return;let r=await n.json();return $(`conversation`in r&&r.conversation?r.conversation:r)}function de(e){let{userId:t,apiBase:n,limit:r=50,refreshKey:i}=e,[a,o]=(0,h.useState)([]),[s,c]=(0,h.useState)(!!t),[l,u]=(0,h.useState)(void 0),[d,f]=(0,h.useState)(0),p=(0,h.useCallback)(async()=>{f(e=>e+1)},[]),m=(0,h.useCallback)(async e=>{try{await fetch(`${n}/conversations/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`include`})}finally{o(t=>t.filter(t=>t.id!==e))}},[n]),g=(0,h.useCallback)(async(e,t)=>{let r=t.trim();o(t=>t.map(t=>t.id===e?{...t,title:r||void 0}:t));let i=await fetch(`${n}/conversations/${encodeURIComponent(e)}`,{method:`PATCH`,credentials:`include`,headers:{"Content-Type":`application/json`},body:JSON.stringify({title:r})});if(!i.ok)throw f(e=>e+1),Error(`PATCH conversation failed: ${i.status}`)},[n]);return(0,h.useEffect)(()=>{if(!t){o([]),c(!1),u(void 0);return}let e=!1;return c(!0),u(void 0),(async()=>{try{let t=await fetch(`${n}/conversations?limit=${encodeURIComponent(String(r))}`,{credentials:`include`});if(!t.ok)throw Error(`GET conversations failed: ${t.status}`);let i=await t.json(),a=Array.isArray(i)?i:i.conversations??i.items??[];if(e)return;let s=a.map($).sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``));o(s);let c=s.filter(e=>!e.title&&!e.preview).slice(0,20);if(c.length>0){let t=await Promise.all(c.map(e=>ue(n,e.id).catch(()=>void 0)));if(e)return;let r=new Map(t.filter(e=>!!(e?.preview||e?.title)).map(e=>[e.id,e]));r.size>0&&o(e=>e.map(e=>{let t=r.get(e.id);return t?{...e,title:e.title??t.title,preview:e.preview??t.preview}:e}))}}catch(t){if(e)return;u(t instanceof Error?t:Error(String(t))),o([])}finally{e||c(!1)}})(),()=>{e=!0}},[t,n,r,d,i]),{conversations:a,isLoading:s,error:l,refetch:p,remove:m,rename:g}}async function fe(e){let t=await fetch(`/api/v1/meta/_drafts?packageId=${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/json`},cache:`no-store`});if(!t.ok)throw Error(`_drafts HTTP ${t.status}`);let n=await t.json(),r=Array.isArray(n)?n:n?.drafts??n?.data?.drafts??[];return Array.isArray(r)?r.length:0}function pe(e){if(!e||e.length===0)return!1;let t=e[e.length-1];return!t||t.role!==`assistant`?!1:t.parts.some(e=>e.type===`text`&&String(e.text??``).trim().length>0)}function me(e){let{chatApi:t,conversationId:n}=e,[r,i]=(0,h.useState)(!1),a=(0,h.useRef)(void 0);return{errorSuppressed:r,handleChatError:(0,h.useCallback)(async e=>{let r=t?.replace(/\/agents\/[^/]+\/chat$/,``);if(!n||!r){i(!1);return}try{let e=Y((await X(r,n))?.messages);if(pe(e)&&a.current){a.current(e),i(!0);return}}catch{}i(!1)},[n,t]),setMessagesRef:a,resetSuppression:(0,h.useCallback)(()=>i(!1),[])}}export{oe as a,re as c,b as d,g as f,q as i,ee as l,fe as n,K as o,de as r,R as s,me as t,C as u};
package/dist/index.html CHANGED
@@ -18,12 +18,12 @@
18
18
  <script>
19
19
  window.process = window.process || { env: { NODE_ENV: 'development' }, version: '', platform: 'browser' };
20
20
  </script>
21
- <script type="module" crossorigin src="./assets/index-JrHkY-wh.js"></script>
21
+ <script type="module" crossorigin src="./assets/index-BgnAjV6_.js"></script>
22
22
  <link rel="stylesheet" crossorigin href="./assets/ui-components-BL3SEdAz.css">
23
23
  <link rel="stylesheet" crossorigin href="./assets/plugin-dashboard-DnNKJB60.css">
24
- <link rel="stylesheet" crossorigin href="./assets/index-DGuFGryh.css">
25
- <link rel="modulepreload" href="./assets/framework-DLckRGJs.js" />
26
- <link rel="modulepreload" href="./assets/ui-components-B2CBE2Rs.js" />
24
+ <link rel="stylesheet" crossorigin href="./assets/index-CJe1zUD0.css">
25
+ <link rel="modulepreload" href="./assets/framework-BLEk-ou3.js" />
26
+ <link rel="modulepreload" href="./assets/ui-components-CrPYFyEM.js" />
27
27
  <link rel="modulepreload" href="./assets/vendor-radix-CSVEhP0L.js" />
28
28
  <link rel="modulepreload" href="./assets/vendor-react-DR370ovB.js" />
29
29
  </head>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@objectstack/console",
3
- "version": "9.8.0",
3
+ "version": "9.9.1",
4
4
  "description": "Prebuilt Console SPA pinned to this @objectstack/framework release. Source of truth: @object-ui/console (https://github.com/objectstack-ai/objectui).",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://github.com/objectstack-ai/framework/tree/main/packages/console",
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-DLckRGJs.js";import{$n as i,Cs as a,Es as o,Fi as s,Gi as c,Gn as l,Ma as u,Si as d,Sr as f,Ts as p,Ui as m,Un as h,Vr as g,Wn as _,Yo as v,oo as y,rs as ee}from"./ui-components-B2CBE2Rs.js";import"./index-JrHkY-wh.js";var b=e(t(),1),x=[`plugin`,`plugins`,`kind`,`package`];function S(e){return[{method:`POST`,path:`${e}/sign-in/email`,desc:`Sign in (email)`,group:`Auth`,bodyTemplate:{email:`user@example.com`,password:``}},{method:`POST`,path:`${e}/sign-up/email`,desc:`Sign up (email)`,group:`Auth`,bodyTemplate:{email:``,password:``,name:``}},{method:`POST`,path:`${e}/sign-out`,desc:`Sign out`,group:`Auth`},{method:`GET`,path:`${e}/get-session`,desc:`Get session`,group:`Auth`}]}var C={ai:{group:`AI`,defaultRoute:`/api/v1/ai`,endpoints:[{method:`POST`,path:`/chat`,desc:`Chat completion`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/chat/stream`,desc:`Streaming chat (SSE)`,bodyTemplate:{messages:[{role:`user`,content:``}]}},{method:`POST`,path:`/complete`,desc:`Text completion`,bodyTemplate:{prompt:``}},{method:`GET`,path:`/models`,desc:`List available models`},{method:`POST`,path:`/nlq`,desc:`Natural language query`,bodyTemplate:{query:``}},{method:`POST`,path:`/suggest`,desc:`AI-powered suggestions`,bodyTemplate:{object:``,field:``,context:{}}},{method:`POST`,path:`/insights`,desc:`AI-generated insights`,bodyTemplate:{object:``,recordIds:[]}},{method:`POST`,path:`/conversations`,desc:`Create conversation`,bodyTemplate:{}},{method:`GET`,path:`/conversations`,desc:`List conversations`},{method:`POST`,path:`/conversations/:id/messages`,desc:`Add message to conversation`,bodyTemplate:{role:`user`,content:``}},{method:`DELETE`,path:`/conversations/:id`,desc:`Delete conversation`}]},workflow:{group:`Workflow`,defaultRoute:`/api/v1/workflow`,endpoints:[{method:`GET`,path:`/:object/config`,desc:`Get workflow configuration`},{method:`GET`,path:`/:object/:recordId/state`,desc:`Get workflow state`},{method:`POST`,path:`/:object/:recordId/transition`,desc:`Execute workflow transition`,bodyTemplate:{targetState:``}},{method:`POST`,path:`/:object/:recordId/approve`,desc:`Approve workflow step`,bodyTemplate:{comment:``}},{method:`POST`,path:`/:object/:recordId/reject`,desc:`Reject workflow step`,bodyTemplate:{comment:``}}]},realtime:{group:`Realtime`,defaultRoute:`/api/v1/realtime`,endpoints:[{method:`POST`,path:`/connect`,desc:`Establish realtime connection`,bodyTemplate:{transport:`websocket`}},{method:`POST`,path:`/disconnect`,desc:`Close realtime connection`,bodyTemplate:{connectionId:``}},{method:`POST`,path:`/subscribe`,desc:`Subscribe to channel`,bodyTemplate:{channel:``}},{method:`POST`,path:`/unsubscribe`,desc:`Unsubscribe from channel`,bodyTemplate:{channel:``}},{method:`PUT`,path:`/presence/:channel`,desc:`Set presence state`,bodyTemplate:{status:`online`}},{method:`GET`,path:`/presence/:channel`,desc:`Get channel presence`}]},notification:{group:`Notifications`,defaultRoute:`/api/v1/notifications`,endpoints:[{method:`GET`,path:``,desc:`List notifications`},{method:`POST`,path:`/devices`,desc:`Register device for push`,bodyTemplate:{token:``,platform:`web`}},{method:`DELETE`,path:`/devices/:deviceId`,desc:`Unregister device`},{method:`GET`,path:`/preferences`,desc:`Get notification preferences`},{method:`PATCH`,path:`/preferences`,desc:`Update notification preferences`,bodyTemplate:{email:!0,push:!0}},{method:`POST`,path:`/read`,desc:`Mark notifications as read`,bodyTemplate:{ids:[]}},{method:`POST`,path:`/read/all`,desc:`Mark all as read`}]},analytics:{group:`Analytics`,defaultRoute:`/api/v1/analytics`,endpoints:[{method:`POST`,path:`/query`,desc:`Execute analytics query`,bodyTemplate:{measures:[],dimensions:[]}},{method:`GET`,path:`/meta`,desc:`Get analytics metadata`}]},automation:{group:`Automation`,defaultRoute:`/api/v1/automation`,endpoints:[{method:`POST`,path:`/trigger`,desc:`Trigger automation`,bodyTemplate:{name:``,params:{}}}]},i18n:{group:`i18n`,defaultRoute:`/api/v1/i18n`,endpoints:[{method:`GET`,path:`/locales`,desc:`Get available locales`},{method:`GET`,path:`/translations/:locale`,desc:`Get translations for locale`},{method:`GET`,path:`/labels/:object/:locale`,desc:`Get translated field labels`}]},ui:{group:`UI`,defaultRoute:`/api/v1/ui`,endpoints:[{method:`GET`,path:`/views`,desc:`List views`},{method:`GET`,path:`/views/:id`,desc:`Get view by ID`},{method:`POST`,path:`/views`,desc:`Create view`,bodyTemplate:{name:``,object:``,type:`list`}},{method:`PATCH`,path:`/views/:id`,desc:`Update view`,bodyTemplate:{name:``}},{method:`DELETE`,path:`/views/:id`,desc:`Delete view`}]},feed:{group:`Feed`,defaultRoute:`/api/v1/feed`,endpoints:[{method:`GET`,path:`/:object/:recordId`,desc:`Get feed items`},{method:`POST`,path:`/:object/:recordId`,desc:`Post feed item`,bodyTemplate:{body:``}}]},storage:{group:`Storage`,defaultRoute:`/api/v1/storage`,endpoints:[{method:`POST`,path:`/upload`,desc:`Upload file (multipart/form-data)`},{method:`GET`,path:`/:fileId`,desc:`Download file`},{method:`DELETE`,path:`/:fileId`,desc:`Delete file`}]}};function w(e,t){let n=C[e];return n?n.endpoints.map(e=>({method:e.method,path:`${t}${e.path}`,desc:e.desc,group:n.group,...e.bodyTemplate?{bodyTemplate:e.bodyTemplate}:{}})):[]}function te(){let e=r(),[t,n]=(0,b.useState)([]),[i,a]=(0,b.useState)([]),[o,s]=(0,b.useState)(!0),[c,l]=(0,b.useState)(null),u=(0,b.useCallback)(async()=>{s(!0),l(null);let t=`/api/v1`,r=`${t}/discovery`,i=[{method:`GET`,path:r,desc:`API Discovery`,group:`System`},{method:`GET`,path:`${t}/meta/types`,desc:`List metadata types`,group:`Metadata`},{method:`GET`,path:`${t}/packages`,desc:`List packages`,group:`System`},{method:`GET`,path:`/api/v1/health`,desc:`Health check`,group:`System`}];try{let o=`/api/v1/auth`,s={},c={};try{let e=await fetch(r);if(e.ok){let t=await e.json(),n=t?.data??t;c=n?.routes??{},s=n?.services??{},c.auth&&(o=c.auth)}}catch{}let l=[];for(let[e,t]of Object.entries(C)){let n=s[e],r=n?.enabled??!1,i=n?.handlerReady??(n?.status===`available`||n?.status===`degraded`),a=n?.route??c[e]??t.defaultRoute;r&&i&&l.push(...w(e,a))}let u=e?.getClient?.(),d=[];try{let e=await u?.meta?.getTypes?.();e&&Array.isArray(e.types)?d=e.types:Array.isArray(e)&&(d=e)}catch{}let f=[];try{let e=d.includes(`object`)?`object`:null;if(e&&u?.meta?.getItems){let t=await u.meta.getItems(e),n=[];Array.isArray(t)?n=t:t&&Array.isArray(t.items)?n=t.items:t&&Array.isArray(t.value)&&(n=t.value),f=n.map(e=>e.name||e.id).filter(Boolean)}}catch{}let p=f.flatMap(e=>{let n=e.startsWith(`sys_`)?`Data: system tables`:`Data: ${e}`;return[{method:`GET`,path:`${t}/data/${e}`,desc:`List ${e}`,group:n},{method:`POST`,path:`${t}/data/${e}`,desc:`Create ${e}`,group:n,bodyTemplate:{name:`example`}},{method:`GET`,path:`${t}/data/${e}/:id`,desc:`Get ${e} by ID`,group:n},{method:`PATCH`,path:`${t}/data/${e}/:id`,desc:`Update ${e}`,group:n,bodyTemplate:{name:`updated`}},{method:`DELETE`,path:`${t}/data/${e}/:id`,desc:`Delete ${e}`,group:n}]}),m=d.filter(e=>!x.includes(e)).map(e=>({method:`GET`,path:`${t}/meta/${e}`,desc:`List ${e} metadata`,group:`Metadata`})),h=f.map(e=>({method:`GET`,path:`${t}/meta/object/${e}`,desc:`${e} schema`,group:`Metadata`})),g=[...i,...S(o),...l,...m,...h,...p],_=new Map;for(let e of g){let t=_.get(e.group)||[];t.push(e),_.set(e.group,t)}let v=[`System`,`Auth`,`AI`,`Workflow`,`Realtime`,`Notifications`,`Analytics`,`Automation`,`i18n`,`UI`,`Feed`,`Storage`,`Metadata`];n(Array.from(_.entries()).sort(([e],[t])=>{let n=v.indexOf(e),r=v.indexOf(t);return n!==-1&&r!==-1?n-r:n===-1?r===-1?e.localeCompare(t):1:-1}).map(([e,t])=>({key:e,label:e,endpoints:t}))),a(g)}catch(e){l(e.message||`Failed to discover APIs`)}finally{s(!1)}},[e]);return(0,b.useEffect)(()=>{u()},[u]),{groups:t,allEndpoints:i,loading:o,error:c,refresh:u}}var T=n(),E={GET:`text-emerald-600 bg-emerald-50 border-emerald-200 dark:text-emerald-400 dark:bg-emerald-950/50`,POST:`text-blue-600 bg-blue-50 border-blue-200 dark:text-blue-400 dark:bg-blue-950/50`,PATCH:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,PUT:`text-amber-600 bg-amber-50 border-amber-200 dark:text-amber-400 dark:bg-amber-950/50`,DELETE:`text-red-600 bg-red-50 border-red-200 dark:text-red-400 dark:bg-red-950/50`},ne={2:`text-emerald-600 dark:text-emerald-400`,3:`text-blue-600 dark:text-blue-400`,4:`text-amber-600 dark:text-amber-400`,5:`text-red-600 dark:text-red-400`},re=[{key:`$top`,placeholder:`10`,hint:`limit`},{key:`$skip`,placeholder:`0`,hint:`offset`},{key:`$sort`,placeholder:`name`,hint:`sort field`},{key:`$select`,placeholder:`name,email`,hint:`fields`},{key:`$count`,placeholder:`true`,hint:`total count`},{key:`$filter`,placeholder:`status eq 'active'`,hint:`OData filter`}],D=1;function O(){let e=r()?.getClient?.(),{groups:t,loading:n,refresh:x}=te(),[S,C]=(0,b.useState)(``),[w,O]=(0,b.useState)(new Set),[k,A]=(0,b.useState)(null),[ie,j]=(0,b.useState)(``),[ae,M]=(0,b.useState)(``),[N,P]=(0,b.useState)(``),[F,I]=(0,b.useState)([]),[L,R]=(0,b.useState)(!1),[z,B]=(0,b.useState)(null),[V,H]=(0,b.useState)([]),[U,oe]=(0,b.useState)(null),[W,G]=(0,b.useState)(!1),K=(0,b.useMemo)(()=>{if(!S)return t;let e=S.toLowerCase();return t.map(t=>({...t,endpoints:t.endpoints.filter(t=>t.desc.toLowerCase().includes(e)||t.path.toLowerCase().includes(e)||t.method.toLowerCase().includes(e))})).filter(e=>e.endpoints.length>0)},[t,S]),se=(0,b.useCallback)(e=>{O(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ce=(0,b.useCallback)(e=>{A(e),j(e.method),M(e.path),P(e.bodyTemplate?JSON.stringify(e.bodyTemplate,null,2):``),I([]),B(null)},[]),q=ie||k?.method||`GET`,J=ae||k?.path||``,Y=(0,b.useMemo)(()=>{let e=F.filter(e=>e.enabled&&e.key.trim());return e.length===0?J:`${J}?${e.map(e=>`${encodeURIComponent(e.key)}=${encodeURIComponent(e.value)}`).join(`&`)}`},[J,F]),X=(0,b.useCallback)((e=``,t=``)=>{I(n=>[...n,{id:D++,key:e,value:t,enabled:!0}])},[]),le=(0,b.useCallback)(e=>{I(t=>t.filter(t=>t.id!==e))},[]),Z=(0,b.useCallback)((e,t,n)=>{I(r=>r.map(r=>r.id===e?{...r,[t]:n}:r))},[]),ue=(0,b.useCallback)(e=>{I(t=>t.map(t=>t.id===e?{...t,enabled:!t.enabled}:t))},[]),Q=(0,b.useCallback)(async()=>{if(L||!Y)return;let t=`${e?.baseUrl??``}${Y}`;R(!0);let n=performance.now();try{let e={method:q,headers:{"Content-Type":`application/json`}};[`POST`,`PATCH`,`PUT`].includes(q)&&N.trim()&&(e.body=N);let r=await fetch(t,e),i=Math.round(performance.now()-n),a;if((r.headers.get(`content-type`)??``).includes(`json`)){let e=await r.json();a=JSON.stringify(e,null,2)}else a=await r.text();B({status:r.status,body:a,duration:i}),H(e=>[{id:Date.now(),method:q,url:Y,body:N||void 0,status:r.status,duration:i,response:a,timestamp:new Date},...e].slice(0,50))}catch(e){let t=Math.round(performance.now()-n);B({status:0,body:`Network Error: ${e.message}`,duration:t})}finally{R(!1)}},[e,Y,q,N,L]),de=(0,b.useCallback)(e=>{j(e.method);let[t,n]=e.url.split(`?`);if(M(t),P(e.body||``),n){let e=new URLSearchParams(n),t=[];e.forEach((e,n)=>{t.push({id:D++,key:n,value:e,enabled:!0})}),I(t)}else I([]);B(null),A(null)},[]),fe=(0,b.useCallback)(()=>{z?.body&&(navigator.clipboard.writeText(z.body),G(!0),setTimeout(()=>G(!1),1500))},[z]),$=e=>ne[String(e)[0]]??`text-muted-foreground`;return(0,T.jsxs)(`div`,{className:`flex flex-1 min-h-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`w-72 shrink-0 border-r flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`h3`,{className:`text-sm font-semibold text-foreground flex-1`,children:`API Endpoints`}),(0,T.jsx)(`button`,{onClick:x,disabled:n,className:`p-1 rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground`,title:`Refresh endpoints`,children:(0,T.jsx)(s,{className:`h-3.5 w-3.5 ${n?`animate-spin`:``}`})})]}),(0,T.jsxs)(`div`,{className:`relative`,children:[(0,T.jsx)(d,{className:`absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,T.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`Search endpoints...`,className:`w-full rounded-md border bg-background pl-8 pr-3 py-1.5 text-sm focus:outline-none focus:ring-1 focus:ring-ring`})]})]}),(0,T.jsx)(`div`,{className:`flex-1 overflow-auto p-2 space-y-1`,children:n?(0,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(u,{className:`h-4 w-4 animate-spin mr-2`}),`Discovering APIs...`]}):K.length===0?(0,T.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(y,{className:`h-6 w-6 opacity-30 mb-2`}),(0,T.jsx)(`span`,{children:S?`No matching endpoints`:`No endpoints found`})]}):K.map(e=>{let t=w.has(e.key)||!!S;return(0,T.jsxs)(h,{open:t,onOpenChange:()=>se(e.key),children:[(0,T.jsx)(l,{asChild:!0,children:(0,T.jsxs)(`button`,{className:`w-full flex items-center gap-1.5 px-2 py-1.5 rounded-md text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground transition-colors`,children:[(0,T.jsx)(a,{className:`h-3 w-3 shrink-0 transition-transform duration-200 ${t?`rotate-90`:``}`}),(0,T.jsx)(`span`,{className:`flex-1 text-left truncate`,children:e.label}),(0,T.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums opacity-60`,children:e.endpoints.length})]})}),(0,T.jsx)(_,{children:(0,T.jsx)(`div`,{className:`ml-3 space-y-0.5 mt-0.5`,children:e.endpoints.map((e,t)=>(0,T.jsxs)(`button`,{onClick:()=>ce(e),className:`w-full text-left flex items-center gap-1.5 px-2 py-1 rounded text-xs transition-colors ${k===e?`bg-accent text-accent-foreground`:`hover:bg-muted/50 text-muted-foreground hover:text-foreground`}`,children:[(0,T.jsx)(i,{variant:`outline`,className:`font-mono text-[9px] shrink-0 px-1 py-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`truncate`,children:e.desc})]},`${e.method}-${e.path}-${t}`))})})]},e.key)})}),(0,T.jsxs)(`div`,{className:`p-3 border-t space-y-2`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,T.jsx)(`h4`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:`Query Parameters`}),(0,T.jsxs)(`button`,{onClick:()=>X(),className:`inline-flex items-center gap-0.5 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,T.jsx)(m,{className:`h-3 w-3`}),`Add`]})]}),(0,T.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:re.map(e=>(0,T.jsx)(`button`,{onClick:()=>X(e.key,``),className:`text-[10px] px-1.5 py-0.5 rounded border bg-muted/30 text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors font-mono`,title:e.hint,children:e.key},e.key))}),F.length>0&&(0,T.jsx)(`div`,{className:`space-y-1`,children:F.map(e=>(0,T.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,T.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:()=>ue(e.id),className:`h-3 w-3 shrink-0 rounded border accent-primary`}),(0,T.jsx)(`input`,{type:`text`,value:e.key,onChange:t=>Z(e.id,`key`,t.target.value),placeholder:`key`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,T.jsx)(`input`,{type:`text`,value:e.value,onChange:t=>Z(e.id,`value`,t.target.value),placeholder:`value`,className:`flex-1 min-w-0 rounded border bg-background px-1.5 py-0.5 text-[10px] font-mono focus:outline-none focus:ring-1 focus:ring-ring`}),(0,T.jsx)(`button`,{onClick:()=>le(e.id),className:`shrink-0 p-0.5 rounded text-muted-foreground hover:text-destructive transition-colors`,children:(0,T.jsx)(f,{className:`h-3 w-3`})})]},e.id))})]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-w-0 overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,T.jsx)(`select`,{value:q,onChange:e=>j(e.target.value),className:`rounded-md border bg-background px-2 py-1.5 font-mono text-xs font-semibold focus:outline-none focus:ring-1 focus:ring-ring ${E[q]||``}`,children:[`GET`,`POST`,`PATCH`,`PUT`,`DELETE`].map(e=>(0,T.jsx)(`option`,{value:e,children:e},e))}),(0,T.jsx)(`input`,{type:`text`,value:J,onChange:e=>M(e.target.value),className:`flex-1 rounded-md border bg-background px-3 py-1.5 font-mono text-sm focus:outline-none focus:ring-1 focus:ring-ring`,placeholder:`/api/v1/...`,onKeyDown:e=>{e.key===`Enter`&&Q()}}),(0,T.jsxs)(`button`,{onClick:Q,disabled:L||!Y,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-1.5 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors`,children:[L?(0,T.jsx)(u,{className:`h-3.5 w-3.5 animate-spin`}):(0,T.jsx)(c,{className:`h-3.5 w-3.5`}),`Send`]})]}),F.some(e=>e.enabled&&e.key.trim())&&(0,T.jsxs)(`div`,{className:`text-[10px] font-mono text-muted-foreground truncate pl-1`,children:[`→ `,Y]})]}),(0,T.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 overflow-auto`,children:[[`POST`,`PATCH`,`PUT`].includes(q)&&(0,T.jsxs)(`div`,{className:`p-3 border-b space-y-1`,children:[(0,T.jsx)(`label`,{className:`text-xs font-medium text-muted-foreground`,children:`Request Body (JSON)`}),(0,T.jsx)(`textarea`,{value:N,onChange:e=>P(e.target.value),rows:5,className:`w-full rounded-md border bg-background px-3 py-2 font-mono text-xs focus:outline-none focus:ring-1 focus:ring-ring resize-y`,placeholder:`{ "key": "value" }`})]}),L&&(0,T.jsxs)(`div`,{className:`flex items-center justify-center py-8 text-muted-foreground text-sm`,children:[(0,T.jsx)(u,{className:`h-4 w-4 animate-spin mr-2`}),`Sending request...`]}),z&&!L&&(0,T.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-muted/30 border-b`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 text-sm`,children:[(0,T.jsx)(`span`,{className:`font-mono font-semibold ${$(z.status)}`,children:z.status||`ERR`}),(0,T.jsxs)(`span`,{className:`text-muted-foreground flex items-center gap-1`,children:[(0,T.jsx)(ee,{className:`h-3 w-3`}),z.duration,`ms`]})]}),(0,T.jsxs)(`button`,{onClick:fe,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[W?(0,T.jsx)(o,{className:`h-3 w-3`}):(0,T.jsx)(v,{className:`h-3 w-3`}),W?`Copied`:`Copy`]})]}),(0,T.jsx)(`pre`,{className:`flex-1 overflow-auto p-3 text-xs font-mono bg-muted/10 whitespace-pre-wrap break-all`,children:z.body})]}),!z&&!L&&(0,T.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-muted-foreground text-sm`,children:(0,T.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,T.jsx)(y,{className:`h-10 w-10 mx-auto opacity-20`}),(0,T.jsxs)(`p`,{children:[`Select an endpoint or type a URL and click `,(0,T.jsx)(`strong`,{children:`Send`})]}),(0,T.jsx)(`p`,{className:`text-xs opacity-60`,children:`All registered APIs are auto-discovered from the platform`})]})}),V.length>0&&(0,T.jsxs)(`div`,{className:`border-t`,children:[(0,T.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2`,children:[(0,T.jsxs)(`h4`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:[`History (`,V.length,`)`]}),(0,T.jsxs)(`button`,{onClick:()=>H([]),className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,T.jsx)(g,{className:`h-3 w-3`}),`Clear`]})]}),(0,T.jsx)(`div`,{className:`space-y-0.5 px-2 pb-2 max-h-60 overflow-auto`,children:V.map(e=>(0,T.jsxs)(`div`,{className:`rounded border`,children:[(0,T.jsxs)(`button`,{onClick:()=>oe(U===e.id?null:e.id),className:`w-full flex items-center gap-2 px-2 py-1.5 text-xs hover:bg-muted/30 transition-colors`,children:[U===e.id?(0,T.jsx)(p,{className:`h-3 w-3 shrink-0`}):(0,T.jsx)(a,{className:`h-3 w-3 shrink-0`}),(0,T.jsx)(i,{variant:`outline`,className:`font-mono text-[9px] shrink-0 ${E[e.method]||``}`,children:e.method}),(0,T.jsx)(`span`,{className:`font-mono truncate text-left flex-1`,children:e.url}),(0,T.jsx)(`span`,{className:`ml-auto shrink-0 font-mono ${$(e.status)}`,children:e.status}),(0,T.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[e.duration,`ms`]}),(0,T.jsx)(`button`,{onClick:t=>{t.stopPropagation(),de(e)},className:`shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors`,title:`Replay request`,children:(0,T.jsx)(c,{className:`h-2.5 w-2.5`})})]}),U===e.id&&(0,T.jsx)(`pre`,{className:`px-3 py-2 text-xs font-mono bg-muted/10 border-t overflow-auto max-h-40 whitespace-pre-wrap break-all`,children:e.response})]},e.id))})]})]})]})]})}export{O as ApiConsolePage};
@@ -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-DR370ovB.js";import{w as a}from"./framework-DLckRGJs.js";import{Ks as o,Ma as s,ys as c}from"./ui-components-B2CBE2Rs.js";import{t as l}from"./index-JrHkY-wh.js";var u=e(t(),1),d=i();function f(){let{appName:e}=n(),t=a(),[i,f]=(0,u.useState)([]),[p,m]=(0,u.useState)(`loading`),[h,g]=(0,u.useState)(``);return(0,u.useEffect)(()=>{let n=!1;async function r(){if(!t)return;let r=t.getClient();if(!r?.meta?.getItems){g(`meta.getItems is not available on this client`),m(`error`);return}m(`loading`);try{let t=await r.meta.getItems(`doc`),i=Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[];if(n)return;f(i.filter(t=>t&&t.name&&t._packageId===e).map(e=>({name:e.name,label:e.label,description:e.description})).sort((e,t)=>(e.label??e.name).localeCompare(t.label??t.name))),m(`ready`)}catch(e){if(n)return;g(e?.message??`Failed to load documentation`),m(`error`)}}return r(),()=>{n=!0}},[t,e]),p===`loading`?(0,d.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,d.jsx)(s,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):p===`error`?(0,d.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,d.jsx)(c,{className:`h-10 w-10 text-destructive`}),(0,d.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Failed to load documentation`}),(0,d.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:h})]}):(0,d.jsx)(l,{children:(0,d.jsx)(`div`,{className:`mx-auto max-w-3xl p-4 sm:p-6`,children:i.length===0?(0,d.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16 text-center text-muted-foreground`,children:[(0,d.jsx)(o,{className:`h-10 w-10`}),(0,d.jsx)(`p`,{className:`text-sm`,children:`This app does not ship any documentation yet.`}),(0,d.jsx)(r,{to:`/docs`,className:`text-sm font-medium text-primary hover:underline`,children:`Browse all documentation`})]}):(0,d.jsx)(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:i.map(t=>(0,d.jsx)(`li`,{children:(0,d.jsxs)(r,{to:`/apps/${e}/docs/${t.name}`,className:`flex items-start gap-3 px-3 py-3 hover:bg-muted/50`,children:[(0,d.jsx)(o,{className:`mt-0.5 h-4 w-4 shrink-0 text-muted-foreground`}),(0,d.jsxs)(`div`,{className:`min-w-0`,children:[(0,d.jsx)(`div`,{className:`text-sm font-medium`,children:t.label??t.name}),t.description?(0,d.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:t.description}):null]})]})},t.name))})})})}export{f as default};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{T as a}from"./framework-DLckRGJs.js";import{$n as o,Hr as s,Io as c,Jn as l,Kn as u,Si as d,Ui as f,Ur as p,Vr as m,Xi as h,hr as g,ni as _,nn as v,qn as y,za as b}from"./ui-components-B2CBE2Rs.js";import{r as x}from"./vendor-ui-utils-rQOI1gAo.js";import"./index-JrHkY-wh.js";var S=e(t(),1);function C(e,t){if(e!=null){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}}var w=r();function T(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,{apps:T,refresh:E}=a(),[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(new Set),[j,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(!1),F=(T||[]).filter(e=>{if(!D)return!0;let t=D.toLowerCase();return(e.name||``).toLowerCase().includes(t)||(e.label||``).toLowerCase().includes(t)||(e.description||``).toLowerCase().includes(t)}),I=(0,S.useCallback)(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),L=(0,S.useCallback)(()=>{k.size===F.length?A(new Set):A(new Set(F.map(e=>e.name)))},[k.size,F]),R=(0,S.useCallback)(async e=>{P(!0);try{let t=e.active===!1;x.success(`${e.label||e.name} ${t?`enabled`:`disabled`}`),await E()}catch{x.error(`Failed to toggle app status`)}finally{P(!1)}},[E]),z=(0,S.useCallback)(async e=>{P(!0);try{x.success(`${e.label||e.name} set as default`),await E()}catch{x.error(`Failed to set default app`)}finally{P(!1)}},[E]),B=(0,S.useCallback)(async e=>{if(j!==e.name){M(e.name);return}P(!0);try{x.success(`${e.label||e.name} deleted`),M(null),await E()}catch{x.error(`Failed to delete app`)}finally{P(!1)}},[j,E]),V=(0,S.useCallback)(async e=>{P(!0);try{x.success(`${k.size} apps ${e?`enabled`:`disabled`}`),A(new Set),await E()}catch{x.error(`Bulk operation failed`)}finally{P(!1)}},[k,E]);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Applications`}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage all configured applications`})]}),(0,w.jsxs)(g,{onClick:()=>e(`${r}/create-app`),"data-testid":`create-app-btn`,children:[(0,w.jsx)(f,{className:`h-4 w-4 mr-2`}),`New App`]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,w.jsx)(`label`,{htmlFor:`app-search`,className:`sr-only`,children:`Search apps`}),(0,w.jsx)(d,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,w.jsx)(v,{id:`app-search`,placeholder:`Search apps...`,value:D,onChange:e=>O(e.target.value),className:`pl-8`,"data-testid":`app-search-input`})]}),k.size>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsxs)(o,{variant:`secondary`,children:[k.size,` selected`]}),(0,w.jsx)(g,{variant:`outline`,size:`sm`,onClick:()=>V(!0),disabled:N,children:`Enable`}),(0,w.jsx)(g,{variant:`outline`,size:`sm`,onClick:()=>V(!1),disabled:N,children:`Disable`})]})]}),F.length>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,w.jsx)(u,{id:`select-all-apps`,checked:k.size===F.length&&F.length>0,onCheckedChange:()=>L()}),(0,w.jsxs)(`label`,{htmlFor:`select-all-apps`,className:`cursor-pointer`,children:[`Select all (`,F.length,`)`]})]}),F.length===0?(0,w.jsxs)(`div`,{className:`text-center py-12 text-muted-foreground`,"data-testid":`no-apps-message`,children:[(0,w.jsx)(b,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{children:`No apps found.`})]}):(0,w.jsx)(`div`,{className:`grid gap-3`,children:F.map(t=>{let n=t.active!==!1,i=t.isDefault===!0,a=j===t.name;return(0,w.jsx)(y,{className:n?``:`opacity-60`,"data-testid":`app-card-${t.name}`,children:(0,w.jsxs)(l,{className:`flex items-center gap-3 py-3 px-4`,children:[(0,w.jsx)(u,{id:`select-app-${t.name}`,checked:k.has(t.name),onCheckedChange:()=>I(t.name),"aria-label":`Select ${t.label||t.name}`,className:`shrink-0`}),(0,w.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,w.jsx)(b,{className:`h-4 w-4`})}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`font-medium truncate`,children:C(t.label)||t.name}),i&&(0,w.jsx)(o,{variant:`default`,className:`text-xs`,children:`Default`}),(0,w.jsx)(o,{variant:n?`secondary`:`outline`,className:`text-xs`,children:n?`Active`:`Inactive`})]}),t.description&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:C(t.description)})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:`Open app`,"aria-label":`Open ${t.label||t.name}`,onClick:()=>e(`/apps/${t._packageId??t.name}`),children:(0,w.jsx)(c,{className:`h-4 w-4`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:`Edit app`,"aria-label":`Edit ${t.label||t.name}`,onClick:()=>e(`${r}/edit-app/${t.name}`),children:(0,w.jsx)(h,{className:`h-4 w-4`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:n?`Disable app`:`Enable app`,"aria-label":n?`Disable ${t.label||t.name}`:`Enable ${t.label||t.name}`,onClick:()=>R(t),disabled:N,children:n?(0,w.jsx)(s,{className:`h-4 w-4`}):(0,w.jsx)(p,{className:`h-4 w-4`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:`Set as default`,"aria-label":`Set ${t.label||t.name} as default`,onClick:()=>z(t),disabled:N||i,children:(0,w.jsx)(_,{className:`h-4 w-4 ${i?`fill-current text-yellow-500`:``}`})}),(0,w.jsx)(g,{variant:`ghost`,size:`icon`,title:a?`Click again to confirm delete`:`Delete app`,"aria-label":a?`Confirm delete ${t.label||t.name}`:`Delete ${t.label||t.name}`,onClick:()=>B(t),disabled:N,className:a?`text-destructive`:``,children:(0,w.jsx)(m,{className:`h-4 w-4`})})]})]})},t.name)})})]})}export{T as AppManagementPage};
@@ -1 +0,0 @@
1
- import"./rolldown-runtime-CMxvf4Kt.js";import{_ as e,f as t,p as n,t as r}from"./vendor-react-DR370ovB.js";import{H as i,R as a,z as o}from"./ui-components-B2CBE2Rs.js";import{n as s}from"./index-JrHkY-wh.js";e();var c=r();function l({extraProps:e}={}){let r=t(),[l]=n(),u=r.ns,d=r.name,f=u&&d?`${u}:${d}`:u??``,p=s(f);if(!p)return(0,c.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,c.jsxs)(a,{children:[(0,c.jsx)(i,{children:`Component not registered`}),(0,c.jsxs)(o,{children:[`No component is registered for `,(0,c.jsx)(`code`,{className:`font-mono`,children:f||`(empty)`}),`. Ensure the plugin that provides this surface is installed and has called`,(0,c.jsx)(`code`,{className:`font-mono`,children:` registerAppComponent()`}),`.`]})]})});let m={};for(let[e,t]of l.entries())m[e]=t;let h=p.component;return(0,c.jsx)(h,{...m,...e??{}})}export{l as ComponentNavView,l as default};
@@ -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-DR370ovB.js";import{r as a}from"./framework-DLckRGJs.js";import{Bt as o,Ht as s,Ut as c,Vt as l,Wt as u,ai as d,hr as f,vi as p,w as m}from"./ui-components-B2CBE2Rs.js";import{r as h}from"./vendor-ui-utils-rQOI1gAo.js";import{a as g,i as _,n as v}from"./MetadataProvider-_6IU7cWK.js";import{a as y,d as b,f as ee,h as te,r as ne,t as re,u as x}from"./plugin-chatbot-DF5LNhQ2.js";import{b as S,n as ie}from"./marketplaceApi-CucX7DD9.js";import{a as C,i as w,o as T,r as ae,s as oe}from"./index-JrHkY-wh.js";var E=e(t(),1),D=r(),O={data_chat:{zh:`智能助手`,en:`Assistant`},metadata_assistant:{zh:`元数据开发助手`,en:`Metadata Assistant`}};function k(e,t,n){let r=t?O[t]:void 0;return r?e?r.zh:r.en:n}function A(e,t,n,r,i){let a=(e??``).toLowerCase().startsWith(`zh`),o=k(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:`已发布`,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`,publishOk:`Published — objects are now live.`,publishFailed:`Publish failed`,seedWarn:`Published, but some sample data failed to load.`,openBuiltApp:`Open app`,suggestions:c}}var j=`/api/v1/ai`;function M(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(/\/$/,``)}${j}`}function se(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 N=new Set([`view`,`record`,`page`,`dashboard`,`design`,`report`,`metadata`]);function P(e){try{return decodeURIComponent(e)}catch{return e}}function ce(e,t){let n=e.split(`/`).filter(Boolean),r=n.indexOf(`apps`);if(r===-1||n.length<r+3)return{};let i=P(n[r+2]);if(N.has(i)||!t.some(e=>e.name===i))return{};let a=n[r+3]?P(n[r+3]):void 0,o=a&&a!==`new`?a:void 0;return{objectName:i,...o?{recordId:o}:{}}}function F({appLabel:e,appName:t,objects:r,agents:b,agentsLoading:x,activeAgent:T,onAgentChange:O,showAgentPicker:k,chatApi:j,apiBase:M,defaultOpen:N=!1,conversationId:P,initialMessages:F}){let{language:I}=a(),L=i(),R=n(),z=E.useMemo(()=>ce(R.pathname,r),[R.pathname,r]),{editor:B}=g(),V=E.useMemo(()=>!F||F.length===0?[]:te(F),[F]),H=E.useMemo(()=>b.find(e=>e.name===T)?.label??T??e,[b,T,e]),U=E.useMemo(()=>A(I,e,T,H,r),[I,e,T,H,r]),W=E.useMemo(()=>se(B,I),[B,I]),{errorSuppressed:le,handleChatError:ue,setMessagesRef:de,resetSuppression:G}=ae({chatApi:j,conversationId:P}),{messages:K,isLoading:q,error:fe,sendMessage:J,stop:pe,reload:me,clear:Y,setMessages:X}=ee({api:j,conversationId:P,onError:ue,body:{context:{activeApp:e,appName:t,objects:r.map(e=>({name:e.name,label:e.label})),agentName:T,autoPublishAiBuilds:S().features.autoPublishAiBuilds,...z.objectName?{objectName:z.objectName}:{},...z.recordId?{recordId:z.recordId}:{},...B?{editing:B}:{}}},initialMessages:V,autoResponse:!j,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});E.useEffect(()=>{de.current=X},[X]),E.useEffect(()=>{oe(P,C(K))},[P,K]);let Z=re({messages:K,apiBase:M,continueConversation:e=>{G(),J(e)}}),Q=k&&b.length>1?(0,D.jsxs)(o,{value:T,onValueChange:O,disabled:x,children:[(0,D.jsx)(c,{className:`h-7 w-[180px] text-xs`,"data-testid":`floating-chatbot-agent-picker`,children:(0,D.jsx)(u,{placeholder:`Choose agent...`})}),(0,D.jsx)(l,{align:`end`,children:b.map(e=>(0,D.jsxs)(s,{value:e.name,className:`text-xs`,children:[(0,D.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,D.jsx)(`span`,{className:`block text-muted-foreground text-[10px] truncate max-w-[220px]`,children:e.description}):null]},e.name))})]}):null,[he,$]=E.useState(!1),ge=E.useMemo(()=>M.replace(/\/v1\/ai$/,``).replace(/\/ai$/,``)||`/api`,[M]),_e=(0,D.jsxs)(D.Fragment,{children:[K.length>0?(0,D.jsx)(f,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":U.newChat,title:U.newChat,"data-testid":`floating-chatbot-new`,onClick:Y,children:(0,D.jsx)(d,{className:`h-4 w-4`})}):null,P?(0,D.jsx)(f,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":U.share,title:U.share,"data-testid":`floating-chatbot-share`,onClick:()=>$(!0),children:(0,D.jsx)(p,{className:`h-4 w-4`})}):null]});return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(ne,{onUpgrade:()=>window.open(ie(),`_blank`,`noopener,noreferrer`),floatingConfig:{position:`bottom-right`,defaultOpen:N,panelWidth:420,panelHeight:560,title:U.title,triggerSize:56},headerExtra:Q,headerActions:_e,messages:K,labels:U.labels,showAvatars:!0,hideClearBar:!0,assistantAvatarFallback:U.agentLabel,suggestions:K.length===0?W??U.suggestions:void 0,placeholder:T?U.placeholder:x?U.loadingPlaceholder:U.placeholder,onSendMessage:e=>{G(),J(e)},onClear:Y,onStop:q?pe:void 0,onReload:me,isLoading:q,error:le?void 0:fe,enableMarkdown:!0,onToolApprove:Z.decide,toolDecisions:Z.decisions,toolApproveLabel:`Approve & run`,toolDenyLabel:`Reject`,toolDenyReason:`Operator rejected from chat`,onReviewDraft:e=>{e[0]&&_(e[0])},toolReviewLabel:U.reviewDraft,onOpenBuiltApp:e=>L(`/apps/${encodeURIComponent(e)}`),openBuiltAppLabel:U.openBuiltApp,onPreviewDraftApp:(e,t)=>L(t?.materialized?`/apps/${encodeURIComponent(e)}`:`/apps/${encodeURIComponent(e)}?preview=draft`),onDraftArtifacts:e=>{for(let t of e)v(t)},fetchPendingDraftCount:w,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(U.seedWarn,{description:i.error??(Array.isArray(i.errors)&&i.errors.length?String(i.errors[0]):void 0)}):h.success(U.publishOk);let a=(n?.data?.published??n?.published??[]).find(e=>e?.type===`app`&&e?.name);return a?.name&&L(`/apps/${encodeURIComponent(a.name)}`),{ok:!0,health:y(n)}}catch(e){return h.error(U.publishFailed,{description:e instanceof Error?e.message:void 0}),!1}},publishDraftsLabel:U.publishDrafts,publishedLabel:U.published,autoPublishDrafts:S().features.autoPublishAiBuilds}),P&&(0,D.jsx)(m,{open:he,onOpenChange:$,objectName:`ai_conversations`,recordId:P,recordLabel:`this conversation`,apiBase:ge})]})}function I({appLabel:e,appName:t,objects:n,apiBase:r,defaultAgent:i,showAgentPicker:a,defaultOpen:o=!1,userId:s}){let c=E.useMemo(()=>M(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}=b({apiBase:c}),[h,g]=E.useState(void 0);E.useEffect(()=>{if(!h&&f.length>0){let e=x(f,i??u);e&&g(e)}},[f,h,i,u]);let _=h?`${c}/agents/${encodeURIComponent(h)}/chat`:void 0,{conversationId:v,initialMessages:y}=T({userId:s,scope:h,apiBase:c});return(0,D.jsx)(F,{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{I as default};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-DLckRGJs.js";import{$n as i,Fi as a,Ft as o,Gi as s,Gt as c,It as l,Jn as u,Lt as d,Ma as f,Mt as p,Pt as m,Rt as h,Xn as g,Yn as _,Zn as v,cs as y,ct as b,dt as x,ft as S,gs as C,hr as w,lt as T,nn as E,on as D,ot as O,qn as k,rs as A,st as j,tt as M,ut as N,wr as P,ys as F}from"./ui-components-B2CBE2Rs.js";import"./index-JrHkY-wh.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:C,cls:`text-emerald-600 border-emerald-300`},completed:{icon:C,cls:`text-emerald-600 border-emerald-300`},failed:{icon:y,cls:`text-red-600 border-red-300`},error:{icon:y,cls:`text-red-600 border-red-300`},running:{icon:f,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:A,cls:`text-amber-600 border-amber-300`},skipped:{icon:F,cls:`text-muted-foreground`}}[e]??{icon:F,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(i,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,o]=(0,I.useState)(!0),[s,c]=(0,I.useState)(null),[l,d]=(0,I.useState)(``),[f,m]=(0,I.useState)(0),h=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){c(`meta.getItems is not available on this client`),o(!1);return}o(!0),c(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!l&&r.length>0&&d(r[0].name)}catch(e){c(e?.message??String(e))}finally{o(!1)}},[e,l]);(0,I.useEffect)(()=>{h()},[h]);let y=(0,I.useMemo)(()=>t.find(e=>e.name===l)??null,[t,l]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(P,{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)(k,{children:[(0,L.jsx)(g,{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)(v,{className:`text-base`,children:`Flow`}),(0,L.jsx)(_,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(w,{variant:`outline`,size:`sm`,onClick:h,disabled:i,children:[(0,L.jsx)(a,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(u,{children:[i&&(0,L.jsx)(p,{className:`h-9 w-72`}),s&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!i&&!s&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!s&&t.length>0&&(0,L.jsx)(`select`,{value:l,onChange:e=>d(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),y&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:y.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:y.name,refreshKey:f})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[a,o]=(0,I.useState)({}),[c,l]=(0,I.useState)(!1),[d,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),p(null),h(null)},[t?.name]);let b=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(k,{children:[(0,L.jsxs)(g,{className:`pb-3`,children:[(0,L.jsx)(v,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(_,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(u,{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)(D,{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)(i,{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)(S,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>b(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a[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:a[e.name]??``,onChange:t=>b(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(E,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>b(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(w,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}l(!0),h(null),p(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}p(await e.automation.execute(t.name,{params:i})),n?.()}catch(e){h(e?.message??String(e))}finally{l(!1)}},disabled:c,size:`sm`,children:[c?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(s,{className:`h-3.5 w-3.5 mr-2`}),c?`Running…`:`Run Flow`]})}),(d||m)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[m||d?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(y,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(C,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof d?.durationMs==`number`&&(0,L.jsxs)(i,{variant:`secondary`,className:`text-[10px] font-mono`,children:[d.durationMs,` ms`]})]}),m&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:m}),d&&(0,L.jsx)(V,{data:d})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,s]=(0,I.useState)([]),[y,S]=(0,I.useState)(!0),[C,E]=(0,I.useState)(null),[D,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){E(`automation.listRuns is not available on this client`),S(!1);return}S(!0),E(null);try{let n=await e.automation.listRuns(t,{limit:20});s(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){E(e?.message??String(e))}finally{S(!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)(k,{children:[(0,L.jsx)(g,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(v,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(_,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(w,{variant:`outline`,size:`sm`,onClick:W,disabled:y,children:[y?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(a,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(u,{children:[y&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(p,{className:`h-8 w-full`}),(0,L.jsx)(p,{className:`h-8 w-full`}),(0,L.jsx)(p,{className:`h-8 w-full`})]}),!y&&C&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:C}),!y&&!C&&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.`}),!y&&!C&&r.length>0&&(0,L.jsxs)(O,{children:[(0,L.jsx)(N,{children:(0,L.jsxs)(x,{children:[(0,L.jsx)(T,{children:`Run`}),(0,L.jsx)(T,{children:`Status`}),(0,L.jsx)(T,{children:`Started`}),(0,L.jsx)(T,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(j,{children:r.map(e=>(0,L.jsxs)(x,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(b,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(b,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(b,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(b,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(m,{open:!!D,onOpenChange:e=>{e||(A(null),P(null))},children:(0,L.jsxs)(o,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(d,{className:`p-4 border-b`,children:[(0,L.jsxs)(h,{className:`font-mono text-sm break-all`,children:[`Run `,D]}),(0,L.jsx)(l,{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)(i,{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)(c,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(p,{className:`h-16 w-full`}),(0,L.jsx)(p,{className:`h-16 w-full`}),(0,L.jsx)(p,{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)(i,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(i,{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,l as i,p as a,t as o,u as s}from"./vendor-react-DR370ovB.js";import{f as c,m as l}from"./infrastructure-CJNwTVno.js";import{B as u,O as d,T as f,r as p,w as m}from"./framework-DLckRGJs.js";import{Co as h,H as g,R as _,Xi as v,mc as y,z as b}from"./ui-components-B2CBE2Rs.js";import{r as x}from"./vendor-ui-utils-rQOI1gAo.js";import"./MetadataProvider-_6IU7cWK.js";import{r as S}from"./ExpressionProvider-wi1dJ2tN.js";import{n as C,r as w,t as T}from"./MetadataInspector-BGWYqUse.js";import{t as E}from"./InterfaceListPage-DAJiEE0k.js";import{a as D,i as O,n as k,r as A,t as j}from"./resolveActionParams-DjRjW-gD.js";var M=e(n(),1),N=o(),P={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function F(e){let{dataSource:t,objects:n,objectName:r,onRefresh:i}=e,a=s(),{user:o,activeOrganization:u}=c(),{fieldLabel:d,fieldOptionLabel:f,actionParamText:p,actionParamOptionLabel:m,actionDescription:h}=y(),g=(0,M.useMemo)(()=>r?n?.find(e=>e.name===r):void 0,[n,r]),_=r||g?.name,v=(0,M.useCallback)(()=>{i?.()},[i]),[b,S]=(0,M.useState)({open:!1,message:``}),[C,w]=(0,M.useState)({open:!1,params:[]}),[T,E]=(0,M.useState)({open:!1}),[F,I]=(0,M.useState)(null),L=(0,M.useRef)(new Set),R=(0,M.useCallback)((e,t)=>new Promise(n=>{E({open:!0,spec:e,data:t,resolve:n})}),[]),z=(0,M.useCallback)((e,t)=>new Promise(n=>{S({open:!0,message:e,options:t,resolve:n})}),[]),B=(0,M.useCallback)((e,t)=>new Promise(i=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=j(e,{objectName:r||g?.name||``,objects:n||[],fieldLabel:d,fieldOptionLabel:f,row:a}),s=r||g?.name;w({open:!0,params:o.map(e=>({...e,label:p(s,t?.name,e.name,`label`,e.label)??e.label,placeholder:p(s,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:p(s,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:m(s,t?.name,e.name,n.value,n.label)})):e.options})),title:t?.label||t?.title,description:h(s,t?.name,t?.description),resolve:i})}),[r,g,n,d,f,p,m]),V=o?{id:o.id,name:o.name,avatar:o.image,isPlatformAdmin:o?.isPlatformAdmin??!1}:P,H=(0,M.useCallback)((e,t)=>{t?.type===`error`?x.error(e):x.success(e)},[]),U=(0,M.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):a(e)},[a]),W=(0,M.useMemo)(()=>l(),[]),G=(0,M.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 W(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&&v(),{success:!0,data:p,reload:e.refreshAfter!==!1}}let a=e.objectName||_;a&&typeof t?.execute==`function`?await t.execute(a,n,r):a&&r.recordId&&Object.keys(r).length>1&&typeof t?.update==`function`&&await t.update(a,r.recordId,r);let o=e.refreshAfter!==!1;return o&&v(),{success:!0,reload:o}}catch(e){return{success:!1,error:e.message}}},[t,_,W,u,v]),K=(0,M.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 W(`/api/v1/automation/${encodeURIComponent(n)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:a,objectName:e.objectName||_,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 I({flowName:n,runId:c.runId,screen:c.screen}),{success:!0};let l=e.refreshAfter!==!1;return l&&v(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,_,v]),q=(0,M.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(L.current.has(s))return{success:!1,error:`Action already in progress`};L.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||x(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&v(),{success:!0}}let i=e.objectName||_||`global`,a=await W(`/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 x.error(e),{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&v();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||x(`浏览器拦截了弹窗 / 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 x.error(t),{success:!1,error:t}}finally{L.current.delete(s)}},[W,_,v]);return{confirmHandler:z,toastHandler:H,navigateHandler:U,paramCollectionHandler:B,resultDialogHandler:R,apiHandler:G,flowHandler:K,serverActionHandler:q,authFetch:W,actionProviderProps:(0,M.useMemo)(()=>({context:{...r?{objectName:r}:{},user:V,apiBase:``,activeOrganization:u?{id:u.id,slug:u.slug,name:u.name}:null},onConfirm:z,onToast:H,onNavigate:U,onParamCollection:B,onResultDialog:R,handlers:{api:G,flow:K,script:q,modal:q}}),[r,V,u,z,H,U,B,R,G,K,q]),dialogs:(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(D,{state:b,onOpenChange:e=>{e||S({open:!1,message:``})}}),(0,N.jsx)(O,{state:C,onOpenChange:e=>{e||w({open:!1,params:[]})}}),(0,N.jsx)(A,{state:T,onAcknowledge:()=>{T.resolve?.(),E({open:!1})}}),(0,N.jsx)(k,{state:F,authFetch:W,baseUrl:``,onClose:()=>I(null),onComplete:()=>{I(null),v()}})]})}}function I({children:e,...t}){let n=F(t);return(0,N.jsxs)(d,{...n.actionProviderProps,children:[e,n.dialogs]})}var L=t({PageView:()=>R});function R(){let{t:e}=p(),{pageName:t}=r(),[n]=a(),{showDebug:o}=C(),l=s(),d=i(),{user:y}=c(),x=y?.role===`admin`,{pages:D,objects:O}=f(),{app:k}=S(),A=m(),[j,P]=(0,M.useState)(0),F=w(D,t,k?._packageId);if(!F)return(0,N.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,N.jsxs)(_,{children:[(0,N.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,N.jsx)(h,{className:`h-6 w-6 text-muted-foreground`})}),(0,N.jsx)(g,{children:e(`empty.pageNotFound`)}),(0,N.jsx)(b,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})});let L=Object.fromEntries(n.entries()),R=d.pathname.match(/\/apps\/([^/]+)/)?.[1],z=x&&!!R&&!!t;return(0,N.jsx)(I,{dataSource:A,objects:O,onRefresh:()=>P(e=>e+1),children:(0,N.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,N.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[z&&(0,N.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,N.jsx)(v,{className:`h-3.5 w-3.5`})}),F.interfaceConfig?.source?(0,N.jsx)(E,{page:F},j):(0,N.jsx)(u,{schema:{...F,type:F.type||`page`,context:{...F.context,params:L,refreshKey:j}}},j)]}),(0,N.jsx)(T,{open:o,sections:[{title:`Page Configuration`,data:F}]})]})})}export{F as n,L as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-DR370ovB.js";import{w as r}from"./framework-DLckRGJs.js";import{$n as i,$o as a,Bn as o,Fi as ee,Hn as s,Ia as te,Io as ne,Jn as re,Ln as c,Ri as ie,Rn as l,Ui as ae,Vn as u,Xn as oe,Yn as se,Yo as ce,Zn as le,ct as d,dt as f,hr as p,lt as m,nn as h,on as g,ot as ue,qn as de,st as fe,ut as pe,yi as me,zn as _}from"./ui-components-B2CBE2Rs.js";import{r as v}from"./vendor-ui-utils-rQOI1gAo.js";import"./index-JrHkY-wh.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)(de,{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)(le,{className:`flex items-center gap-2`,children:[(0,b.jsx)(ie,{className:`h-4 w-4`}),`Public Forms`]}),(0,b.jsx)(se,{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)(ae,{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)(re,{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)(ue,{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)(i,{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)(ne,{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)(te,{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)(a,{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)(ce,{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)(me,{className:`h-3.5 w-3.5`})})]})})]},e.name)})})]})]})]}),(0,b.jsx)(c,{open:ge,onOpenChange:O,children:(0,b.jsxs)(l,{className:`sm:max-w-md`,children:[(0,b.jsxs)(u,{children:[(0,b.jsx)(s,{children:`Publish a FormView`}),(0,b.jsxs)(_,{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)(o,{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)(c,{open:_e,onOpenChange:F,children:(0,b.jsxs)(l,{className:`sm:max-w-lg`,children:[(0,b.jsxs)(u,{children:[(0,b.jsx)(s,{children:I?`Edit ${I.label??I.name}`:`Edit form`}),(0,b.jsx)(_,{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)(o,{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 +0,0 @@
1
- import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,l as i,r as a,t as o,u as s}from"./vendor-react-DR370ovB.js";import{f as c,m as l}from"./infrastructure-CJNwTVno.js";import{B as u,O as d,d as f,m as ee,p,r as m,ut as h,x as g}from"./framework-DLckRGJs.js";import{H as _,R as v,Wo as y,mc as b,ws as x,z as te}from"./ui-components-B2CBE2Rs.js";import{r as S}from"./vendor-ui-utils-rQOI1gAo.js";import{n as ne}from"./RecentItemsProvider-B76qldBH.js";import{i as re,n as ie,t as ae}from"./useActionModal-BKaoxO40.js";import{i as oe,n as se}from"./utils-bipVuqQL.js";import{n as ce,t as le}from"./MetadataInspector-BGWYqUse.js";import{n as ue,o as de,r as fe,s as pe}from"./plugins-views-gs7PYt1Y.js";import{t as me}from"./ManagedByBadge-BAL_PuGz.js";import{t as he}from"./skeletons-Cdt8ttDk.js";import{a as ge,i as _e,n as ve,r as ye,t as be}from"./resolveActionParams-DjRjW-gD.js";var C=e(n(),1),w=o(),xe=(0,C.createContext)(void 0);function T({children:e}){let[t,n]=(0,C.useState)(`home`),[r,i]=(0,C.useState)(),[a,o]=(0,C.useState)(),s=(0,C.useMemo)(()=>({context:t,setContext:n,currentAppName:r,setCurrentAppName:i,recordTitle:a,setRecordTitle:o}),[t,r,a]);return(0,w.jsx)(xe.Provider,{value:s,children:e})}function E(){return(0,C.useContext)(xe)||{context:`app`,setContext:()=>{},currentAppName:void 0,setCurrentAppName:()=>{},recordTitle:void 0,setRecordTitle:()=>{}}}function Se(e){let{setRecordTitle:t}=E();(0,C.useEffect)(()=>(t(e),()=>t(void 0)),[e,t])}function D(e){let{url:t,channel:n,autoReconnect:r=!0,reconnectInterval:i=1e3,maxReconnectAttempts:a=10,authToken:o}=e,[s,c]=(0,C.useState)(`disconnected`),[l,u]=(0,C.useState)(null),[d,f]=(0,C.useState)([]),[ee,p]=(0,C.useState)(null),m=(0,C.useRef)(null),h=(0,C.useRef)(0),g=(0,C.useRef)(null),_=(0,C.useRef)(new Map),v=(0,C.useRef)([]),y=(0,C.useRef)(!0),b=(0,C.useRef)(!1),x=(0,C.useCallback)(()=>{g.current!==null&&(clearTimeout(g.current),g.current=null)},[]),te=(0,C.useCallback)(e=>{for(;v.current.length>0;){let t=v.current.shift(),r={type:t.type,channel:n,data:t.data,timestamp:new Date().toISOString()};e.send(JSON.stringify(r))}},[n]),S=(0,C.useCallback)(()=>{if(typeof WebSocket>`u`){p(Error(`WebSocket is not available in this environment`)),c(`error`);return}if(!t){p(Error(`WebSocket URL is required`)),c(`error`);return}try{let e=new URL(t);if(e.protocol!==`ws:`&&e.protocol!==`wss:`){p(Error(`WebSocket URL must use ws: or wss: protocol`)),c(`error`);return}}catch{p(Error(`Invalid WebSocket URL`)),c(`error`);return}m.current&&=(b.current=!0,m.current.close(),null),b.current=!1,c(`connecting`),p(null);let e=o?`${t}?token=${encodeURIComponent(o)}&channel=${encodeURIComponent(n)}`:`${t}?channel=${encodeURIComponent(n)}`,s;try{s=new WebSocket(e)}catch(e){if(!y.current)return;p(e instanceof Error?e:Error(`Failed to create WebSocket connection`)),c(`error`);return}m.current=s,s.onopen=()=>{y.current&&(c(`connected`),p(null),h.current=0,te(s))},s.onmessage=e=>{if(y.current)try{let t=JSON.parse(String(e.data));if(t.channel!==n)return;u(t),f(e=>[...e,t]);let r=_.current.get(t.type);r&&r.forEach(e=>e(t.data))}catch{}},s.onerror=()=>{y.current&&(p(Error(`WebSocket connection error`)),c(`error`))},s.onclose=()=>{if(y.current){if(m.current=null,b.current){c(`disconnected`);return}if(r&&h.current<a){c(`reconnecting`);let e=Math.min(i*2**h.current,3e4);h.current+=1,g.current=setTimeout(()=>{y.current&&S()},e)}else c(`disconnected`)}}},[t,n,o,r,i,a,te]),ne=(0,C.useCallback)(()=>{x(),b.current=!0,h.current=0,m.current&&=(m.current.close(),null),c(`disconnected`)},[x]),re=(0,C.useCallback)(()=>{x(),h.current=0,S()},[S,x]),ie=(0,C.useCallback)((e,t)=>{let r=m.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 v.current.push({type:e,data:t})},[n]),ae=(0,C.useCallback)((e,t)=>(_.current.has(e)||_.current.set(e,new Set),_.current.get(e).add(t),()=>{let n=_.current.get(e);n&&(n.delete(t),n.size===0&&_.current.delete(e))}),[]);return(0,C.useEffect)(()=>(y.current=!0,t&&S(),()=>{y.current=!1,x(),b.current=!0,m.current&&=(m.current.close(),null)}),[t,n,o]),{connectionState:s,isConnected:s===`connected`,lastMessage:l,messages:d,send:ie,subscribe:ae,disconnect:ne,reconnect:re,error:ee}}var O=0;function Ce(){return O+=1,`conflict-${Date.now()}-${O}`}var we=0;function k(){return we+=1,`ver-${Date.now()}-${we}`}function A(e,t,n){let[r,i]=(0,C.useState)([]),[a,o]=(0,C.useState)([]);return{versions:r,currentVersion:(0,C.useMemo)(()=>r.length===0?0:r[r.length-1].version,[r]),conflicts:a,hasConflicts:a.length>0,recordVersion:(0,C.useCallback)((n,r)=>{i(i=>{let a=i.length===0?1:i[i.length-1].version+1,o={id:k(),version:a,timestamp:new Date().toISOString(),userId:e,userName:t,changes:n,message:r};return[...i,o]})},[e,t]),resolveConflict:(0,C.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:k(),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,C.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:k(),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,C.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:k(),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,C.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,C.useCallback)(e=>{let t={...e,id:Ce()};o(e=>[...e,t])},[]),clearHistory:(0,C.useCallback)(()=>{i([]),o([])},[])}}var j={sm:24,md:32,lg:40},M={active:`#22c55e`,idle:`#f59e0b`,away:`#94a3b8`};function N(e){return e.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}function Te({users:e,maxVisible:t=5,size:n=`md`,showStatus:r=!0,className:i}){let a=j[n],o=Math.round(a*.3),s=Math.round(a*.35),c=Math.max(8,Math.round(a*.28)),l=(0,C.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`},ee={...f,backgroundColor:`#e2e8f0`,color:`#475569`,marginLeft:`-${o}px`},p={position:`absolute`,bottom:`-1px`,right:`-1px`,width:`${c}px`,height:`${c}px`,borderRadius:`50%`,border:`2px solid #fff`,boxSizing:`border-box`},m=(0,C.useMemo)(()=>[...l].reverse(),[l]);return C.createElement(`div`,{style:d,className:i,role:`group`,"aria-label":`${e.length} user${e.length===1?``:`s`} present`},u>0&&C.createElement(`div`,{key:`overflow`,style:ee,title:`${u} more user${u===1?``:`s`}`},`+${u}`),m.map((e,t)=>C.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?C.createElement(`img`,{src:e.avatar,alt:e.userName,style:{width:`100%`,height:`100%`,objectFit:`cover`}}):N(e.userName),r&&C.createElement(`span`,{style:{...p,backgroundColor:M[e.status]}}))))}var Ee=C.createContext({});function De(){let e=C.useContext(Ee),[t,n]=C.useState([]);return C.useEffect(()=>{if(!e.subscribeTenant){n([]);return}return e.subscribeTenant(e=>{n(Array.isArray(e)?e:[])})},[e]),t}function Oe(e,t){let n=C.useContext(Ee),[r,i]=C.useState([]);return C.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 ke={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 Ae(e){let t=ke[e?.managedBy??`platform`]??ke.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 je=new Set([`record:discussion`,`record:chatter`]);function Me(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`&&je.has(r)?!0:[e.children,e.items,e.body,e.components,e.properties?.children,e.properties?.items,e.regions].some(n)};return n(e)}var Ne=t({RecordDetailView:()=>ze}),Pe={id:`current-user`,name:`Demo User`},Fe=new Set([`created_at`,`created_by`,`updated_at`,`updated_by`]),Ie=new Set([`organization_id`,`tenant_id`,`is_deleted`,`deleted_at`]),P=[`description`,`notes`,`note`,`remark`,`remarks`,`comments`],Le=new Set([`textarea`,`markdown`,`html`,`rich-text`,`json`,`code`]);function Re(e,t){if(Le.has(t?.type))return!0;let n=e.toLowerCase();return P.some(e=>n===e||n.endsWith(`_${e}`))}function ze({dataSource:e,objects:t,onEdit:n,objectNameOverride:o,recordIdOverride:xe,embedded:T}){let E=r(),D=E.appName,O=o??E.objectName,Ce=xe??E.recordId,{showDebug:we}=ce(),{user:k}=c(),A=s(),j=i().state?.from,{t:M}=m(),{objectLabel:N,viewLabel:Ee,sectionLabel:De,actionLabel:ke,actionConfirm:je,actionSuccess:Ne,actionParamText:P,actionParamOptionLabel:Le,actionDescription:ze,fieldLabel:Be,fieldOptionLabel:Ve}=b(),{isFavorite:He,toggleFavorite:Ue,refreshLabel:We}=re(),{addRecentItem:Ge}=ne(),[Ke,qe]=(0,C.useState)(!0),[Je,F]=(0,C.useState)([]),[I,Ye]=(0,C.useState)([]),[Xe,L]=(0,C.useState)(0),[Ze,R]=(0,C.useState)(null),[Qe,$e]=(0,C.useState)({}),[et,tt]=(0,C.useState)(null),[nt,rt]=(0,C.useState)(!1),[z,it]=(0,C.useState)(),B=t.find(e=>e.name===O);Se(T?void 0:z);let V=Ce,at=Oe(O,V),H=(0,C.useMemo)(()=>!O||!V?null:{id:`record:${O}:${V}`,label:z||V||``,href:`/apps/${D}/${O}/record/${V}`,type:`record`},[D,O,V,z]),ot=H?He(H.id):!1,st=(0,C.useCallback)(()=>{H&&Ue(H)},[H,Ue]),{page:U,slots:W}=g(O),ct=(0,C.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]),lt=(0,C.useMemo)(()=>U||!B||!ct&&!W?null:ue(B,W?{slots:W}:void 0),[ct,U,W,B]),G=U||lt,[K,q]=(0,C.useState)(null),[ut,J]=(0,C.useState)(`idle`);(0,C.useEffect)(()=>{let t=!1;if(!G||!V||!O||!e?.findOne){q(null),J(`idle`);return}let n=h(B?.fields),r=n.length>0?{$expand:n}:void 0,i=()=>{J(`loading`),(r?e.findOne(O,V,r):e.findOne(O,V)).then(e=>{t||(e&&typeof e==`object`?(q(e),J(`loaded`)):(q(null),J(`missing`)))}).catch(()=>{t||(q(null),J(`missing`))})};i();let a=e=>{let t=e.detail||{};t.objectName!==O||String(t.recordId)!==String(V)||i()};return window.addEventListener(`objectui:record-changed`,a),()=>{t=!0,window.removeEventListener(`objectui:record-changed`,a)}},[G,O,V,e,B]),(0,C.useEffect)(()=>{if(!K||typeof K!=`object`||!B)return;let e=se(B,K);e&&e!==`Untitled`&&e!==z&&it(e)},[K,B,z]),(0,C.useEffect)(()=>{if(!O||!V||!D||!z)return;let e=`record:${O}:${V}`;Ge({id:e,label:z,href:`/apps/${D}/${O}/record/${V}`,type:`record`}),We(e,z)},[D,O,V,z,Ge,We]);let[dt,ft]=(0,C.useState)({open:!1,message:``}),[pt,mt]=(0,C.useState)({open:!1,params:[]}),[Y,ht]=(0,C.useState)({open:!1}),gt=(0,C.useCallback)((e,t)=>new Promise(n=>{ht({open:!0,spec:e,data:t,resolve:n})}),[]),_t=(0,C.useCallback)((e,t)=>new Promise(n=>{ft({open:!0,message:e,options:t,resolve:n})}),[]),vt=(0,C.useCallback)((e,n)=>new Promise(r=>{let i=be(e,{objectName:O||B?.name||``,objects:t||[],fieldLabel:Be,fieldOptionLabel:Ve}),a=O||B?.name;mt({open:!0,params:i.map(e=>({...e,label:P(a,n?.name,e.name,`label`,e.label)??e.label,placeholder:P(a,n?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:P(a,n?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(t=>({...t,label:Le(a,n?.name,e.name,t.value,t.label)})):e.options})),title:n?.label||n?.title,description:ze(a,n?.name,n?.description),resolve:r})}),[O,B,t,Be,Ve,P,Le]),yt=(0,C.useCallback)((e,t)=>{t?.type===`error`?S.error(e):S.success(e)},[]),bt=(0,C.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):A(e)},[A]),xt=(0,C.useCallback)(async t=>{try{let n=t.target||t.name,r=t.params||{};switch(n){case`opportunity_change_stage`:await e.update(O,V,{stage:r.new_stage});break;case`opportunity_mark_won`:await e.update(O,V,{stage:`closed_won`});break;case`opportunity_mark_lost`:await e.update(O,V,{stage:`closed_lost`,loss_reason:r.loss_reason});break;default:Object.keys(r).length>0&&await e.update(O,V,r);break}let i=t.refreshAfter===!0;return i&&L(e=>e+1),{success:!0,reload:i}}catch(e){return{success:!1,error:e.message}}},[e,O,V]),{modalHandler:St,modalElement:Ct}=ae(e),X=(0,C.useMemo)(()=>l(),[]),wt=(0,C.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 X(`/api/v1/automation/${encodeURIComponent(t)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:V,objectName:O,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 R({flowName:t,runId:i.runId,screen:i.screen}),{success:!0};let a=e.refreshAfter!==!1;return a&&L(e=>e+1),{success:!0,data:r?.data,reload:a}}catch(e){return{success:!1,error:e.message}}},[X,V,O]),Tt=(0,C.useRef)(new Set),Et=(0,C.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(Tt.current.has(r))return{success:!1,error:`Action already in progress`};Tt.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||S(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(t,`_blank`)}catch{window.location.href=t}}},duration:1e4})}return e.refreshAfter===!0&&L(e=>e+1),{success:!0}}let a=e.objectName||O||`global`,o=await X(`/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);if(!o.ok||s&&s.success===!1){let e=s?.error||`Action "${t}" failed (HTTP ${o.status})`;if(i)try{i.close()}catch{}return S.error(e),{success:!1,error:e}}let c=e.refreshAfter!==!1;c&&L(e=>e+1);let l=s?.data;if(l&&typeof l==`object`&&typeof l.redirectUrl==`string`){let e=l.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||S(`浏览器拦截了弹窗 / 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:l,reload:c}}catch(e){if(i)try{i.close()}catch{}let t=e.message;return S.error(t),{success:!1,error:t}}finally{Tt.current.delete(r)}},[X,V,O]),Z=ie(O,V,k?.id),Dt=(0,C.useRef)(Z);Dt.current=Z;let Ot=(0,C.useCallback)(async e=>{let t=e.target||e.name,n=e.params&&!Array.isArray(e.params)?e.params:{};try{if(t===`approve_request`)await Dt.current.approve({comment:n.comment});else if(t===`reject_request`)await Dt.current.reject({comment:n.comment});else return{success:!1,error:`Unknown approval target: ${t}`};return L(e=>e+1),{success:!0,reload:!0}}catch(e){return{success:!1,error:e?.message||String(e)}}},[]),kt=(0,C.useMemo)(()=>oe(B,t),[B,t]);(0,C.useEffect)(()=>{if(G||!e||!V||kt.length===0)return;let t=!1;return Promise.all(kt.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;$e(n)}),()=>{t=!0}},[e,V,kt,B,G]);let At=(0,C.useMemo)(()=>!B||B.name===`sys_audit_log`||B.enable?.trackHistory!==!0?!1:t.some(e=>e.name===`sys_audit_log`),[B,t]);(0,C.useEffect)(()=>{if(!e||!V||!B||!At){tt(null);return}let t=!1;return rt(!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};tt(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),tt([]))}).finally(()=>{t||rt(!1)}),()=>{t=!0}},[e,V,B,At]),(0,C.useEffect)(()=>{if(!e)return;let t=!1,n=k?[{id:String(k.id),label:k.name||k.email||String(k.id),avatarUrl:k.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))];Ye(o.length>0?o:n)}catch{if(t)return;Ye(n)}})(),()=>{t=!0}},[e,k?.id,k?.name,k?.email]);let Q=(0,C.useMemo)(()=>k?{id:k.id,name:k.name,avatar:k.image}:Pe,[k?.id,k?.name,k?.image]);(0,C.useEffect)(()=>{if(!e||!O||!V)return;let t=`${O}:${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??`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)}));F(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:O,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??`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&&F(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,O,V,Q]);let jt=(0,C.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(F(e=>[...e,n]),e){let r=`${O}:${V}`,i=fe(t,I);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,O,V,I]),Mt=(0,C.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(F(e=>[...e,r].map(e=>e.id===t?{...e,replyCount:(e.replyCount??0)+1}:e)),e){let i=`${O}:${V}`,a=fe(n,I);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,O,V,I]),Nt=(0,C.useCallback)((t,n)=>{F(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,C.useEffect)(()=>{qe(!0),queueMicrotask(()=>qe(!1))},[O,Ce]);let $=(0,C.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?De(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=>!Fe.has(e)&&!Ie.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=>!Re(e,B.fields[e])),r=e.filter(e=>Re(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:De(B.name,`details`,M(`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:ke(B.name,e.name,e.label||e.name),...e.confirmText!==void 0&&{confirmText:je(B.name,e.name,e.confirmText)},...e.successMessage!==void 0&&{successMessage:Ne(B.name,e.name,e.successMessage)}}));if(Z.available&&Z.canDecide){let e={name:`comment`,label:M(`approvals.comment`,{defaultValue:`Comment (optional)`}),type:`text`,multiline:!0};t.push({name:`approve_request`,type:`approval`,target:`approve_request`,label:M(`approvals.approve`,{defaultValue:`Approve`}),icon:`check`,variant:`default`,locations:[`record_header`],refreshAfter:!0,collectParams:[e],successMessage:M(`approvals.approveSuccess`,{defaultValue:`Approved`})}),t.push({name:`reject_request`,type:`approval`,target:`reject_request`,label:M(`approvals.reject`,{defaultValue:`Reject`}),icon:`x`,variant:`destructive`,locations:[`record_header`],refreshAfter:!0,confirmText:M(`approvals.rejectConfirm`,{defaultValue:`Reject this approval request?`}),collectParams:[e],successMessage:M(`approvals.rejectSuccess`,{defaultValue:`Rejected`})})}return t})(),o=B.views?.detail?.highlightFields??[],s=B.views?.detail?.sectionGroups??B.views?.form?.sectionGroups,c=D?`/apps/${D}`:``,l=kt.map(({childObject:n,childLabel:r,referenceField:i,title:a,columns:o})=>{let s=t.find(e=>e.name===n),l=V||``,u=a||(s?N({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}`:``}`},ee=e=>{let t=e?.id||e?._id;return t?`${c}/${n}/record/${encodeURIComponent(String(t))}/edit`:null},p=e=>{let t=e?.id||e?._id;return t?`${c}/${n}/record/${encodeURIComponent(String(t))}`:null},m=c?()=>A(d()):void 0,h=c?()=>A(f()):void 0,g=c?e=>{let t=p(e);t&&A(t)}:void 0,_=c?e=>{let t=ee(e);t&&A(t)}:void 0,v=e&&l?async t=>{let r=t?.id||t?._id;if(r)try{await e.delete(n,r),S.success(M(`detail.deleteSuccess`,{defaultValue:`Deleted`})),$e(e=>({...e,[n]:(e[n]||[]).filter(e=>(e.id||e._id)!==r)}))}catch(e){S.error(e?.message||M(`detail.deleteError`,{defaultValue:`Delete failed`}))}}:void 0;return{title:u,type:`table`,api:n,data:Qe[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:m,onViewAll:h,onRowClick:g,onRowEdit:_,onRowDelete:v}}),u=Ae(B);return{type:`detail-view`,objectName:B.name,resourceId:V,showBack:!T,onBack:`history`,showEdit:u.edit,title:B.label,primaryField:n,sections:i,autoTabs:!0,autoDiscoverRelated:!0,...At&&{history:{entries:et??[],loading:nt&&et===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,Qe,Xe,D,A,e,M,N,t,At,et,nt,Z.available,Z.canDecide,Z.pendingRequest,Z.latestRequest,T]);if(Ke)return(0,w.jsx)(he,{});if(!B)return(0,w.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,w.jsxs)(v,{children:[(0,w.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,w.jsx)(y,{className:`h-6 w-6 text-muted-foreground`})}),(0,w.jsx)(_,{children:M(`empty.objectNotFound`)}),(0,w.jsx)(te,{children:M(`empty.objectNotFoundDescription`,{name:O})})]})});if(G&&ut===`missing`)return(0,w.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,w.jsxs)(v,{children:[(0,w.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,w.jsx)(y,{className:`h-6 w-6 text-muted-foreground`})}),(0,w.jsx)(_,{children:M(`empty.recordNotFound`,{defaultValue:`Record not found`})}),(0,w.jsx)(te,{children:M(`empty.recordNotFoundDescription`,{defaultValue:`The record you are looking for does not exist or may have been deleted.`})})]})});if(G){let t=G?.disableDiscussion===!0,r=Me(G),i=!t&&!r,o=(()=>{let e=$.actions;if(!Array.isArray(e))return[];let t=e.find(e=>Array.isArray(e?.actions))?.actions??e;return Array.isArray(t)?t:[]})(),s=(()=>{let t=Ae(B),r=[];return t.edit&&(r.push({name:`sys_inline_edit`,label:M(`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:O}}))}}),r.push({name:`sys_edit`,label:M(`detail.edit`,{defaultValue:`Edit`}),type:`script`,locations:[`record_header`],variant:`default`,onClick:()=>n({id:V})})),r.push({name:`sys_share`,label:M(`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),S.success(M(`detail.linkCopied`,{defaultValue:`Link copied`}))}catch(e){S.error(M(`detail.linkCopyFailed`,{defaultValue:`Failed to copy link`})+(e?.message?`: ${e.message}`:``))}}}),t.delete&&r.push({name:`sys_delete`,label:M(`detail.delete`,{defaultValue:`Delete`}),type:`script`,locations:[`record_header`],variant:`destructive`,onClick:async()=>{let t=M(`detail.deleteConfirmation`,{defaultValue:`Are you sure you want to delete this record?`});if(window.confirm(t))try{await e.delete(O,V),S.success(M(`detail.deleted`,{defaultValue:`Record deleted`})),A(`${D?`/apps/${D}`:``}/${O}`,{replace:!0})}catch(e){S.error(e?.message||`Delete failed`)}}}),r})(),c=o.length>0?o:void 0,l=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,m=$.history?{entries:$.history.entries??[],loading:!!$.history.loading,emptyText:$.history.emptyText}:void 0,h=U?G:ue(B,{sections:$.sections,highlightFields:Array.isArray($.highlightFields)?$.highlightFields.map(e=>typeof e==`string`?e:e?.name).filter(e=>!!e):void 0,headerActions:c,related:l,history:m,showReferenceRail:B?.detail?.showReferenceRail===!0||void 0,hideReferenceRail:B?.detail?.hideReferenceRail===!0||void 0,hideRelatedTab:B?.detail?.hideRelatedTab===!0||void 0,...W?{slots:W}:{}});return(0,w.jsxs)(`div`,{className:`h-full bg-background overflow-hidden flex flex-col relative`,children:[(0,w.jsxs)(`div`,{className:`absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2`,children:[at.length>0&&(0,w.jsx)(Te,{users:at,size:`sm`,maxVisible:3,showStatus:!0}),(0,w.jsx)(me,{managedBy:B?.managedBy})]}),(0,w.jsx)(ee,{objectName:O,recordId:V,data:K,objectSchema:B,dataSource:e,embedded:T,headerSystemActions:s,isFavorite:ot,onToggleFavorite:H?st:void 0,children:(0,w.jsx)(p,{children:(0,w.jsx)(f,{items:Je,onAddComment:jt,onAddReply:Mt,onToggleReaction:Nt,mentionSuggestions:I,children:(0,w.jsxs)(d,{context:{record:K||{},objectName:O,user:Q},onConfirm:_t,onToast:yt,onNavigate:bt,onParamCollection:vt,onResultDialog:gt,onModal:St,handlers:{api:xt,flow:wt,script:Et,approval:Ot},children:[(0,w.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-row`,children:[(0,w.jsxs)(`div`,{className:`flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48`,children:[j?.pathname&&j?.label&&(0,w.jsxs)(a,{to:j.pathname,className:`inline-flex items-center gap-1 mb-3 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,w.jsx)(x,{className:`h-4 w-4`}),(0,w.jsx)(`span`,{children:j.label})]}),(0,w.jsx)(u,{schema:h}),i&&(0,w.jsx)(`div`,{className:`mt-6`,children:(0,w.jsx)(de,{config:{position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:Je,onAddComment:jt,onAddReply:Mt,onToggleReaction:Nt,mentionSuggestions:I})})]}),(0,w.jsx)(le,{open:we,sections:[{title:`Page Schema`,data:h}]})]}),Ct]})})})}),(0,w.jsx)(ge,{state:dt,onOpenChange:e=>{e||ft(e=>({...e,open:!1}))}}),(0,w.jsx)(_e,{state:pt,onOpenChange:e=>{e||mt(e=>({...e,open:!1}))}}),(0,w.jsx)(ye,{state:Y,onAcknowledge:()=>{Y.resolve?.(),ht({open:!1})}}),(0,w.jsx)(ve,{state:Ze,authFetch:X,baseUrl:``,onClose:()=>R(null),onComplete:()=>{R(null),L(e=>e+1)}})]})}return(0,w.jsxs)(`div`,{className:`h-full bg-background overflow-hidden flex flex-col relative`,children:[(0,w.jsxs)(`div`,{className:`absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2`,children:[at.length>0&&(0,w.jsx)(Te,{users:at,size:`sm`,maxVisible:3,showStatus:!0}),(0,w.jsx)(me,{managedBy:B?.managedBy})]}),(0,w.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-row`,children:[(0,w.jsx)(`div`,{className:`flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48`,children:(0,w.jsxs)(d,{context:{record:{},objectName:O,user:Q},onConfirm:_t,onToast:yt,onNavigate:bt,onParamCollection:vt,onResultDialog:gt,onModal:St,handlers:{api:xt,flow:wt,script:Et,approval:Ot},children:[(0,w.jsx)(pe,{schema:$,dataSource:e,objectLabel:N({name:B.name,label:B.label}),isFavorite:ot,onToggleFavorite:H?st:void 0,onDataLoaded:e=>{if(!e||typeof e!=`object`)return;let t=se(B,e);t&&t!==z&&t!==`Untitled`&&it(t)},onEdit:()=>{n({id:V})},discussionSlot:(0,w.jsx)(de,{config:{position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:Je,onAddComment:jt,onAddReply:Mt,onToggleReaction:Nt})},Xe),Ct]})}),(0,w.jsx)(le,{open:we,sections:[{title:`View Schema`,data:$}]})]}),(0,w.jsx)(ge,{state:dt,onOpenChange:e=>{e||ft(e=>({...e,open:!1}))}}),(0,w.jsx)(_e,{state:pt,onOpenChange:e=>{e||mt(e=>({...e,open:!1}))}}),(0,w.jsx)(ye,{state:Y,onAcknowledge:()=>{Y.resolve?.(),ht({open:!1})}}),(0,w.jsx)(ve,{state:Ze,authFetch:X,baseUrl:``,onClose:()=>R(null),onComplete:()=>{R(null),L(e=>e+1)}})]})}export{Te as a,T as c,De as i,E as l,Ne as n,A as o,Ae as r,D as s,ze as t};
@@ -1 +0,0 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-DR370ovB.js";import{d as a}from"./infrastructure-CJNwTVno.js";import{w as o}from"./framework-DLckRGJs.js";import{$n as s,Ar as c,Ci as l,Ga as u,Jn as d,Jr as f,Ma as p,Rs as m,Wo as h,Ws as g,Xn as _,Yn as v,Zn as y,bi as b,ei as x,jr as S,mi as C,qn as w,za as T}from"./ui-components-B2CBE2Rs.js";import"./index-JrHkY-wh.js";var E=e(t(),1),D=r();function O(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,O=o(),k=a(),[A,j]=(0,E.useState)({users:null,orgs:null,roles:null,permissions:null,auditLogs:null}),[M,N]=(0,E.useState)(!0),P=(0,E.useCallback)(async()=>{if(O){N(!0);try{let[e,t,n,r,i]=await Promise.all([O.find(`sys_user`).catch(()=>({data:[]})),O.find(`sys_org`).catch(()=>({data:[]})),O.find(`sys_role`).catch(()=>({data:[]})),O.find(`sys_permission`).catch(()=>({data:[]})),O.find(`sys_audit_log`).catch(()=>({data:[]}))]);j({users:e.data?.length??0,orgs:t.data?.length??0,roles:n.data?.length??0,permissions:r.data?.length??0,auditLogs:i.data?.length??0})}catch{}finally{N(!1)}}},[O]);(0,E.useEffect)(()=>{P()},[P]);let F=[{title:`Applications`,description:`Manage all configured applications`,icon:T,href:`${r}/system/apps`,countLabel:``,count:null},{title:`Metadata`,description:`Browse and edit every metadata type the platform exposes`,icon:h,href:`${r}/component/metadata/directory`,countLabel:``,count:null}],I=[{title:`Users`,description:`Manage system users and accounts`,icon:c,href:`${r}/system/users`,countLabel:`users`,count:A.users},{title:`Organizations`,description:`Manage organizations and teams`,icon:m,href:`${r}/system/organizations`,countLabel:`organizations`,count:A.orgs},{title:`Roles`,description:`Configure roles and access levels`,icon:C,href:`${r}/system/roles`,countLabel:`roles`,count:A.roles},{title:`Permissions`,description:`Manage permission rules and assignments`,icon:u,href:`${r}/system/permissions`,countLabel:`permissions`,count:A.permissions},{title:`Audit Log`,description:`View system activity and changes`,icon:l,href:`${r}/system/audit-log`,countLabel:`entries`,count:A.auditLogs},{title:`AI Approvals`,description:`Review actions AI agents propose before they execute`,icon:g,href:`${r}/system/ai-approvals`,countLabel:``,count:null},{title:`App Marketplace`,description:`Browse and install approved apps from the ObjectStack catalog`,icon:x,href:`${r}/system/marketplace`,countLabel:``,count:null,adminOnly:!0},{title:`Settings`,description:`Configure mail, branding, feature flags, and more`,icon:b,href:`${r}/system/settings`,countLabel:``,count:null},{title:`Developer`,description:`API console, flow runs, and public form management`,icon:f,href:`${r}/developer`,countLabel:``,count:null},{title:`Profile`,description:`View and edit your account settings`,icon:S,href:`${r}/system/profile`,countLabel:``,count:null}],L=[...F,...I].filter(e=>!e.adminOnly||k);return(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`System Settings`}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage applications, users, roles, permissions, and system configuration`})]}),M&&(0,D.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,D.jsx)(p,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),`Loading statistics...`]}),(0,D.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:L.map(t=>{let n=t.icon;return(0,D.jsxs)(w,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>e(t.href),"data-testid":`hub-card-${t.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${t.title}: ${t.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(t.href))},children:[(0,D.jsxs)(_,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,D.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,D.jsx)(n,{className:`h-5 w-5`})}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,D.jsx)(y,{className:`text-base`,children:t.title}),(0,D.jsx)(v,{className:`text-xs`,children:t.description})]})]}),(0,D.jsx)(d,{className:`pt-0`,children:t.count!==null&&(0,D.jsxs)(s,{variant:`secondary`,children:[t.count,` `,t.countLabel]})})]},t.title)})})]})}export{O as SystemHubPage};