@objectstack/console 12.6.0 → 13.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/dist/.objectui-sha +1 -1
  2. package/dist/assets/{AdapterProvider-BmqhWHIU.js → AdapterProvider-G7o889LL.js} +1 -1
  3. package/dist/assets/{AiPendingActionsPage-BRZ9smBE.js → AiPendingActionsPage-B_bQ89Ap.js} +1 -1
  4. package/dist/assets/{ApiConsolePage-1bt8j6wO.js → ApiConsolePage-oJexbnMd.js} +1 -1
  5. package/dist/assets/{AppDocsIndex-Bn1CdcNi.js → AppDocsIndex-B2EMS--S.js} +1 -1
  6. package/dist/assets/{AppManagementPage-CeZ7gA3p.js → AppManagementPage-BSLRnX7p.js} +1 -1
  7. package/dist/assets/{ApprovalsInboxPage-Cm6RlF50.js → ApprovalsInboxPage-DbdgZkz_.js} +1 -1
  8. package/dist/assets/{AuditLogPage-BUapxa-t.js → AuditLogPage-JHBVKm-o.js} +1 -1
  9. package/dist/assets/{ComponentNavView-CV-L0t8o.js → ComponentNavView-Be3JMpLK.js} +1 -1
  10. package/dist/assets/ConsoleFloatingChatbot-MtFbTLoq.js +1 -0
  11. package/dist/assets/{CreateViewDialog-CMNLzv6j.js → CreateViewDialog-CboUdp-q.js} +1 -1
  12. package/dist/assets/DashboardView-1nXwC0y_.js +1 -0
  13. package/dist/assets/{DeveloperHubPage-CigDAiDQ.js → DeveloperHubPage-B55QdK7b.js} +1 -1
  14. package/dist/assets/{ExpressionProvider-ODpzkcN3.js → ExpressionProvider-B3pkCzAo.js} +1 -1
  15. package/dist/assets/{FlowRunsPage-DQy0C86b.js → FlowRunsPage-CKOKC3O1.js} +1 -1
  16. package/dist/assets/{IntegrationsPage-D8453O8m.js → IntegrationsPage-gLs4Ms2t.js} +1 -1
  17. package/dist/assets/{InterfaceListPage-B_B_Fttt.js → InterfaceListPage-CwGb2Th3.js} +1 -1
  18. package/dist/assets/{ManagedByBadge-BGSB7vGi.js → ManagedByBadge-BtJfBjbT.js} +1 -1
  19. package/dist/assets/{MarketplaceAccessDenied-CAuxNcMw.js → MarketplaceAccessDenied-Bl4faFLm.js} +1 -1
  20. package/dist/assets/{MarketplaceInstalledPage-DIKAvmEt.js → MarketplaceInstalledPage-BQH-qEi5.js} +1 -1
  21. package/dist/assets/{MarketplacePackagePage-DWvYmWIA.js → MarketplacePackagePage-B2BXohna.js} +2 -2
  22. package/dist/assets/{MarketplacePage-SkUEdd3B.js → MarketplacePage-C_HnQQYH.js} +1 -1
  23. package/dist/assets/{MetadataInspector-RvnQ-QOT.js → MetadataInspector-DwPx9ueN.js} +1 -1
  24. package/dist/assets/{MetadataProvider-Cm9vi7AZ.js → MetadataProvider-seOmvY8N.js} +1 -1
  25. package/dist/assets/{ObjectDataPage-DeFtGZ6x.js → ObjectDataPage-D8W0OzJe.js} +1 -1
  26. package/dist/assets/PageView-cehnKJ9R.js +1 -0
  27. package/dist/assets/{ProfilePage-7etuxYZk.js → ProfilePage-CPk5ilAm.js} +1 -1
  28. package/dist/assets/{PublicFormsPage-BsrJk1W2.js → PublicFormsPage-5oWNwPiZ.js} +1 -1
  29. package/dist/assets/RecordDetailView-CUcCVoa1.js +9 -0
  30. package/dist/assets/{RecordFormPage-CBPvAXGe.js → RecordFormPage-Dmw4MMhg.js} +1 -1
  31. package/dist/assets/ReportDefaultInspector-BBTLmEl-.js +11 -0
  32. package/dist/assets/ReportView-BPkQVP9-.js +2 -0
  33. package/dist/assets/SearchResultsPage-quEMr1ZW.js +1 -0
  34. package/dist/assets/{SettingsHub-ZMQjBQwP.js → SettingsHub-B5Y0DjDk.js} +1 -1
  35. package/dist/assets/{SettingsView-eCnpX1vu.js → SettingsView-Q3e7GG0S.js} +1 -1
  36. package/dist/assets/{SystemHubPage-B8o4-NXd.js → SystemHubPage-SIzLdDrE.js} +1 -1
  37. package/dist/assets/appRoute-1sYdkwBz.js +1 -0
  38. package/dist/assets/conversationLanguage-CgUPnufx.js +1 -0
  39. package/dist/assets/data-adapter-BP-pyfs8.js +7 -0
  40. package/dist/assets/{framework-B3O15Lsq.js → framework-CBCX6Urh.js} +8 -8
  41. package/dist/assets/{getIcon-B5xaQx5N.js → getIcon-Ci4w4xXM.js} +1 -1
  42. package/dist/assets/{highlighted-body-OFNGDK62-B_roNkgm.js → highlighted-body-OFNGDK62-B5Pqh6xJ.js} +1 -1
  43. package/dist/assets/index-Df624lGg.js +2 -0
  44. package/dist/assets/{index-BXgUF5nO.css → index-GDbpsyLD.css} +1 -1
  45. package/dist/assets/{infrastructure-Bcx6-8du.js → infrastructure-ASGyCRMg.js} +1 -1
  46. package/dist/assets/marketplaceApi-N63OOXW-.js +1 -0
  47. package/dist/assets/mermaid-GHXKKRXX-BlWXnAVk.js +1 -0
  48. package/dist/assets/metadata-admin-Jkl-QChK.js +23 -0
  49. package/dist/assets/{plugin-calendar-BKbWgkod.js → plugin-calendar-BHRBKeJq.js} +1 -1
  50. package/dist/assets/{plugin-charts-BZo5ApEF.js → plugin-charts-DyKYgW3L.js} +1 -1
  51. package/dist/assets/plugin-chatbot-CNLp4fGv.js +120 -0
  52. package/dist/assets/{plugin-dashboard-CRFZp7gC.js → plugin-dashboard-uOZwquef.js} +1 -1
  53. package/dist/assets/plugin-form-CX8z6nsj.js +1 -0
  54. package/dist/assets/{plugin-gantt-D9YRdBGD.js → plugin-gantt-CyktuI6d.js} +1 -1
  55. package/dist/assets/{plugin-grid-eiIl2HN_.js → plugin-grid-DNGRZzGM.js} +1 -1
  56. package/dist/assets/{plugin-kanban-3rFMGC21.js → plugin-kanban-B0Dwrpca.js} +1 -1
  57. package/dist/assets/{plugin-map-BHQrQ_Wu.js → plugin-map-Co_pYpOZ.js} +1 -1
  58. package/dist/assets/{plugin-markdown-DesFSRDB.js → plugin-markdown-CS5R-t3i.js} +1 -1
  59. package/dist/assets/{plugin-report-BKD6SOp5.js → plugin-report-_y8nt0FZ.js} +1 -1
  60. package/dist/assets/{plugin-timeline-BrkABjqu.js → plugin-timeline-Cy03-xov.js} +1 -1
  61. package/dist/assets/{plugin-tree-CKck3lEJ.js → plugin-tree-DCAEE54g.js} +1 -1
  62. package/dist/assets/plugin-view-OZpEPOgT.js +1 -0
  63. package/dist/assets/plugins-views-BVxwkRdi.js +4 -0
  64. package/dist/assets/{skeletons-CzC0fiXD.js → skeletons-BjaBYe9k.js} +1 -1
  65. package/dist/assets/{src-BeTFx9-N.js → src-D6ENIa3w.js} +1 -1
  66. package/dist/assets/src-rXeXV_HX.js +16 -0
  67. package/dist/assets/{types-UYoEctl-.js → types-DXCQOIiO.js} +1 -1
  68. package/dist/assets/{ui-components-rkvkkTxO.js → ui-components-BOOpjWsQ.js} +9 -9
  69. package/dist/assets/{ui-layout-CAjjF5_S.js → ui-layout-vWAZODrs.js} +1 -1
  70. package/dist/assets/{useMetadata-DO66YueM.js → useMetadata-D-bLZoNN.js} +1 -1
  71. package/dist/assets/useOpenRecordList-B3tjtz1e.js +1 -0
  72. package/dist/assets/{useRecordApprovals-obyIj2_8.js → useRecordApprovals-jo_LH43z.js} +1 -1
  73. package/dist/assets/vendor-objectstack-Jcqd9154.js +108 -0
  74. package/dist/index.html +4 -4
  75. package/package.json +1 -1
  76. package/dist/assets/ConsoleFloatingChatbot-CO_DukxV.js +0 -1
  77. package/dist/assets/DashboardView-CnKtk1aW.js +0 -1
  78. package/dist/assets/DashboardWidgetInspector-CYPIrTyy.js +0 -1
  79. package/dist/assets/PageView-BQS9pq2N.js +0 -1
  80. package/dist/assets/RecordDetailView-CzR6BAUv.js +0 -9
  81. package/dist/assets/ReportDefaultInspector-ah_Be1RZ.js +0 -11
  82. package/dist/assets/ReportView-D5Hifbvj.js +0 -2
  83. package/dist/assets/SearchResultsPage-24ufpv2l.js +0 -1
  84. package/dist/assets/appRoute-CbCiASix.js +0 -1
  85. package/dist/assets/data-adapter-CdxWNPpK.js +0 -7
  86. package/dist/assets/index-Bp2ZvXdP.js +0 -2
  87. package/dist/assets/marketplaceApi-zYQofLEk.js +0 -1
  88. package/dist/assets/mermaid-GHXKKRXX-B7uCX_yo.js +0 -1
  89. package/dist/assets/metadata-admin-BveAqpPs.js +0 -22
  90. package/dist/assets/plugin-chatbot-D2Uv-hn9.js +0 -120
  91. package/dist/assets/plugin-form-FeZEoC2R.js +0 -1
  92. package/dist/assets/plugin-view-BJ9uLrnO.js +0 -1
  93. package/dist/assets/plugins-views-CibWNUsP.js +0 -4
  94. package/dist/assets/src--WewDM7z.js +0 -16
  95. package/dist/assets/useOpenRecordList-DsTb016S.js +0 -1
  96. package/dist/assets/useReconcileOnError-DMumPfoY.js +0 -1
  97. package/dist/assets/vendor-objectstack-Bw0HRuFa.js +0 -95
@@ -1 +1 @@
1
- import{f as e,m as t,r as n}from"./vendor-react-BGDDiZfJ.js";import{$n as r,Ar as i,Fo as a,Xi as o,ei as s,er as c,nr as l,rr as u,tr as d}from"./ui-components-rkvkkTxO.js";var f=n();function p(){let n=e(),{appName:p}=t(),m=p?`/apps/${p}`:``,h=[{title:`Integrations & APIs`,description:`Your app as a REST API — base URL, endpoints, and connect samples`,icon:o,href:`${m}/developer/integrations`},{title:`API Console`,description:`Inspect and exercise REST endpoints with auto-discovered services`,icon:s,href:`${m}/developer/api-console`},{title:`Flow Runs`,description:`Trigger flows with sample inputs and inspect recent run history`,icon:i,href:`${m}/developer/flow-runs`},{title:`Public Forms`,description:`Publish, share, and embed FormViews available to anonymous users`,icon:a,href:`${m}/developer/public-forms`}];return(0,f.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,f.jsxs)(`div`,{className:`min-w-0`,children:[(0,f.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Developer`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Tools for building, debugging, and sharing ObjectStack apps`})]}),(0,f.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:h.map(e=>{let t=e.icon;return(0,f.jsxs)(r,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>n(e.href),"data-testid":`hub-card-${e.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${e.title}: ${e.description}`,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.href))},children:[(0,f.jsxs)(l,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,f.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,f.jsx)(t,{className:`h-5 w-5`})}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(u,{className:`text-base`,children:e.title}),(0,f.jsx)(d,{className:`text-xs`,children:e.description})]})]}),(0,f.jsx)(c,{className:`pt-0`})]},e.title)})})]})}export{p as DeveloperHubPage};
1
+ import{f as e,m as t,r as n}from"./vendor-react-BGDDiZfJ.js";import{$n as r,Ar as i,Fo as a,Xi as o,ei as s,er as c,nr as l,rr as u,tr as d}from"./ui-components-BOOpjWsQ.js";var f=n();function p(){let n=e(),{appName:p}=t(),m=p?`/apps/${p}`:``,h=[{title:`Integrations & APIs`,description:`Your app as a REST API — base URL, endpoints, and connect samples`,icon:o,href:`${m}/developer/integrations`},{title:`API Console`,description:`Inspect and exercise REST endpoints with auto-discovered services`,icon:s,href:`${m}/developer/api-console`},{title:`Flow Runs`,description:`Trigger flows with sample inputs and inspect recent run history`,icon:i,href:`${m}/developer/flow-runs`},{title:`Public Forms`,description:`Publish, share, and embed FormViews available to anonymous users`,icon:a,href:`${m}/developer/public-forms`}];return(0,f.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,f.jsxs)(`div`,{className:`min-w-0`,children:[(0,f.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Developer`}),(0,f.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Tools for building, debugging, and sharing ObjectStack apps`})]}),(0,f.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:h.map(e=>{let t=e.icon;return(0,f.jsxs)(r,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>n(e.href),"data-testid":`hub-card-${e.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${e.title}: ${e.description}`,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.href))},children:[(0,f.jsxs)(l,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,f.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,f.jsx)(t,{className:`h-5 w-5`})}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(u,{className:`text-base`,children:e.title}),(0,f.jsx)(d,{className:`text-xs`,children:e.description})]})]}),(0,f.jsx)(c,{className:`pt-0`})]},e.title)})})]})}export{p as DeveloperHubPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BGDDiZfJ.js";import{$ as r,Vt as i}from"./framework-B3O15Lsq.js";var a=e(n(),1),o=t(),s=(0,a.createContext)(null);function c({children:e,user:t={},app:n={},data:c={},features:l={}}){let u=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l,evaluator:new i({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}},t={current_user:{},ctx:{user:{}},...e};return{...e,evaluator:new i(t)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BGDDiZfJ.js";import{$ as r,Vt as i}from"./framework-CBCX6Urh.js";var a=e(n(),1),o=t(),s=(0,a.createContext)(null);function c({children:e,user:t={},app:n={},data:c={},features:l={}}){let u=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l,evaluator:new i({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}},t={current_user:{},ctx:{user:{}},...e};return{...e,evaluator:new i(t)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BGDDiZfJ.js";import{L as r}from"./framework-B3O15Lsq.js";import{$n as i,Ar as a,Bt as o,Ht as s,Ps as c,Rt as l,Ss as u,Ut as d,Vi as f,Vt as p,Wt as m,Zi as h,Zt as g,_t as _,ar as v,dn as y,er as b,ft as x,gs as S,gt as C,ht as w,js as T,mt as E,nr as D,pt as O,rr as k,sn as A,st as j,tr as M,vt as N,xr as P,za as F}from"./ui-components-rkvkkTxO.js";import"./src--WewDM7z.js";var I=e(n(),1),L=t();function R({status:e}){let t={success:{icon:T,cls:`text-emerald-600 border-emerald-300`},completed:{icon:T,cls:`text-emerald-600 border-emerald-300`},failed:{icon:u,cls:`text-red-600 border-red-300`},error:{icon:u,cls:`text-red-600 border-red-300`},running:{icon:F,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:S,cls:`text-amber-600 border-amber-300`},skipped:{icon:c,cls:`text-muted-foreground`}}[e]??{icon:c,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(v,{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)([]),[o,s]=(0,I.useState)(!0),[c,u]=(0,I.useState)(null),[d,p]=(0,I.useState)(``),[m,h]=(0,I.useState)(0),g=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){u(`meta.getItems is not available on this client`),s(!1);return}s(!0),u(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),!d&&r.length>0&&p(r[0].name)}catch(e){u(e?.message??String(e))}finally{s(!1)}},[e,d]);(0,I.useEffect)(()=>{g()},[g]);let _=(0,I.useMemo)(()=>t.find(e=>e.name===d)??null,[t,d]);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)(a,{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)(i,{children:[(0,L.jsx)(D,{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)(k,{className:`text-base`,children:`Flow`}),(0,L.jsx)(M,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(P,{variant:`outline`,size:`sm`,onClick:g,disabled:o,children:[(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 ${o?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(b,{children:[o&&(0,L.jsx)(l,{className:`h-9 w-72`}),c&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:c}),!o&&!c&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!o&&!c&&t.length>0&&(0,L.jsx)(`select`,{value:d,onChange:e=>p(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))})]})]}),_&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:_.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:_.name,refreshKey:m})]})]})}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)({}),[s,c]=(0,I.useState)(!1),[l,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),d(null),p(null)},[t?.name]);let m=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(i,{children:[(0,L.jsxs)(D,{className:`pb-3`,children:[(0,L.jsx)(k,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(M,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(b,{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)(y,{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)(v,{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)(N,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>m(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)(j,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>m(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(A,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>m(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(P,{onClick:async()=>{if(!e?.automation?.execute){p(`automation.execute is not available on this client`);return}c(!0),p(null),d(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}let o=await e.automation.execute(t.name,{params:i});d(o),n?.()}catch(e){p(e?.message??String(e))}finally{c(!1)}},disabled:s,size:`sm`,children:[s?(0,L.jsx)(F,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(h,{className:`h-3.5 w-3.5 mr-2`}),s?`Running…`:`Run Flow`]})}),(l||f)&&(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:[f||l?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(u,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(T,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof l?.durationMs==`number`&&(0,L.jsxs)(v,{variant:`secondary`,className:`text-[10px] font-mono`,children:[l.durationMs,` ms`]})]}),f&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:f}),l&&(0,L.jsx)(V,{data:l})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,a]=(0,I.useState)([]),[c,u]=(0,I.useState)(!0),[h,y]=(0,I.useState)(null),[S,T]=(0,I.useState)(null),[A,j]=(0,I.useState)(null),[N,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){y(`automation.listRuns is not available on this client`),u(!1);return}u(!0),y(null);try{let n=await e.automation.listRuns(t,{limit:20}),r=Array.isArray(n)?n:n?.items??n?.runs??[];a(r)}catch(e){y(e?.message??String(e))}finally{u(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{T(n),j(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);j(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(i,{children:[(0,L.jsx)(D,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(k,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(M,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(P,{variant:`outline`,size:`sm`,onClick:W,disabled:c,children:[c?(0,L.jsx)(F,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(b,{children:[c&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(l,{className:`h-8 w-full`}),(0,L.jsx)(l,{className:`h-8 w-full`}),(0,L.jsx)(l,{className:`h-8 w-full`})]}),!c&&h&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:h}),!c&&!h&&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.`}),!c&&!h&&r.length>0&&(0,L.jsxs)(x,{children:[(0,L.jsx)(C,{children:(0,L.jsxs)(_,{children:[(0,L.jsx)(w,{children:`Run`}),(0,L.jsx)(w,{children:`Status`}),(0,L.jsx)(w,{children:`Started`}),(0,L.jsx)(w,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(O,{children:r.map(e=>(0,L.jsxs)(_,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(E,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(E,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(E,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(E,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(o,{open:!!S,onOpenChange:e=>{e||(T(null),j(null))},children:(0,L.jsxs)(p,{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)(m,{className:`font-mono text-sm break-all`,children:[`Run `,S]}),(0,L.jsx)(s,{children:A&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:A.status}),typeof A.durationMs==`number`&&(0,L.jsxs)(v,{variant:`secondary`,className:`text-[10px] font-mono`,children:[A.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(A.startedAt)})]})})]}),(0,L.jsxs)(g,{className:`flex-1 p-4`,children:[N&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(l,{className:`h-16 w-full`}),(0,L.jsx)(l,{className:`h-16 w-full`}),(0,L.jsx)(l,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!N&&A&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(A.steps)&&A.steps.length>0?A.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)(v,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(v,{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:A})]})})]})]})})]})}export{H as FlowRunsPage};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BGDDiZfJ.js";import{L as r}from"./framework-CBCX6Urh.js";import{$n as i,Ar as a,Bt as o,Ht as s,Ps as c,Rt as l,Ss as u,Ut as d,Vi as f,Vt as p,Wt as m,Zi as h,Zt as g,_t as _,ar as v,dn as y,er as b,ft as x,gs as S,gt as C,ht as w,js as T,mt as E,nr as D,pt as O,rr as k,sn as A,st as j,tr as M,vt as N,xr as P,za as F}from"./ui-components-BOOpjWsQ.js";import"./src-rXeXV_HX.js";var I=e(n(),1),L=t();function R({status:e}){let t={success:{icon:T,cls:`text-emerald-600 border-emerald-300`},completed:{icon:T,cls:`text-emerald-600 border-emerald-300`},failed:{icon:u,cls:`text-red-600 border-red-300`},error:{icon:u,cls:`text-red-600 border-red-300`},running:{icon:F,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:S,cls:`text-amber-600 border-amber-300`},skipped:{icon:c,cls:`text-muted-foreground`}}[e]??{icon:c,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(v,{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)([]),[o,s]=(0,I.useState)(!0),[c,u]=(0,I.useState)(null),[d,p]=(0,I.useState)(``),[m,h]=(0,I.useState)(0),g=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){u(`meta.getItems is not available on this client`),s(!1);return}s(!0),u(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),!d&&r.length>0&&p(r[0].name)}catch(e){u(e?.message??String(e))}finally{s(!1)}},[e,d]);(0,I.useEffect)(()=>{g()},[g]);let _=(0,I.useMemo)(()=>t.find(e=>e.name===d)??null,[t,d]);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)(a,{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)(i,{children:[(0,L.jsx)(D,{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)(k,{className:`text-base`,children:`Flow`}),(0,L.jsx)(M,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(P,{variant:`outline`,size:`sm`,onClick:g,disabled:o,children:[(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 ${o?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(b,{children:[o&&(0,L.jsx)(l,{className:`h-9 w-72`}),c&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:c}),!o&&!c&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!o&&!c&&t.length>0&&(0,L.jsx)(`select`,{value:d,onChange:e=>p(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))})]})]}),_&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:_.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:_.name,refreshKey:m})]})]})}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)({}),[s,c]=(0,I.useState)(!1),[l,d]=(0,I.useState)(null),[f,p]=(0,I.useState)(null);(0,I.useEffect)(()=>{o({}),d(null),p(null)},[t?.name]);let m=(e,t)=>o(n=>({...n,[e]:t}));return(0,L.jsxs)(i,{children:[(0,L.jsxs)(D,{className:`pb-3`,children:[(0,L.jsx)(k,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(M,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(b,{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)(y,{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)(v,{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)(N,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>m(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)(j,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>m(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(A,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>m(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(P,{onClick:async()=>{if(!e?.automation?.execute){p(`automation.execute is not available on this client`);return}c(!0),p(null),d(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}let o=await e.automation.execute(t.name,{params:i});d(o),n?.()}catch(e){p(e?.message??String(e))}finally{c(!1)}},disabled:s,size:`sm`,children:[s?(0,L.jsx)(F,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(h,{className:`h-3.5 w-3.5 mr-2`}),s?`Running…`:`Run Flow`]})}),(l||f)&&(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:[f||l?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(u,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(T,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof l?.durationMs==`number`&&(0,L.jsxs)(v,{variant:`secondary`,className:`text-[10px] font-mono`,children:[l.durationMs,` ms`]})]}),f&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:f}),l&&(0,L.jsx)(V,{data:l})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,a]=(0,I.useState)([]),[c,u]=(0,I.useState)(!0),[h,y]=(0,I.useState)(null),[S,T]=(0,I.useState)(null),[A,j]=(0,I.useState)(null),[N,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){y(`automation.listRuns is not available on this client`),u(!1);return}u(!0),y(null);try{let n=await e.automation.listRuns(t,{limit:20}),r=Array.isArray(n)?n:n?.items??n?.runs??[];a(r)}catch(e){y(e?.message??String(e))}finally{u(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{T(n),j(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);j(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(i,{children:[(0,L.jsx)(D,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(k,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(M,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(P,{variant:`outline`,size:`sm`,onClick:W,disabled:c,children:[c?(0,L.jsx)(F,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(b,{children:[c&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(l,{className:`h-8 w-full`}),(0,L.jsx)(l,{className:`h-8 w-full`}),(0,L.jsx)(l,{className:`h-8 w-full`})]}),!c&&h&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:h}),!c&&!h&&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.`}),!c&&!h&&r.length>0&&(0,L.jsxs)(x,{children:[(0,L.jsx)(C,{children:(0,L.jsxs)(_,{children:[(0,L.jsx)(w,{children:`Run`}),(0,L.jsx)(w,{children:`Status`}),(0,L.jsx)(w,{children:`Started`}),(0,L.jsx)(w,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(O,{children:r.map(e=>(0,L.jsxs)(_,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(E,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(E,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(E,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(E,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(o,{open:!!S,onOpenChange:e=>{e||(T(null),j(null))},children:(0,L.jsxs)(p,{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)(m,{className:`font-mono text-sm break-all`,children:[`Run `,S]}),(0,L.jsx)(s,{children:A&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:A.status}),typeof A.durationMs==`number`&&(0,L.jsxs)(v,{variant:`secondary`,className:`text-[10px] font-mono`,children:[A.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(A.startedAt)})]})})]}),(0,L.jsxs)(g,{className:`flex-1 p-4`,children:[N&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(l,{className:`h-16 w-full`}),(0,L.jsx)(l,{className:`h-16 w-full`}),(0,L.jsx)(l,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!N&&A&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(A.steps)&&A.steps.length>0?A.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)(v,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(v,{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:A})]})})]})]})})]})}export{H as FlowRunsPage};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,m as n,r,y as i}from"./vendor-react-BGDDiZfJ.js";import{$n as a,Ci as o,Gn as s,Jn as c,Kn as l,Qo as u,Un as d,Us as f,Wn as p,Xi as m,ar as h,cc as g,cs as _,dr as v,ei as y,er as b,lr as x,nr as S,ns as C,qn as w,rr as T,sn as E,to as D,tr as O,ur as k,xr as A}from"./ui-components-rkvkkTxO.js";var j=e(i(),1),M=`objectstack`,N=`Query and modify data in an ObjectStack app over MCP — discover objects, read and filter records, and create/update/delete under your own permissions and row-level security. Use when the user wants to inspect or change data in their ObjectStack environment.`,P=`<YOUR_ENV_MCP_URL>`;function F(e={}){let t=e.mcpUrl?.trim()||P,n=e.envName?.trim();return`---
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,m as n,r,y as i}from"./vendor-react-BGDDiZfJ.js";import{$n as a,Ci as o,Gn as s,Jn as c,Kn as l,Qo as u,Un as d,Us as f,Wn as p,Xi as m,ar as h,cc as g,cs as _,dr as v,ei as y,er as b,lr as x,nr as S,ns as C,qn as w,rr as T,sn as E,to as D,tr as O,ur as k,xr as A}from"./ui-components-BOOpjWsQ.js";var j=e(i(),1),M=`objectstack`,N=`Query and modify data in an ObjectStack app over MCP — discover objects, read and filter records, and create/update/delete under your own permissions and row-level security. Use when the user wants to inspect or change data in their ObjectStack environment.`,P=`<YOUR_ENV_MCP_URL>`;function F(e={}){let t=e.mcpUrl?.trim()||P,n=e.envName?.trim();return`---
2
2
  name: ${M}
3
3
  description: ${N}
4
4
  ---
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,r,y as i}from"./vendor-react-BGDDiZfJ.js";import{L as a,R as o,Y as s,l as c,q as l}from"./framework-B3O15Lsq.js";import{G as u,J as d,V as f,W as p,ns as m}from"./ui-components-rkvkkTxO.js";import"./MetadataProvider-Cm9vi7AZ.js";import{t as h}from"./RecordDetailView-CzR6BAUv.js";import{l as g}from"./plugins-views-CibWNUsP.js";var _=e(i(),1),v=`uf_`;function y(e){let t={};return e.forEach((e,n)=>{if(n.startsWith(v)&&e!==``){let r=n.slice(3);t[r]=e.split(`,`).map(e=>{try{return decodeURIComponent(e)}catch{return e}})}}),Object.keys(t).length>0?t:void 0}function b(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t)){let t=v+e;r&&r.length>0?n.set(t,r.map(e=>encodeURIComponent(String(e))).join(`,`)):n.delete(t)}return n}var x=r();function S(e){return Array.isArray(e?.columns)&&e.columns.length>0}function C(e,t){let n=e?.listViews||e?.list_views||{},r=(t?[n[`${e?.name}.${t}`],n[t],...t==="default"||t===`list`?[e?.list]:[]]:[e?.list,...Object.values(n)]).filter(Boolean);return r.find(S)??r[0]}var w=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]);function T(e){let t=e?.highlightFields;if(Array.isArray(t)&&t.length>0)return t.filter(t=>e.fields?.[t]);let n=e?.fields;return n&&typeof n==`object`?Object.entries(n).filter(([e,t])=>t&&!t.hidden&&!w.has(e)).map(([e])=>e).slice(0,6):[]}function E(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!w.has(e)&&t(e,n))?.[0]}var D=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),O=new Set([`date`,`datetime`,`time`]),k=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function A(e){let t=E(e,(e,t)=>D.has(t.type))??E(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function j(e){return E(e,(e,t)=>O.has(t.type))??E(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function M(e){let t=j(e);return t?{startDateField:t}:void 0}function N(e){let t=E(e,(e,t)=>k.has(t.type));return t?{coverField:t}:void 0}var P=new Set([`location`,`geo`,`geolocation`,`geopoint`,`point`]);function F(e){let t=E(e,(e,t)=>O.has(t.type)&&/start|begin|kickoff/i.test(e))??E(e,(e,t)=>O.has(t.type));if(!t)return;let n=E(e,(e,n)=>O.has(n.type)&&e!==t&&/end|due|finish|deadline|close/i.test(e))??E(e,(e,n)=>O.has(n.type)&&e!==t);if(!n)return;let r=E(e,(e,t)=>(t.type===`number`||t.type===`percent`)&&/progress|percent|complete/i.test(e));return{startDateField:t,endDateField:n,...r?{progressField:r}:{}}}function I(e){let t=E(e,(e,t)=>P.has(t.type))??E(e,e=>/location|address|geo|coords?|place|venue/i.test(e));return t?{locationField:t}:void 0}function L({page:e,className:r,onConfigChange:i,reserveEditAffordance:v}){let{t:w}=c(),{objects:E}=o(),D=a(),O=t(),[k,j]=n(),[P]=_.useState(()=>y(new URLSearchParams(window.location.search))),L=_.useCallback(e=>{j(t=>b(t,e),{replace:!0})},[j]),R=e?.interfaceConfig||{},z=_.useMemo(()=>(E||[]).find(e=>e.name===R.source),[E,R.source]),B=_.useMemo(()=>C(z,R.sourceView),[z,R.sourceView]),V=R.recordAction===`page`||R.recordAction===`modal`||R.recordAction===`none`?R.recordAction:`drawer`,H=_.useCallback(e=>`/apps/${window.location.pathname.split(`/`)[2]||``}/${R.source}/record/${encodeURIComponent(String(e))}`,[R.source]),U=l({navigation:{mode:V===`none`?`none`:V},objectName:R.source,onNavigate:e=>O(H(e))}),W=k.get(`recordId`),G=_.useCallback((e,t)=>{if(V===`none`)return;let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(H(n),`_blank`);return}if((V===`drawer`||V===`modal`)&&n!=null){j(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t});return}U.handleClick(e,t)},[V,H,U,j]),ee=_.useCallback(()=>{j(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[j]);_.useEffect(()=>{W&&!U.isOpen?U.open({id:W}):!W&&U.isOpen&&U.close()},[W]);let K=z?.name,q=!!B&&!S(B),J=B?.name??(R.sourceView?`${R.source}.${R.sourceView}`:void 0),[Y,X]=_.useState(null);_.useEffect(()=>{let e=!1;if(X(null),!(!K||!R.source||!q||!J))return(async()=>{try{let t=D,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(R.source))?.[J]??null),!S(n)&&typeof t?.getView==`function`&&(n=await t.getView(R.source,J)),!e&&n&&typeof n==`object`&&X(n)}catch{}})(),()=>{e=!0}},[K,R.source,R.sourceView,q,J,D]);let Z=_.useMemo(()=>Y?{...B,...Y}:B,[B,Y]),te=JSON.stringify(Z??null),Q=_.useMemo(()=>{if(!z)return;let e=Z||{},t=R.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=R.userActions||{},a=e.kanban??(r.has(`kanban`)?A(z):void 0),o=e.calendar??(r.has(`calendar`)?M(z):void 0),s=e.timeline??(r.has(`timeline`)?M(z):void 0),c=e.gallery??(r.has(`gallery`)?N(z):void 0),l=e.gantt??(r.has(`gantt`)?F(z):void 0),u=e.options?.map??(r.has(`map`)?I(z):void 0),d=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(R.filterBy)?R.filterBy:[]],f=S(R)?R.columns:S(e)?e.columns:T(z),p=Array.isArray(R.sort)&&R.sort.length?R.sort:e.sort;return{type:`list-view`,objectName:z.name,viewType:n[0]??e.type??`grid`,fields:f,...d.length?{filters:d}:{},...p?.length?{sort:p}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:l,...u||e.options?{options:{...e.options??{},...u?{map:u}:{}}}:{},userFilters:R.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:R.showRecordCount,addRecord:R.addRecord,showSearch:i.search!==!1,showSort:i.sort!==!1,showFilters:i.filter===!0,showDensity:i.rowHeight===!0,showHideFields:!1,showGroup:!1,showColor:!1,allowExport:!1,inlineEdit:i.editInline===!0}},[K,te,R]);if(!z||!Q)return(0,x.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,x.jsxs)(p,{children:[(0,x.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,x.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,x.jsx)(d,{children:w(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,x.jsx)(u,{children:w(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:R.source||`?`})})]})});let $=Array.isArray(R.buttons)&&R.buttons.length?R.buttons.map(e=>(z.actions||[]).find(t=>t?.name===e)).filter(Boolean).map(e=>({...e,locations:[`list_toolbar`]})):[];return(0,x.jsxs)(`div`,{className:r??`h-full flex flex-col`,"data-testid":`interface-list-page`,children:[(0,x.jsxs)(`div`,{className:`pl-4 pt-4 pb-2 shrink-0 flex items-start justify-between gap-3 ${v?`pr-12`:`pr-4`}`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h1`,{className:`text-lg font-semibold leading-tight`,children:typeof e.label==`string`?e.label:e.name}),typeof e.description==`string`&&e.description&&(0,x.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:e.description})]}),$.length>0&&(0,x.jsx)(`div`,{className:`shrink-0`,"data-testid":`interface-page-buttons`,children:(0,x.jsx)(s,{schema:{type:`action:bar`,location:`list_toolbar`,actions:$,size:`sm`,variant:`outline`}})})]}),(0,x.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,x.jsx)(g,{schema:Q,dataSource:D,userFilterSelections:P,onUserFilterSelectionsChange:L,onSortChange:i?e=>i({sort:e}):void 0,onColumnStateChange:i?e=>{e?.order?.length&&i({columns:e.order})}:void 0,onRowClick:V===`none`?void 0:G})}),U.isOverlay&&(0,x.jsx)(f,{...U,setIsOpen:e=>{e||ee()},title:typeof e.label==`string`?e.label:R.source||`Record`,children:e=>(0,x.jsx)(h,{objectNameOverride:R.source,recordIdOverride:String(e?.id??e?._id??W??``),embedded:!0,dataSource:D,objects:E,onEdit:()=>{}})})]})}export{A as a,N as i,M as n,b as o,T as r,y as s,L as t};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,r,y as i}from"./vendor-react-BGDDiZfJ.js";import{L as a,R as o,Y as s,l as c,q as l}from"./framework-CBCX6Urh.js";import{G as u,J as d,V as f,W as p,ns as m}from"./ui-components-BOOpjWsQ.js";import"./MetadataProvider-seOmvY8N.js";import{t as h}from"./RecordDetailView-CUcCVoa1.js";import{l as g}from"./plugins-views-BVxwkRdi.js";var _=e(i(),1),v=`uf_`;function y(e){let t={};return e.forEach((e,n)=>{if(n.startsWith(v)&&e!==``){let r=n.slice(3);t[r]=e.split(`,`).map(e=>{try{return decodeURIComponent(e)}catch{return e}})}}),Object.keys(t).length>0?t:void 0}function b(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t)){let t=v+e;r&&r.length>0?n.set(t,r.map(e=>encodeURIComponent(String(e))).join(`,`)):n.delete(t)}return n}var x=r();function S(e){return Array.isArray(e?.columns)&&e.columns.length>0}function C(e,t){let n=e?.listViews||e?.list_views||{},r=(t?[n[`${e?.name}.${t}`],n[t],...t==="default"||t===`list`?[e?.list]:[]]:[e?.list,...Object.values(n)]).filter(Boolean);return r.find(S)??r[0]}var w=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]);function T(e){let t=e?.highlightFields;if(Array.isArray(t)&&t.length>0)return t.filter(t=>e.fields?.[t]);let n=e?.fields;return n&&typeof n==`object`?Object.entries(n).filter(([e,t])=>t&&!t.hidden&&!w.has(e)).map(([e])=>e).slice(0,6):[]}function E(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!w.has(e)&&t(e,n))?.[0]}var D=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),O=new Set([`date`,`datetime`,`time`]),k=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function A(e){let t=E(e,(e,t)=>D.has(t.type))??E(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function j(e){return E(e,(e,t)=>O.has(t.type))??E(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function M(e){let t=j(e);return t?{startDateField:t}:void 0}function N(e){let t=E(e,(e,t)=>k.has(t.type));return t?{coverField:t}:void 0}var P=new Set([`location`,`geo`,`geolocation`,`geopoint`,`point`]);function F(e){let t=E(e,(e,t)=>O.has(t.type)&&/start|begin|kickoff/i.test(e))??E(e,(e,t)=>O.has(t.type));if(!t)return;let n=E(e,(e,n)=>O.has(n.type)&&e!==t&&/end|due|finish|deadline|close/i.test(e))??E(e,(e,n)=>O.has(n.type)&&e!==t);if(!n)return;let r=E(e,(e,t)=>(t.type===`number`||t.type===`percent`)&&/progress|percent|complete/i.test(e));return{startDateField:t,endDateField:n,...r?{progressField:r}:{}}}function I(e){let t=E(e,(e,t)=>P.has(t.type))??E(e,e=>/location|address|geo|coords?|place|venue/i.test(e));return t?{locationField:t}:void 0}function L({page:e,className:r,onConfigChange:i,reserveEditAffordance:v}){let{t:w}=c(),{objects:E}=o(),D=a(),O=t(),[k,j]=n(),[P]=_.useState(()=>y(new URLSearchParams(window.location.search))),L=_.useCallback(e=>{j(t=>b(t,e),{replace:!0})},[j]),R=e?.interfaceConfig||{},z=_.useMemo(()=>(E||[]).find(e=>e.name===R.source),[E,R.source]),B=_.useMemo(()=>C(z,R.sourceView),[z,R.sourceView]),V=R.recordAction===`page`||R.recordAction===`modal`||R.recordAction===`none`?R.recordAction:`drawer`,H=_.useCallback(e=>`/apps/${window.location.pathname.split(`/`)[2]||``}/${R.source}/record/${encodeURIComponent(String(e))}`,[R.source]),U=l({navigation:{mode:V===`none`?`none`:V},objectName:R.source,onNavigate:e=>O(H(e))}),W=k.get(`recordId`),G=_.useCallback((e,t)=>{if(V===`none`)return;let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(H(n),`_blank`);return}if((V===`drawer`||V===`modal`)&&n!=null){j(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t});return}U.handleClick(e,t)},[V,H,U,j]),ee=_.useCallback(()=>{j(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[j]);_.useEffect(()=>{W&&!U.isOpen?U.open({id:W}):!W&&U.isOpen&&U.close()},[W]);let K=z?.name,q=!!B&&!S(B),J=B?.name??(R.sourceView?`${R.source}.${R.sourceView}`:void 0),[Y,X]=_.useState(null);_.useEffect(()=>{let e=!1;if(X(null),!(!K||!R.source||!q||!J))return(async()=>{try{let t=D,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(R.source))?.[J]??null),!S(n)&&typeof t?.getView==`function`&&(n=await t.getView(R.source,J)),!e&&n&&typeof n==`object`&&X(n)}catch{}})(),()=>{e=!0}},[K,R.source,R.sourceView,q,J,D]);let Z=_.useMemo(()=>Y?{...B,...Y}:B,[B,Y]),te=JSON.stringify(Z??null),Q=_.useMemo(()=>{if(!z)return;let e=Z||{},t=R.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=R.userActions||{},a=e.kanban??(r.has(`kanban`)?A(z):void 0),o=e.calendar??(r.has(`calendar`)?M(z):void 0),s=e.timeline??(r.has(`timeline`)?M(z):void 0),c=e.gallery??(r.has(`gallery`)?N(z):void 0),l=e.gantt??(r.has(`gantt`)?F(z):void 0),u=e.options?.map??(r.has(`map`)?I(z):void 0),d=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(R.filterBy)?R.filterBy:[]],f=S(R)?R.columns:S(e)?e.columns:T(z),p=Array.isArray(R.sort)&&R.sort.length?R.sort:e.sort;return{type:`list-view`,objectName:z.name,viewType:n[0]??e.type??`grid`,fields:f,...d.length?{filters:d}:{},...p?.length?{sort:p}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:l,...u||e.options?{options:{...e.options??{},...u?{map:u}:{}}}:{},userFilters:R.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:R.showRecordCount,addRecord:R.addRecord,showSearch:i.search!==!1,showSort:i.sort!==!1,showFilters:i.filter===!0,showDensity:i.rowHeight===!0,showHideFields:!1,showGroup:!1,showColor:!1,allowExport:!1,inlineEdit:i.editInline===!0}},[K,te,R]);if(!z||!Q)return(0,x.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,x.jsxs)(p,{children:[(0,x.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,x.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,x.jsx)(d,{children:w(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,x.jsx)(u,{children:w(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:R.source||`?`})})]})});let $=Array.isArray(R.buttons)&&R.buttons.length?R.buttons.map(e=>(z.actions||[]).find(t=>t?.name===e)).filter(Boolean).map(e=>({...e,locations:[`list_toolbar`]})):[];return(0,x.jsxs)(`div`,{className:r??`h-full flex flex-col`,"data-testid":`interface-list-page`,children:[(0,x.jsxs)(`div`,{className:`pl-4 pt-4 pb-2 shrink-0 flex items-start justify-between gap-3 ${v?`pr-12`:`pr-4`}`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h1`,{className:`text-lg font-semibold leading-tight`,children:typeof e.label==`string`?e.label:e.name}),typeof e.description==`string`&&e.description&&(0,x.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:e.description})]}),$.length>0&&(0,x.jsx)(`div`,{className:`shrink-0`,"data-testid":`interface-page-buttons`,children:(0,x.jsx)(s,{schema:{type:`action:bar`,location:`list_toolbar`,actions:$,size:`sm`,variant:`outline`}})})]}),(0,x.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:(0,x.jsx)(g,{schema:Q,dataSource:D,userFilterSelections:P,onUserFilterSelectionsChange:L,onSortChange:i?e=>i({sort:e}):void 0,onColumnStateChange:i?e=>{e?.order?.length&&i({columns:e.order})}:void 0,onRowClick:V===`none`?void 0:G})}),U.isOverlay&&(0,x.jsx)(f,{...U,setIsOpen:e=>{e||ee()},title:typeof e.label==`string`?e.label:R.source||`Record`,children:e=>(0,x.jsx)(h,{objectNameOverride:R.source,recordIdOverride:String(e?.id??e?._id??W??``),embedded:!0,dataSource:D,objects:E,onEdit:()=>{}})})]})}export{A as a,N as i,M as n,b as o,T as r,y as s,L as t};
@@ -1 +1 @@
1
- import{r as e}from"./vendor-react-BGDDiZfJ.js";import{Ci as t,Ei as n,Ft as r,It as i,Lt as a,Pt as o,Ra as s,Tc as c,ar as l,kc as u}from"./ui-components-rkvkkTxO.js";var d=e(),f={config:{icon:n,short:`Admin config`,title:`Administrator configuration`,body:()=>`These rows define how the platform behaves at runtime. Author them here; the runtime data they produce lives in a separate table.`,tone:`border-sky-300/60 bg-sky-50 text-sky-900 hover:bg-sky-100 dark:border-sky-500/40 dark:bg-sky-950/40 dark:text-sky-100`},system:{icon:s,short:`System-managed`,title:`Managed by the platform`,body:()=>`Rows here are created automatically when actions run on the source record. The list below is a read-only monitoring surface — row-level actions (Approve, Recall, Resend, …) live on each row.`,tone:`border-slate-300/60 bg-slate-50 text-slate-900 hover:bg-slate-100 dark:border-slate-500/40 dark:bg-slate-950/40 dark:text-slate-100`},"append-only":{icon:c,short:`Read-only · Audit log`,title:`Read-only historical record`,body:()=>`Immutable audit log. Rows cannot be created, edited, or deleted from the UI — they're written by the platform when events occur. Use Export to download for compliance review.`,tone:`border-zinc-300/60 bg-zinc-50 text-zinc-900 hover:bg-zinc-100 dark:border-zinc-500/40 dark:bg-zinc-950/40 dark:text-zinc-100`},"better-auth":{icon:t,short:`Identity`,title:`Managed by the identity provider`,body:e=>`This object's schema is owned by ${e}. Direct edits bypass password hashing, session validation, two-factor checks, and audit hooks. Manage these records through your authentication provider's sign-in, invitation, and security flows instead.`,tone:`border-amber-300/60 bg-amber-50 text-amber-900 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`}};function p({managedBy:e,label:t,className:n}){if(!e||e===`platform`)return null;let s=f[e];if(!s)return null;let c=s.icon,p=t??`better-auth`;return(0,d.jsx)(i,{delayDuration:200,children:(0,d.jsxs)(o,{children:[(0,d.jsx)(a,{asChild:!0,children:(0,d.jsxs)(l,{variant:`outline`,"data-testid":`managed-by-badge`,"data-bucket":e,className:u(`gap-1 font-normal text-[11px] leading-none py-0.5 px-1.5 cursor-help`,s.tone,n),children:[(0,d.jsx)(c,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{children:s.short})]})}),(0,d.jsxs)(r,{side:`bottom`,align:`start`,className:`max-w-xs text-xs leading-relaxed`,children:[(0,d.jsx)(`p`,{className:`font-semibold mb-1`,children:s.title}),(0,d.jsx)(`p`,{className:`text-muted-foreground`,children:s.body(p)})]})]})})}export{p as t};
1
+ import{r as e}from"./vendor-react-BGDDiZfJ.js";import{Ci as t,Ei as n,Ft as r,It as i,Lt as a,Pt as o,Ra as s,Tc as c,ar as l,kc as u}from"./ui-components-BOOpjWsQ.js";var d=e(),f={config:{icon:n,short:`Admin config`,title:`Administrator configuration`,body:()=>`These rows define how the platform behaves at runtime. Author them here; the runtime data they produce lives in a separate table.`,tone:`border-sky-300/60 bg-sky-50 text-sky-900 hover:bg-sky-100 dark:border-sky-500/40 dark:bg-sky-950/40 dark:text-sky-100`},system:{icon:s,short:`System-managed`,title:`Managed by the platform`,body:()=>`Rows here are created automatically when actions run on the source record. The list below is a read-only monitoring surface — row-level actions (Approve, Recall, Resend, …) live on each row.`,tone:`border-slate-300/60 bg-slate-50 text-slate-900 hover:bg-slate-100 dark:border-slate-500/40 dark:bg-slate-950/40 dark:text-slate-100`},"append-only":{icon:c,short:`Read-only · Audit log`,title:`Read-only historical record`,body:()=>`Immutable audit log. Rows cannot be created, edited, or deleted from the UI — they're written by the platform when events occur. Use Export to download for compliance review.`,tone:`border-zinc-300/60 bg-zinc-50 text-zinc-900 hover:bg-zinc-100 dark:border-zinc-500/40 dark:bg-zinc-950/40 dark:text-zinc-100`},"better-auth":{icon:t,short:`Identity`,title:`Managed by the identity provider`,body:e=>`This object's schema is owned by ${e}. Direct edits bypass password hashing, session validation, two-factor checks, and audit hooks. Manage these records through your authentication provider's sign-in, invitation, and security flows instead.`,tone:`border-amber-300/60 bg-amber-50 text-amber-900 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`}};function p({managedBy:e,label:t,className:n}){if(!e||e===`platform`)return null;let s=f[e];if(!s)return null;let c=s.icon,p=t??`better-auth`;return(0,d.jsx)(i,{delayDuration:200,children:(0,d.jsxs)(o,{children:[(0,d.jsx)(a,{asChild:!0,children:(0,d.jsxs)(l,{variant:`outline`,"data-testid":`managed-by-badge`,"data-bucket":e,className:u(`gap-1 font-normal text-[11px] leading-none py-0.5 px-1.5 cursor-help`,s.tone,n),children:[(0,d.jsx)(c,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{children:s.short})]})}),(0,d.jsxs)(r,{side:`bottom`,align:`start`,className:`max-w-xs text-xs leading-relaxed`,children:[(0,d.jsx)(`p`,{className:`font-semibold mb-1`,children:s.title}),(0,d.jsx)(`p`,{className:`text-muted-foreground`,children:s.body(p)})]})]})})}export{p as t};
@@ -1 +1 @@
1
- import{f as e,m as t,r as n}from"./vendor-react-BGDDiZfJ.js";import{l as r}from"./framework-B3O15Lsq.js";import{$n as i,Ra as a,er as o,xr as s}from"./ui-components-rkvkkTxO.js";var c=n();function l(){let n=e(),{appName:l}=t(),{t:u}=r(),d=l?`/apps/${l}`:`/`;return(0,c.jsx)(`div`,{className:`container mx-auto max-w-2xl px-6 py-16`,children:(0,c.jsx)(i,{children:(0,c.jsxs)(o,{className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,c.jsx)(`div`,{className:`rounded-full bg-muted p-3`,children:(0,c.jsx)(a,{className:`h-6 w-6 text-muted-foreground`})}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`h2`,{className:`text-lg font-semibold`,children:u(`marketplace.accessDenied.title`)}),(0,c.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:u(`marketplace.accessDenied.description`)})]}),(0,c.jsx)(s,{variant:`outline`,onClick:()=>n(d),children:u(`marketplace.action.backHome`)})]})})})}export{l as t};
1
+ import{f as e,m as t,r as n}from"./vendor-react-BGDDiZfJ.js";import{l as r}from"./framework-CBCX6Urh.js";import{$n as i,Ra as a,er as o,xr as s}from"./ui-components-BOOpjWsQ.js";var c=n();function l(){let n=e(),{appName:l}=t(),{t:u}=r(),d=l?`/apps/${l}`:`/`;return(0,c.jsx)(`div`,{className:`container mx-auto max-w-2xl px-6 py-16`,children:(0,c.jsx)(i,{children:(0,c.jsxs)(o,{className:`flex flex-col items-center gap-4 py-12 text-center`,children:[(0,c.jsx)(`div`,{className:`rounded-full bg-muted p-3`,children:(0,c.jsx)(a,{className:`h-6 w-6 text-muted-foreground`})}),(0,c.jsxs)(`div`,{children:[(0,c.jsx)(`h2`,{className:`text-lg font-semibold`,children:u(`marketplace.accessDenied.title`)}),(0,c.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:u(`marketplace.accessDenied.description`)})]}),(0,c.jsx)(s,{variant:`outline`,onClick:()=>n(d),children:u(`marketplace.action.backHome`)})]})})})}export{l as t};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BGDDiZfJ.js";import{d as o}from"./infrastructure-Bcx6-8du.js";import{Kt as s,l as c}from"./framework-B3O15Lsq.js";import{$n as l,Cc as u,Hi as d,Jo as f,Ps as p,Rt as m,ar as h,er as g,nr as _,oi as v,qr as y,rr as b,xr as x}from"./ui-components-rkvkkTxO.js";import{_ as S,l as C,u as w}from"./marketplaceApi-zYQofLEk.js";import{t as T}from"./MarketplaceAccessDenied-CAuxNcMw.js";var E=e(a(),1),D=i();function O(){let e=n(),{appName:t}=r(),i=o(),{t:a,language:s}=c(),u=t?`/apps/${t}`:``,[v,O]=(0,E.useState)([]),[k,A]=(0,E.useState)(`local`),[j,M]=(0,E.useState)(!0),[N,P]=(0,E.useState)(null),[F,I]=(0,E.useState)(null),L=async()=>{M(!0);try{let e=await C();e.connected?(A(`cloud`),O(e.items)):(A(`local`),O(await w()))}finally{M(!1)}};(0,E.useEffect)(()=>{L()},[]);let R=async e=>{if(confirm(a(`marketplace.uninstall.confirm`,{manifestId:e.manifestId,version:e.version}))){P(e.manifestId),I(null);try{await S(e.manifestId),I({ok:!0,message:a(`marketplace.uninstall.successInList`,{manifestId:e.manifestId})}),await L()}catch(e){I({ok:!1,message:e?.message??String(e)})}finally{P(null)}}};return i?(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(x,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:j,children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.refresh`)]})}),F&&(0,D.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${F.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(p,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{children:F.message})]})}),j&&v.length===0?(0,D.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(m,{className:`h-20 w-full`},t))}):v.length===0?(0,D.jsxs)(`div`,{className:`text-center py-12 text-sm text-muted-foreground border rounded-md`,children:[(0,D.jsx)(`p`,{children:a(`marketplace.installedEmpty`)}),(0,D.jsx)(x,{variant:`link`,className:`mt-2`,onClick:()=>e(`${u}/system/marketplace`),children:a(`marketplace.browseLink`)})]}):(0,D.jsx)(`div`,{className:`grid gap-3`,children:v.map(t=>(0,D.jsxs)(l,{children:[(0,D.jsxs)(_,{className:`flex flex-row items-start justify-between gap-3 pb-2`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsxs)(b,{className:`text-base truncate flex items-center gap-2`,children:[t.manifestId,(0,D.jsx)(h,{variant:`outline`,children:a(`marketplace.versionBadge`,{version:t.version})})]}),(0,D.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap gap-x-3 gap-y-1`,children:[(0,D.jsx)(`span`,{children:a(`marketplace.installedAt`,{when:new Date(t.installedAt).toLocaleString(s||void 0)})}),t.installedBy&&(0,D.jsx)(`span`,{children:a(`marketplace.installedBy`,{user:t.installedBy})}),(0,D.jsxs)(`span`,{children:[a(`marketplace.installedPackageId`),` `,(0,D.jsx)(`code`,{className:`font-mono`,children:t.packageId})]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,D.jsxs)(x,{variant:`ghost`,size:`sm`,onClick:()=>e(`${u}/system/marketplace/${t.packageId}`),children:[(0,D.jsx)(f,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.action.details`)]}),k===`local`&&(0,D.jsxs)(x,{variant:`outline`,size:`sm`,onClick:()=>void R(t),disabled:N===t.manifestId,children:[(0,D.jsx)(y,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),N===t.manifestId?a(`marketplace.action.uninstalling`):a(`marketplace.action.uninstall`)]})]})]}),k===`local`&&(0,D.jsx)(g,{className:`pt-0 text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:a(`marketplace.cachedAs`,{path:`.objectstack/installed-packages/${t.manifestId.replace(/[^a-zA-Z0-9._-]/g,`_`)}.json`})}})]},t.manifestId))}),(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground border-t pt-4`,dangerouslySetInnerHTML:{__html:a(`marketplace.installedAdditiveNote`)}})]}):(0,D.jsx)(T,{})}s.register(`marketplace:installed-list`,()=>(0,D.jsx)(O,{}),{namespace:`app-shell`,label:`Installed Marketplace Packages`,category:`plugin`,inputs:[]});var k=t({MarketplaceInstalledPage:()=>A});function A(){let e=n(),{appName:t}=r(),{t:i}=c(),a=t?`/apps/${t}`:``;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6 max-w-5xl`,children:[(0,D.jsxs)(x,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>e(`${a}/system/marketplace`),children:[(0,D.jsx)(u,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.back`)]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(v,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.installedTitle`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,dangerouslySetInnerHTML:{__html:i(`marketplace.installedSubtitle`)}})]}),(0,D.jsx)(O,{})]})}export{k as t};
1
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BGDDiZfJ.js";import{d as o}from"./infrastructure-ASGyCRMg.js";import{Kt as s,l as c}from"./framework-CBCX6Urh.js";import{$n as l,Cc as u,Hi as d,Jo as f,Ps as p,Rt as m,ar as h,er as g,nr as _,oi as v,qr as y,rr as b,xr as x}from"./ui-components-BOOpjWsQ.js";import{_ as S,l as C,u as w}from"./marketplaceApi-N63OOXW-.js";import{t as T}from"./MarketplaceAccessDenied-Bl4faFLm.js";var E=e(a(),1),D=i();function O(){let e=n(),{appName:t}=r(),i=o(),{t:a,language:s}=c(),u=t?`/apps/${t}`:``,[v,O]=(0,E.useState)([]),[k,A]=(0,E.useState)(`local`),[j,M]=(0,E.useState)(!0),[N,P]=(0,E.useState)(null),[F,I]=(0,E.useState)(null),L=async()=>{M(!0);try{let e=await C();e.connected?(A(`cloud`),O(e.items)):(A(`local`),O(await w()))}finally{M(!1)}};(0,E.useEffect)(()=>{L()},[]);let R=async e=>{if(confirm(a(`marketplace.uninstall.confirm`,{manifestId:e.manifestId,version:e.version}))){P(e.manifestId),I(null);try{await S(e.manifestId),I({ok:!0,message:a(`marketplace.uninstall.successInList`,{manifestId:e.manifestId})}),await L()}catch(e){I({ok:!1,message:e?.message??String(e)})}finally{P(null)}}};return i?(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(x,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:j,children:[(0,D.jsx)(d,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.refresh`)]})}),F&&(0,D.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${F.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:(0,D.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,D.jsx)(p,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{children:F.message})]})}),j&&v.length===0?(0,D.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(m,{className:`h-20 w-full`},t))}):v.length===0?(0,D.jsxs)(`div`,{className:`text-center py-12 text-sm text-muted-foreground border rounded-md`,children:[(0,D.jsx)(`p`,{children:a(`marketplace.installedEmpty`)}),(0,D.jsx)(x,{variant:`link`,className:`mt-2`,onClick:()=>e(`${u}/system/marketplace`),children:a(`marketplace.browseLink`)})]}):(0,D.jsx)(`div`,{className:`grid gap-3`,children:v.map(t=>(0,D.jsxs)(l,{children:[(0,D.jsxs)(_,{className:`flex flex-row items-start justify-between gap-3 pb-2`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsxs)(b,{className:`text-base truncate flex items-center gap-2`,children:[t.manifestId,(0,D.jsx)(h,{variant:`outline`,children:a(`marketplace.versionBadge`,{version:t.version})})]}),(0,D.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap gap-x-3 gap-y-1`,children:[(0,D.jsx)(`span`,{children:a(`marketplace.installedAt`,{when:new Date(t.installedAt).toLocaleString(s||void 0)})}),t.installedBy&&(0,D.jsx)(`span`,{children:a(`marketplace.installedBy`,{user:t.installedBy})}),(0,D.jsxs)(`span`,{children:[a(`marketplace.installedPackageId`),` `,(0,D.jsx)(`code`,{className:`font-mono`,children:t.packageId})]})]})]}),(0,D.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,D.jsxs)(x,{variant:`ghost`,size:`sm`,onClick:()=>e(`${u}/system/marketplace/${t.packageId}`),children:[(0,D.jsx)(f,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.action.details`)]}),k===`local`&&(0,D.jsxs)(x,{variant:`outline`,size:`sm`,onClick:()=>void R(t),disabled:N===t.manifestId,children:[(0,D.jsx)(y,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),N===t.manifestId?a(`marketplace.action.uninstalling`):a(`marketplace.action.uninstall`)]})]})]}),k===`local`&&(0,D.jsx)(g,{className:`pt-0 text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:a(`marketplace.cachedAs`,{path:`.objectstack/installed-packages/${t.manifestId.replace(/[^a-zA-Z0-9._-]/g,`_`)}.json`})}})]},t.manifestId))}),(0,D.jsx)(`p`,{className:`text-xs text-muted-foreground border-t pt-4`,dangerouslySetInnerHTML:{__html:a(`marketplace.installedAdditiveNote`)}})]}):(0,D.jsx)(T,{})}s.register(`marketplace:installed-list`,()=>(0,D.jsx)(O,{}),{namespace:`app-shell`,label:`Installed Marketplace Packages`,category:`plugin`,inputs:[]});var k=t({MarketplaceInstalledPage:()=>A});function A(){let e=n(),{appName:t}=r(),{t:i}=c(),a=t?`/apps/${t}`:``;return(0,D.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6 max-w-5xl`,children:[(0,D.jsxs)(x,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>e(`${a}/system/marketplace`),children:[(0,D.jsx)(u,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.back`)]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(v,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,D.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.installedTitle`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,dangerouslySetInnerHTML:{__html:i(`marketplace.installedSubtitle`)}})]}),(0,D.jsx)(O,{})]})}export{k as t};
@@ -1,4 +1,4 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BGDDiZfJ.js";import{d as ee}from"./infrastructure-Bcx6-8du.js";import{R as te,l as ne}from"./framework-B3O15Lsq.js";import{$n as re,Cc as ie,Ci as o,Do as ae,Gn as oe,Jn as se,Jo as ce,Jt as le,Kn as ue,Kt as de,Mr as s,Ns as fe,Ps as c,Qn as l,Qo as pe,Rt as u,Si as d,Un as me,Wn as he,Xt as ge,Yo as _e,Yt as ve,ar as f,dn as p,ds as m,er as ye,fn as be,ga as xe,hn as h,js as g,nr as Se,ns as Ce,oc as we,pn as Te,qn as Ee,qr as _,qt as De,rr as Oe,va as ke,xn as Ae,xr as v,za as y}from"./ui-components-rkvkkTxO.js";import"./MetadataProvider-Cm9vi7AZ.js";import{n as je}from"./assistantBus-BFk4fCbM.js";import{_ as Me,a as Ne,c as Pe,g as Fe,h as Ie,i as Le,m as Re,o as ze,p as Be,r as b,s as Ve,t as He,u as Ue,x}from"./marketplaceApi-zYQofLEk.js";import{n as We,t as Ge}from"./usePackageL10n-CiFMHfKe.js";import{t as Ke}from"./MarketplaceAccessDenied-CAuxNcMw.js";var S=e(a(),1),C=i();function qe(e){let t=e.replace(/\r\n/g,`
1
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BGDDiZfJ.js";import{d as ee}from"./infrastructure-ASGyCRMg.js";import{R as te,l as ne}from"./framework-CBCX6Urh.js";import{$n as re,Cc as ie,Ci as o,Do as ae,Gn as oe,Jn as se,Jo as ce,Jt as le,Kn as ue,Kt as de,Mr as s,Ns as fe,Ps as c,Qn as l,Qo as pe,Rt as u,Si as d,Un as me,Wn as he,Xt as ge,Yo as _e,Yt as ve,ar as f,dn as p,ds as m,er as ye,fn as be,ga as xe,hn as h,js as g,nr as Se,ns as Ce,oc as we,pn as Te,qn as Ee,qr as _,qt as De,rr as Oe,va as ke,xn as Ae,xr as v,za as y}from"./ui-components-BOOpjWsQ.js";import"./MetadataProvider-seOmvY8N.js";import{n as je}from"./assistantBus-BFk4fCbM.js";import{S as b,_ as Me,a as Ne,c as Pe,g as Fe,h as Ie,i as Le,m as Re,o as ze,p as Be,r as x,s as Ve,t as He,u as Ue}from"./marketplaceApi-N63OOXW-.js";import{n as We,t as Ge}from"./usePackageL10n-CiFMHfKe.js";import{t as Ke}from"./MarketplaceAccessDenied-Bl4faFLm.js";var S=e(a(),1),C=i();function qe(e){let t=e.replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `),n=[],r=0;for(;r<t.length;){let e=t[r];if(e.startsWith("```")){let i=e.slice(3).trim();r++;let a=[];for(;r<t.length&&!t[r].startsWith("```");)a.push(t[r]),r++;r++,n.push({type:`code`,text:a.join(`
4
- `),lang:i});continue}let i=/^(#{1,3})\s+(.*)$/.exec(e);if(i){let e=i[1].length;n.push({type:`h${e}`,text:i[2].trim()}),r++;continue}if(/^[-*]\s+/.test(e)){let e=[];for(;r<t.length&&/^[-*]\s+/.test(t[r]);)e.push(t[r].replace(/^[-*]\s+/,``)),r++;n.push({type:`ul`,items:e});continue}if(/^\d+\.\s+/.test(e)){let e=[];for(;r<t.length&&/^\d+\.\s+/.test(t[r]);)e.push(t[r].replace(/^\d+\.\s+/,``)),r++;n.push({type:`ol`,items:e});continue}if(!e.trim()){r++;continue}let a=[];for(;r<t.length&&t[r].trim()&&!/^#{1,3}\s+/.test(t[r])&&!/^[-*]\s+/.test(t[r])&&!/^\d+\.\s+/.test(t[r])&&!t[r].startsWith("```");)a.push(t[r]),r++;n.push({type:`p`,text:a.join(` `)})}return n}function w(e){let t=[],n=e,r=0,i=[{re:/`([^`]+)`/,render:e=>(0,C.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[0.85em]`,children:e[1]},`k${r++}`)},{re:/\*\*([^*]+)\*\*/,render:e=>(0,C.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e[1]},`k${r++}`)},{re:/\*([^*]+)\*/,render:e=>(0,C.jsx)(`em`,{children:e[1]},`k${r++}`)},{re:/\[([^\]]+)\]\(([^)]+)\)/,render:e=>(0,C.jsx)(`a`,{href:e[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-violet-600 underline-offset-2 hover:underline dark:text-violet-400`,children:e[1]},`k${r++}`)}];for(;n;){let e=-1,r=null,a=null;for(let t of i){let i=t.re.exec(n);i&&(e===-1||i.index<e)&&(e=i.index,r=i,a=t)}if(!r||!a){t.push(n);break}e>0&&t.push(n.slice(0,e)),t.push(a.render(r)),n=n.slice(e+r[0].length)}return(0,C.jsx)(C.Fragment,{children:t.map((e,t)=>(0,C.jsx)(S.Fragment,{children:e},t))})}function Je({source:e,className:t}){let n=qe(e);return(0,C.jsx)(`div`,{className:`flex flex-col gap-4 text-sm leading-relaxed text-foreground/90 ${t??``}`,children:n.map((e,t)=>{switch(e.type){case`h1`:return(0,C.jsx)(`h2`,{className:`mt-2 text-xl font-bold tracking-tight`,children:w(e.text??``)},t);case`h2`:return(0,C.jsx)(`h3`,{className:`mt-3 text-base font-semibold tracking-tight`,children:w(e.text??``)},t);case`h3`:return(0,C.jsx)(`h4`,{className:`mt-2 text-sm font-semibold tracking-tight text-foreground/80`,children:w(e.text??``)},t);case`p`:return(0,C.jsx)(`p`,{children:w(e.text??``)},t);case`ul`:return(0,C.jsx)(`ul`,{className:`ml-1 flex list-none flex-col gap-1.5`,children:(e.items??[]).map((e,t)=>(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-violet-500/70`}),(0,C.jsx)(`span`,{children:w(e)})]},t))},t);case`ol`:return(0,C.jsx)(`ol`,{className:`ml-5 flex list-decimal flex-col gap-1.5 marker:text-muted-foreground`,children:(e.items??[]).map((e,t)=>(0,C.jsx)(`li`,{className:`pl-1`,children:w(e)},t))},t);case`code`:return(0,C.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border bg-muted/40 p-3 text-xs leading-relaxed`,children:(0,C.jsx)(`code`,{className:`font-mono`,children:e.text})},t)}return null})})}var T={node:`In-process · full trust`,sandbox:`Sandboxed`,worker:`Out-of-process`};function E({icon:e,label:t,items:n}){return!n||n.length===0?null:(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(e,{className:`h-3.5 w-3.5 mt-0.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium`,children:t}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:n.map(e=>(0,C.jsx)(`code`,{className:`font-mono text-[11px] px-1 py-0.5 rounded bg-muted break-all`,children:e},e))})]})]})}function Ye({version:e}){let{t}=ne();if(!e?.contains_code)return null;let n=e.permissions??{},r=(n.services?.length??0)+(n.hooks?.length??0)+(n.network?.length??0)+(n.fs?.length??0)>0;return(0,C.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-3 text-sm`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,C.jsx)(m,{className:`h-4 w-4 text-amber-600 shrink-0`,"aria-hidden":`true`}),t(`marketplace.disclosure.containsCode`,{defaultValue:`This package contains code`})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.runtime&&(0,C.jsx)(f,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:T[e.runtime]??e.runtime})}),e.platform_verified?(0,C.jsxs)(f,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,C.jsx)(d,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,C.jsxs)(f,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,C.jsx)(o,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,C.jsxs)(f,{variant:`outline`,className:`gap-1`,children:[(0,C.jsx)(g,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.signed`,{defaultValue:`Signed`})]})]}),r?(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.grantsIntro`,{defaultValue:`On install, this package will be granted:`})}),(0,C.jsx)(E,{icon:we,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,C.jsx)(E,{icon:s,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,C.jsx)(E,{icon:ke,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,C.jsx)(E,{icon:ae,label:t(`marketplace.disclosure.fs`,{defaultValue:`Filesystem access`}),items:n.fs??void 0})]}):(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.noPermissions`,{defaultValue:`Requests no special permissions.`})})]})}var D=t({MarketplacePackagePage:()=>O});function O(){let e=n(),{packageId:t,appName:i}=r(),a=ee(),{t:o,language:ae}=ne(),s=i?`/apps/${i}`:``,{refresh:d}=te(),[m,we]=(0,S.useState)(null),[ke,qe]=(0,S.useState)(!0),[w,T]=(0,S.useState)(null),[E,D]=(0,S.useState)(!1),[O,Xe]=(0,S.useState)([]),[Ze,k]=(0,S.useState)(!1),[A,j]=(0,S.useState)(null),[M,N]=(0,S.useState)(``),[Qe,$e]=(0,S.useState)({}),[P,et]=(0,S.useState)(!1),[tt,nt]=(0,S.useState)(!1),[F,rt]=(0,S.useState)(!1),[I,L]=(0,S.useState)(null),[R,it]=(0,S.useState)(null),[z,B]=(0,S.useState)(null),[V,H]=(0,S.useState)(null),[U,W]=(0,S.useState)(null),[at,G]=(0,S.useState)([]),[K,q]=(0,S.useState)(!1),[J,Y]=(0,S.useState)(null);(0,S.useEffect)(()=>{if(!x().features.installLocal)return;let e=!1;return(async()=>{let t=await Ue();e||G(t)})(),()=>{e=!0}},[t,J]),(0,S.useEffect)(()=>{if(!t)return;let e=x().defaultEnvironmentId??``,n=!1;return(async()=>{let r=await b(t,e);n||!r||(B(r),it(r.version))})(),()=>{n=!0}},[t]),(0,S.useEffect)(()=>{let e=!1;return(async()=>{if(t){qe(!0),T(null);try{let n=await Le(t);e||we(n)}catch(t){e||T(t?.message??String(t))}finally{e||qe(!1)}}})(),()=>{e=!0}},[t]);let ot=async()=>{D(!0),L(null),j(null);let e=x().defaultEnvironmentId;if(e){k(!1),N(e),Xe([]);return}k(!0);try{let[e,n]=await Promise.all([Ve(),Pe()]),r=e.filter(e=>{let t=e.organization_id;return t?n.has(String(t)):!1});Xe(r),$e({});let i=t;i&&Promise.all(r.map(async e=>{try{let t=await b(i,e.id);return t?[e.id,t.version]:null}catch{return null}})).then(e=>{let t={};for(let n of e)n&&(t[n[0]]=n[1]);$e(t)}),e.length>0&&r.length===0?j(o(`marketplace.install.noPermission`)):r.length===1&&N(r[0].id)}catch(e){let t=e?.status;j(t===401||t===403?o(`marketplace.install.signInFirst`):e?.message??String(e))}finally{k(!1)}},st=async()=>{if(!(!t||!M)){rt(!0),L(null);try{let e=(await ze({packageId:t,environmentId:M,seedSampleData:P}))?.installation?.version??m?.package?.latest_version?.version??m?.versions?.[0]?.version??``;it(e||`installed`);try{let e=x().defaultEnvironmentId||M;if(e){let n=await b(t,e);n&&B(n)}}catch{}let n=x().defaultEnvironmentId;if(!n||n===M)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await d()}catch{}L({ok:!0,message:o(`marketplace.install.success`)}),je()}catch(e){L({ok:!1,message:e?.message??String(e)})}finally{rt(!1)}}},ct=async()=>{if(t){q(!0),Y(null);try{let e=await Ne({packageId:t});try{await d(`app`)}catch{}Y({ok:!0,message:o(`marketplace.install.localSuccess`,{version:e.version,name:m?.package?Ge(m.package,ae).displayName:e.manifestId})}),je()}catch(e){let t=e?.code,n=e?.message??String(e);t===`manifest_conflict`?n=o(`marketplace.install.localManifestConflict`,{message:n}):t===`unauthorized`?n=o(`marketplace.install.localUnauthorized`):t===`marketplace_unavailable`&&(n=o(`marketplace.install.localMarketplaceUnavailable`)),Y({ok:!1,message:n})}finally{q(!1)}}},lt=async()=>{if($&&confirm(o(`marketplace.uninstall.confirm`,{manifestId:$.manifestId,version:$.version}))){q(!0),Y(null);try{await Me($.manifestId);try{await d(`app`)}catch{}Y({ok:!0,message:o(`marketplace.uninstall.successInDetail`,{manifestId:$.manifestId})})}catch(e){Y({ok:!1,message:e?.message??String(e)})}finally{q(!1)}}},ut=async()=>{if(z){H(`reseed`),W(null);try{let e=await Fe(z.installationId);e.ok?(B({...z,withSampleData:!0}),W({ok:!0,text:o(`marketplace.detail.reseedQueued`)||`Sample data will be re-seeded on next environment access.`})):W({ok:!1,text:e.error||`Re-seed failed`})}finally{H(null)}}},dt=async()=>{if(z&&confirm(o(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){H(`purge`),W(null);try{let e=await Re(z.installationId);if(e.ok){B({...z,withSampleData:!1});let t=e.deleted??0;W({ok:!0,text:t>0?o(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:o(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}else W({ok:!1,text:e.error||`Purge failed`})}finally{H(null)}}},ft=async()=>{if($){H(`reseed`),W(null);try{let e=await Ie($.manifestId);G(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!0}:e));let t=e.inserted??0,n=e.updated??0,r=e.errors??0,i=o(`marketplace.detail.reseedLocalSuccess`,{inserted:t,updated:n})||`Sample data re-seeded (inserted=${t}, updated=${n}).`;W(r>0?{ok:!1,text:`${i} ${o(`marketplace.detail.reseedPartialErrors`,{count:r})||`(${r} record(s) failed to write)`}`}:{ok:!0,text:i})}catch(e){W({ok:!1,text:e?.message||`Re-seed failed`})}finally{H(null)}}},pt=async()=>{if($&&confirm(o(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){H(`purge`),W(null);try{let e=await Be($.manifestId);G(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!1}:e));let t=e.deleted??0;W({ok:!0,text:t>0?o(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:o(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}catch(e){W({ok:!1,text:e?.message||`Purge failed`})}finally{H(null)}}};if(ke)return(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsx)(u,{className:`h-8 w-32`}),(0,C.jsx)(u,{className:`h-16 w-full`}),(0,C.jsx)(u,{className:`h-64 w-full`})]});if(w||!m)return(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsxs)(v,{variant:`ghost`,size:`sm`,onClick:()=>e(`${s}/system/marketplace`),children:[(0,C.jsx)(ie,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.back`)]}),(0,C.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,C.jsx)(c,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`font-medium text-destructive`,children:o(`marketplace.load.packageFailed`)}),(0,C.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:w??o(`marketplace.load.notFound`)})]})]})]});let X=m.package,Z=Ge(X,ae),Q=X.latest_version?.version??m.versions[0]?.version??null,$=at.find(e=>e.manifestId===X.manifest_id)??null,mt=!!X.latest_version?.contains_code,ht=!!R&&R!==`installed`&&!!Q&&R!==Q,gt=x().features.installLocal,_t=!Q||K||F||!gt&&!!R&&!ht,vt=gt?{label:o(K?`marketplace.action.working`:$?`marketplace.action.reinstall`:`marketplace.action.install`),onClick:ct}:{label:F?o(`marketplace.action.installing`):R?ht?o(`marketplace.action.updateTo`,{defaultValue:`Update`,version:Q}):o(`marketplace.action.installed`,{defaultValue:`Installed`}):o(`marketplace.action.installToCloud`),onClick:ot},yt=X.category?o(`marketplace.category.${X.category}`,{defaultValue:X.category}):null;return a?(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsxs)(v,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${s}/system/marketplace`),children:[(0,C.jsx)(ie,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.back`)]}),(0,C.jsxs)(`div`,{className:`flex items-start gap-5 flex-wrap sm:flex-nowrap rounded-2xl border bg-gradient-to-br from-primary/5 via-background to-background p-6 sm:p-8`,children:[(0,C.jsx)(We,{iconUrl:X.icon_url,displayName:Z.displayName,manifestId:X.manifest_id,className:`h-20 w-20 rounded-2xl shadow-sm ring-1 ring-border shrink-0`,initialClassName:`text-3xl font-bold`}),(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,C.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight truncate`,children:Z.displayName||X.manifest_id}),X.homepage_url&&(0,C.jsxs)(`a`,{href:X.homepage_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:o(`marketplace.detail.homepage`),children:[(0,C.jsx)(ce,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:o(`marketplace.detail.homepage`)})]})]}),(0,C.jsxs)(`div`,{className:`text-sm text-muted-foreground mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,C.jsx)(`code`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:X.manifest_id}),Q&&(0,C.jsx)(f,{variant:`outline`,children:o(`marketplace.versionBadge`,{version:Q})}),X.publisher&&X.publisher!==`private`&&(0,C.jsx)(f,{variant:X.publisher===`objectstack`?`default`:`secondary`,children:X.publisher}),yt&&(0,C.jsx)(f,{variant:`outline`,children:yt}),X.license&&(0,C.jsx)(f,{variant:`outline`,className:`font-normal`,children:X.license}),$&&(0,C.jsxs)(f,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(g,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:$.version})]}),!$&&R&&(0,C.jsxs)(f,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(g,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:R})]}),ht&&(0,C.jsxs)(f,{variant:`default`,className:`bg-amber-500 hover:bg-amber-500 gap-1`,children:[(0,C.jsx)(fe,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.updateAvailable`,{defaultValue:`Update available`}),` → v`,Q]})]}),Z.description&&(0,C.jsx)(`p`,{className:`text-sm sm:text-base text-foreground/80 mt-3 max-w-2xl leading-relaxed`,children:Z.description})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-start`,children:[(0,C.jsxs)(v,{onClick:vt.onClick,disabled:_t,size:`lg`,className:`min-w-[8rem]`,children:[(0,C.jsx)(pe,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),vt.label]}),$&&(0,C.jsxs)(be,{children:[(0,C.jsx)(Ae,{asChild:!0,children:(0,C.jsx)(v,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":o(`marketplace.detail.moreOptions`),children:(0,C.jsx)(_e,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(Te,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(h,{onSelect:ft,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(Ce,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),$.withSampleData?o(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:o(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,C.jsxs)(h,{onSelect:pt,disabled:V!==null||!$.withSampleData,className:`text-destructive focus:text-destructive`,children:[V===`purge`?(0,C.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(_,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,C.jsxs)(h,{onSelect:lt,disabled:K,className:`text-destructive focus:text-destructive`,children:[(0,C.jsx)(_,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!$&&z&&!x().cloudUrl&&(0,C.jsxs)(be,{children:[(0,C.jsx)(Ae,{asChild:!0,children:(0,C.jsx)(v,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":o(`marketplace.detail.moreOptions`)||`More options`,children:(0,C.jsx)(_e,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(Te,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(h,{onSelect:ut,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(Ce,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),z.withSampleData?o(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:o(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,C.jsxs)(h,{onSelect:dt,disabled:V!==null||!z.withSampleData,className:`text-destructive focus:text-destructive`,children:[V===`purge`?(0,C.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(_,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.purgeSampleData`)||`Purge sample data`]})]})]})]})]}),U&&(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm ${U.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[U.ok?(0,C.jsx)(g,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(c,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:U.text}),(0,C.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>W(null),children:o(`marketplace.action.dismiss`)})]}),J&&(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm whitespace-pre-wrap ${J.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[J.ok?(0,C.jsx)(g,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(c,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:J.message}),(0,C.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>Y(null),children:o(`marketplace.action.dismiss`)})]}),(0,C.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,C.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:(0,C.jsxs)(re,{children:[(0,C.jsx)(Se,{children:(0,C.jsx)(Oe,{className:`text-base`,children:o(`marketplace.detail.about`)})}),(0,C.jsx)(ye,{children:Z.readme?(0,C.jsx)(Je,{source:Z.readme}):(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.detail.noReadme`)})})]})}),(0,C.jsx)(`div`,{className:`space-y-4`,children:(0,C.jsxs)(re,{children:[(0,C.jsx)(Se,{children:(0,C.jsx)(Oe,{className:`text-base`,children:o(`marketplace.detail.versions`)})}),(0,C.jsx)(ye,{children:m.versions.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.detail.noApprovedVersions`)}):(0,C.jsx)(`ul`,{className:`space-y-3`,children:m.versions.map(e=>(0,C.jsxs)(`li`,{className:`space-y-1 text-sm`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(xe,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,C.jsxs)(`code`,{className:`font-mono`,children:[`v`,e.version]}),e.is_prerelease&&(0,C.jsx)(f,{variant:`outline`,className:`text-xs`,children:o(`marketplace.detail.prerelease`)})]}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.published_at?new Date(e.published_at).toLocaleDateString():`—`})]}),e.release_notes&&e.release_notes.trim()&&(0,C.jsx)(`p`,{className:`whitespace-pre-line pl-5 text-xs text-muted-foreground`,children:e.release_notes.trim()})]},e.id))})})]})})]}),(0,C.jsx)(me,{open:E,onOpenChange:e=>{D(e),e||(L(null),nt(!1))},children:(0,C.jsxs)(he,{children:[(0,C.jsxs)(Ee,{children:[(0,C.jsx)(se,{children:o(`marketplace.install.dialogTitle`,{name:Z.displayName||X.manifest_id})}),(0,C.jsx)(oe,{children:x().defaultEnvironmentId?o(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):o(`marketplace.install.dialogDescPicker`)})]}),Ze?(0,C.jsx)(u,{className:`h-10 w-full`}):A?(0,C.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-sm space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(c,{className:`h-4 w-4 mt-0.5 text-amber-600`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:A})]}),(0,C.jsx)(`a`,{href:He(X.id),target:`_blank`,rel:`noopener noreferrer`,children:(0,C.jsxs)(v,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,C.jsx)(ce,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.action.openOnCloud`)]})})]}):x().defaultEnvironmentId?(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(l,{id:`seed`,checked:P,onCheckedChange:e=>et(e===!0)}),(0,C.jsx)(p,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:o(`marketplace.install.includeSampleData`)})]}):O.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.install.noEnvs`)}):(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(p,{htmlFor:`env-select`,children:o(`marketplace.install.environment`)}),(0,C.jsxs)(de,{value:M,onValueChange:N,children:[(0,C.jsx)(ve,{id:`env-select`,children:(0,C.jsx)(ge,{placeholder:o(`marketplace.install.environmentPlaceholder`)})}),(0,C.jsx)(De,{children:O.map(e=>{let t=Qe[e.id],n=!!t&&!!Q&&t!==`installed`&&t!==Q;return(0,C.jsxs)(le,{value:e.id,children:[e.display_name||e.hostname||e.id,e.plan&&(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.plan]}),t&&(n?(0,C.jsxs)(`span`,{className:`text-amber-600`,children:[` · `,o(`marketplace.install.updateTo`,{defaultValue:`Update → v{{version}}`,version:Q})]}):(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,o(`marketplace.install.installedVersion`,{defaultValue:`Installed v{{version}}`,version:t})]}))]},e.id)})})]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(l,{id:`seed`,checked:P,onCheckedChange:e=>et(e===!0)}),(0,C.jsx)(p,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:o(`marketplace.install.includeSampleData`)})]})]}),mt&&!A&&(0,C.jsxs)(`div`,{className:`space-y-3`,children:[(0,C.jsx)(Ye,{version:X.latest_version}),(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(l,{id:`ack-perms`,checked:tt,onCheckedChange:e=>nt(e===!0)}),(0,C.jsx)(p,{htmlFor:`ack-perms`,className:`text-sm font-normal cursor-pointer leading-snug`,children:o(`marketplace.disclosure.acknowledge`,{defaultValue:`I understand this package runs code and grants the permissions above.`})})]})]}),I&&(0,C.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${I.ok?`border-green-500/30 bg-green-500/5 text-green-700`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:I.message}),(0,C.jsxs)(ue,{children:[(0,C.jsx)(v,{variant:`outline`,onClick:()=>D(!1),children:o(`marketplace.action.close`)}),!A&&(0,C.jsx)(v,{onClick:st,disabled:!M||F||I?.ok===!0||mt&&!tt,children:o(F?`marketplace.action.installing`:`marketplace.action.install`)})]})]})})]}):(0,C.jsx)(Ke,{})}export{D as t};
4
+ `),lang:i});continue}let i=/^(#{1,3})\s+(.*)$/.exec(e);if(i){let e=i[1].length;n.push({type:`h${e}`,text:i[2].trim()}),r++;continue}if(/^[-*]\s+/.test(e)){let e=[];for(;r<t.length&&/^[-*]\s+/.test(t[r]);)e.push(t[r].replace(/^[-*]\s+/,``)),r++;n.push({type:`ul`,items:e});continue}if(/^\d+\.\s+/.test(e)){let e=[];for(;r<t.length&&/^\d+\.\s+/.test(t[r]);)e.push(t[r].replace(/^\d+\.\s+/,``)),r++;n.push({type:`ol`,items:e});continue}if(!e.trim()){r++;continue}let a=[];for(;r<t.length&&t[r].trim()&&!/^#{1,3}\s+/.test(t[r])&&!/^[-*]\s+/.test(t[r])&&!/^\d+\.\s+/.test(t[r])&&!t[r].startsWith("```");)a.push(t[r]),r++;n.push({type:`p`,text:a.join(` `)})}return n}function w(e){let t=[],n=e,r=0,i=[{re:/`([^`]+)`/,render:e=>(0,C.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[0.85em]`,children:e[1]},`k${r++}`)},{re:/\*\*([^*]+)\*\*/,render:e=>(0,C.jsx)(`strong`,{className:`font-semibold text-foreground`,children:e[1]},`k${r++}`)},{re:/\*([^*]+)\*/,render:e=>(0,C.jsx)(`em`,{children:e[1]},`k${r++}`)},{re:/\[([^\]]+)\]\(([^)]+)\)/,render:e=>(0,C.jsx)(`a`,{href:e[2],target:`_blank`,rel:`noopener noreferrer`,className:`text-violet-600 underline-offset-2 hover:underline dark:text-violet-400`,children:e[1]},`k${r++}`)}];for(;n;){let e=-1,r=null,a=null;for(let t of i){let i=t.re.exec(n);i&&(e===-1||i.index<e)&&(e=i.index,r=i,a=t)}if(!r||!a){t.push(n);break}e>0&&t.push(n.slice(0,e)),t.push(a.render(r)),n=n.slice(e+r[0].length)}return(0,C.jsx)(C.Fragment,{children:t.map((e,t)=>(0,C.jsx)(S.Fragment,{children:e},t))})}function Je({source:e,className:t}){let n=qe(e);return(0,C.jsx)(`div`,{className:`flex flex-col gap-4 text-sm leading-relaxed text-foreground/90 ${t??``}`,children:n.map((e,t)=>{switch(e.type){case`h1`:return(0,C.jsx)(`h2`,{className:`mt-2 text-xl font-bold tracking-tight`,children:w(e.text??``)},t);case`h2`:return(0,C.jsx)(`h3`,{className:`mt-3 text-base font-semibold tracking-tight`,children:w(e.text??``)},t);case`h3`:return(0,C.jsx)(`h4`,{className:`mt-2 text-sm font-semibold tracking-tight text-foreground/80`,children:w(e.text??``)},t);case`p`:return(0,C.jsx)(`p`,{children:w(e.text??``)},t);case`ul`:return(0,C.jsx)(`ul`,{className:`ml-1 flex list-none flex-col gap-1.5`,children:(e.items??[]).map((e,t)=>(0,C.jsxs)(`li`,{className:`flex gap-2`,children:[(0,C.jsx)(`span`,{"aria-hidden":`true`,className:`mt-1.5 inline-block h-1.5 w-1.5 shrink-0 rounded-full bg-violet-500/70`}),(0,C.jsx)(`span`,{children:w(e)})]},t))},t);case`ol`:return(0,C.jsx)(`ol`,{className:`ml-5 flex list-decimal flex-col gap-1.5 marker:text-muted-foreground`,children:(e.items??[]).map((e,t)=>(0,C.jsx)(`li`,{className:`pl-1`,children:w(e)},t))},t);case`code`:return(0,C.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border bg-muted/40 p-3 text-xs leading-relaxed`,children:(0,C.jsx)(`code`,{className:`font-mono`,children:e.text})},t)}return null})})}var T={node:`In-process · full trust`,sandbox:`Sandboxed`,worker:`Out-of-process`};function E({icon:e,label:t,items:n}){return!n||n.length===0?null:(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(e,{className:`h-3.5 w-3.5 mt-0.5 text-muted-foreground shrink-0`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsx)(`div`,{className:`text-xs font-medium`,children:t}),(0,C.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-0.5`,children:n.map(e=>(0,C.jsx)(`code`,{className:`font-mono text-[11px] px-1 py-0.5 rounded bg-muted break-all`,children:e},e))})]})]})}function Ye({version:e}){let{t}=ne();if(!e?.contains_code)return null;let n=e.permissions??{},r=(n.services?.length??0)+(n.hooks?.length??0)+(n.network?.length??0)+(n.fs?.length??0)>0;return(0,C.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 space-y-3 text-sm`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 font-medium`,children:[(0,C.jsx)(m,{className:`h-4 w-4 text-amber-600 shrink-0`,"aria-hidden":`true`}),t(`marketplace.disclosure.containsCode`,{defaultValue:`This package contains code`})]}),(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[e.runtime&&(0,C.jsx)(f,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:T[e.runtime]??e.runtime})}),e.platform_verified?(0,C.jsxs)(f,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,C.jsx)(d,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,C.jsxs)(f,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,C.jsx)(o,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,C.jsxs)(f,{variant:`outline`,className:`gap-1`,children:[(0,C.jsx)(g,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.signed`,{defaultValue:`Signed`})]})]}),r?(0,C.jsxs)(`div`,{className:`space-y-2`,children:[(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.grantsIntro`,{defaultValue:`On install, this package will be granted:`})}),(0,C.jsx)(E,{icon:we,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,C.jsx)(E,{icon:s,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,C.jsx)(E,{icon:ke,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,C.jsx)(E,{icon:ae,label:t(`marketplace.disclosure.fs`,{defaultValue:`Filesystem access`}),items:n.fs??void 0})]}):(0,C.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:t(`marketplace.disclosure.noPermissions`,{defaultValue:`Requests no special permissions.`})})]})}var D=t({MarketplacePackagePage:()=>O});function O(){let e=n(),{packageId:t,appName:i}=r(),a=ee(),{t:o,language:ae}=ne(),s=i?`/apps/${i}`:``,{refresh:d}=te(),[m,we]=(0,S.useState)(null),[ke,qe]=(0,S.useState)(!0),[w,T]=(0,S.useState)(null),[E,D]=(0,S.useState)(!1),[O,Xe]=(0,S.useState)([]),[Ze,k]=(0,S.useState)(!1),[A,j]=(0,S.useState)(null),[M,N]=(0,S.useState)(``),[Qe,$e]=(0,S.useState)({}),[P,et]=(0,S.useState)(!1),[tt,nt]=(0,S.useState)(!1),[F,rt]=(0,S.useState)(!1),[I,L]=(0,S.useState)(null),[R,it]=(0,S.useState)(null),[z,B]=(0,S.useState)(null),[V,H]=(0,S.useState)(null),[U,W]=(0,S.useState)(null),[at,G]=(0,S.useState)([]),[K,q]=(0,S.useState)(!1),[J,Y]=(0,S.useState)(null);(0,S.useEffect)(()=>{if(!b().features.installLocal)return;let e=!1;return(async()=>{let t=await Ue();e||G(t)})(),()=>{e=!0}},[t,J]),(0,S.useEffect)(()=>{if(!t)return;let e=b().defaultEnvironmentId??``,n=!1;return(async()=>{let r=await x(t,e);n||!r||(B(r),it(r.version))})(),()=>{n=!0}},[t]),(0,S.useEffect)(()=>{let e=!1;return(async()=>{if(t){qe(!0),T(null);try{let n=await Le(t);e||we(n)}catch(t){e||T(t?.message??String(t))}finally{e||qe(!1)}}})(),()=>{e=!0}},[t]);let ot=async()=>{D(!0),L(null),j(null);let e=b().defaultEnvironmentId;if(e){k(!1),N(e),Xe([]);return}k(!0);try{let[e,n]=await Promise.all([Ve(),Pe()]),r=e.filter(e=>{let t=e.organization_id;return t?n.has(String(t)):!1});Xe(r),$e({});let i=t;i&&Promise.all(r.map(async e=>{try{let t=await x(i,e.id);return t?[e.id,t.version]:null}catch{return null}})).then(e=>{let t={};for(let n of e)n&&(t[n[0]]=n[1]);$e(t)}),e.length>0&&r.length===0?j(o(`marketplace.install.noPermission`)):r.length===1&&N(r[0].id)}catch(e){let t=e?.status;j(t===401||t===403?o(`marketplace.install.signInFirst`):e?.message??String(e))}finally{k(!1)}},st=async()=>{if(!(!t||!M)){rt(!0),L(null);try{let e=(await ze({packageId:t,environmentId:M,seedSampleData:P}))?.installation?.version??m?.package?.latest_version?.version??m?.versions?.[0]?.version??``;it(e||`installed`);try{let e=b().defaultEnvironmentId||M;if(e){let n=await x(t,e);n&&B(n)}}catch{}let n=b().defaultEnvironmentId;if(!n||n===M)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await d()}catch{}L({ok:!0,message:o(`marketplace.install.success`)}),je()}catch(e){L({ok:!1,message:e?.message??String(e)})}finally{rt(!1)}}},ct=async()=>{if(t){q(!0),Y(null);try{let e=await Ne({packageId:t});try{await d(`app`)}catch{}Y({ok:!0,message:o(`marketplace.install.localSuccess`,{version:e.version,name:m?.package?Ge(m.package,ae).displayName:e.manifestId})}),je()}catch(e){let t=e?.code,n=e?.message??String(e);t===`manifest_conflict`?n=o(`marketplace.install.localManifestConflict`,{message:n}):t===`unauthorized`?n=o(`marketplace.install.localUnauthorized`):t===`marketplace_unavailable`&&(n=o(`marketplace.install.localMarketplaceUnavailable`)),Y({ok:!1,message:n})}finally{q(!1)}}},lt=async()=>{if($&&confirm(o(`marketplace.uninstall.confirm`,{manifestId:$.manifestId,version:$.version}))){q(!0),Y(null);try{await Me($.manifestId);try{await d(`app`)}catch{}Y({ok:!0,message:o(`marketplace.uninstall.successInDetail`,{manifestId:$.manifestId})})}catch(e){Y({ok:!1,message:e?.message??String(e)})}finally{q(!1)}}},ut=async()=>{if(z){H(`reseed`),W(null);try{let e=await Fe(z.installationId);e.ok?(B({...z,withSampleData:!0}),W({ok:!0,text:o(`marketplace.detail.reseedQueued`)||`Sample data will be re-seeded on next environment access.`})):W({ok:!1,text:e.error||`Re-seed failed`})}finally{H(null)}}},dt=async()=>{if(z&&confirm(o(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){H(`purge`),W(null);try{let e=await Re(z.installationId);if(e.ok){B({...z,withSampleData:!1});let t=e.deleted??0;W({ok:!0,text:t>0?o(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:o(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}else W({ok:!1,text:e.error||`Purge failed`})}finally{H(null)}}},ft=async()=>{if($){H(`reseed`),W(null);try{let e=await Ie($.manifestId);G(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!0}:e));let t=e.inserted??0,n=e.updated??0,r=e.errors??0,i=o(`marketplace.detail.reseedLocalSuccess`,{inserted:t,updated:n})||`Sample data re-seeded (inserted=${t}, updated=${n}).`;W(r>0?{ok:!1,text:`${i} ${o(`marketplace.detail.reseedPartialErrors`,{count:r})||`(${r} record(s) failed to write)`}`}:{ok:!0,text:i})}catch(e){W({ok:!1,text:e?.message||`Re-seed failed`})}finally{H(null)}}},pt=async()=>{if($&&confirm(o(`marketplace.detail.purgeConfirm`)||`Delete all sample records seeded by this package? User-added records will NOT be touched.`)){H(`purge`),W(null);try{let e=await Be($.manifestId);G(e=>e.map(e=>e.manifestId===$.manifestId?{...e,withSampleData:!1}:e));let t=e.deleted??0;W({ok:!0,text:t>0?o(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:o(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}catch(e){W({ok:!1,text:e?.message||`Purge failed`})}finally{H(null)}}};if(ke)return(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsx)(u,{className:`h-8 w-32`}),(0,C.jsx)(u,{className:`h-16 w-full`}),(0,C.jsx)(u,{className:`h-64 w-full`})]});if(w||!m)return(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsxs)(v,{variant:`ghost`,size:`sm`,onClick:()=>e(`${s}/system/marketplace`),children:[(0,C.jsx)(ie,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.back`)]}),(0,C.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,C.jsx)(c,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,C.jsxs)(`div`,{children:[(0,C.jsx)(`div`,{className:`font-medium text-destructive`,children:o(`marketplace.load.packageFailed`)}),(0,C.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:w??o(`marketplace.load.notFound`)})]})]})]});let X=m.package,Z=Ge(X,ae),Q=X.latest_version?.version??m.versions[0]?.version??null,$=at.find(e=>e.manifestId===X.manifest_id)??null,mt=!!X.latest_version?.contains_code,ht=!!R&&R!==`installed`&&!!Q&&R!==Q,gt=b().features.installLocal,_t=!Q||K||F||!gt&&!!R&&!ht,vt=gt?{label:o(K?`marketplace.action.working`:$?`marketplace.action.reinstall`:`marketplace.action.install`),onClick:ct}:{label:F?o(`marketplace.action.installing`):R?ht?o(`marketplace.action.updateTo`,{defaultValue:`Update`,version:Q}):o(`marketplace.action.installed`,{defaultValue:`Installed`}):o(`marketplace.action.installToCloud`),onClick:ot},yt=X.category?o(`marketplace.category.${X.category}`,{defaultValue:X.category}):null;return a?(0,C.jsxs)(`div`,{className:`mx-auto w-full max-w-6xl flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsxs)(v,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${s}/system/marketplace`),children:[(0,C.jsx)(ie,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.back`)]}),(0,C.jsxs)(`div`,{className:`flex items-start gap-5 flex-wrap sm:flex-nowrap rounded-2xl border bg-gradient-to-br from-primary/5 via-background to-background p-6 sm:p-8`,children:[(0,C.jsx)(We,{iconUrl:X.icon_url,displayName:Z.displayName,manifestId:X.manifest_id,className:`h-20 w-20 rounded-2xl shadow-sm ring-1 ring-border shrink-0`,initialClassName:`text-3xl font-bold`}),(0,C.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,C.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight truncate`,children:Z.displayName||X.manifest_id}),X.homepage_url&&(0,C.jsxs)(`a`,{href:X.homepage_url,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,title:o(`marketplace.detail.homepage`),children:[(0,C.jsx)(ce,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:o(`marketplace.detail.homepage`)})]})]}),(0,C.jsxs)(`div`,{className:`text-sm text-muted-foreground mt-2 flex flex-wrap items-center gap-1.5`,children:[(0,C.jsx)(`code`,{className:`font-mono text-xs px-1.5 py-0.5 rounded bg-muted`,children:X.manifest_id}),Q&&(0,C.jsx)(f,{variant:`outline`,children:o(`marketplace.versionBadge`,{version:Q})}),X.publisher&&X.publisher!==`private`&&(0,C.jsx)(f,{variant:X.publisher===`objectstack`?`default`:`secondary`,children:X.publisher}),yt&&(0,C.jsx)(f,{variant:`outline`,children:yt}),X.license&&(0,C.jsx)(f,{variant:`outline`,className:`font-normal`,children:X.license}),$&&(0,C.jsxs)(f,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(g,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:$.version})]}),!$&&R&&(0,C.jsxs)(f,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(g,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:R})]}),ht&&(0,C.jsxs)(f,{variant:`default`,className:`bg-amber-500 hover:bg-amber-500 gap-1`,children:[(0,C.jsx)(fe,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.updateAvailable`,{defaultValue:`Update available`}),` → v`,Q]})]}),Z.description&&(0,C.jsx)(`p`,{className:`text-sm sm:text-base text-foreground/80 mt-3 max-w-2xl leading-relaxed`,children:Z.description})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0 self-start`,children:[(0,C.jsxs)(v,{onClick:vt.onClick,disabled:_t,size:`lg`,className:`min-w-[8rem]`,children:[(0,C.jsx)(pe,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),vt.label]}),$&&(0,C.jsxs)(be,{children:[(0,C.jsx)(Ae,{asChild:!0,children:(0,C.jsx)(v,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":o(`marketplace.detail.moreOptions`),children:(0,C.jsx)(_e,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(Te,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(h,{onSelect:ft,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(Ce,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),$.withSampleData?o(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:o(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,C.jsxs)(h,{onSelect:pt,disabled:V!==null||!$.withSampleData,className:`text-destructive focus:text-destructive`,children:[V===`purge`?(0,C.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(_,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,C.jsxs)(h,{onSelect:lt,disabled:K,className:`text-destructive focus:text-destructive`,children:[(0,C.jsx)(_,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!$&&z&&!b().cloudUrl&&(0,C.jsxs)(be,{children:[(0,C.jsx)(Ae,{asChild:!0,children:(0,C.jsx)(v,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":o(`marketplace.detail.moreOptions`)||`More options`,children:(0,C.jsx)(_e,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(Te,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(h,{onSelect:ut,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(Ce,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),z.withSampleData?o(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:o(`marketplace.detail.addSampleData`)||`Add sample data`]}),(0,C.jsxs)(h,{onSelect:dt,disabled:V!==null||!z.withSampleData,className:`text-destructive focus:text-destructive`,children:[V===`purge`?(0,C.jsx)(y,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(_,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.purgeSampleData`)||`Purge sample data`]})]})]})]})]}),U&&(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm ${U.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[U.ok?(0,C.jsx)(g,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(c,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:U.text}),(0,C.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>W(null),children:o(`marketplace.action.dismiss`)})]}),J&&(0,C.jsxs)(`div`,{role:`status`,className:`flex items-start gap-2 rounded-md border p-3 text-sm whitespace-pre-wrap ${J.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:[J.ok?(0,C.jsx)(g,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(c,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:J.message}),(0,C.jsx)(`button`,{type:`button`,className:`text-xs underline opacity-60 hover:opacity-100`,onClick:()=>Y(null),children:o(`marketplace.action.dismiss`)})]}),(0,C.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,C.jsx)(`div`,{className:`lg:col-span-2 space-y-4`,children:(0,C.jsxs)(re,{children:[(0,C.jsx)(Se,{children:(0,C.jsx)(Oe,{className:`text-base`,children:o(`marketplace.detail.about`)})}),(0,C.jsx)(ye,{children:Z.readme?(0,C.jsx)(Je,{source:Z.readme}):(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.detail.noReadme`)})})]})}),(0,C.jsx)(`div`,{className:`space-y-4`,children:(0,C.jsxs)(re,{children:[(0,C.jsx)(Se,{children:(0,C.jsx)(Oe,{className:`text-base`,children:o(`marketplace.detail.versions`)})}),(0,C.jsx)(ye,{children:m.versions.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.detail.noApprovedVersions`)}):(0,C.jsx)(`ul`,{className:`space-y-3`,children:m.versions.map(e=>(0,C.jsxs)(`li`,{className:`space-y-1 text-sm`,children:[(0,C.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,C.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,C.jsx)(xe,{className:`h-3.5 w-3.5 text-muted-foreground`,"aria-hidden":`true`}),(0,C.jsxs)(`code`,{className:`font-mono`,children:[`v`,e.version]}),e.is_prerelease&&(0,C.jsx)(f,{variant:`outline`,className:`text-xs`,children:o(`marketplace.detail.prerelease`)})]}),(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.published_at?new Date(e.published_at).toLocaleDateString():`—`})]}),e.release_notes&&e.release_notes.trim()&&(0,C.jsx)(`p`,{className:`whitespace-pre-line pl-5 text-xs text-muted-foreground`,children:e.release_notes.trim()})]},e.id))})})]})})]}),(0,C.jsx)(me,{open:E,onOpenChange:e=>{D(e),e||(L(null),nt(!1))},children:(0,C.jsxs)(he,{children:[(0,C.jsxs)(Ee,{children:[(0,C.jsx)(se,{children:o(`marketplace.install.dialogTitle`,{name:Z.displayName||X.manifest_id})}),(0,C.jsx)(oe,{children:b().defaultEnvironmentId?o(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):o(`marketplace.install.dialogDescPicker`)})]}),Ze?(0,C.jsx)(u,{className:`h-10 w-full`}):A?(0,C.jsxs)(`div`,{className:`rounded-md border border-amber-500/30 bg-amber-500/5 p-3 text-sm space-y-2`,children:[(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(c,{className:`h-4 w-4 mt-0.5 text-amber-600`,"aria-hidden":`true`}),(0,C.jsx)(`div`,{className:`flex-1`,children:A})]}),(0,C.jsx)(`a`,{href:He(X.id),target:`_blank`,rel:`noopener noreferrer`,children:(0,C.jsxs)(v,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,C.jsx)(ce,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),o(`marketplace.action.openOnCloud`)]})})]}):b().defaultEnvironmentId?(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(l,{id:`seed`,checked:P,onCheckedChange:e=>et(e===!0)}),(0,C.jsx)(p,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:o(`marketplace.install.includeSampleData`)})]}):O.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(`marketplace.install.noEnvs`)}):(0,C.jsxs)(`div`,{className:`space-y-4`,children:[(0,C.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,C.jsx)(p,{htmlFor:`env-select`,children:o(`marketplace.install.environment`)}),(0,C.jsxs)(de,{value:M,onValueChange:N,children:[(0,C.jsx)(ve,{id:`env-select`,children:(0,C.jsx)(ge,{placeholder:o(`marketplace.install.environmentPlaceholder`)})}),(0,C.jsx)(De,{children:O.map(e=>{let t=Qe[e.id],n=!!t&&!!Q&&t!==`installed`&&t!==Q;return(0,C.jsxs)(le,{value:e.id,children:[e.display_name||e.hostname||e.id,e.plan&&(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,e.plan]}),t&&(n?(0,C.jsxs)(`span`,{className:`text-amber-600`,children:[` · `,o(`marketplace.install.updateTo`,{defaultValue:`Update → v{{version}}`,version:Q})]}):(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,o(`marketplace.install.installedVersion`,{defaultValue:`Installed v{{version}}`,version:t})]}))]},e.id)})})]})]}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(l,{id:`seed`,checked:P,onCheckedChange:e=>et(e===!0)}),(0,C.jsx)(p,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:o(`marketplace.install.includeSampleData`)})]})]}),mt&&!A&&(0,C.jsxs)(`div`,{className:`space-y-3`,children:[(0,C.jsx)(Ye,{version:X.latest_version}),(0,C.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,C.jsx)(l,{id:`ack-perms`,checked:tt,onCheckedChange:e=>nt(e===!0)}),(0,C.jsx)(p,{htmlFor:`ack-perms`,className:`text-sm font-normal cursor-pointer leading-snug`,children:o(`marketplace.disclosure.acknowledge`,{defaultValue:`I understand this package runs code and grants the permissions above.`})})]})]}),I&&(0,C.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${I.ok?`border-green-500/30 bg-green-500/5 text-green-700`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:I.message}),(0,C.jsxs)(ue,{children:[(0,C.jsx)(v,{variant:`outline`,onClick:()=>D(!1),children:o(`marketplace.action.close`)}),!A&&(0,C.jsx)(v,{onClick:st,disabled:!M||F||I?.ok===!0||mt&&!tt,children:o(F?`marketplace.action.installing`:`marketplace.action.install`)})]})]})})]}):(0,C.jsx)(Ke,{})}export{D as t};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BGDDiZfJ.js";import{d as o}from"./infrastructure-Bcx6-8du.js";import{l as s}from"./framework-B3O15Lsq.js";import{$n as c,Hi as l,Oi as u,Ps as ee,Rt as d,Ti as f,ar as p,er as m,ga as h,js as g,nr as _,oi as v,rr as y,sn as b,tr as x,xr as S}from"./ui-components-rkvkkTxO.js";import{n as te}from"./assistantBus-BFk4fCbM.js";import{a as ne,d as C,f as re,l as ie,o as ae,u as oe,x as se}from"./marketplaceApi-zYQofLEk.js";import{n as w,t as T}from"./usePackageL10n-CiFMHfKe.js";import{t as ce}from"./MarketplaceAccessDenied-CAuxNcMw.js";var E=t({MarketplacePage:()=>A}),D=e(a(),1),O=i();function k(){let{language:e,t}=s();return n=>{if(!n)return``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=Math.floor((Date.now()-r.getTime())/864e5);if(i<1)return t(`marketplace.relativeTime.today`);try{let t=new Intl.RelativeTimeFormat(e||`en`,{numeric:`auto`});return i<30?t.format(-i,`day`):i<365?t.format(-Math.floor(i/30),`month`):t.format(-Math.floor(i/365),`year`)}catch{return i<30?t(`marketplace.relativeTime.daysAgo`,{count:i}):i<365?t(`marketplace.relativeTime.monthsAgo`,{count:Math.floor(i/30)}):t(`marketplace.relativeTime.yearsAgo`,{count:Math.floor(i/365)})}}}function A(){let e=n(),{appName:t}=r(),i=o(),{t:a,language:E}=s(),A=k(),j=t?`/apps/${t}`:``,[M,N]=(0,D.useState)([]),[P,F]=(0,D.useState)(!0),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(``),[H,U]=(0,D.useState)([]),[W,le]=(0,D.useState)([]),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(null),[ue,Y]=(0,D.useState)(new Set),de=(0,D.useMemo)(()=>{let e=new Map;for(let t of H)e.set(t.manifestId,t);return e},[H]),X=async()=>{F(!0),L(null);try{let[e,t,n,r]=await Promise.all([C({limit:100}),oe(),re(),ie()]);N(e.items??[]),U(t),le(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);Y(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,D.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{se().features.installLocal?await ne({packageId:e.manifest_id||e.id,versionId:`latest`}):await ae({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:a(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X(),te()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,D.useMemo)(()=>{let e=new Set;for(let t of M)t.category&&e.add(t.category);return Array.from(e).sort()},[M]),Q=e=>{let t=`marketplace.category.${e}`,n=a(t,{defaultValue:e});return n===t?e:n},$=(0,D.useMemo)(()=>{let e=R.trim().toLowerCase();return M.filter(t=>{if(B&&t.category!==B)return!1;if(!e)return!0;let n=T(t,E);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,E]);return i?(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(v,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:a(`marketplace.title`)})]}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:a(`marketplace.subtitle`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(S,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,O.jsx)(f,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?a(`marketplace.installedCount`,{count:H.length}):a(`marketplace.installed`)]}),(0,O.jsxs)(S,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,O.jsx)(l,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.refresh`)]})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(u,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,O.jsx)(b,{value:R,onChange:e=>z(e.target.value),placeholder:a(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":a(`marketplace.searchAria`)})]}),Z.length>0&&(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,O.jsx)(S,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:a(`marketplace.all`)}),Z.map(e=>(0,O.jsx)(S,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,O.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,O.jsx)(ee,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`font-medium text-destructive`,children:a(`marketplace.load.failed`)}),(0,O.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:a(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,O.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(v,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:a(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,O.jsx)(p,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,O.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${q.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:q.text}),(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:W.map(e=>{let t=ue.has(e.manifest_id);return(0,O.jsxs)(c,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,O.jsxs)(_,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(y,{className:`text-base truncate`,children:e.display_name}),(0,O.jsx)(x,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,O.jsx)(p,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,O.jsxs)(m,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||a(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,O.jsxs)(p,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(h,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,O.jsx)(`div`,{className:`ml-auto`,children:t?(0,O.jsxs)(p,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(g,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,O.jsx)(S,{size:`sm`,onClick:()=>void fe(e),disabled:G===e.id,children:G===e.id?a(`marketplace.org.installing`,{defaultValue:`Installing…`}):a(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,O.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,O.jsxs)(c,{children:[(0,O.jsxs)(_,{className:`pb-2`,children:[(0,O.jsx)(d,{className:`h-10 w-10 rounded-lg mb-2`}),(0,O.jsx)(d,{className:`h-5 w-3/4`}),(0,O.jsx)(d,{className:`h-4 w-1/2 mt-1`})]}),(0,O.jsx)(m,{children:(0,O.jsx)(d,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,O.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?a(`marketplace.noApprovedYet`):a(`marketplace.noMatchFilters`)}):(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:$.map(t=>{let n=de.get(t.manifest_id),r=T(t,E);return(0,O.jsxs)(c,{className:`cursor-pointer transition-colors hover:bg-accent/50 flex flex-col`,onClick:()=>e(`${j}/system/marketplace/${t.id}`),role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(`${j}/system/marketplace/${t.id}`))},"data-testid":`marketplace-card-${t.manifest_id}`,children:[(0,O.jsxs)(_,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(y,{className:`text-base truncate`,children:r.displayName}),(0,O.jsx)(x,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,O.jsx)(p,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,O.jsxs)(m,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||a(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,O.jsxs)(p,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(g,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,O.jsxs)(p,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(h,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,O.jsx)(p,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,O.jsx)(ce,{})}export{E as t};
1
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{f as n,m as r,r as i,y as a}from"./vendor-react-BGDDiZfJ.js";import{d as o}from"./infrastructure-ASGyCRMg.js";import{l as s}from"./framework-CBCX6Urh.js";import{$n as c,Hi as l,Oi as u,Ps as ee,Rt as d,Ti as f,ar as p,er as m,ga as h,js as g,nr as _,oi as v,rr as y,sn as b,tr as x,xr as S}from"./ui-components-BOOpjWsQ.js";import{n as te}from"./assistantBus-BFk4fCbM.js";import{S as ne,a as C,d as re,f as ie,l as ae,o as oe,u as se}from"./marketplaceApi-N63OOXW-.js";import{n as w,t as T}from"./usePackageL10n-CiFMHfKe.js";import{t as ce}from"./MarketplaceAccessDenied-Bl4faFLm.js";var E=t({MarketplacePage:()=>A}),D=e(a(),1),O=i();function k(){let{language:e,t}=s();return n=>{if(!n)return``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=Math.floor((Date.now()-r.getTime())/864e5);if(i<1)return t(`marketplace.relativeTime.today`);try{let t=new Intl.RelativeTimeFormat(e||`en`,{numeric:`auto`});return i<30?t.format(-i,`day`):i<365?t.format(-Math.floor(i/30),`month`):t.format(-Math.floor(i/365),`year`)}catch{return i<30?t(`marketplace.relativeTime.daysAgo`,{count:i}):i<365?t(`marketplace.relativeTime.monthsAgo`,{count:Math.floor(i/30)}):t(`marketplace.relativeTime.yearsAgo`,{count:Math.floor(i/365)})}}}function A(){let e=n(),{appName:t}=r(),i=o(),{t:a,language:E}=s(),A=k(),j=t?`/apps/${t}`:``,[M,N]=(0,D.useState)([]),[P,F]=(0,D.useState)(!0),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(``),[H,U]=(0,D.useState)([]),[W,le]=(0,D.useState)([]),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(null),[ue,Y]=(0,D.useState)(new Set),de=(0,D.useMemo)(()=>{let e=new Map;for(let t of H)e.set(t.manifestId,t);return e},[H]),X=async()=>{F(!0),L(null);try{let[e,t,n,r]=await Promise.all([re({limit:100}),se(),ie(),ae()]);N(e.items??[]),U(t),le(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);Y(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,D.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{ne().features.installLocal?await C({packageId:e.manifest_id||e.id,versionId:`latest`}):await oe({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:a(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X(),te()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,D.useMemo)(()=>{let e=new Set;for(let t of M)t.category&&e.add(t.category);return Array.from(e).sort()},[M]),Q=e=>{let t=`marketplace.category.${e}`,n=a(t,{defaultValue:e});return n===t?e:n},$=(0,D.useMemo)(()=>{let e=R.trim().toLowerCase();return M.filter(t=>{if(B&&t.category!==B)return!1;if(!e)return!0;let n=T(t,E);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,E]);return i?(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(v,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:a(`marketplace.title`)})]}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:a(`marketplace.subtitle`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(S,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,O.jsx)(f,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?a(`marketplace.installedCount`,{count:H.length}):a(`marketplace.installed`)]}),(0,O.jsxs)(S,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,O.jsx)(l,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),a(`marketplace.refresh`)]})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(u,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,O.jsx)(b,{value:R,onChange:e=>z(e.target.value),placeholder:a(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":a(`marketplace.searchAria`)})]}),Z.length>0&&(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,O.jsx)(S,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:a(`marketplace.all`)}),Z.map(e=>(0,O.jsx)(S,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,O.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,O.jsx)(ee,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`font-medium text-destructive`,children:a(`marketplace.load.failed`)}),(0,O.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:a(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,O.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(v,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:a(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,O.jsx)(p,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,O.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${q.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:q.text}),(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:W.map(e=>{let t=ue.has(e.manifest_id);return(0,O.jsxs)(c,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,O.jsxs)(_,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(y,{className:`text-base truncate`,children:e.display_name}),(0,O.jsx)(x,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,O.jsx)(p,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,O.jsxs)(m,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||a(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,O.jsxs)(p,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(h,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,O.jsx)(`div`,{className:`ml-auto`,children:t?(0,O.jsxs)(p,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(g,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,O.jsx)(S,{size:`sm`,onClick:()=>void fe(e),disabled:G===e.id,children:G===e.id?a(`marketplace.org.installing`,{defaultValue:`Installing…`}):a(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,O.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,O.jsxs)(c,{children:[(0,O.jsxs)(_,{className:`pb-2`,children:[(0,O.jsx)(d,{className:`h-10 w-10 rounded-lg mb-2`}),(0,O.jsx)(d,{className:`h-5 w-3/4`}),(0,O.jsx)(d,{className:`h-4 w-1/2 mt-1`})]}),(0,O.jsx)(m,{children:(0,O.jsx)(d,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,O.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?a(`marketplace.noApprovedYet`):a(`marketplace.noMatchFilters`)}):(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:$.map(t=>{let n=de.get(t.manifest_id),r=T(t,E);return(0,O.jsxs)(c,{className:`cursor-pointer transition-colors hover:bg-accent/50 flex flex-col`,onClick:()=>e(`${j}/system/marketplace/${t.id}`),role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(`${j}/system/marketplace/${t.id}`))},"data-testid":`marketplace-card-${t.manifest_id}`,children:[(0,O.jsxs)(_,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(y,{className:`text-base truncate`,children:r.displayName}),(0,O.jsx)(x,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,O.jsx)(p,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,O.jsxs)(m,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||a(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,O.jsxs)(p,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(g,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,O.jsxs)(p,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(h,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),a(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,O.jsx)(p,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,O.jsx)(ce,{})}export{E as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BGDDiZfJ.js";import{Dt as r,l as i}from"./framework-B3O15Lsq.js";import{Bs as a,Hs as o,Us as s,cs as c}from"./ui-components-rkvkkTxO.js";function l(e,t,n){if(!(!e||t==null)){if(n){let r=e.find(e=>e.name===t&&e._packageId===n);if(r)return r}return e.find(e=>e.name===t)}}var u=e(n(),1),d=t();function f({sections:e,open:t}){if(!t)return null;let{t:n}=i(),[r,l]=(0,u.useState)([`0`]),[f,p]=(0,u.useState)(null),m=async(e,t)=>{try{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),p(t),setTimeout(()=>p(null),2e3)}catch(e){console.error(`Failed to copy:`,e)}},h=e=>{l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,d.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,d.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`layout.metadata.panelTitle`)}),(0,d.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:n(`layout.metadata.jsonBadge`)})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let i=String(t),l=r.includes(i),u=f===t;return(0,d.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,d.jsxs)(`button`,{onClick:()=>h(i),className:`flex-1 flex items-center justify-between text-left`,children:[(0,d.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),l?(0,d.jsx)(o,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,d.jsx)(a,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,d.jsx)(`button`,{onClick:()=>m(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:n(`layout.metadata.copyJson`),children:u?(0,d.jsx)(s,{className:`h-3 w-3 text-green-600`}):(0,d.jsx)(c,{className:`h-3 w-3 text-muted-foreground`})})]}),l&&(0,d.jsx)(`div`,{className:`px-4 pb-4`,children:(0,d.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,d.jsx)(`pre`,{className:`text-[11px] leading-relaxed p-3 overflow-auto max-h-96 font-mono text-foreground/90`,children:JSON.stringify(e.data,null,2)})})})]},t)})})]})}function p(){let[e,t]=(0,u.useState)((0,u.useMemo)(()=>{try{return typeof window<`u`?r(window.location.search).enabled:!1}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}export{p as n,l as r,f as t};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BGDDiZfJ.js";import{Dt as r,l as i}from"./framework-CBCX6Urh.js";import{Bs as a,Hs as o,Us as s,cs as c}from"./ui-components-BOOpjWsQ.js";function l(e,t,n){if(!(!e||t==null)){if(n){let r=e.find(e=>e.name===t&&e._packageId===n);if(r)return r}return e.find(e=>e.name===t)}}var u=e(n(),1),d=t();function f({sections:e,open:t}){if(!t)return null;let{t:n}=i(),[r,l]=(0,u.useState)([`0`]),[f,p]=(0,u.useState)(null),m=async(e,t)=>{try{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),p(t),setTimeout(()=>p(null),2e3)}catch(e){console.error(`Failed to copy:`,e)}},h=e=>{l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,d.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,d.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`layout.metadata.panelTitle`)}),(0,d.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:n(`layout.metadata.jsonBadge`)})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let i=String(t),l=r.includes(i),u=f===t;return(0,d.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,d.jsxs)(`button`,{onClick:()=>h(i),className:`flex-1 flex items-center justify-between text-left`,children:[(0,d.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),l?(0,d.jsx)(o,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,d.jsx)(a,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,d.jsx)(`button`,{onClick:()=>m(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:n(`layout.metadata.copyJson`),children:u?(0,d.jsx)(s,{className:`h-3 w-3 text-green-600`}):(0,d.jsx)(c,{className:`h-3 w-3 text-muted-foreground`})})]}),l&&(0,d.jsx)(`div`,{className:`px-4 pb-4`,children:(0,d.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,d.jsx)(`pre`,{className:`text-[11px] leading-relaxed p-3 overflow-auto max-h-96 font-mono text-foreground/90`,children:JSON.stringify(e.data,null,2)})})})]},t)})})]})}function p(){let[e,t]=(0,u.useState)((0,u.useMemo)(()=>{try{return typeof window<`u`?r(window.location.search).enabled:!1}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}export{p as n,l as r,f as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{d as t,f as n,r,y as i}from"./vendor-react-BGDDiZfJ.js";import{I as a}from"./framework-B3O15Lsq.js";import{n as o}from"./data-adapter-CdxWNPpK.js";import{i as s}from"./plugin-form-FeZEoC2R.js";import{a as c,o as l}from"./assistantBus-BFk4fCbM.js";var u=e(i(),1),d=r(),f=(0,u.createContext)(!1),p=`preview`,m=`draft`;function h(e){return new URLSearchParams(e).get(p)===m}var g=!1;function _(){g=!0}function v({force:e,children:r}){let i=t(),a=n(),o=(0,u.useMemo)(()=>h(i.search),[i.search]),[s,c]=(0,u.useState)(o);return(0,u.useEffect)(()=>{if(o){c(!0),g=!1;return}if(!s)return;if(g){g=!1,c(!1);return}let e=new URLSearchParams(i.search);e.set(p,m),a(`${i.pathname}?${e.toString()}${i.hash}`,{replace:!0})},[o,s,i.pathname,i.search,i.hash,a]),(0,d.jsx)(f.Provider,{value:e??(o||s),children:r})}function y(){return(0,u.useContext)(f)}var b=300*1e3,x=[`app`,`view`],S={apps:`app`,objects:`object`,dashboards:`dashboard`,reports:`report`,pages:`page`},C=`objectui:metadata:`;function w(){try{let e=import.meta;if(e&&e.env&&typeof e.env.MODE==`string`)return e.env.MODE!==`production`}catch{}return!1}var T=w();function E(...e){T&&console.debug(`[MetadataProvider]`,...e)}function D(e){return Array.isArray(e)?e:e&&typeof e==`object`&&`items`in e&&Array.isArray(e.items)?e.items:[]}function O(e){return e==null?null:typeof e==`object`&&`item`in e?e.item??null:e}function k(e){return!!e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`}function A(e){return!!e&&typeof e==`object`&&!!e.viewKind&&!!e.object}function j(e,t){if(!e.length||!t.length)return e;let n={},r=new Set;for(let e of t)A(e)&&r.add(e.object);for(let e of t){if(A(e)){let t=n[e.object]||={listViews:{},formViews:{}},r=e.name||`${e.object}.${e.viewKind}`,i=e.config&&typeof e.config==`object`?e.config:{},a={...i,name:r,label:e.label??i.label,isDefault:!!e.isDefault};e.viewKind===`form`?(t.formViews[r]=a,(e.isDefault||!t.form)&&(t.form=a)):(t.listViews[r]=a,e.isDefault&&(t.primary=a));continue}let t=e?.name||e?.list?.data?.object||e?.form?.data?.object;if(!t||r.has(t))continue;let i=n[t]||={listViews:{},formViews:{}};if(e.list){i.primary=e.list;let t=e.list.name||`list`;i.listViews[t]=e.list}if(e.form&&(i.form=e.form),e.listViews&&typeof e.listViews==`object`)for(let[t,n]of Object.entries(e.listViews))i.listViews[t]=n;if(e.formViews&&typeof e.formViews==`object`)for(let[t,n]of Object.entries(e.formViews))i.formViews[t]=n}return e.map(e=>{let t=n[e.name];if(!t)return e;let r=e.listViews||e.list_views||{},i=e.formViews||e.form_views||{},a={...e,listViews:{...t.listViews,...r}};return(Object.keys(t.formViews).length||Object.keys(i).length)&&(a.formViews={...t.formViews,...i}),t.primary&&!e.list&&(a.list=t.primary),t.form&&!e.form&&(a.form=t.form),a})}function M(e){if(!e?.length)return e;let t={};for(let n of e){let e=n?.fields;if(!e)continue;let r=Array.isArray(e)?e.map(e=>[e?.name,e]):Object.entries(e);for(let[e,i]of r){let r=i;if(!e||!r?.inlineEdit||r.type!==`master_detail`&&r.type!==`lookup`)continue;let a=r.reference;a&&(t[a]||=[]).push({childObject:n.name,relationshipField:e,inlineMode:s(n,r.inlineEdit,{relationshipField:e}),...r.inlineTitle?{title:r.inlineTitle}:{},...Array.isArray(r.inlineColumns)?{columns:r.inlineColumns}:{},...typeof r.inlineAmountField==`string`?{amountField:r.inlineAmountField}:{}})}}return Object.keys(t).length?e.map(e=>{let n=t[e.name];if(!n?.length)return e;let r={...e.form||{type:`simple`}},i=Array.isArray(r.subforms)?r.subforms:[],a=new Set(i.map(e=>e.childObject));r.subforms=[...n.filter(e=>!a.has(e.childObject)),...i];let o={...e,form:r};return e.formViews?.default&&(o.formViews={...e.formViews,default:{...e.formViews.default,subforms:r.subforms}}),o}):e}function N(){return{status:`idle`,items:[],byName:new Map,error:null,fetchedAt:0,promise:null}}function P(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(C+e);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function F(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(C+e,JSON.stringify(t))}catch{}}function I({children:e,adapter:t,ttlMs:n=b}){let r=(0,u.useRef)(new Map),i=(0,u.useRef)(new Map),s=(0,u.useRef)(t);s.current=t;let f=y(),p=(0,u.useMemo)(()=>f?new o({baseUrl:``,previewDrafts:!0}):null,[f]),m=(0,u.useRef)(p);m.current=p;let[h,g]=(0,u.useState)(0),_=(0,u.useCallback)(()=>{typeof queueMicrotask==`function`?queueMicrotask(()=>g(e=>e+1)):Promise.resolve().then(()=>g(e=>e+1))},[]);(0,u.useEffect)(()=>{r.current.clear(),i.current.clear(),_()},[f,_]);let v=(0,u.useCallback)(e=>{let t=r.current.get(e);return t||(t=N(),r.current.set(e,t)),t},[]),C=(0,u.useCallback)(e=>{let t=v(e);if(t.promise)return t.promise;if(t.status===`ready`&&Date.now()-t.fetchedAt<n)return E(`cache hit (fresh) type=${e} items=${t.items.length}`),Promise.resolve(t.items);let r=Date.now();t.status=`loading`,t.error=null;let i=m.current,a=(i?i.list(e):s.current.getClient().meta.getItems(e)).then(n=>{let a=D(n);t.items=a,t.status=`ready`,t.error=null,t.fetchedAt=Date.now(),t.promise=null,t.byName.clear();for(let e of a)k(e)&&t.byName.set(e.name,e);return e===`app`&&!i&&F(e,a),E(`fetched type=${e} items=${a.length} in ${Date.now()-r}ms`),_(),a}).catch(n=>{let r=n instanceof Error?n:Error(String(n));return t.status=`error`,t.error=r,t.promise=null,E(`fetch failed type=${e}`,r),_(),[]});return t.promise=a,a},[_,v,n]),w=(0,u.useCallback)((e,t)=>{let n=v(e);if(n.byName.has(t))return E(`item cache hit type=${e} name=${t}`),Promise.resolve(n.byName.get(t)??null);let r=i.current.get(e);r||(r=new Map,i.current.set(e,r));let a=r.get(t);if(a)return a;let o=Date.now(),c=m.current,l=(c?c.get(e,t):s.current.getClient().meta.getItem(e,t)).then(i=>{let a=O(i);return a&&n.byName.set(t,a),E(`fetched item type=${e} name=${t} in ${Date.now()-o}ms`),r.delete(t),a}).catch(n=>(r.delete(t),E(`fetch item failed type=${e} name=${t}`,n),null));return r.set(t,l),l},[v]),T=(0,u.useCallback)(async e=>{if(e){let t=v(e);t.fetchedAt=0,t.byName.clear(),await C(e);return}let t=Array.from(r.current.keys()).filter(e=>r.current.get(e).status!==`idle`);await Promise.all(t.map(e=>{let t=r.current.get(e);return t.fetchedAt=0,t.byName.clear(),C(e)}))},[C,v]),A=(0,u.useCallback)((e,t)=>{let n=r.current.get(e);n&&(t?(n.byName.delete(t),n.items=n.items.filter(e=>e?.name!==t),E(`invalidated type=${e} name=${t}`)):(n.status=`idle`,n.items=[],n.byName.clear(),n.error=null,n.fetchedAt=0,E(`invalidated type=${e}`)),_())},[_]);(0,u.useEffect)(()=>{if(f)return c(({type:e})=>{A(e)})},[f,A]),(0,u.useEffect)(()=>l(()=>{try{s.current?.clearCache?.()}catch{}T()}),[T]);let[I,L]=(0,u.useState)(!0),[R,z]=(0,u.useState)(null);(0,u.useEffect)(()=>{let e=!1,t=f?null:P(`app`);if(t){let e=v(`app`);e.items=t,e.status=`ready`,e.fetchedAt=0;for(let n of t)k(n)&&e.byName.set(n.name,n);_(),L(!1)}return(async()=>{for(let t of x)try{await C(t),e||z(null)}catch(t){e||z(t instanceof Error?t:Error(String(t)))}e||L(!1)})(),()=>{e=!0}},[t,C,v,_,f]);let B=(0,u.useMemo)(()=>{let e=e=>{let t=v(e);return t.status===`idle`&&C(e),t.items};return{apps:v(`app`).items,get objects(){let t=e(S.objects),n=e(`view`);return M(n.length?j(t,n):t)},get dashboards(){return e(S.dashboards)},get reports(){return e(S.reports)},get pages(){return e(S.pages)},loading:I,error:R??v(`app`).error,refresh:T,invalidate:A,ensureType:C,getItem:w,getItemsByType:t=>e(t),getTypeStatus:e=>v(e).status}},[h,I,R,C,w,v,T,A]);return(0,d.jsx)(a.Provider,{value:B,children:e})}export{y as a,_ as i,p as n,v as r,I as t};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{d as t,f as n,r,y as i}from"./vendor-react-BGDDiZfJ.js";import{I as a}from"./framework-CBCX6Urh.js";import{n as o}from"./data-adapter-BP-pyfs8.js";import{i as s}from"./plugin-form-CX8z6nsj.js";import{a as c,o as l}from"./assistantBus-BFk4fCbM.js";var u=e(i(),1),d=r(),f=(0,u.createContext)(!1),p=`preview`,m=`draft`;function h(e){return new URLSearchParams(e).get(p)===m}var g=!1;function _(){g=!0}function v({force:e,children:r}){let i=t(),a=n(),o=(0,u.useMemo)(()=>h(i.search),[i.search]),[s,c]=(0,u.useState)(o);return(0,u.useEffect)(()=>{if(o){c(!0),g=!1;return}if(!s)return;if(g){g=!1,c(!1);return}let e=new URLSearchParams(i.search);e.set(p,m),a(`${i.pathname}?${e.toString()}${i.hash}`,{replace:!0})},[o,s,i.pathname,i.search,i.hash,a]),(0,d.jsx)(f.Provider,{value:e??(o||s),children:r})}function y(){return(0,u.useContext)(f)}var b=300*1e3,x=[`app`,`view`],S={apps:`app`,objects:`object`,dashboards:`dashboard`,reports:`report`,pages:`page`},C=`objectui:metadata:`;function w(){try{let e=import.meta;if(e&&e.env&&typeof e.env.MODE==`string`)return e.env.MODE!==`production`}catch{}return!1}var T=w();function E(...e){T&&console.debug(`[MetadataProvider]`,...e)}function D(e){return Array.isArray(e)?e:e&&typeof e==`object`&&`items`in e&&Array.isArray(e.items)?e.items:[]}function O(e){return e==null?null:typeof e==`object`&&`item`in e?e.item??null:e}function k(e){return!!e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`}function A(e){return!!e&&typeof e==`object`&&!!e.viewKind&&!!e.object}function j(e,t){if(!e.length||!t.length)return e;let n={},r=new Set;for(let e of t)A(e)&&r.add(e.object);for(let e of t){if(A(e)){let t=n[e.object]||={listViews:{},formViews:{}},r=e.name||`${e.object}.${e.viewKind}`,i=e.config&&typeof e.config==`object`?e.config:{},a={...i,name:r,label:e.label??i.label,isDefault:!!e.isDefault};e.viewKind===`form`?(t.formViews[r]=a,(e.isDefault||!t.form)&&(t.form=a)):(t.listViews[r]=a,e.isDefault&&(t.primary=a));continue}let t=e?.name||e?.list?.data?.object||e?.form?.data?.object;if(!t||r.has(t))continue;let i=n[t]||={listViews:{},formViews:{}};if(e.list){i.primary=e.list;let t=e.list.name||`list`;i.listViews[t]=e.list}if(e.form&&(i.form=e.form),e.listViews&&typeof e.listViews==`object`)for(let[t,n]of Object.entries(e.listViews))i.listViews[t]=n;if(e.formViews&&typeof e.formViews==`object`)for(let[t,n]of Object.entries(e.formViews))i.formViews[t]=n}return e.map(e=>{let t=n[e.name];if(!t)return e;let r=e.listViews||e.list_views||{},i=e.formViews||e.form_views||{},a={...e,listViews:{...t.listViews,...r}};return(Object.keys(t.formViews).length||Object.keys(i).length)&&(a.formViews={...t.formViews,...i}),t.primary&&!e.list&&(a.list=t.primary),t.form&&!e.form&&(a.form=t.form),a})}function M(e){if(!e?.length)return e;let t={};for(let n of e){let e=n?.fields;if(!e)continue;let r=Array.isArray(e)?e.map(e=>[e?.name,e]):Object.entries(e);for(let[e,i]of r){let r=i;if(!e||!r?.inlineEdit||r.type!==`master_detail`&&r.type!==`lookup`)continue;let a=r.reference;a&&(t[a]||=[]).push({childObject:n.name,relationshipField:e,inlineMode:s(n,r.inlineEdit,{relationshipField:e}),...r.inlineTitle?{title:r.inlineTitle}:{},...Array.isArray(r.inlineColumns)?{columns:r.inlineColumns}:{},...typeof r.inlineAmountField==`string`?{amountField:r.inlineAmountField}:{}})}}return Object.keys(t).length?e.map(e=>{let n=t[e.name];if(!n?.length)return e;let r={...e.form||{type:`simple`}},i=Array.isArray(r.subforms)?r.subforms:[],a=new Set(i.map(e=>e.childObject));r.subforms=[...n.filter(e=>!a.has(e.childObject)),...i];let o={...e,form:r};return e.formViews?.default&&(o.formViews={...e.formViews,default:{...e.formViews.default,subforms:r.subforms}}),o}):e}function N(){return{status:`idle`,items:[],byName:new Map,error:null,fetchedAt:0,promise:null}}function P(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(C+e);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function F(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(C+e,JSON.stringify(t))}catch{}}function I({children:e,adapter:t,ttlMs:n=b}){let r=(0,u.useRef)(new Map),i=(0,u.useRef)(new Map),s=(0,u.useRef)(t);s.current=t;let f=y(),p=(0,u.useMemo)(()=>f?new o({baseUrl:``,previewDrafts:!0}):null,[f]),m=(0,u.useRef)(p);m.current=p;let[h,g]=(0,u.useState)(0),_=(0,u.useCallback)(()=>{typeof queueMicrotask==`function`?queueMicrotask(()=>g(e=>e+1)):Promise.resolve().then(()=>g(e=>e+1))},[]);(0,u.useEffect)(()=>{r.current.clear(),i.current.clear(),_()},[f,_]);let v=(0,u.useCallback)(e=>{let t=r.current.get(e);return t||(t=N(),r.current.set(e,t)),t},[]),C=(0,u.useCallback)(e=>{let t=v(e);if(t.promise)return t.promise;if(t.status===`ready`&&Date.now()-t.fetchedAt<n)return E(`cache hit (fresh) type=${e} items=${t.items.length}`),Promise.resolve(t.items);let r=Date.now();t.status=`loading`,t.error=null;let i=m.current,a=(i?i.list(e):s.current.getClient().meta.getItems(e)).then(n=>{let a=D(n);t.items=a,t.status=`ready`,t.error=null,t.fetchedAt=Date.now(),t.promise=null,t.byName.clear();for(let e of a)k(e)&&t.byName.set(e.name,e);return e===`app`&&!i&&F(e,a),E(`fetched type=${e} items=${a.length} in ${Date.now()-r}ms`),_(),a}).catch(n=>{let r=n instanceof Error?n:Error(String(n));return t.status=`error`,t.error=r,t.promise=null,E(`fetch failed type=${e}`,r),_(),[]});return t.promise=a,a},[_,v,n]),w=(0,u.useCallback)((e,t)=>{let n=v(e);if(n.byName.has(t))return E(`item cache hit type=${e} name=${t}`),Promise.resolve(n.byName.get(t)??null);let r=i.current.get(e);r||(r=new Map,i.current.set(e,r));let a=r.get(t);if(a)return a;let o=Date.now(),c=m.current,l=(c?c.get(e,t):s.current.getClient().meta.getItem(e,t)).then(i=>{let a=O(i);return a&&n.byName.set(t,a),E(`fetched item type=${e} name=${t} in ${Date.now()-o}ms`),r.delete(t),a}).catch(n=>(r.delete(t),E(`fetch item failed type=${e} name=${t}`,n),null));return r.set(t,l),l},[v]),T=(0,u.useCallback)(async e=>{if(e){let t=v(e);t.fetchedAt=0,t.byName.clear(),await C(e);return}let t=Array.from(r.current.keys()).filter(e=>r.current.get(e).status!==`idle`);await Promise.all(t.map(e=>{let t=r.current.get(e);return t.fetchedAt=0,t.byName.clear(),C(e)}))},[C,v]),A=(0,u.useCallback)((e,t)=>{let n=r.current.get(e);n&&(t?(n.byName.delete(t),n.items=n.items.filter(e=>e?.name!==t),E(`invalidated type=${e} name=${t}`)):(n.status=`idle`,n.items=[],n.byName.clear(),n.error=null,n.fetchedAt=0,E(`invalidated type=${e}`)),_())},[_]);(0,u.useEffect)(()=>{if(f)return c(({type:e})=>{A(e)})},[f,A]),(0,u.useEffect)(()=>l(()=>{try{s.current?.clearCache?.()}catch{}T()}),[T]);let[I,L]=(0,u.useState)(!0),[R,z]=(0,u.useState)(null);(0,u.useEffect)(()=>{let e=!1,t=f?null:P(`app`);if(t){let e=v(`app`);e.items=t,e.status=`ready`,e.fetchedAt=0;for(let n of t)k(n)&&e.byName.set(n.name,n);_(),L(!1)}return(async()=>{for(let t of x)try{await C(t),e||z(null)}catch(t){e||z(t instanceof Error?t:Error(String(t)))}e||L(!1)})(),()=>{e=!0}},[t,C,v,_,f]);let B=(0,u.useMemo)(()=>{let e=e=>{let t=v(e);return t.status===`idle`&&C(e),t.items};return{apps:v(`app`).items,get objects(){let t=e(S.objects),n=e(`view`);return M(n.length?j(t,n):t)},get dashboards(){return e(S.dashboards)},get reports(){return e(S.reports)},get pages(){return e(S.pages)},loading:I,error:R??v(`app`).error,refresh:T,invalidate:A,ensureType:C,getItem:w,getItemsByType:t=>e(t),getTypeStatus:e=>v(e).status}},[h,I,R,C,w,v,T,A]);return(0,d.jsx)(a.Provider,{value:B,children:e})}export{y as a,_ as i,p as n,v as r,I as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,m as r,r as i,y as a}from"./vendor-react-BGDDiZfJ.js";import{d as ee,f as o,n as s,t as c}from"./infrastructure-Bcx6-8du.js";import{l,q as u}from"./framework-B3O15Lsq.js";import{Fc as te,G as d,J as f,Or as ne,Ra as re,V as ie,W as p,Yi as ae,ji as oe,ns as m,xr as h}from"./ui-components-rkvkkTxO.js";import{t as se}from"./RecordDetailView-CzR6BAUv.js";import{r as g}from"./useMetadata-DO66YueM.js";import{t as _}from"./getIcon-B5xaQx5N.js";import{n as v,t as y}from"./CreateViewDialog-CMNLzv6j.js";import{a as b,i as x,n as ce,o as le,r as ue,s as de}from"./InterfaceListPage-B_B_Fttt.js";import{l as fe}from"./plugins-views-CibWNUsP.js";import{t as pe}from"./runtime-metadata-persistence-D1KKivGr.js";var S=e(a(),1),C=i();function w(e){let t=[];return e.forEach((e,n)=>{let r=/^filter\[(.+)\]$/.exec(n);r&&r[1]&&e!==``&&t.push([r[1],`=`,e])}),t}var T=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),E=4;function D({dataSource:e,objects:i}){let{appName:a,objectName:D}=r(),{t:O}=l(),{objectLabel:k,fieldLabel:A}=te(),j=t(),[M,N]=n(),{can:P}=s(),{canRead:F}=c(D??``),{user:I}=o(),L=ee(),R=g(),[z,B]=S.useState(!1),V=S.useMemo(()=>(i||[]).find(e=>e.name===D),[i,D]),[me]=S.useState(()=>de(new URLSearchParams(window.location.search))),he=S.useCallback(e=>{N(t=>le(t,e),{replace:!0})},[N]),H=Array.from(M.entries()).filter(([e])=>e.startsWith(`filter[`)).map(([e,t])=>`${e}=${t}`).join(`&`),U=S.useMemo(()=>{let e=w(new URLSearchParams(H)),t=e.filter(([e])=>F(e));if(t.length<e.length){let t=e.filter(([e])=>!F(e)).map(([e])=>e);console.warn(`[ObjectDataPage] Dropped URL filter(s) on unreadable field(s): ${t.join(`, `)}`)}return t.map(([e,t,n])=>n===`{current_user_id}`?[e,t,I?.id??n]:[e,t,n])},[H,F,I?.id]),ge=S.useCallback(e=>{N(t=>{let n=new URLSearchParams(t);return n.delete(`filter[${e}]`),n})},[N]),W=S.useMemo(()=>ue(V).filter(e=>F(e)),[V,F]),G=S.useMemo(()=>{let e=V?.fields;if(!e||typeof e!=`object`)return;let t=Object.entries(e).filter(([e,t])=>t&&!t.hidden&&T.has(t.type)&&F(e)).slice(0,E).map(([e])=>({field:e}));return t.length>0?{element:`dropdown`,fields:t}:void 0},[V,F]),K=S.useCallback(e=>`/apps/${a}/${D}/record/${encodeURIComponent(String(e))}`,[a,D]),q=u({navigation:{mode:`drawer`},objectName:D??``,onNavigate:e=>j(K(e))}),J=M.get(`recordId`),_e=S.useCallback((e,t)=>{let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(K(n),`_blank`);return}n!=null&&N(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t})},[K,N]),ve=S.useCallback(()=>{N(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[N]);S.useEffect(()=>{J&&!q.isOpen?q.open({id:J}):!J&&q.isOpen&&q.close()},[J]);let Y=S.useMemo(()=>b(V),[V]),X=S.useMemo(()=>ce(V),[V]),Z=S.useMemo(()=>x(V),[V]),Q=S.useMemo(()=>{let e=[`grid`];return Y&&e.push(`kanban`),X&&e.push(`calendar`),Z&&e.push(`gallery`),e},[Y,X,Z]),$=S.useMemo(()=>{if(V)return{type:`list-view`,objectName:V.name,viewType:`grid`,fields:W,...U.length?{filters:U}:{},kanban:Y,calendar:X,gallery:Z,userFilters:G,appearance:{allowedVisualizations:Q},showViewSwitcher:Q.length>1,showSearch:!0,showSort:!0,showFilters:!0,showGroup:!0,showHideFields:!0,showDensity:!0,showRecordCount:!0}},[V,W,U,Y,X,Z,G,Q]),ye=S.useCallback(async e=>{try{let t={...e,columns:Array.isArray(e.columns)&&e.columns.length>0?e.columns:W,...U.length?{filter:U}:{}},n=await pe(`view`,String(e?.name??e?.id??``),t,{metadataClient:R});n&&j(`../view/${n}`,{relative:`path`})}catch(e){console.error(`[ObjectDataPage] Failed to save view:`,e)}},[W,U,R,j]);return V?P(V.name,`read`)?(0,C.jsxs)(`div`,{className:`h-full flex flex-col bg-background min-w-0 overflow-hidden`,"data-testid":`object-data-page`,children:[(0,C.jsx)(`div`,{className:`hidden sm:block`,children:(0,C.jsx)(v,{title:(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`truncate`,children:k(V)}),(0,C.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:O(`console.objectData.badge`,{defaultValue:`Data`})})]}),description:O(`console.objectData.description`,{defaultValue:`URL-defined data slice — not bound to any saved view.`}),icon:S.createElement(_(V?.icon),{className:`h-4 w-4`}),actions:(0,C.jsxs)(C.Fragment,{children:[P(V.name,`create`)&&(0,C.jsxs)(h,{size:`sm`,onClick:()=>j(`../new`,{relative:`path`}),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-new-button`,children:[(0,C.jsx)(ae,{className:`h-4 w-4`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectView.new`)})]}),L&&(0,C.jsxs)(h,{size:`sm`,variant:`outline`,onClick:()=>B(!0),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-save-as-view`,children:[(0,C.jsx)(oe,{className:`h-4 w-4`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectData.saveAsView`,{defaultValue:`Save as view`})})]})]})})}),U.length>0&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b px-3 sm:px-4 py-2 shrink-0`,"data-testid":`object-data-filter-chips`,children:[(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`console.objectData.filteredBy`,{defaultValue:`Filtered by`})}),U.map(([e,,t])=>(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border bg-muted/40 px-2 py-0.5 text-xs`,children:[(0,C.jsx)(`span`,{className:`font-medium`,children:A(V.name,e,e)}),(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[`= `,String(t)]}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>ge(e),className:`ml-0.5 rounded-full hover:bg-muted p-0.5`,"aria-label":O(`console.objectData.removeFilter`,{defaultValue:`Remove filter {{field}}`,field:e}),"data-testid":`object-data-remove-filter-${e}`,children:(0,C.jsx)(ne,{className:`h-3 w-3`})})]},e))]}),(0,C.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:$&&(0,C.jsx)(fe,{schema:$,dataSource:e,userFilterSelections:me,onUserFilterSelectionsChange:he,onRowClick:_e})}),q.isOverlay&&(0,C.jsx)(ie,{...q,setIsOpen:e=>{e||ve()},title:k(V),children:t=>(0,C.jsx)(se,{objectNameOverride:V.name,recordIdOverride:String(t?.id??t?._id??J??``),embedded:!0,dataSource:e,objects:i,onEdit:()=>{}})}),L&&(0,C.jsx)(y,{open:z,onOpenChange:B,onCreate:ye,objectDef:V})]}):(0,C.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`object-data-403`,children:(0,C.jsxs)(p,{children:[(0,C.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,C.jsx)(re,{className:`h-6 w-6 text-muted-foreground`})}),(0,C.jsx)(f,{children:O(`console.objectData.noAccessTitle`,{defaultValue:`Access denied`})}),(0,C.jsx)(d,{children:O(`console.objectData.noAccess`,{defaultValue:`You do not have permission to view this data.`})})]})}):(0,C.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,C.jsxs)(p,{children:[(0,C.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,C.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,C.jsx)(f,{children:O(`console.objectView.objectNotFound`)}),(0,C.jsx)(d,{children:O(`console.objectView.objectNotFoundDescription`,{objectName:D})})]})})}export{D as ObjectDataPage};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{f as t,h as n,m as r,r as i,y as a}from"./vendor-react-BGDDiZfJ.js";import{d as ee,f as o,n as s,t as c}from"./infrastructure-ASGyCRMg.js";import{l,q as u}from"./framework-CBCX6Urh.js";import{Fc as te,G as d,J as f,Or as ne,Ra as re,V as ie,W as p,Yi as ae,ji as oe,ns as m,xr as h}from"./ui-components-BOOpjWsQ.js";import{t as se}from"./RecordDetailView-CUcCVoa1.js";import{r as g}from"./useMetadata-D-bLZoNN.js";import{t as _}from"./getIcon-Ci4w4xXM.js";import{n as v,t as y}from"./CreateViewDialog-CboUdp-q.js";import{a as b,i as x,n as ce,o as le,r as ue,s as de}from"./InterfaceListPage-CwGb2Th3.js";import{l as fe}from"./plugins-views-BVxwkRdi.js";import{t as pe}from"./runtime-metadata-persistence-D1KKivGr.js";var S=e(a(),1),C=i();function w(e){let t=[];return e.forEach((e,n)=>{let r=/^filter\[(.+)\]$/.exec(n);r&&r[1]&&e!==``&&t.push([r[1],`=`,e])}),t}var T=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),E=4;function D({dataSource:e,objects:i}){let{appName:a,objectName:D}=r(),{t:O}=l(),{objectLabel:k,fieldLabel:A}=te(),j=t(),[M,N]=n(),{can:P}=s(),{canRead:F}=c(D??``),{user:I}=o(),L=ee(),R=g(),[z,B]=S.useState(!1),V=S.useMemo(()=>(i||[]).find(e=>e.name===D),[i,D]),[me]=S.useState(()=>de(new URLSearchParams(window.location.search))),he=S.useCallback(e=>{N(t=>le(t,e),{replace:!0})},[N]),H=Array.from(M.entries()).filter(([e])=>e.startsWith(`filter[`)).map(([e,t])=>`${e}=${t}`).join(`&`),U=S.useMemo(()=>{let e=w(new URLSearchParams(H)),t=e.filter(([e])=>F(e));if(t.length<e.length){let t=e.filter(([e])=>!F(e)).map(([e])=>e);console.warn(`[ObjectDataPage] Dropped URL filter(s) on unreadable field(s): ${t.join(`, `)}`)}return t.map(([e,t,n])=>n===`{current_user_id}`?[e,t,I?.id??n]:[e,t,n])},[H,F,I?.id]),ge=S.useCallback(e=>{N(t=>{let n=new URLSearchParams(t);return n.delete(`filter[${e}]`),n})},[N]),W=S.useMemo(()=>ue(V).filter(e=>F(e)),[V,F]),G=S.useMemo(()=>{let e=V?.fields;if(!e||typeof e!=`object`)return;let t=Object.entries(e).filter(([e,t])=>t&&!t.hidden&&T.has(t.type)&&F(e)).slice(0,E).map(([e])=>({field:e}));return t.length>0?{element:`dropdown`,fields:t}:void 0},[V,F]),K=S.useCallback(e=>`/apps/${a}/${D}/record/${encodeURIComponent(String(e))}`,[a,D]),q=u({navigation:{mode:`drawer`},objectName:D??``,onNavigate:e=>j(K(e))}),J=M.get(`recordId`),_e=S.useCallback((e,t)=>{let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(K(n),`_blank`);return}n!=null&&N(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t})},[K,N]),ve=S.useCallback(()=>{N(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[N]);S.useEffect(()=>{J&&!q.isOpen?q.open({id:J}):!J&&q.isOpen&&q.close()},[J]);let Y=S.useMemo(()=>b(V),[V]),X=S.useMemo(()=>ce(V),[V]),Z=S.useMemo(()=>x(V),[V]),Q=S.useMemo(()=>{let e=[`grid`];return Y&&e.push(`kanban`),X&&e.push(`calendar`),Z&&e.push(`gallery`),e},[Y,X,Z]),$=S.useMemo(()=>{if(V)return{type:`list-view`,objectName:V.name,viewType:`grid`,fields:W,...U.length?{filters:U}:{},kanban:Y,calendar:X,gallery:Z,userFilters:G,appearance:{allowedVisualizations:Q},showViewSwitcher:Q.length>1,showSearch:!0,showSort:!0,showFilters:!0,showGroup:!0,showHideFields:!0,showDensity:!0,showRecordCount:!0}},[V,W,U,Y,X,Z,G,Q]),ye=S.useCallback(async e=>{try{let t={...e,columns:Array.isArray(e.columns)&&e.columns.length>0?e.columns:W,...U.length?{filter:U}:{}},n=await pe(`view`,String(e?.name??e?.id??``),t,{metadataClient:R});n&&j(`../view/${n}`,{relative:`path`})}catch(e){console.error(`[ObjectDataPage] Failed to save view:`,e)}},[W,U,R,j]);return V?P(V.name,`read`)?(0,C.jsxs)(`div`,{className:`h-full flex flex-col bg-background min-w-0 overflow-hidden`,"data-testid":`object-data-page`,children:[(0,C.jsx)(`div`,{className:`hidden sm:block`,children:(0,C.jsx)(v,{title:(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,C.jsx)(`span`,{className:`truncate`,children:k(V)}),(0,C.jsx)(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:O(`console.objectData.badge`,{defaultValue:`Data`})})]}),description:O(`console.objectData.description`,{defaultValue:`URL-defined data slice — not bound to any saved view.`}),icon:S.createElement(_(V?.icon),{className:`h-4 w-4`}),actions:(0,C.jsxs)(C.Fragment,{children:[P(V.name,`create`)&&(0,C.jsxs)(h,{size:`sm`,onClick:()=>j(`../new`,{relative:`path`}),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-new-button`,children:[(0,C.jsx)(ae,{className:`h-4 w-4`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectView.new`)})]}),L&&(0,C.jsxs)(h,{size:`sm`,variant:`outline`,onClick:()=>B(!0),className:`shadow-none gap-1.5 h-8 sm:h-9`,"data-testid":`object-data-save-as-view`,children:[(0,C.jsx)(oe,{className:`h-4 w-4`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:O(`console.objectData.saveAsView`,{defaultValue:`Save as view`})})]})]})})}),U.length>0&&(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 border-b px-3 sm:px-4 py-2 shrink-0`,"data-testid":`object-data-filter-chips`,children:[(0,C.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:O(`console.objectData.filteredBy`,{defaultValue:`Filtered by`})}),U.map(([e,,t])=>(0,C.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border bg-muted/40 px-2 py-0.5 text-xs`,children:[(0,C.jsx)(`span`,{className:`font-medium`,children:A(V.name,e,e)}),(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[`= `,String(t)]}),(0,C.jsx)(`button`,{type:`button`,onClick:()=>ge(e),className:`ml-0.5 rounded-full hover:bg-muted p-0.5`,"aria-label":O(`console.objectData.removeFilter`,{defaultValue:`Remove filter {{field}}`,field:e}),"data-testid":`object-data-remove-filter-${e}`,children:(0,C.jsx)(ne,{className:`h-3 w-3`})})]},e))]}),(0,C.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto`,children:$&&(0,C.jsx)(fe,{schema:$,dataSource:e,userFilterSelections:me,onUserFilterSelectionsChange:he,onRowClick:_e})}),q.isOverlay&&(0,C.jsx)(ie,{...q,setIsOpen:e=>{e||ve()},title:k(V),children:t=>(0,C.jsx)(se,{objectNameOverride:V.name,recordIdOverride:String(t?.id??t?._id??J??``),embedded:!0,dataSource:e,objects:i,onEdit:()=>{}})}),L&&(0,C.jsx)(y,{open:z,onOpenChange:B,onCreate:ye,objectDef:V})]}):(0,C.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`object-data-403`,children:(0,C.jsxs)(p,{children:[(0,C.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,C.jsx)(re,{className:`h-6 w-6 text-muted-foreground`})}),(0,C.jsx)(f,{children:O(`console.objectData.noAccessTitle`,{defaultValue:`Access denied`})}),(0,C.jsx)(d,{children:O(`console.objectData.noAccess`,{defaultValue:`You do not have permission to view this data.`})})]})}):(0,C.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,C.jsxs)(p,{children:[(0,C.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,C.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,C.jsx)(f,{children:O(`console.objectView.objectNotFound`)}),(0,C.jsx)(d,{children:O(`console.objectView.objectNotFoundDescription`,{objectName:D})})]})})}export{D as ObjectDataPage};
@@ -0,0 +1 @@
1
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{d as n,f as r,h as i,m as a,r as o,y as s}from"./vendor-react-BGDDiZfJ.js";import{d as c,f as l,m as u,n as d}from"./infrastructure-ASGyCRMg.js";import{H as f,L as p,R as m,Y as h,b as g,l as _}from"./framework-CBCX6Urh.js";import{B as v,Fc as y,Fo as b,G as x,J as S,W as C,_r as w,fr as T,gr as E,hr as D,mr as O,na as k,vr as A,xr as j,yr as M}from"./ui-components-BOOpjWsQ.js";import{r as N}from"./vendor-ui-utils-BzQBRdq3.js";import"./MetadataProvider-seOmvY8N.js";import{r as P}from"./ExpressionProvider-B3pkCzAo.js";import{c as ee,i as te,l as ne,r as re,u as ie}from"./RecordDetailView-CUcCVoa1.js";import{n as F,r as I,t as L}from"./MetadataInspector-DwPx9ueN.js";import{t as R}from"./InterfaceListPage-CwGb2Th3.js";var z=e(s(),1),B=o();function V(e,t){if(/^https?:\/\//i.test(e)||e.startsWith(`mailto:`))return{href:e,external:!e.startsWith(`mailto:`)};let n=(t||``).replace(/\/+$/,``);return{href:`${n}${e}`,external:!!n}}function H({cta:e,apiBase:t,primary:n,onNavigate:r}){let{href:i,external:a}=V(e.url,t);return(0,B.jsx)(j,{asChild:!0,variant:n?`default`:`outline`,size:`sm`,children:(0,B.jsx)(`a`,{href:i,onClick:r,...a?{target:`_blank`,rel:`noopener noreferrer`}:{},"data-testid":`entitlement-cta-${n?`primary`:`secondary`}`,children:e.label})})}function ae({state:e,apiBase:t,onOpenChange:n}){let r=e.spec;return(0,B.jsx)(T,{open:e.open,onOpenChange:e=>{e||n(!1)},children:(0,B.jsxs)(D,{"data-testid":`environment-entitlement-dialog`,children:[(0,B.jsxs)(A,{children:[(0,B.jsx)(M,{children:r?.title}),(0,B.jsx)(E,{children:r?.message})]}),(0,B.jsxs)(w,{children:[(0,B.jsx)(O,{children:`Close`}),r?.secondaryCta&&(0,B.jsx)(H,{cta:r.secondaryCta,apiBase:t,primary:!1,onNavigate:()=>n(!1)}),r?.cta&&(0,B.jsx)(H,{cta:r.cta,apiBase:t,primary:!0,onNavigate:()=>n(!1)})]})]})})}var U=new Set([`DEV_ENV_PLAN_LOCKED`,`DEV_ENV_LIMIT`,`PRODUCTION_ENV_LIMIT`]);function W(e){return typeof e==`string`&&U.has(e)}var G=`/settings/billing`;function oe(e){let t=e?.code;if(!W(t))return null;let n=typeof e?.error==`string`&&e.error?e.error:typeof e?.message==`string`?e.message:``,r=typeof e?.upgrade_url==`string`&&e.upgrade_url?e.upgrade_url:G,i=typeof e?.contact_url==`string`&&e.contact_url?e.contact_url:``;return t===`PRODUCTION_ENV_LIMIT`?{code:t,title:`You already have your production environment`,message:n||`Each organization includes exactly one production environment. Create a separate organization for another, or contact us about an Enterprise arrangement.`,cta:i?{label:`Contact sales`,url:i}:void 0}:{code:t,title:t===`DEV_ENV_PLAN_LOCKED`?`Development environments are a paid feature`:`Development environment limit reached`,message:n||(t===`DEV_ENV_PLAN_LOCKED`?`Your free plan includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`:`Capacity scales with AI seats. Add an AI seat, or archive an unused development environment to free one up.`),cta:{label:`Upgrade plan`,url:r}}}function K(e){return e.hasProductionEnv?e.canCreateDevelopmentEnv===!1?`upgrade_for_development`:`add_development`:`setup_production`}function q(e){return{code:`DEV_ENV_PLAN_LOCKED`,title:`Development environments are a paid feature`,message:`${e.plan&&e.plan!==`free`?`your ${e.plan} plan`:`your free plan`} includes one production environment. Upgrade to add development environments — build in dev, then publish to production.`,cta:{label:`Upgrade plan`,url:e.upgradeUrl||`/settings/billing`}}}var J=/^\s*\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}\s*$/;function Y(e,t){let n=t;for(let t of e.split(`.`)){if(n==null)return;n=n[t]}return n}function se(e,t){if(!e.includes(`{{`))return e;let n=e.match(J);if(n){let e=Y(n[1],t);return e===void 0?``:e}return e.replace(/\{\{\s*page\.([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*\}\}/g,(e,n)=>{let r=Y(n,t);return r==null?``:String(r)})}function X(e,t){if(typeof e==`string`)return se(e,t);if(Array.isArray(e))return e.map(e=>X(e,t));if(e&&typeof e==`object`){let n={};for(let[r,i]of Object.entries(e))n[r]=X(i,t);return n}return e}function Z(e,t){return t?X(e,t):e}var ce={id:`current-user`,name:`Demo User`,isPlatformAdmin:!1};function Q(e){let t=e.locations;return Array.isArray(t)?t.some(e=>e===`list_item`||e===`record_header`||e===`record_more`||e===`record_section`):!1}function $(e){let{dataSource:t,objects:n,objectName:i,onRefresh:a}=e,o=r(),{user:s,activeOrganization:c}=l(),{systemPermissions:f}=d(),{fieldLabel:p,fieldOptionLabel:m,actionParamText:h,actionParamOptionLabel:_,actionDescription:v}=y(),b=(0,z.useMemo)(()=>i?n?.find(e=>e.name===i):void 0,[n,i]),x=i||b?.name,S=(0,z.useCallback)(()=>{a?.()},[a]),C=g({dataSource:t,onUndo:()=>{S(),N.success(`Change undone`)}}),[w,T]=(0,z.useState)({open:!1,message:``}),[E,D]=(0,z.useState)({open:!1,params:[]}),[O,k]=(0,z.useState)({open:!1}),[A,j]=(0,z.useState)(null),[M,P]=(0,z.useState)({open:!1}),F=(0,z.useRef)(new Set),I=(0,z.useCallback)((e,t)=>new Promise(n=>{k({open:!0,spec:e,data:t,resolve:n})}),[]),L=(0,z.useCallback)((e,t)=>new Promise(n=>{T({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,z.useCallback)((e,t)=>new Promise(r=>{let a=t?.params&&!Array.isArray(t.params)?t.params._rowRecord:void 0,o=typeof t?.objectName==`string`&&t.objectName?t.objectName:void 0,s=re(e,{objectName:o||i||b?.name||``,objects:n||[],fieldLabel:p,fieldOptionLabel:m,row:a}),c=o||i||b?.name,l=s.map(e=>({...e,label:h(c,t?.name,e.name,`label`,e.label)??e.label,placeholder:h(c,t?.name,e.name,`placeholder`,e.placeholder)??e.placeholder,helpText:h(c,t?.name,e.name,`helpText`,e.helpText)??e.helpText,options:Array.isArray(e.options)?e.options.map(n=>({...n,label:_(c,t?.name,e.name,n.value,n.label)})):e.options}));D({open:!0,params:l,title:t?.label||t?.title,description:v(c,t?.name,t?.description),resolve:r})}),[i,b,n,p,m,h,_]),V=s?{id:s.id,name:s.name,avatar:s.image,isPlatformAdmin:s?.isPlatformAdmin??!1,systemPermissions:f??[]}:{...ce,systemPermissions:f??[]},H=(0,z.useCallback)((e,t)=>{if(t?.type===`error`){N.error(e);return}if(t?.undo){N.success(e,{duration:t.duration,action:{label:t.undo.label||`Undo`,onClick:()=>{C.undo()}}});return}N.success(e,{duration:t?.duration})},[C]),U=(0,z.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):o(e)},[o]),W=(0,z.useMemo)(()=>u(),[]),G=(0,z.useCallback)(e=>{P({open:!0,spec:e})},[]),K=(0,z.useCallback)(async(e,n)=>{try{let r=e.target||e.name,i=e.params||{},a=typeof r==`string`?r:``;if(a.startsWith(`/`)||/^https?:\/\//i.test(a)){let t={...i},r=t._rowRecord;delete t._rowRecord;let o=n?.pageVariables??void 0,s=Z(t,o),l=a;r&&/\{[a-z_][a-z0-9_]*\}/i.test(l)&&(l=l.replace(/\{([a-z_][a-z0-9_]*)\}/gi,(e,t)=>{let n=r[t];return n==null?``:encodeURIComponent(String(n))}));let u=l.startsWith(`http`)?l:`${l}`,d=e.bodyShape&&typeof e.bodyShape==`object`&&e.bodyShape.wrap?e.bodyShape.wrap:void 0,f=d?{[d]:s}:{...s};if(r&&e.recordIdParam){let t=r[e.recordIdField||`id`];t!=null&&(f[e.recordIdParam]=t)}/\/api\/v1\/auth\//.test(l)&&!f.organizationId&&c?.id&&(f.organizationId=c.id),e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(f,Z(e.bodyExtra,o));let p=(e.method||`POST`).toUpperCase(),m={method:p,headers:{"Content-Type":`application/json`},credentials:`include`};p!==`GET`&&p!==`DELETE`&&(m.body=JSON.stringify(f));let h=await W(u,m);if(!h.ok){let e=null;try{e=await h.json()}catch{}let t=oe(e);return t?(G(t),{success:!1}):{success:!1,error:e?.error||e?.message||`HTTP ${h.status}`}}let g=await h.json().catch(()=>({}));return e.refreshAfter!==!1&&S(),{success:!0,data:g,reload:e.refreshAfter!==!1}}let o=e.objectName||x,s=i._rowRecord,l={...i};delete l._rowRecord;let u=l.recordId??s?.[e.recordIdField||`id`];delete l.recordId,e.bodyExtra&&typeof e.bodyExtra==`object`&&Object.assign(l,e.bodyExtra),o&&typeof t?.execute==`function`?await t.execute(o,r,l):o&&u&&Object.keys(l).length>0&&typeof t?.update==`function`&&await t.update(o,u,l);let d;if(e.undoable&&o&&u&&s&&Object.keys(l).length>0&&typeof t?.update==`function`){let t={};for(let e of Object.keys(l))t[e]=s[e]??null;d={id:`undo-${o}-${u}-${Date.now()}`,type:`update`,objectName:o,recordId:String(u),timestamp:Date.now(),description:e.label||`Undo ${o}`,undoData:t,redoData:{...l}}}let f=e.refreshAfter!==!1;return f&&S(),{success:!0,reload:f,undo:d}}catch(e){return{success:!1,error:e.message}}},[t,x,W,c,S,G]),q=(0,z.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 n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)a=n[0]?.id;else if(n.length>1)return{success:!1,error:`This flow runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This flow runs on a single record — select a row first.`}}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||x,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 j({flowName:n,runId:c.runId,screen:c.screen}),{success:!0,silent:!0};let l=e.refreshAfter!==!1;return l&&S(),{success:!0,data:s?.data,reload:l}}catch(e){return{success:!1,error:e.message}}},[W,x,S]),J=(0,z.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 n=Array.isArray(t?.selectedRecords)?t.selectedRecords:[];if(n.length===1)o=n[0]?.[a];else if(n.length>1)return{success:!1,error:`This action runs on a single record — select exactly one row.`};else if(Q(e))return{success:!1,error:`This action runs on a single record — select a row first.`}}let s=`${n}:${o??``}`;if(F.current.has(s))return{success:!1,error:`Action already in progress`};F.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||N(`浏览器拦截了弹窗 / Popup blocked`,{description:`点击在新标签页打开环境`,action:{label:`打开环境`,onClick:()=>{try{window.open(n,`_blank`)}catch{window.location.href=n}}},duration:1e4})}return e.refreshAfter===!0&&S(),{success:!0}}let i=e.objectName||x||`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{success:!1,error:e}}let l=e.refreshAfter!==!1;l&&S();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||N(`浏览器拦截了弹窗 / 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{}return{success:!1,error:e.message}}finally{F.current.delete(s)}},[W,x,S]);return{confirmHandler:L,toastHandler:H,navigateHandler:U,paramCollectionHandler:R,resultDialogHandler:I,apiHandler:K,flowHandler:q,serverActionHandler:J,authFetch:W,openEntitlementDialog:G,actionProviderProps:(0,z.useMemo)(()=>({context:{...i?{objectName:i}:{},user:V,apiBase:``,activeOrganization:c?{id:c.id,slug:c.slug,name:c.name}:null},onConfirm:L,onToast:H,onNavigate:U,onParamCollection:R,onResultDialog:I,handlers:{api:K,flow:q,script:J,modal:J}}),[i,V,c,L,H,U,R,I,K,q,J]),dialogs:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(ie,{state:w,onOpenChange:e=>{e||T({open:!1,message:``})}}),(0,B.jsx)(ne,{state:E,onOpenChange:e=>{e||D({open:!1,params:[]})}}),(0,B.jsx)(ee,{state:O,onAcknowledge:()=>{O.resolve?.(),k({open:!1})}}),(0,B.jsx)(te,{state:A,authFetch:W,baseUrl:``,dataSource:t,objects:n,onClose:()=>j(null),onComplete:()=>{j(null),S()}}),(0,B.jsx)(ae,{state:M,apiBase:``,onOpenChange:e=>{e||P({open:!1})}})]})}}function le({children:e,...t}){let n=$(t);return(0,B.jsxs)(f,{...n.actionProviderProps,children:[e,n.dialogs]})}var ue=t({PageView:()=>de});function de(){let{t:e}=_(),{pageName:t}=a(),[o]=i(),{showDebug:s}=F(),l=r(),u=n(),d=c(),{pages:f,objects:g,getTypeStatus:y}=m(),{app:w}=P(),T=p(),[E,D]=(0,z.useState)(0),O=I(f,t,w?._packageId);if(!O){let n=y?.(`page`);return n===`idle`||n===`loading`?(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,"data-testid":`page-loading`,children:(0,B.jsx)(v,{className:`h-5 w-5 text-muted-foreground`})}):(0,B.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,B.jsxs)(C,{children:[(0,B.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,B.jsx)(b,{className:`h-6 w-6 text-muted-foreground`})}),(0,B.jsx)(S,{children:e(`empty.pageNotFound`)}),(0,B.jsx)(x,{children:e(`empty.pageNotFoundDescription`,{name:t})})]})})}let A=Object.fromEntries(o.entries()),j=u.pathname.match(/\/apps\/([^/]+)/)?.[1],M=d&&!!j&&!!t;return(0,B.jsx)(le,{dataSource:T,objects:g,onRefresh:()=>D(e=>e+1),children:(0,B.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative`,children:[M&&(0,B.jsx)(`button`,{type:`button`,onClick:()=>{M&&l(`/apps/${j}/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,B.jsx)(k,{className:`h-3.5 w-3.5`})}),O.interfaceConfig?.source?(0,B.jsx)(R,{page:O,reserveEditAffordance:M},E):(0,B.jsx)(h,{schema:{...O,type:O.type||`page`,context:{...O.context,params:A,refreshKey:E}}},E)]}),(0,B.jsx)(L,{open:s,sections:[{title:`Page Configuration`,data:O}]})]})})}export{q as a,K as i,$ as n,G as r,ue as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BGDDiZfJ.js";import{f as r,o as i}from"./infrastructure-Bcx6-8du.js";import{$n as a,Br as o,Lr as s,Or as c,Ps as l,Ra as u,ar as d,cr as f,dn as p,er as m,js as h,lr as g,nr as _,or as v,rr as y,sn as b,sr as x,tr as S,ur as C,w,xr as T,za as E}from"./ui-components-rkvkkTxO.js";var D=e(n(),1),O=t();function k(){let{user:e,updateUser:t,isLoading:n,changePassword:u,setInitialPassword:k,hasLocalPassword:j}=r(),{upload:M}=w(),[N,P]=(0,D.useState)(e?.name??``),[F,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(null),z=(0,D.useRef)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null);return(0,D.useEffect)(()=>{P(e?.name??``)},[e?.name]),e?(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Profile`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage your account settings`})]}),(0,O.jsx)(a,{children:(0,O.jsxs)(m,{className:`pt-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(v,{className:`h-16 w-16`,children:[(0,O.jsx)(f,{src:e.image??void 0,alt:e.name??`User`}),(0,O.jsx)(x,{className:`text-lg bg-primary text-primary-foreground`,children:i(e)})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:e.name??`User`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:e.email}),(0,O.jsx)(d,{variant:`secondary`,className:`mt-1`,children:e.role??`member`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0`,children:[(0,O.jsx)(`input`,{ref:z,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];if(z.current&&(z.current.value=``),n){V(!0),U(null);try{let e=await M(n);await t({image:e.url})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},"data-testid":`profile-avatar-file`}),(0,O.jsxs)(T,{type:`button`,variant:`outline`,size:`sm`,disabled:B,onClick:()=>z.current?.click(),"data-testid":`profile-avatar-upload-btn`,children:[B?(0,O.jsx)(E,{className:`mr-2 h-4 w-4 animate-spin`}):(0,O.jsx)(o,{className:`mr-2 h-4 w-4`}),e.image?`Replace`:`Upload`]}),e.image&&(0,O.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,disabled:B,onClick:async()=>{V(!0),U(null);try{await t({image:null})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}},"data-testid":`profile-avatar-remove-btn`,children:[(0,O.jsx)(c,{className:`mr-2 h-4 w-4`}),`Remove`]})]})]}),H&&(0,O.jsxs)(g,{variant:`destructive`,className:`mt-4`,children:[(0,O.jsx)(l,{className:`h-4 w-4`}),(0,O.jsx)(C,{children:H})]})]})}),(0,O.jsxs)(a,{children:[(0,O.jsxs)(_,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(s,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(y,{className:`text-base sm:text-lg`,children:`Personal Information`})]}),(0,O.jsx)(S,{children:`Update your name and view account details`})]}),(0,O.jsx)(m,{children:(0,O.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),R(null),I(!1);try{await t({name:N}),I(!0)}catch(e){R(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[L&&(0,O.jsxs)(g,{variant:`destructive`,children:[(0,O.jsx)(l,{className:`h-4 w-4`}),(0,O.jsx)(C,{children:L})]}),F&&(0,O.jsxs)(g,{children:[(0,O.jsx)(h,{className:`h-4 w-4 text-green-600`}),(0,O.jsx)(C,{className:`text-green-800 dark:text-green-400`,children:`Profile updated successfully.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{htmlFor:`profile-name`,children:`Name`}),(0,O.jsx)(b,{id:`profile-name`,type:`text`,value:N,onChange:e=>P(e.target.value),required:!0,"aria-required":`true`,disabled:n})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{htmlFor:`profile-email`,children:`Email`}),(0,O.jsx)(b,{id:`profile-email`,type:`email`,value:e.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Email cannot be changed.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{children:`Role`}),(0,O.jsx)(b,{type:`text`,value:e.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,O.jsx)(T,{type:`submit`,disabled:n,className:`w-full sm:w-auto`,children:n?`Saving…`:`Save Changes`})]})})]}),(0,O.jsx)(A,{changePassword:u,setInitialPassword:k,hasLocalPassword:j})]}):null}function A({changePassword:e,setInitialPassword:t,hasLocalPassword:n,highlight:r,onPasswordSet:i}){let[o,s]=(0,D.useState)(null),[c,d]=(0,D.useState)(``),[f,v]=(0,D.useState)(``),[x,w]=(0,D.useState)(``),[E,k]=(0,D.useState)(!1),[A,j]=(0,D.useState)(null),[M,N]=(0,D.useState)(null);(0,D.useEffect)(()=>{let e=!1;return n().then(t=>{e||s(t)}).catch(()=>{e||s(!1)}),()=>{e=!0}},[n]);let P=()=>{d(``),v(``),w(``)},F=async n=>{if(n.preventDefault(),j(null),N(null),f.length<8){j(`Password must be at least 8 characters`);return}if(f!==x){j(`Passwords do not match`);return}k(!0);try{if(o){if(!c){j(`Enter your current password`),k(!1);return}await e(c,f),N(`Password changed.`)}else await t(f),N(`Local password set. You can now sign in with email and password on this environment.`),s(!0),i?.();P()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},I=o===null;return(0,O.jsxs)(a,{className:r?`ring-2 ring-amber-300 dark:ring-amber-700`:void 0,children:[(0,O.jsxs)(_,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(u,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(y,{className:`text-base sm:text-lg`,children:o?`Change Password`:`Set Local Password`})]}),(0,O.jsx)(S,{children:o?`Update the password you use to sign in to this environment.`:`You signed in via single sign-on. Set a local password to also sign in with email and password on this environment.`})]}),(0,O.jsx)(m,{children:(0,O.jsxs)(`form`,{onSubmit:F,className:`space-y-4 max-w-md`,children:[o&&(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{htmlFor:`current-password`,children:`Current password`}),(0,O.jsx)(b,{id:`current-password`,type:`password`,autoComplete:`current-password`,value:c,onChange:e=>d(e.target.value),disabled:E||I,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{htmlFor:`new-password`,children:o?`New password`:`Password`}),(0,O.jsx)(b,{id:`new-password`,type:`password`,autoComplete:`new-password`,value:f,onChange:e=>v(e.target.value),disabled:E||I,minLength:8,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{htmlFor:`confirm-password`,children:`Confirm password`}),(0,O.jsx)(b,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,value:x,onChange:e=>w(e.target.value),disabled:E||I,minLength:8,required:!0})]}),A&&(0,O.jsxs)(g,{variant:`destructive`,children:[(0,O.jsx)(l,{className:`h-4 w-4`}),(0,O.jsx)(C,{children:A})]}),M&&(0,O.jsxs)(g,{children:[(0,O.jsx)(h,{className:`h-4 w-4`}),(0,O.jsx)(C,{children:M})]}),(0,O.jsx)(T,{type:`submit`,disabled:E||I,className:`w-full sm:w-auto`,children:E?`Saving…`:o?`Change password`:`Set password`})]})})]})}export{k as ProfilePage};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BGDDiZfJ.js";import{f as r,o as i}from"./infrastructure-ASGyCRMg.js";import{$n as a,Br as o,Lr as s,Or as c,Ps as l,Ra as u,ar as d,cr as f,dn as p,er as m,js as h,lr as g,nr as _,or as v,rr as y,sn as b,sr as x,tr as S,ur as C,w,xr as T,za as E}from"./ui-components-BOOpjWsQ.js";var D=e(n(),1),O=t();function k(){let{user:e,updateUser:t,isLoading:n,changePassword:u,setInitialPassword:k,hasLocalPassword:j}=r(),{upload:M}=w(),[N,P]=(0,D.useState)(e?.name??``),[F,I]=(0,D.useState)(!1),[L,R]=(0,D.useState)(null),z=(0,D.useRef)(null),[B,V]=(0,D.useState)(!1),[H,U]=(0,D.useState)(null);return(0,D.useEffect)(()=>{P(e?.name??``)},[e?.name]),e?(0,O.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Profile`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage your account settings`})]}),(0,O.jsx)(a,{children:(0,O.jsxs)(m,{className:`pt-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,O.jsxs)(v,{className:`h-16 w-16`,children:[(0,O.jsx)(f,{src:e.image??void 0,alt:e.name??`User`}),(0,O.jsx)(x,{className:`text-lg bg-primary text-primary-foreground`,children:i(e)})]}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:e.name??`User`}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:e.email}),(0,O.jsx)(d,{variant:`secondary`,className:`mt-1`,children:e.role??`member`})]}),(0,O.jsxs)(`div`,{className:`flex flex-col gap-2 shrink-0`,children:[(0,O.jsx)(`input`,{ref:z,type:`file`,accept:`image/*`,className:`hidden`,onChange:async e=>{let n=e.target.files?.[0];if(z.current&&(z.current.value=``),n){V(!0),U(null);try{let e=await M(n);await t({image:e.url})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}}},"data-testid":`profile-avatar-file`}),(0,O.jsxs)(T,{type:`button`,variant:`outline`,size:`sm`,disabled:B,onClick:()=>z.current?.click(),"data-testid":`profile-avatar-upload-btn`,children:[B?(0,O.jsx)(E,{className:`mr-2 h-4 w-4 animate-spin`}):(0,O.jsx)(o,{className:`mr-2 h-4 w-4`}),e.image?`Replace`:`Upload`]}),e.image&&(0,O.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,disabled:B,onClick:async()=>{V(!0),U(null);try{await t({image:null})}catch(e){U(e instanceof Error?e.message:String(e))}finally{V(!1)}},"data-testid":`profile-avatar-remove-btn`,children:[(0,O.jsx)(c,{className:`mr-2 h-4 w-4`}),`Remove`]})]})]}),H&&(0,O.jsxs)(g,{variant:`destructive`,className:`mt-4`,children:[(0,O.jsx)(l,{className:`h-4 w-4`}),(0,O.jsx)(C,{children:H})]})]})}),(0,O.jsxs)(a,{children:[(0,O.jsxs)(_,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(s,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(y,{className:`text-base sm:text-lg`,children:`Personal Information`})]}),(0,O.jsx)(S,{children:`Update your name and view account details`})]}),(0,O.jsx)(m,{children:(0,O.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),R(null),I(!1);try{await t({name:N}),I(!0)}catch(e){R(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[L&&(0,O.jsxs)(g,{variant:`destructive`,children:[(0,O.jsx)(l,{className:`h-4 w-4`}),(0,O.jsx)(C,{children:L})]}),F&&(0,O.jsxs)(g,{children:[(0,O.jsx)(h,{className:`h-4 w-4 text-green-600`}),(0,O.jsx)(C,{className:`text-green-800 dark:text-green-400`,children:`Profile updated successfully.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{htmlFor:`profile-name`,children:`Name`}),(0,O.jsx)(b,{id:`profile-name`,type:`text`,value:N,onChange:e=>P(e.target.value),required:!0,"aria-required":`true`,disabled:n})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{htmlFor:`profile-email`,children:`Email`}),(0,O.jsx)(b,{id:`profile-email`,type:`email`,value:e.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,O.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Email cannot be changed.`})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{children:`Role`}),(0,O.jsx)(b,{type:`text`,value:e.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,O.jsx)(T,{type:`submit`,disabled:n,className:`w-full sm:w-auto`,children:n?`Saving…`:`Save Changes`})]})})]}),(0,O.jsx)(A,{changePassword:u,setInitialPassword:k,hasLocalPassword:j})]}):null}function A({changePassword:e,setInitialPassword:t,hasLocalPassword:n,highlight:r,onPasswordSet:i}){let[o,s]=(0,D.useState)(null),[c,d]=(0,D.useState)(``),[f,v]=(0,D.useState)(``),[x,w]=(0,D.useState)(``),[E,k]=(0,D.useState)(!1),[A,j]=(0,D.useState)(null),[M,N]=(0,D.useState)(null);(0,D.useEffect)(()=>{let e=!1;return n().then(t=>{e||s(t)}).catch(()=>{e||s(!1)}),()=>{e=!0}},[n]);let P=()=>{d(``),v(``),w(``)},F=async n=>{if(n.preventDefault(),j(null),N(null),f.length<8){j(`Password must be at least 8 characters`);return}if(f!==x){j(`Passwords do not match`);return}k(!0);try{if(o){if(!c){j(`Enter your current password`),k(!1);return}await e(c,f),N(`Password changed.`)}else await t(f),N(`Local password set. You can now sign in with email and password on this environment.`),s(!0),i?.();P()}catch(e){j(e instanceof Error?e.message:String(e))}finally{k(!1)}},I=o===null;return(0,O.jsxs)(a,{className:r?`ring-2 ring-amber-300 dark:ring-amber-700`:void 0,children:[(0,O.jsxs)(_,{children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(u,{className:`h-4 w-4 text-muted-foreground`}),(0,O.jsx)(y,{className:`text-base sm:text-lg`,children:o?`Change Password`:`Set Local Password`})]}),(0,O.jsx)(S,{children:o?`Update the password you use to sign in to this environment.`:`You signed in via single sign-on. Set a local password to also sign in with email and password on this environment.`})]}),(0,O.jsx)(m,{children:(0,O.jsxs)(`form`,{onSubmit:F,className:`space-y-4 max-w-md`,children:[o&&(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{htmlFor:`current-password`,children:`Current password`}),(0,O.jsx)(b,{id:`current-password`,type:`password`,autoComplete:`current-password`,value:c,onChange:e=>d(e.target.value),disabled:E||I,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{htmlFor:`new-password`,children:o?`New password`:`Password`}),(0,O.jsx)(b,{id:`new-password`,type:`password`,autoComplete:`new-password`,value:f,onChange:e=>v(e.target.value),disabled:E||I,minLength:8,required:!0})]}),(0,O.jsxs)(`div`,{className:`space-y-2`,children:[(0,O.jsx)(p,{htmlFor:`confirm-password`,children:`Confirm password`}),(0,O.jsx)(b,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,value:x,onChange:e=>w(e.target.value),disabled:E||I,minLength:8,required:!0})]}),A&&(0,O.jsxs)(g,{variant:`destructive`,children:[(0,O.jsx)(l,{className:`h-4 w-4`}),(0,O.jsx)(C,{children:A})]}),M&&(0,O.jsxs)(g,{children:[(0,O.jsx)(h,{className:`h-4 w-4`}),(0,O.jsx)(C,{children:M})]}),(0,O.jsx)(T,{type:`submit`,disabled:E||I,className:`w-full sm:w-auto`,children:E?`Saving…`:o?`Change password`:`Set password`})]})})]})}export{k as ProfilePage};