@objectstack/console 10.0.0 → 10.3.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 (91) hide show
  1. package/dist/assets/{AdapterProvider-497l4p4y.js → AdapterProvider-BNg96rLB.js} +1 -1
  2. package/dist/assets/{AiPendingActionsPage-ux0cUuun.js → AiPendingActionsPage-DX6zBTm5.js} +1 -1
  3. package/dist/assets/{ApiConsolePage-uUkhblGX.js → ApiConsolePage-BV6fdN_d.js} +1 -1
  4. package/dist/assets/{AppDocsIndex-BSiJIyVl.js → AppDocsIndex-CFievvEN.js} +1 -1
  5. package/dist/assets/{AppManagementPage-COxgYP-L.js → AppManagementPage-BwMda0Jw.js} +1 -1
  6. package/dist/assets/{ApprovalsInboxPage-Dfa8zdNx.js → ApprovalsInboxPage-CLB_n_w1.js} +1 -1
  7. package/dist/assets/{AuditLogPage-DD_8Xcar.js → AuditLogPage-B5jAkCIM.js} +1 -1
  8. package/dist/assets/{ComponentNavView-BxuZYn-k.js → ComponentNavView-BlIradDc.js} +1 -1
  9. package/dist/assets/ConsoleFloatingChatbot-Bn99Z39a.js +1 -0
  10. package/dist/assets/DashboardView-BQ1jDkNk.js +1 -0
  11. package/dist/assets/{DashboardWidgetInspector-DKZkel6E.js → DashboardWidgetInspector-BR98NQH8.js} +1 -1
  12. package/dist/assets/{DeveloperHubPage-fRcSSqZS.js → DeveloperHubPage-CQ2_nCOl.js} +1 -1
  13. package/dist/assets/{ExpressionProvider-CHhp2xGN.js → ExpressionProvider-Tm4jr_3p.js} +1 -1
  14. package/dist/assets/{FlowRunsPage-dkCyzr_z.js → FlowRunsPage-B179CDQR.js} +1 -1
  15. package/dist/assets/{IntegrationsPage-BsKw9532.js → IntegrationsPage-Ch5OmIKz.js} +2 -2
  16. package/dist/assets/{InterfaceListPage-BChUfRxQ.js → InterfaceListPage-B5-dEiYQ.js} +1 -1
  17. package/dist/assets/{ManagedByBadge-By7dMA5p.js → ManagedByBadge-DdytxDlp.js} +1 -1
  18. package/dist/assets/{MarketplaceAccessDenied-BfvByBjR.js → MarketplaceAccessDenied-BRaR8_1a.js} +1 -1
  19. package/dist/assets/{MarketplaceInstalledPage-DvncMfVp.js → MarketplaceInstalledPage-BtW9YVL_.js} +1 -1
  20. package/dist/assets/{MarketplacePackagePage-BLKOlOvZ.js → MarketplacePackagePage-CHWrggYQ.js} +2 -2
  21. package/dist/assets/{MarketplacePage-Dkjj-Z_o.js → MarketplacePage-D9egwY6W.js} +1 -1
  22. package/dist/assets/{MetadataInspector-DXNojk_m.js → MetadataInspector-Cx8ePTT_.js} +1 -1
  23. package/dist/assets/{MetadataProvider-0eg8cMSY.js → MetadataProvider-QdHbK1P5.js} +1 -1
  24. package/dist/assets/PageView-Cz5sZQ5t.js +1 -0
  25. package/dist/assets/{ProfilePage-D4gJzhqR.js → ProfilePage-COEmwLJ3.js} +1 -1
  26. package/dist/assets/{PublicFormsPage-C46q0LJ_.js → PublicFormsPage-Dc2X36T6.js} +1 -1
  27. package/dist/assets/RecordDetailView-BgaxhKDF.js +9 -0
  28. package/dist/assets/{RecordFormPage-CmfCTKov.js → RecordFormPage-Hs6Ml27g.js} +1 -1
  29. package/dist/assets/{ReportDefaultInspector-CRLMz2jp.js → ReportDefaultInspector-CoX9gMMh.js} +3 -3
  30. package/dist/assets/{ReportView-B4fZ9FuM.js → ReportView-BM3Ai6gG.js} +1 -1
  31. package/dist/assets/{SearchResultsPage-BjfVk8_a.js → SearchResultsPage-CmNe7LEF.js} +1 -1
  32. package/dist/assets/{SettingsHub-C_eMjvQA.js → SettingsHub-E8tuZ4eC.js} +1 -1
  33. package/dist/assets/{SettingsView-BRVJ5Qgf.js → SettingsView-Zy-v0lBl.js} +1 -1
  34. package/dist/assets/{SystemHubPage-X9aTvTMd.js → SystemHubPage-BAzCcy5f.js} +1 -1
  35. package/dist/assets/{data-adapter-DISUVKTH.js → data-adapter-dGnCpoPP.js} +1 -1
  36. package/dist/assets/{framework-DI54pxGD.js → framework-D5XqsLzE.js} +7 -6
  37. package/dist/assets/{highlighted-body-OFNGDK62-13WB1hjG.js → highlighted-body-OFNGDK62-DQgrzYjA.js} +1 -1
  38. package/dist/assets/index-DOshzaoZ.css +2 -0
  39. package/dist/assets/index-DnQZFTk9.js +2 -0
  40. package/dist/assets/{infrastructure-BsIvKvpW.js → infrastructure-HR_Bc4bJ.js} +1 -1
  41. package/dist/assets/{marketplaceApi-DL8PegzV.js → marketplaceApi-BEwXWaVr.js} +1 -1
  42. package/dist/assets/mermaid-GHXKKRXX-BhYOzfYs.js +1 -0
  43. package/dist/assets/metadata-admin-B-J5LjrF.js +21 -0
  44. package/dist/assets/{plugin-calendar--KxXPKcZ.js → plugin-calendar-BRaVMiNC.js} +1 -1
  45. package/dist/assets/plugin-charts-lC1nlc8y.js +7 -0
  46. package/dist/assets/plugin-chatbot-DiZuqXNz.js +120 -0
  47. package/dist/assets/plugin-dashboard-Bru0NpLD.js +6 -0
  48. package/dist/assets/{plugin-form-CfWEBrxU.js → plugin-form-CnIr9O51.js} +1 -1
  49. package/dist/assets/plugin-gantt-DjNJ3XF1.js +93 -0
  50. package/dist/assets/plugin-grid-CLR5UBO-.js +6 -0
  51. package/dist/assets/plugin-kanban-C_oukMvw.js +1 -0
  52. package/dist/assets/{plugin-map-BJaiEhqS.js → plugin-map-7UTNE-o1.js} +1 -1
  53. package/dist/assets/{plugin-markdown-5mHDCnjJ.js → plugin-markdown-4BcL1bu0.js} +1 -1
  54. package/dist/assets/plugin-report-DnFF3lpC.js +59 -0
  55. package/dist/assets/{plugin-timeline-CRg278ig.js → plugin-timeline-C2lZtCO1.js} +1 -1
  56. package/dist/assets/{plugin-tree-D3iB5Xsc.js → plugin-tree-Ch_JGKmm.js} +1 -1
  57. package/dist/assets/plugin-view-XyXvMY2E.js +1 -0
  58. package/dist/assets/plugins-views-Ck67hsjt.js +4 -0
  59. package/dist/assets/{skeletons-CCMkzfAg.js → skeletons-B4Te484-.js} +1 -1
  60. package/dist/assets/{src-BTw3UGh8.js → src-Bw-Pk_Bz.js} +1 -1
  61. package/dist/assets/src-DzwWvy9u.js +2 -0
  62. package/dist/assets/{types-BXXHtG0t.js → types-aLjHZGFr.js} +1 -1
  63. package/dist/assets/ui-components-DiLX53DV.js +42 -0
  64. package/dist/assets/ui-layout-s7dWTKAK.js +1 -0
  65. package/dist/assets/{useActionModal-DezoqP6c.js → useActionModal-DjfU9Nzh.js} +1 -1
  66. package/dist/assets/{useOpenRecordList-DjbGsO2B.js → useOpenRecordList-D2EZK86D.js} +1 -1
  67. package/dist/assets/{useReconcileOnError-Df2Wf71r.js → useReconcileOnError-CGxw9vPi.js} +1 -1
  68. package/dist/assets/vendor-objectstack-C1teU2a6.js +96 -0
  69. package/dist/index.html +4 -4
  70. package/package.json +1 -1
  71. package/dist/assets/ConsoleFloatingChatbot-DEn_10k3.js +0 -1
  72. package/dist/assets/DashboardView-Ca89ME-z.js +0 -1
  73. package/dist/assets/PageView-DCLMAUNP.js +0 -1
  74. package/dist/assets/RecordDetailView-B11-8-pz.js +0 -9
  75. package/dist/assets/index-BnskSwad.css +0 -2
  76. package/dist/assets/index-Nsh10i14.js +0 -4
  77. package/dist/assets/mermaid-GHXKKRXX-CnMh6H1N.js +0 -1
  78. package/dist/assets/metadata-admin-BI5ITi-1.js +0 -21
  79. package/dist/assets/plugin-charts-BtGgj50F.js +0 -7
  80. package/dist/assets/plugin-chatbot-BnXRjqnw.js +0 -120
  81. package/dist/assets/plugin-dashboard-BJU4e4Lc.js +0 -6
  82. package/dist/assets/plugin-gantt-DWE_Yo3S.js +0 -39
  83. package/dist/assets/plugin-grid-MJIEbrKE.js +0 -6
  84. package/dist/assets/plugin-kanban-CuXc4XOR.js +0 -1
  85. package/dist/assets/plugin-report-DXVbwZO1.js +0 -59
  86. package/dist/assets/plugin-view-DuycwTEq.js +0 -1
  87. package/dist/assets/plugins-views-FDlQfg4L.js +0 -4
  88. package/dist/assets/src-KdhDBRhc.js +0 -2
  89. package/dist/assets/ui-components-BecTKcFn.js +0 -42
  90. package/dist/assets/ui-layout-BG3TnLjr.js +0 -1
  91. package/dist/assets/vendor-objectstack-CMEER4tu.js +0 -96
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{R as r,l as i,m as a}from"./vendor-objectstack-CMEER4tu.js";import{$r as o,$t as s,An as c,Bs as l,Bt as u,Ci as d,Cr as f,Es as p,Fa as m,Fn as h,Fs as g,Go as _,Hs as v,Ht as y,In as b,Is as x,Jo as S,Mn as ee,Nn as C,Ns as w,Pn as te,Rs as T,Ut as E,Vr as D,Vt as O,Wi as k,Wt as A,ao as j,co as M,en as ne,er as re,gr as N,is as ie,nn as P,on as F,tn as ae,vc as oe,yc as I,zs as se}from"./ui-components-BecTKcFn.js";import{G as ce,J as le,K as ue,U as de,V as fe,W as L,Z as R,_ as pe,a as me,g as he,i as ge,j as _e,p as ve,q as ye,r as be,t as xe,y as z}from"./ReportDefaultInspector-CRLMz2jp.js";var B=e(t(),1),V=n();function Se(e,t){if(!t)return!0;let n=t.toLowerCase();return e.value.toLowerCase().includes(n)||e.label.toLowerCase().includes(n)||(e.group?.toLowerCase().includes(n)??!1)}function H({label:e,value:t,onCommit:n,options:r,placeholder:i=`Select…`,searchPlaceholder:a=`Search or type…`,emptyText:o=`No match — keep typing to use a custom value.`,disabled:l,loading:u,allowCustom:d=!0,mono:f,className:m}){let[g,_]=B.useState(!1),[v,y]=B.useState(``),x=r.find(e=>e.value===t),S=x?x.label:t||(u?`Loading…`:i),T=B.useMemo(()=>r.filter(e=>Se(e,v)),[r,v]),E=B.useMemo(()=>{let e=[],t=new Map;for(let n of T){let r=n.group??``;t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return e.map(e=>({heading:e,items:t.get(e)}))},[T]),D=v.trim(),O=d&&!!D&&!r.some(e=>e.value===D),k=e=>{n(e),_(!1),y(``)},A=(0,V.jsxs)(s,{open:g,onOpenChange:e=>{_(e),e||y(``)},children:[(0,V.jsx)(ae,{asChild:!0,children:(0,V.jsxs)(N,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":g,disabled:l,className:I(`h-8 w-full justify-between px-2 text-sm font-normal`,m),children:[(0,V.jsx)(`span`,{className:I(`truncate`,f&&`font-mono`,!x&&!t&&`text-muted-foreground`),children:S}),(0,V.jsx)(p,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,V.jsx)(ne,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,V.jsxs)(c,{shouldFilter:!1,children:[(0,V.jsx)(te,{value:v,onValueChange:y,placeholder:a}),(0,V.jsxs)(b,{children:[!O&&T.length===0&&(0,V.jsx)(ee,{children:o}),O&&(0,V.jsx)(C,{children:(0,V.jsx)(h,{value:`__custom__${D}`,onSelect:()=>k(D),children:(0,V.jsxs)(`span`,{className:`truncate`,children:[`Use `,(0,V.jsxs)(`span`,{className:`font-mono`,children:[`“`,D,`”`]})]})})}),E.map((e,n)=>(0,V.jsx)(C,{heading:e.heading||void 0,children:e.items.map(e=>(0,V.jsxs)(h,{value:e.value,onSelect:()=>k(e.value),children:[(0,V.jsx)(w,{className:I(`h-3.5 w-3.5`,e.value===t?`opacity-100`:`opacity-0`)}),(0,V.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,V.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,V.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${n}`))]})]})})]});return e?(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(F,{className:`text-xs text-muted-foreground`,children:e}),A]}):A}var Ce=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function U(e,t){if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=e.default;if(typeof t==`string`&&t)return t}return t}function we(e){let t=e.reference??e.reference_to??e.referenceTo??e.reference_to_object;if(typeof t==`string`&&t)return t;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0];if(t&&typeof t==`object`){let e=t.object;if(typeof e==`string`&&e)return e}}function Te(e){switch(e){case`lookup`:case`master_detail`:case`masterDetail`:case`master-detail`:return`lookup`;case`date`:case`datetime`:case`time`:return`date`;case`number`:case`currency`:case`percent`:case`int`:case`integer`:case`float`:case`double`:case`autonumber`:return`number`;case`boolean`:case`toggle`:return`boolean`;default:return`string`}}function W(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=U(e.label,t),r=_e(e.fields).entries.map(e=>({name:e.name,label:U(e.def.label,e.name),type:typeof e.def.type==`string`?e.def.type:void 0,def:e.def}));return{label:n,fields:r,relationships:r.filter(e=>e.type&&Ce.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:we(e.def)}))}}function Ee(e,t,n){let r=e.fields.map(t=>({value:t.name,label:t.label,type:t.type,group:e.label}));for(let i of t){let t=e.relationships.find(e=>e.name===i),a=t?.referenceTo?n[t.referenceTo]:void 0;if(!a)continue;let o=`${t.label} → ${a.label}`;for(let e of a.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:o})}return r}function G(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>G(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t?!0:Object.values(n).some(e=>e&&typeof e==`object`&&G(e,t))}function K(){let e=R(),[t,n]=B.useState({options:[],loading:!0});return B.useEffect(()=>{let t=!1;return n(e=>({...e,loading:!0})),e.list(`object`).then(e=>{t||n({options:(Array.isArray(e)?e:[]).map(e=>({name:typeof e.name==`string`?e.name:``,label:U(e.label,typeof e.name==`string`?e.name:``)})).filter(e=>!!e.name).sort((e,t)=>e.label.localeCompare(t.label)),loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function De(e,t){let n=R(),r=t.join(`\0`),[i,a]=B.useState({relationships:[],fieldOptions:[],loading:!!e});return B.useEffect(()=>{if(!e){a({relationships:[],fieldOptions:[],loading:!1});return}let t=!1;return a(e=>({...e,loading:!0})),(async()=>{try{let i=await n.get(`object`,e);if(t)return;let o=W(i,e),s=new Set;for(let e of r?r.split(`\0`):[]){let t=o.relationships.find(t=>t.name===e);t?.referenceTo&&s.add(t.referenceTo)}let c=await Promise.all([...s].map(async e=>{try{return[e,W(await n.get(`object`,e),e)]}catch{return[e,W(null,e)]}}));if(t)return;let l=Object.fromEntries(c),u=r?r.split(`\0`):[];a({relationships:o.relationships,fieldOptions:Ee(o,u,l),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function Oe(e){let t=R(),[n,r]=B.useState({reports:0,dashboards:0,loading:!!e});return B.useEffect(()=>{if(!e){r({reports:0,dashboards:0,loading:!1});return}let n=!1;return r(e=>({...e,loading:!0})),(async()=>{let[i,a]=await Promise.all([t.list(`report`).catch(()=>[]),t.list(`dashboard`).catch(()=>[])]);n||r({reports:(Array.isArray(i)?i:[]).filter(t=>G(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>G(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}var q={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:j},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:se},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:T},line:{id:`line`,label:`Line chart`,category:`chart`,icon:l},area:{id:`area`,label:`Area chart`,category:`chart`,icon:v},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:x},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:_},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:g},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:D},table:{id:`table`,label:`Data table`,category:`data`,icon:o},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:S},list:{id:`list`,label:`Record list`,category:`data`,icon:m},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:ie}},ke={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},J=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(q).filter(t=>t.category===e)})),Y=oe;function X({onAdd:e,label:t=`Add widget`}){let[n,r]=B.useState(!1),[i,a]=B.useState(``),o=B.useRef(null),s=B.useRef(null);B.useEffect(()=>{if(!n){a(``);return}let e=e=>{o.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>s.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let c=B.useMemo(()=>{let e=i.trim().toLowerCase();return e?J.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):J},[i]);return(0,V.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:()=>r(e=>!e),children:[(0,V.jsx)(k,{className:`h-3 w-3`}),t]}),n&&(0,V.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,V.jsx)(d,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,V.jsx)(`input`,{ref:s,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search widgets…`,className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground`})]}),(0,V.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,V.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):c.map(t=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:ke[t.category]}),t.types.map(t=>(0,V.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{e(t.id),r(!1)},children:[(0,V.jsx)(q[t.id]?.icon??Y,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,V.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,V.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var Ae={io:`input`,unrepresentable:`any`},je=new Set([`widgets`,`label`,`description`,`name`]),Z,Me=!1;function Ne(){if(Z||Me)return Z;try{Z=r(i,Ae)}catch(e){Me=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return Z}var Q;function Pe(){if(Q)return Q;if(!(!a||typeof a!=`object`)){try{let e=JSON.parse(JSON.stringify(a));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!je.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Q=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return Q}}var Fe=new Set([`name`,`label`,`description`,`widgets`]);function Ie({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=B.useCallback(e=>z(e,r),[r]),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,l=B.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),u=e=>{let n=le(`widget`,l.map(e=>e?.id).filter(Boolean)),r=q[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:ce(l,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},d=e=>{t({widgets:ye(l,e,null)})},p=(e,n)=>{e!==n&&t({widgets:ue(l,e,n)})},m=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[h,g]=B.useState(null),[_,v]=B.useState(null),{schema:y,form:b}=B.useMemo(()=>me({bundledSchema:Ne(),bundledForm:Pe(),serverSchema:a,excludeFields:Fe,sectionTitle:z(`engine.inspector.moreFields`,r)}),[a,r]);return(0,V.jsxs)(de,{kindLabel:o(`engine.inspector.dashboard.kind`),title:String(s||e.name||o(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:o(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,V.jsx)(L,{label:o(`engine.inspector.dashboard.label`),value:s,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,V.jsx)(L,{label:o(`engine.inspector.dashboard.description`),value:c,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,V.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(F,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,V.jsx)(re,{variant:`outline`,className:`text-[10px]`,children:l.length})]}),l.length===0?(0,V.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.widgetsEmpty`)}):(0,V.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let r=q[e?.type]?.icon??Y;return(0,V.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{h!=null&&h!==t&&p(h,t),g(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&h!==null&&h!==t?` border-primary`:``),children:[!n&&(0,V.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,V.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>m(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,V.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,V.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>d(t),title:o(`engine.inspector.dashboard.removeWidget`),"aria-label":o(`engine.inspector.dashboard.removeWidget`),children:(0,V.jsx)(f,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,V.jsx)(X,{onAdd:u,label:o(`engine.inspector.add.widget`)})]}),(0,V.jsx)(`div`,{className:`border-t pt-3`,children:y?(0,V.jsx)(ve,{schema:y,form:b,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,V.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var Le=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],Re=[`count`,`sum`,`avg`,`min`,`max`],ze=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function Be(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function Ve({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){let s=Array.isArray(e.widgets)?e.widgets:[],c=t.kind===`widget`?t.id:void 0,l=c?Be(e,c):null,d=l?.widget??{},p=typeof d.dataset==`string`?d.dataset:``,m=typeof d.object==`string`?d.object:``,h=Array.isArray(d.dimensions)?d.dimensions.filter(e=>typeof e==`string`):[],g=Array.isArray(d.values)?d.values.filter(e=>typeof e==`string`):[],_=be(),v=ge(p||void 0,_),{options:b,loading:x}=K(),{fields:S}=he(m||void 0),ee=B.useMemo(()=>{let e=_.datasets.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return p&&!e.some(e=>e.value===p)&&e.push({value:p,label:p}),e},[_.datasets,p]),C=B.useMemo(()=>b.map(e=>({value:e.name,label:e.label})),[b]),w=B.useMemo(()=>S.map(e=>({value:e.name,label:e.label,hint:e.type})),[S]),te=B.useMemo(()=>v.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[v.measures]),T=B.useMemo(()=>v.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[v.dimensions]);if(t.kind!==`widget`)return(0,V.jsx)(He,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});if(!l)return(0,V.jsx)(He,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:D,index:k}=l;function j(e){let t=[...s];t[k]={...t[k],...e},n({widgets:t})}function M(e){n({widgets:ue(s,k,e)}),D.id&&i?.({kind:`widget`,id:D.id,label:D.title??void 0})}return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:z(`engine.inspector.widget.kind`,o)}),(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:D.title||t.label||`Widget ${k+1}`})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,V.jsx)(fe,{index:k,total:s.length,onMove:M,upLabel:z(`engine.inspector.reorder.up`,o),downLabel:z(`engine.inspector.reorder.down`,o),disabled:a}),(0,V.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:z(`engine.inspector.widget.close`,o),"aria-label":z(`engine.inspector.widget.close`,o),children:(0,V.jsx)(f,{className:`h-3.5 w-3.5`})})]})]}),(0,V.jsx)($,{id:`widget-title`,label:z(`engine.inspector.widget.title`,o),children:(0,V.jsx)(P,{id:`widget-title`,value:D.title??``,onChange:e=>j({title:e.target.value}),disabled:a})}),(0,V.jsx)($,{id:`widget-type`,label:z(`engine.inspector.widget.type`,o),children:(0,V.jsxs)(u,{value:D.type??`metric`,onValueChange:e=>j({type:e}),disabled:a,children:[(0,V.jsx)(E,{id:`widget-type`,children:(0,V.jsx)(A,{})}),(0,V.jsx)(O,{children:Le.map(e=>(0,V.jsx)(y,{value:e.value,children:e.label},e.value))})]})}),(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,V.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:z(`engine.inspector.widget.datasetSection`,o)}),(0,V.jsxs)($,{id:`widget-dataset`,label:z(`engine.inspector.widget.dataset`,o),children:[(0,V.jsx)(H,{value:p,onCommit:e=>j({dataset:e||void 0}),options:ee,loading:_.loading,placeholder:z(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:z(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,V.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:z(`engine.inspector.widget.datasetHint`,o)})]}),p&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xe,{label:z(`engine.inspector.widget.dimensions`,o),emptyText:z(`engine.inspector.widget.dimensionsHint`,o),names:h,options:T,loading:v.loading,error:v.error,readOnly:a,onCommit:e=>j({dimensions:e})}),(0,V.jsx)(xe,{label:z(`engine.inspector.widget.values`,o),emptyText:z(`engine.inspector.widget.valuesHint`,o),names:g,options:te,loading:v.loading,error:v.error,readOnly:a,onCommit:e=>j({values:e})})]})]}),(0,V.jsx)($,{id:`widget-object`,label:z(`engine.inspector.widget.object`,o),children:(0,V.jsx)(H,{value:D.object??``,onCommit:e=>j({object:e||void 0}),options:C,loading:x,placeholder:`Select an object…`,searchPlaceholder:`Search objects…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-value-field`,label:z(`engine.inspector.widget.valueField`,o),children:(0,V.jsx)(H,{value:D.valueField??``,onCommit:e=>j({valueField:e||void 0}),options:w,placeholder:D.object?`Select a field…`:`e.g. amount`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-category-field`,label:z(`engine.inspector.widget.categoryField`,o),children:(0,V.jsx)(H,{value:D.categoryField??``,onCommit:e=>j({categoryField:e||void 0}),options:w,placeholder:D.object?`Select a field…`:`e.g. status`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-aggregate`,label:z(`engine.inspector.widget.aggregate`,o),children:(0,V.jsxs)(u,{value:D.aggregate??`count`,onValueChange:e=>j({aggregate:e}),disabled:a,children:[(0,V.jsx)(E,{id:`widget-aggregate`,children:(0,V.jsx)(A,{})}),(0,V.jsx)(O,{children:Re.map(e=>(0,V.jsx)(y,{value:e,children:e},e))})]})}),(0,V.jsx)($,{id:`widget-color`,label:z(`engine.inspector.widget.color`,o),children:(0,V.jsx)(pe,{value:D.colorVariant??`default`,onChange:e=>j({colorVariant:e}),disabled:a,options:ze.map(e=>({value:e}))})}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsx)($,{id:`widget-w`,label:z(`engine.inspector.widget.width`,o),children:(0,V.jsx)(P,{id:`widget-w`,type:`number`,min:1,value:D.layout?.w??1,onChange:e=>j({layout:{...D.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,V.jsx)($,{id:`widget-h`,label:z(`engine.inspector.widget.height`,o),children:(0,V.jsx)(P,{id:`widget-h`,type:`number`,min:1,value:D.layout?.h??1,onChange:e=>j({layout:{...D.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,V.jsx)(`div`,{className:`pt-2 border-t`,children:(0,V.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(k,1),n({widgets:t}),r()},children:z(`engine.inspector.widget.remove`,o)})})]})}function $({id:e,label:t,children:n}){return(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(F,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function He({message:e,onClose:t,locale:n}){return(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,V.jsx)(`p`,{children:e}),(0,V.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:z(`engine.inspector.widget.close`,n)})]})}export{Te as a,K as c,q as i,H as l,Ie as n,De as o,X as r,Oe as s,Ve as t};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{R as r,l as i,m as a}from"./vendor-objectstack-C1teU2a6.js";import{$r as o,$t as s,An as c,Bs as l,Bt as u,Ci as d,Cr as f,Es as p,Fa as m,Fn as h,Fs as g,Go as _,Hs as v,Ht as y,In as b,Is as x,Jo as S,Mn as ee,Nn as C,Ns as w,Pn as te,Rs as T,Ut as E,Vr as D,Vt as O,Wi as k,Wt as A,_c as j,ao as M,co as ne,en as re,er as ie,gr as N,is as ae,nn as P,on as F,tn as oe,vc as I,zs as se}from"./ui-components-DiLX53DV.js";import{G as ce,J as le,K as ue,U as de,V as fe,W as L,Z as R,_ as pe,a as me,g as he,i as ge,j as _e,p as ve,q as ye,r as be,t as xe,y as z}from"./ReportDefaultInspector-CoX9gMMh.js";var B=e(t(),1),V=n();function Se(e,t){if(!t)return!0;let n=t.toLowerCase();return e.value.toLowerCase().includes(n)||e.label.toLowerCase().includes(n)||(e.group?.toLowerCase().includes(n)??!1)}function H({label:e,value:t,onCommit:n,options:r,placeholder:i=`Select…`,searchPlaceholder:a=`Search or type…`,emptyText:o=`No match — keep typing to use a custom value.`,disabled:l,loading:u,allowCustom:d=!0,mono:f,className:m}){let[g,_]=B.useState(!1),[v,y]=B.useState(``),x=r.find(e=>e.value===t),S=x?x.label:t||(u?`Loading…`:i),T=B.useMemo(()=>r.filter(e=>Se(e,v)),[r,v]),E=B.useMemo(()=>{let e=[],t=new Map;for(let n of T){let r=n.group??``;t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return e.map(e=>({heading:e,items:t.get(e)}))},[T]),D=v.trim(),O=d&&!!D&&!r.some(e=>e.value===D),k=e=>{n(e),_(!1),y(``)},A=(0,V.jsxs)(s,{open:g,onOpenChange:e=>{_(e),e||y(``)},children:[(0,V.jsx)(oe,{asChild:!0,children:(0,V.jsxs)(N,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":g,disabled:l,className:I(`h-8 w-full justify-between px-2 text-sm font-normal`,m),children:[(0,V.jsx)(`span`,{className:I(`truncate`,f&&`font-mono`,!x&&!t&&`text-muted-foreground`),children:S}),(0,V.jsx)(p,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,V.jsx)(re,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,V.jsxs)(c,{shouldFilter:!1,children:[(0,V.jsx)(te,{value:v,onValueChange:y,placeholder:a}),(0,V.jsxs)(b,{children:[!O&&T.length===0&&(0,V.jsx)(ee,{children:o}),O&&(0,V.jsx)(C,{children:(0,V.jsx)(h,{value:`__custom__${D}`,onSelect:()=>k(D),children:(0,V.jsxs)(`span`,{className:`truncate`,children:[`Use `,(0,V.jsxs)(`span`,{className:`font-mono`,children:[`“`,D,`”`]})]})})}),E.map((e,n)=>(0,V.jsx)(C,{heading:e.heading||void 0,children:e.items.map(e=>(0,V.jsxs)(h,{value:e.value,onSelect:()=>k(e.value),children:[(0,V.jsx)(w,{className:I(`h-3.5 w-3.5`,e.value===t?`opacity-100`:`opacity-0`)}),(0,V.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,V.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,V.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${n}`))]})]})})]});return e?(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsx)(F,{className:`text-xs text-muted-foreground`,children:e}),A]}):A}var Ce=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function U(e,t){if(typeof e==`string`&&e)return e;if(e&&typeof e==`object`){let t=e.default;if(typeof t==`string`&&t)return t}return t}function we(e){let t=e.reference??e.reference_to??e.referenceTo??e.reference_to_object;if(typeof t==`string`&&t)return t;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0];if(t&&typeof t==`object`){let e=t.object;if(typeof e==`string`&&e)return e}}function Te(e){switch(e){case`lookup`:case`master_detail`:case`masterDetail`:case`master-detail`:return`lookup`;case`date`:case`datetime`:case`time`:return`date`;case`number`:case`currency`:case`percent`:case`int`:case`integer`:case`float`:case`double`:case`autonumber`:return`number`;case`boolean`:case`toggle`:return`boolean`;default:return`string`}}function W(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=U(e.label,t),r=_e(e.fields).entries.map(e=>({name:e.name,label:U(e.def.label,e.name),type:typeof e.def.type==`string`?e.def.type:void 0,def:e.def}));return{label:n,fields:r,relationships:r.filter(e=>e.type&&Ce.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:we(e.def)}))}}function Ee(e,t,n){let r=e.fields.map(t=>({value:t.name,label:t.label,type:t.type,group:e.label}));for(let i of t){let t=e.relationships.find(e=>e.name===i),a=t?.referenceTo?n[t.referenceTo]:void 0;if(!a)continue;let o=`${t.label} → ${a.label}`;for(let e of a.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:o})}return r}function G(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>G(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t?!0:Object.values(n).some(e=>e&&typeof e==`object`&&G(e,t))}function K(){let e=R(),[t,n]=B.useState({options:[],loading:!0});return B.useEffect(()=>{let t=!1;return n(e=>({...e,loading:!0})),e.list(`object`).then(e=>{t||n({options:(Array.isArray(e)?e:[]).map(e=>({name:typeof e.name==`string`?e.name:``,label:U(e.label,typeof e.name==`string`?e.name:``)})).filter(e=>!!e.name).sort((e,t)=>e.label.localeCompare(t.label)),loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function De(e,t){let n=R(),r=t.join(`\0`),[i,a]=B.useState({relationships:[],fieldOptions:[],loading:!!e});return B.useEffect(()=>{if(!e){a({relationships:[],fieldOptions:[],loading:!1});return}let t=!1;return a(e=>({...e,loading:!0})),(async()=>{try{let i=await n.get(`object`,e);if(t)return;let o=W(i,e),s=new Set;for(let e of r?r.split(`\0`):[]){let t=o.relationships.find(t=>t.name===e);t?.referenceTo&&s.add(t.referenceTo)}let c=await Promise.all([...s].map(async e=>{try{return[e,W(await n.get(`object`,e),e)]}catch{return[e,W(null,e)]}}));if(t)return;let l=Object.fromEntries(c),u=r?r.split(`\0`):[];a({relationships:o.relationships,fieldOptions:Ee(o,u,l),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function Oe(e){let t=R(),[n,r]=B.useState({reports:0,dashboards:0,loading:!!e});return B.useEffect(()=>{if(!e){r({reports:0,dashboards:0,loading:!1});return}let n=!1;return r(e=>({...e,loading:!0})),(async()=>{let[i,a]=await Promise.all([t.list(`report`).catch(()=>[]),t.list(`dashboard`).catch(()=>[])]);n||r({reports:(Array.isArray(i)?i:[]).filter(t=>G(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>G(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}var q={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:M},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:se},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:T},line:{id:`line`,label:`Line chart`,category:`chart`,icon:l},area:{id:`area`,label:`Area chart`,category:`chart`,icon:v},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:x},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:_},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:g},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:D},table:{id:`table`,label:`Data table`,category:`data`,icon:o},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:S},list:{id:`list`,label:`Record list`,category:`data`,icon:m},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:ae}},ke={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},J=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(q).filter(t=>t.category===e)})),Y=j;function X({onAdd:e,label:t=`Add widget`}){let[n,r]=B.useState(!1),[i,a]=B.useState(``),o=B.useRef(null),s=B.useRef(null);B.useEffect(()=>{if(!n){a(``);return}let e=e=>{o.current?.contains(e.target)||r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),queueMicrotask(()=>s.current?.focus()),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[n]);let c=B.useMemo(()=>{let e=i.trim().toLowerCase();return e?J.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):J},[i]);return(0,V.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,V.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded border border-dashed px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/30 hover:text-foreground`,onClick:()=>r(e=>!e),children:[(0,V.jsx)(k,{className:`h-3 w-3`}),t]}),n&&(0,V.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,V.jsx)(d,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,V.jsx)(`input`,{ref:s,type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:`Search widgets…`,className:`w-full bg-transparent text-xs outline-none placeholder:text-muted-foreground`})]}),(0,V.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,V.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):c.map(t=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:ke[t.category]}),t.types.map(t=>(0,V.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-xs hover:bg-accent`,onClick:()=>{e(t.id),r(!1)},children:[(0,V.jsx)(q[t.id]?.icon??Y,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,V.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,V.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var Ae={io:`input`,unrepresentable:`any`},je=new Set([`widgets`,`label`,`description`,`name`]),Z,Me=!1;function Ne(){if(Z||Me)return Z;try{Z=r(i,Ae)}catch(e){Me=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return Z}var Q;function Pe(){if(Q)return Q;if(!(!a||typeof a!=`object`)){try{let e=JSON.parse(JSON.stringify(a));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!je.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Q=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return Q}}var Fe=new Set([`name`,`label`,`description`,`widgets`]);function Ie({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=B.useCallback(e=>z(e,r),[r]),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,l=B.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),u=e=>{let n=le(`widget`,l.map(e=>e?.id).filter(Boolean)),r=q[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:ce(l,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},d=e=>{t({widgets:ye(l,e,null)})},p=(e,n)=>{e!==n&&t({widgets:ue(l,e,n)})},m=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[h,g]=B.useState(null),[_,v]=B.useState(null),{schema:y,form:b}=B.useMemo(()=>me({bundledSchema:Ne(),bundledForm:Pe(),serverSchema:a,excludeFields:Fe,sectionTitle:z(`engine.inspector.moreFields`,r)}),[a,r]);return(0,V.jsxs)(de,{kindLabel:o(`engine.inspector.dashboard.kind`),title:String(s||e.name||o(`engine.inspector.dashboard.kind`)),onClose:()=>{},closeLabel:o(`engine.inspector.dashboard.close`),hideClose:!0,children:[(0,V.jsx)(L,{label:o(`engine.inspector.dashboard.label`),value:s,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,V.jsx)(L,{label:o(`engine.inspector.dashboard.description`),value:c,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,V.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(F,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,V.jsx)(ie,{variant:`outline`,className:`text-[10px]`,children:l.length})]}),l.length===0?(0,V.jsx)(`p`,{className:`rounded-md border border-dashed bg-muted/30 px-3 py-3 text-center text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.widgetsEmpty`)}):(0,V.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let r=q[e?.type]?.icon??Y;return(0,V.jsxs)(`div`,{draggable:!n,onDragStart:()=>g(t),onDragEnd:()=>{g(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{h!=null&&h!==t&&p(h,t),g(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&h!==null&&h!==t?` border-primary`:``),children:[!n&&(0,V.jsx)(ne,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,V.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,V.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>m(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,V.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,V.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,className:`h-6 w-6 shrink-0 p-0 opacity-0 group-hover:opacity-100`,onClick:()=>d(t),title:o(`engine.inspector.dashboard.removeWidget`),"aria-label":o(`engine.inspector.dashboard.removeWidget`),children:(0,V.jsx)(f,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,V.jsx)(X,{onAdd:u,label:o(`engine.inspector.add.widget`)})]}),(0,V.jsx)(`div`,{className:`border-t pt-3`,children:y?(0,V.jsx)(ve,{schema:y,form:b,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,V.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var Le=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],Re=[`count`,`sum`,`avg`,`min`,`max`],ze=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function Be(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function Ve({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){let s=Array.isArray(e.widgets)?e.widgets:[],c=t.kind===`widget`?t.id:void 0,l=c?Be(e,c):null,d=l?.widget??{},p=typeof d.dataset==`string`?d.dataset:``,m=typeof d.object==`string`?d.object:``,h=Array.isArray(d.dimensions)?d.dimensions.filter(e=>typeof e==`string`):[],g=Array.isArray(d.values)?d.values.filter(e=>typeof e==`string`):[],_=be(),v=ge(p||void 0,_),{options:b,loading:x}=K(),{fields:S}=he(m||void 0),ee=B.useMemo(()=>{let e=_.datasets.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return p&&!e.some(e=>e.value===p)&&e.push({value:p,label:p}),e},[_.datasets,p]),C=B.useMemo(()=>b.map(e=>({value:e.name,label:e.label})),[b]),w=B.useMemo(()=>S.map(e=>({value:e.name,label:e.label,hint:e.type})),[S]),te=B.useMemo(()=>v.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[v.measures]),T=B.useMemo(()=>v.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[v.dimensions]);if(t.kind!==`widget`)return(0,V.jsx)(He,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});if(!l)return(0,V.jsx)(He,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:D,index:k}=l;function j(e){let t=[...s];t[k]={...t[k],...e},n({widgets:t})}function M(e){n({widgets:ue(s,k,e)}),D.id&&i?.({kind:`widget`,id:D.id,label:D.title??void 0})}return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:z(`engine.inspector.widget.kind`,o)}),(0,V.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:D.title||t.label||`Widget ${k+1}`})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,V.jsx)(fe,{index:k,total:s.length,onMove:M,upLabel:z(`engine.inspector.reorder.up`,o),downLabel:z(`engine.inspector.reorder.down`,o),disabled:a}),(0,V.jsx)(N,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:z(`engine.inspector.widget.close`,o),"aria-label":z(`engine.inspector.widget.close`,o),children:(0,V.jsx)(f,{className:`h-3.5 w-3.5`})})]})]}),(0,V.jsx)($,{id:`widget-title`,label:z(`engine.inspector.widget.title`,o),children:(0,V.jsx)(P,{id:`widget-title`,value:D.title??``,onChange:e=>j({title:e.target.value}),disabled:a})}),(0,V.jsx)($,{id:`widget-type`,label:z(`engine.inspector.widget.type`,o),children:(0,V.jsxs)(u,{value:D.type??`metric`,onValueChange:e=>j({type:e}),disabled:a,children:[(0,V.jsx)(E,{id:`widget-type`,children:(0,V.jsx)(A,{})}),(0,V.jsx)(O,{children:Le.map(e=>(0,V.jsx)(y,{value:e.value,children:e.label},e.value))})]})}),(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,V.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:z(`engine.inspector.widget.datasetSection`,o)}),(0,V.jsxs)($,{id:`widget-dataset`,label:z(`engine.inspector.widget.dataset`,o),children:[(0,V.jsx)(H,{value:p,onCommit:e=>j({dataset:e||void 0}),options:ee,loading:_.loading,placeholder:z(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:z(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,V.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:z(`engine.inspector.widget.datasetHint`,o)})]}),p&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(xe,{label:z(`engine.inspector.widget.dimensions`,o),emptyText:z(`engine.inspector.widget.dimensionsHint`,o),names:h,options:T,loading:v.loading,error:v.error,readOnly:a,onCommit:e=>j({dimensions:e})}),(0,V.jsx)(xe,{label:z(`engine.inspector.widget.values`,o),emptyText:z(`engine.inspector.widget.valuesHint`,o),names:g,options:te,loading:v.loading,error:v.error,readOnly:a,onCommit:e=>j({values:e})})]})]}),(0,V.jsx)($,{id:`widget-object`,label:z(`engine.inspector.widget.object`,o),children:(0,V.jsx)(H,{value:D.object??``,onCommit:e=>j({object:e||void 0}),options:C,loading:x,placeholder:`Select an object…`,searchPlaceholder:`Search objects…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-value-field`,label:z(`engine.inspector.widget.valueField`,o),children:(0,V.jsx)(H,{value:D.valueField??``,onCommit:e=>j({valueField:e||void 0}),options:w,placeholder:D.object?`Select a field…`:`e.g. amount`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-category-field`,label:z(`engine.inspector.widget.categoryField`,o),children:(0,V.jsx)(H,{value:D.categoryField??``,onCommit:e=>j({categoryField:e||void 0}),options:w,placeholder:D.object?`Select a field…`:`e.g. status`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,V.jsx)($,{id:`widget-aggregate`,label:z(`engine.inspector.widget.aggregate`,o),children:(0,V.jsxs)(u,{value:D.aggregate??`count`,onValueChange:e=>j({aggregate:e}),disabled:a,children:[(0,V.jsx)(E,{id:`widget-aggregate`,children:(0,V.jsx)(A,{})}),(0,V.jsx)(O,{children:Re.map(e=>(0,V.jsx)(y,{value:e,children:e},e))})]})}),(0,V.jsx)($,{id:`widget-color`,label:z(`engine.inspector.widget.color`,o),children:(0,V.jsx)(pe,{value:D.colorVariant??`default`,onChange:e=>j({colorVariant:e}),disabled:a,options:ze.map(e=>({value:e}))})}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsx)($,{id:`widget-w`,label:z(`engine.inspector.widget.width`,o),children:(0,V.jsx)(P,{id:`widget-w`,type:`number`,min:1,value:D.layout?.w??1,onChange:e=>j({layout:{...D.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,V.jsx)($,{id:`widget-h`,label:z(`engine.inspector.widget.height`,o),children:(0,V.jsx)(P,{id:`widget-h`,type:`number`,min:1,value:D.layout?.h??1,onChange:e=>j({layout:{...D.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,V.jsx)(`div`,{className:`pt-2 border-t`,children:(0,V.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(k,1),n({widgets:t}),r()},children:z(`engine.inspector.widget.remove`,o)})})]})}function $({id:e,label:t,children:n}){return(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,V.jsx)(F,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function He({message:e,onClose:t,locale:n}){return(0,V.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,V.jsx)(`p`,{children:e}),(0,V.jsx)(N,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:z(`engine.inspector.widget.close`,n)})]})}export{Te as a,K as c,q as i,H as l,Ie as n,De as o,X as r,Oe as s,Ve as t};
@@ -1 +1 @@
1
- import{f as e,t,u as n}from"./vendor-react-ClIa1CJA.js";import{Do as r,Gi as i,Jn as a,Qn as o,Tr as s,Xn as c,Yn as l,Yr as u,Zn as d}from"./ui-components-BecTKcFn.js";var f=t();function p(){let t=n(),{appName:p}=e(),m=p?`/apps/${p}`:``,h=[{title:`Integrations & APIs`,description:`Your app as a REST API — base URL, endpoints, and connect samples`,icon:i,href:`${m}/developer/integrations`},{title:`API Console`,description:`Inspect and exercise REST endpoints with auto-discovered services`,icon:u,href:`${m}/developer/api-console`},{title:`Flow Runs`,description:`Trigger flows with sample inputs and inspect recent run history`,icon:s,href:`${m}/developer/flow-runs`},{title:`Public Forms`,description:`Publish, share, and embed FormViews available to anonymous users`,icon:r,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 n=e.icon;return(0,f.jsxs)(a,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>t(e.href),"data-testid":`hub-card-${e.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${e.title}: ${e.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.href))},children:[(0,f.jsxs)(d,{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)(n,{className:`h-5 w-5`})}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(o,{className:`text-base`,children:e.title}),(0,f.jsx)(c,{className:`text-xs`,children:e.description})]})]}),(0,f.jsx)(l,{className:`pt-0`})]},e.title)})})]})}export{p as DeveloperHubPage};
1
+ import{f as e,t,u as n}from"./vendor-react-ClIa1CJA.js";import{Do as r,Gi as i,Jn as a,Qn as o,Tr as s,Xn as c,Yn as l,Yr as u,Zn as d}from"./ui-components-DiLX53DV.js";var f=t();function p(){let t=n(),{appName:p}=e(),m=p?`/apps/${p}`:``,h=[{title:`Integrations & APIs`,description:`Your app as a REST API — base URL, endpoints, and connect samples`,icon:i,href:`${m}/developer/integrations`},{title:`API Console`,description:`Inspect and exercise REST endpoints with auto-discovered services`,icon:u,href:`${m}/developer/api-console`},{title:`Flow Runs`,description:`Trigger flows with sample inputs and inspect recent run history`,icon:s,href:`${m}/developer/flow-runs`},{title:`Public Forms`,description:`Publish, share, and embed FormViews available to anonymous users`,icon:r,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 n=e.icon;return(0,f.jsxs)(a,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>t(e.href),"data-testid":`hub-card-${e.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${e.title}: ${e.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.href))},children:[(0,f.jsxs)(d,{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)(n,{className:`h-5 w-5`})}),(0,f.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,f.jsx)(o,{className:`text-base`,children:e.title}),(0,f.jsx)(c,{className:`text-xs`,children:e.description})]})]}),(0,f.jsx)(l,{className:`pt-0`})]},e.title)})})]})}export{p as DeveloperHubPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{W as r,vt as i}from"./framework-DI54pxGD.js";var a=e(t(),1),o=n(),s=(0,a.createContext)(null);function c({children:e,user:t={},app:n={},data:c={},features:l={}}){let u=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l,evaluator:new i({user:t,app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}};return{...e,evaluator:new i(e)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{W as r,yt as i}from"./framework-D5XqsLzE.js";var a=e(t(),1),o=n(),s=(0,a.createContext)(null);function c({children:e,user:t={},app:n={},data:c={},features:l={}}){let u=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l,evaluator:new i({user:t,app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({user:t,app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}};return{...e,evaluator:new i(e)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{k as r}from"./framework-DI54pxGD.js";import{Ft as i,Gt as a,Ii as o,It as s,Jn as c,Ki as l,Lt as u,Mt as d,Pa as f,Pt as p,Qn as m,Rt as h,Tr as g,Xn as _,Yn as v,Zn as y,cs as b,ct as x,dt as S,er as C,ft as w,gr as T,lt as E,nn as D,on as O,ot as k,ps as A,st as j,tt as M,ut as N,ws as P,xs as F}from"./ui-components-BecTKcFn.js";import"./src-KdhDBRhc.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:F,cls:`text-emerald-600 border-emerald-300`},completed:{icon:F,cls:`text-emerald-600 border-emerald-300`},failed:{icon:A,cls:`text-red-600 border-red-300`},error:{icon:A,cls:`text-red-600 border-red-300`},running:{icon:f,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:b,cls:`text-amber-600 border-amber-300`},skipped:{icon:P,cls:`text-muted-foreground`}}[e]??{icon:P,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(C,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,a]=(0,I.useState)(!0),[s,l]=(0,I.useState)(null),[u,f]=(0,I.useState)(``),[p,h]=(0,I.useState)(0),b=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),a(!1);return}a(!0),l(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!u&&r.length>0&&f(r[0].name)}catch(e){l(e?.message??String(e))}finally{a(!1)}},[e,u]);(0,I.useEffect)(()=>{b()},[b]);let x=(0,I.useMemo)(()=>t.find(e=>e.name===u)??null,[t,u]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(g,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,L.jsxs)(c,{children:[(0,L.jsx)(y,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(m,{className:`text-base`,children:`Flow`}),(0,L.jsx)(_,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(T,{variant:`outline`,size:`sm`,onClick:b,disabled:i,children:[(0,L.jsx)(o,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(v,{children:[i&&(0,L.jsx)(d,{className:`h-9 w-72`}),s&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!i&&!s&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!s&&t.length>0&&(0,L.jsx)(`select`,{value:u,onChange:e=>f(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),x&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:x.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:x.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[i,a]=(0,I.useState)({}),[o,s]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[p,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{a({}),d(null),h(null)},[t?.name]);let g=(e,t)=>a(n=>({...n,[e]:t}));return(0,L.jsxs)(c,{children:[(0,L.jsxs)(y,{className:`pb-3`,children:[(0,L.jsx)(m,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(_,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(v,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(O,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(C,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(w,{id:`var-${e.name}`,checked:i[e.name]===`true`,onCheckedChange:t=>g(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(M,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(D,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(T,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}s(!0),h(null),d(null);try{let a={};for(let e of r){let t=i[e.name];t!==void 0&&(a[e.name]=B(t,e.type))}d(await e.automation.execute(t.name,{params:a})),n?.()}catch(e){h(e?.message??String(e))}finally{s(!1)}},disabled:o,size:`sm`,children:[o?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(l,{className:`h-3.5 w-3.5 mr-2`}),o?`Running…`:`Run Flow`]})}),(u||p)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[p||u?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(F,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof u?.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono`,children:[u.durationMs,` ms`]})]}),p&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:p}),u&&(0,L.jsx)(V,{data:u})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,l]=(0,I.useState)([]),[g,b]=(0,I.useState)(!0),[w,D]=(0,I.useState)(null),[O,A]=(0,I.useState)(null),[M,P]=(0,I.useState)(null),[F,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){D(`automation.listRuns is not available on this client`),b(!1);return}b(!0),D(null);try{let n=await e.automation.listRuns(t,{limit:20});l(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){D(e?.message??String(e))}finally{b(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{A(n),P(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);P(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(c,{children:[(0,L.jsx)(y,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(m,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(_,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(T,{variant:`outline`,size:`sm`,onClick:W,disabled:g,children:[g?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(o,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(v,{children:[g&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(d,{className:`h-8 w-full`}),(0,L.jsx)(d,{className:`h-8 w-full`}),(0,L.jsx)(d,{className:`h-8 w-full`})]}),!g&&w&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:w}),!g&&!w&&r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!g&&!w&&r.length>0&&(0,L.jsxs)(k,{children:[(0,L.jsx)(N,{children:(0,L.jsxs)(S,{children:[(0,L.jsx)(E,{children:`Run`}),(0,L.jsx)(E,{children:`Status`}),(0,L.jsx)(E,{children:`Started`}),(0,L.jsx)(E,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(j,{children:r.map(e=>(0,L.jsxs)(S,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(x,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(x,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(x,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(x,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(p,{open:!!O,onOpenChange:e=>{e||(A(null),P(null))},children:(0,L.jsxs)(i,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(u,{className:`p-4 border-b`,children:[(0,L.jsxs)(h,{className:`font-mono text-sm break-all`,children:[`Run `,O]}),(0,L.jsx)(s,{children:M&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:M.status}),typeof M.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono`,children:[M.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(M.startedAt)})]})})]}),(0,L.jsxs)(a,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(d,{className:`h-16 w-full`}),(0,L.jsx)(d,{className:`h-16 w-full`}),(0,L.jsx)(d,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&M&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(M.steps)&&M.steps.length>0?M.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(C,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:M})]})})]})]})})]})}export{H as FlowRunsPage};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{k as r}from"./framework-D5XqsLzE.js";import{Ft as i,Gt as a,Ii as o,It as s,Jn as c,Ki as l,Lt as u,Mt as d,Pa as f,Pt as p,Qn as m,Rt as h,Tr as g,Xn as _,Yn as v,Zn as y,cs as b,ct as x,dt as S,er as C,ft as w,gr as T,lt as E,nn as D,on as O,ot as k,ps as A,st as j,tt as M,ut as N,ws as P,xs as F}from"./ui-components-DiLX53DV.js";import"./src-DzwWvy9u.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:F,cls:`text-emerald-600 border-emerald-300`},completed:{icon:F,cls:`text-emerald-600 border-emerald-300`},failed:{icon:A,cls:`text-red-600 border-red-300`},error:{icon:A,cls:`text-red-600 border-red-300`},running:{icon:f,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:b,cls:`text-amber-600 border-amber-300`},skipped:{icon:P,cls:`text-muted-foreground`}}[e]??{icon:P,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(C,{variant:`outline`,className:`text-[10px] font-mono inline-flex items-center gap-1 ${t.cls}`,children:[(0,L.jsx)(n,{className:`h-3 w-3`}),e]})}function z(e){if(!e)return`—`;try{return new Date(e).toLocaleString()}catch{return e}}function B(e,t){switch(t){case`number`:{if(e===``)return;let t=Number(e);return Number.isNaN(t)?e:t}case`boolean`:return e===`true`;case`object`:case`list`:case`array`:if(e.trim()===``)return;try{return JSON.parse(e)}catch{return e}default:return e}}function V({data:e}){return(0,L.jsx)(`pre`,{className:`rounded border bg-muted/30 p-2 text-xs font-mono overflow-auto whitespace-pre-wrap break-all max-h-96`,children:JSON.stringify(e,null,2)})}function H(){let e=r()?.getClient?.(),[t,n]=(0,I.useState)([]),[i,a]=(0,I.useState)(!0),[s,l]=(0,I.useState)(null),[u,f]=(0,I.useState)(``),[p,h]=(0,I.useState)(0),b=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){l(`meta.getItems is not available on this client`),a(!1);return}a(!0),l(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!u&&r.length>0&&f(r[0].name)}catch(e){l(e?.message??String(e))}finally{a(!1)}},[e,u]);(0,I.useEffect)(()=>{b()},[b]);let x=(0,I.useMemo)(()=>t.find(e=>e.name===u)??null,[t,u]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(g,{className:`h-5 w-5`}),`Flow Runs`]}),(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Pick a flow, trigger a test run with sample inputs, and inspect recent run history`})]}),(0,L.jsxs)(c,{children:[(0,L.jsx)(y,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(m,{className:`text-base`,children:`Flow`}),(0,L.jsx)(_,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(T,{variant:`outline`,size:`sm`,onClick:b,disabled:i,children:[(0,L.jsx)(o,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(v,{children:[i&&(0,L.jsx)(d,{className:`h-9 w-72`}),s&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:s}),!i&&!s&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!s&&t.length>0&&(0,L.jsx)(`select`,{value:u,onChange:e=>f(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),x&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:x.spec,onExecuted:()=>h(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:x.name,refreshKey:p})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[i,a]=(0,I.useState)({}),[o,s]=(0,I.useState)(!1),[u,d]=(0,I.useState)(null),[p,h]=(0,I.useState)(null);(0,I.useEffect)(()=>{a({}),d(null),h(null)},[t?.name]);let g=(e,t)=>a(n=>({...n,[e]:t}));return(0,L.jsxs)(c,{children:[(0,L.jsxs)(y,{className:`pb-3`,children:[(0,L.jsx)(m,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(_,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(v,{className:`space-y-3`,children:[r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This flow declares no input variables. Click Run to invoke with no parameters.`}),r.map(e=>(0,L.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,L.jsxs)(O,{htmlFor:`var-${e.name}`,className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-xs`,children:e.name}),(0,L.jsx)(C,{variant:`outline`,className:`text-[10px] font-mono`,children:e.type})]}),e.type===`boolean`?(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(w,{id:`var-${e.name}`,checked:i[e.name]===`true`,onCheckedChange:t=>g(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(M,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(D,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:i[e.name]??``,onChange:t=>g(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(T,{onClick:async()=>{if(!e?.automation?.execute){h(`automation.execute is not available on this client`);return}s(!0),h(null),d(null);try{let a={};for(let e of r){let t=i[e.name];t!==void 0&&(a[e.name]=B(t,e.type))}d(await e.automation.execute(t.name,{params:a})),n?.()}catch(e){h(e?.message??String(e))}finally{s(!1)}},disabled:o,size:`sm`,children:[o?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(l,{className:`h-3.5 w-3.5 mr-2`}),o?`Running…`:`Run Flow`]})}),(u||p)&&(0,L.jsxs)(`div`,{className:`pt-2 border-t mt-2 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[p||u?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(F,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof u?.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono`,children:[u.durationMs,` ms`]})]}),p&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:p}),u&&(0,L.jsx)(V,{data:u})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,l]=(0,I.useState)([]),[g,b]=(0,I.useState)(!0),[w,D]=(0,I.useState)(null),[O,A]=(0,I.useState)(null),[M,P]=(0,I.useState)(null),[F,B]=(0,I.useState)(!1),[H,U]=(0,I.useState)(null),W=(0,I.useCallback)(async()=>{if(!e?.automation?.listRuns){D(`automation.listRuns is not available on this client`),b(!1);return}b(!0),D(null);try{let n=await e.automation.listRuns(t,{limit:20});l(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){D(e?.message??String(e))}finally{b(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{A(n),P(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);P(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(c,{children:[(0,L.jsx)(y,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(m,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(_,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(T,{variant:`outline`,size:`sm`,onClick:W,disabled:g,children:[g?(0,L.jsx)(f,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(o,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(v,{children:[g&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(d,{className:`h-8 w-full`}),(0,L.jsx)(d,{className:`h-8 w-full`}),(0,L.jsx)(d,{className:`h-8 w-full`})]}),!g&&w&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:w}),!g&&!w&&r.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground py-6 text-center`,children:`No runs yet. Use the Test Run panel to invoke this flow.`}),!g&&!w&&r.length>0&&(0,L.jsxs)(k,{children:[(0,L.jsx)(N,{children:(0,L.jsxs)(S,{children:[(0,L.jsx)(E,{children:`Run`}),(0,L.jsx)(E,{children:`Status`}),(0,L.jsx)(E,{children:`Started`}),(0,L.jsx)(E,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(j,{children:r.map(e=>(0,L.jsxs)(S,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(x,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(x,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(x,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(x,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(p,{open:!!O,onOpenChange:e=>{e||(A(null),P(null))},children:(0,L.jsxs)(i,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(u,{className:`p-4 border-b`,children:[(0,L.jsxs)(h,{className:`font-mono text-sm break-all`,children:[`Run `,O]}),(0,L.jsx)(s,{children:M&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:M.status}),typeof M.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono`,children:[M.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(M.startedAt)})]})})]}),(0,L.jsxs)(a,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(d,{className:`h-16 w-full`}),(0,L.jsx)(d,{className:`h-16 w-full`}),(0,L.jsx)(d,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&M&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(M.steps)&&M.steps.length>0?M.steps.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border p-3 space-y-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,L.jsxs)(`span`,{className:`text-muted-foreground font-mono text-xs`,children:[`#`,t+1]}),(0,L.jsx)(`span`,{className:`font-mono text-sm font-medium`,children:e.nodeLabel||e.nodeId}),e.nodeType&&(0,L.jsx)(C,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(C,{variant:`secondary`,className:`text-[10px] font-mono ml-auto`,children:[e.durationMs,` ms`]})]}),e.input!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Input`}),(0,L.jsx)(V,{data:e.input})]}),e.output!==void 0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Output`}),(0,L.jsx)(V,{data:e.output})]}),e.error&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-red-500 mb-1`,children:`Error`}),(0,L.jsx)(V,{data:e.error})]})]},`${e.nodeId}-${t}`)):(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground mb-1`,children:`Run`}),(0,L.jsx)(V,{data:M})]})})]})]})})]})}export{H as FlowRunsPage};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{Bn as a,Gi as o,Hn as s,Jn as c,Jo as l,Ns as u,Qn as d,Qs as f,Rn as p,Un as m,Vn as h,Wo as g,Xa as _,Xn as v,Yn as y,Yr as b,Zn as x,ar as S,er as C,es as w,gr as T,ir as E,nn as D,or as O,vi as k,zn as A}from"./ui-components-BecTKcFn.js";var j=e(t(),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-CMxvf4Kt.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{Bn as a,Gi as o,Hn as s,Jn as c,Jo as l,Ns as u,Qn as d,Rn as f,Un as p,Vn as m,Wo as h,Xa as g,Xn as _,Yn as v,Yr as y,Zn as b,Zs as x,ar as S,er as C,es as w,gr as T,ir as E,nn as D,or as O,vi as k,zn as A}from"./ui-components-DiLX53DV.js";var j=e(t(),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
  ---
@@ -79,4 +79,4 @@ create/update payload.
79
79
  3. \`query_records\` to read / verify current state.
80
80
  4. \`create_record\` / \`update_record\` / \`delete_record\` to make changes,
81
81
  confirming destructive steps with the user.
82
- `}var I=r();function L(){let[e,t]=(0,j.useState)(!1);return[e,e=>{navigator.clipboard?.writeText(e),t(!0),setTimeout(()=>t(!1),1500)}]}function R({value:e,label:t}){let[n,r]=L();return(0,I.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2 text-xs`,onClick:()=>r(e),"aria-label":`Copy ${t??`value`}`,children:[n?(0,I.jsx)(u,{className:`size-3.5`}):(0,I.jsx)(w,{className:`size-3.5`}),n?`Copied`:`Copy`]})}function z(){let e=typeof window<`u`?window.location.origin:``,[t,n]=(0,j.useState)(null),[r,i]=(0,j.useState)(null),[o,l]=(0,j.useState)(`Agent key`),[b,C]=(0,j.useState)(!1),[M,N]=(0,j.useState)(null),[P,z]=(0,j.useState)(null),[B,V]=(0,j.useState)(!1),[H,U]=L();(0,j.useEffect)(()=>{let t=!1;return(async()=>{try{let r=await(await fetch(`/api/v1/discovery`,{credentials:`include`})).json().catch(()=>({})),a=r?.data?.routes?.mcp??r?.routes?.mcp;if(t)return;a?(n(a.startsWith(`http`)?a:`${e}${a}`),i(!0)):i(!1)}catch{t||i(!1)}})(),()=>{t=!0}},[e]);let W=async()=>{C(!0),N(null);try{let e=await fetch(`/api/v1/keys`,{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:JSON.stringify({name:o.trim()||`Agent key`})}),t=await e.json().catch(()=>({})),n=t?.data;if(!e.ok||!n?.key)throw Error(t?.error?.message||`Request failed (${e.status})`);z(n),V(!0)}catch(e){N(e?.message??`Failed to generate key`)}finally{C(!1)}},G=()=>{let e=F({mcpUrl:t??void 0}),n=new Blob([e],{type:`text/markdown;charset=utf-8`}),r=document.createElement(`a`);r.href=URL.createObjectURL(n),r.download=`SKILL.md`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(r.href),1e3)},K=t??`${e}/api/v1/mcp`;return(0,I.jsxs)(c,{children:[(0,I.jsxs)(x,{className:`pb-2`,children:[(0,I.jsxs)(d,{className:`text-base flex items-center gap-2`,children:[(0,I.jsx)(f,{className:`size-4`}),` Connect an AI agent (MCP)`]}),(0,I.jsx)(v,{className:`text-xs`,children:`Every app in this environment is an agent-ready toolset. Connect Claude, Cursor, Codex or any MCP client — one connection covers all your apps (new ones appear automatically).`})]}),(0,I.jsxs)(y,{className:`flex flex-col gap-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`MCP endpoint`}),r===!1?(0,I.jsxs)(E,{children:[(0,I.jsx)(k,{className:`size-4`}),(0,I.jsx)(O,{children:`MCP is not enabled for this environment`}),(0,I.jsxs)(S,{className:`text-xs`,children:[`Connecting agents is opt-in. An admin can enable it by setting`,` `,(0,I.jsx)(`code`,{className:`font-mono`,children:`OS_MCP_SERVER_ENABLED=true`}),`. You can still generate a key and download the skill below.`]})]}):(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`flex-1 truncate rounded bg-muted px-2 py-1.5 font-mono text-xs`,children:K}),(0,I.jsx)(R,{value:K,label:`MCP URL`})]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,I.jsx)(_,{className:`size-3.5`}),` API key`]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{value:o,onChange:e=>l(e.target.value),placeholder:`Key name (e.g. Claude desktop)`,className:`h-8 max-w-xs text-sm`}),(0,I.jsx)(T,{type:`button`,size:`sm`,onClick:W,disabled:b,children:b?`Generating…`:`Generate key`})]}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The key acts as you (your permissions + row-level security). Shown once — copy it immediately. Revoke anytime from the API Keys list.`}),M&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:M})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Agent skill (portable)`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(T,{type:`button`,variant:`outline`,size:`sm`,className:`gap-1.5`,onClick:G,children:[(0,I.jsx)(g,{className:`size-4`}),` Download SKILL.md`]}),(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Works with any skills-capable agent (Claude, Codex, Gemini, Cursor…).`})]})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-3 text-xs leading-relaxed`,children:[(0,I.jsx)(`div`,{className:`mb-1 font-medium`,children:`Connect in 3 steps`}),(0,I.jsxs)(`ol`,{className:`list-decimal space-y-0.5 pl-4 text-muted-foreground`,children:[(0,I.jsx)(`li`,{children:`Add a remote MCP server pointing at the endpoint above.`}),(0,I.jsxs)(`li`,{children:[`Set the header `,(0,I.jsx)(`code`,{className:`font-mono`,children:`x-api-key: <your key>`}),` (a session Bearer is `,(0,I.jsx)(`em`,{children:`not`}),` an API key).`]}),(0,I.jsxs)(`li`,{children:[`Drop in `,(0,I.jsx)(`code`,{className:`font-mono`,children:`SKILL.md`}),` so the agent knows how to drive your data.`]})]})]})]}),(0,I.jsx)(p,{open:B,onOpenChange:V,children:(0,I.jsxs)(A,{children:[(0,I.jsxs)(s,{children:[(0,I.jsxs)(m,{className:`flex items-center gap-2`,children:[(0,I.jsx)(_,{className:`size-4`}),` Your new API key`]}),(0,I.jsxs)(a,{children:[`Copy this now — for your security it will `,(0,I.jsx)(`strong`,{children:`not be shown again`}),`.`]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`flex-1 break-all rounded bg-muted px-2 py-2 font-mono text-xs`,children:P?.key}),(0,I.jsxs)(T,{type:`button`,variant:`secondary`,size:`sm`,className:`gap-1.5`,onClick:()=>P&&U(P.key),children:[H?(0,I.jsx)(u,{className:`size-3.5`}):(0,I.jsx)(w,{className:`size-3.5`}),H?`Copied`:`Copy`]})]}),(0,I.jsxs)(E,{children:[(0,I.jsx)(k,{className:`size-4`}),(0,I.jsxs)(S,{className:`text-xs`,children:[`Send it as `,(0,I.jsx)(`code`,{className:`font-mono`,children:`x-api-key`}),`. It carries your permissions — store it like a password and revoke it if leaked.`]})]})]}),(0,I.jsx)(h,{children:(0,I.jsx)(T,{type:`button`,onClick:()=>V(!1),children:`Done`})})]})})]})}var B={GET:`bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,POST:`bg-blue-500/10 text-blue-700 dark:text-blue-400`,PATCH:`bg-amber-500/10 text-amber-700 dark:text-amber-400`,DELETE:`bg-red-500/10 text-red-700 dark:text-red-400`};function V({value:e,label:t}){let[n,r]=(0,j.useState)(!1);return(0,I.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2 text-xs`,onClick:()=>{navigator.clipboard?.writeText(e),r(!0),setTimeout(()=>r(!1),1500)},"aria-label":`Copy ${t??`value`}`,children:[n?(0,I.jsx)(u,{className:`size-3.5`}):(0,I.jsx)(w,{className:`size-3.5`}),n?`Copied`:`Copy`]})}function H(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,a=typeof window<`u`?window.location.origin:``,[s,u]=(0,j.useState)([]),[f,p]=(0,j.useState)(!0),[m,h]=(0,j.useState)(null);(0,j.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch(`/api/v1/meta/object`,{credentials:`include`});if(!t.ok)throw Error(`meta/object ${t.status}`);let n=await t.json(),r=n?.data??n?.items??n??[],i=(Array.isArray(r)?r:[]).map(e=>({name:String(e.name??``),label:e.label||void 0})).filter(e=>e.name&&!e.name.startsWith(`sys_`));e||u(i)}catch(t){e||h(t?.message??`failed to load objects`)}finally{e||p(!1)}})(),()=>{e=!0}},[]);let g=s[0]?.name??`your_object`,S=(0,j.useMemo)(()=>`# List ${g} records\ncurl "${a}/api/v1/data/${g}?$top=10" \\\n -H "x-api-key: <YOUR_API_KEY>"`,[a,g]),w=e=>[{method:`GET`,path:`/api/v1/data/${e}`,desc:`List / query`},{method:`POST`,path:`/api/v1/data/${e}`,desc:`Create`},{method:`GET`,path:`/api/v1/data/${e}/:id`,desc:`Read one`},{method:`PATCH`,path:`/api/v1/data/${e}/:id`,desc:`Update`},{method:`DELETE`,path:`/api/v1/data/${e}/:id`,desc:`Delete`}];return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,I.jsx)(o,{className:`size-5 text-primary`}),` Integrations & APIs`]}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Every object you build is instantly a REST API. Drive your app from code or an agent.`})]}),(0,I.jsxs)(c,{children:[(0,I.jsxs)(x,{className:`pb-2`,children:[(0,I.jsx)(d,{className:`text-base`,children:`Base URL`}),(0,I.jsx)(v,{className:`text-xs`,children:`This environment's API root.`})]}),(0,I.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`code`,{className:`flex-1 truncate rounded bg-muted px-2 py-1.5 font-mono text-xs`,children:[a,`/api/v1`]}),(0,I.jsx)(V,{value:`${a}/api/v1`,label:`base URL`})]})]}),(0,I.jsx)(z,{}),(0,I.jsxs)(c,{children:[(0,I.jsxs)(x,{className:`pb-2 flex flex-row items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(d,{className:`text-base flex items-center gap-2`,children:[(0,I.jsx)(l,{className:`size-4`}),` REST endpoints`]}),(0,I.jsx)(v,{className:`text-xs`,children:`Auto-generated CRUD for every published object (OData query params on list).`})]}),(0,I.jsxs)(T,{type:`button`,variant:`outline`,size:`sm`,className:`gap-1.5`,onClick:()=>e(`${r}/developer/api-console`),children:[(0,I.jsx)(b,{className:`size-4`}),` Open API Console`]})]}),(0,I.jsxs)(y,{className:`flex flex-col gap-4`,children:[f&&(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading objects…`}),m&&(0,I.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`Couldn't load objects: `,m]}),!f&&!m&&s.length===0&&(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No business objects yet — build one with the AI assistant, publish it, and it appears here as an API.`}),s.map(e=>(0,I.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`font-medium text-sm`,children:e.label||e.name}),(0,I.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground`,children:e.name})]}),(0,I.jsx)(`div`,{className:`divide-y`,children:w(e.name).map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1.5`,children:[(0,I.jsx)(C,{className:`w-16 justify-center font-mono text-[10px] ${B[e.method]??``}`,children:e.method}),(0,I.jsx)(`code`,{className:`flex-1 truncate font-mono text-xs`,children:e.path}),(0,I.jsx)(`span`,{className:`hidden shrink-0 text-xs text-muted-foreground sm:inline`,children:e.desc})]},e.method+e.path))})]},e.name))]})]}),(0,I.jsxs)(c,{children:[(0,I.jsx)(x,{className:`pb-2`,children:(0,I.jsxs)(d,{className:`text-base flex items-center gap-2`,children:[(0,I.jsx)(_,{className:`size-4`}),` Authentication`]})}),(0,I.jsxs)(y,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,I.jsxs)(`p`,{children:[`In the console you're already authenticated — use `,(0,I.jsx)(`strong`,{children:`Open API Console`}),` above to call these endpoints now.`]}),(0,I.jsxs)(`p`,{children:[`For external programs and AI agents, generate a `,(0,I.jsx)(`strong`,{children:`self-serve API key`}),` in the `,(0,I.jsx)(`strong`,{children:`Connect an AI agent`}),` section above. Send it as the`,` `,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:`x-api-key`}),` header; it runs under your permissions and row-level security, and is revocable.`]})]})]}),(0,I.jsxs)(c,{children:[(0,I.jsxs)(x,{className:`pb-2 flex flex-row items-center justify-between`,children:[(0,I.jsx)(d,{className:`text-base`,children:`Sample (cURL)`}),(0,I.jsx)(V,{value:S,label:`cURL sample`})]}),(0,I.jsx)(y,{children:(0,I.jsx)(`pre`,{className:`overflow-x-auto rounded bg-muted p-3 font-mono text-xs leading-relaxed`,children:S})})]})]})}export{H as IntegrationsPage};
82
+ `}var I=r();function L(){let[e,t]=(0,j.useState)(!1);return[e,e=>{navigator.clipboard?.writeText(e),t(!0),setTimeout(()=>t(!1),1500)}]}function R({value:e,label:t}){let[n,r]=L();return(0,I.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2 text-xs`,onClick:()=>r(e),"aria-label":`Copy ${t??`value`}`,children:[n?(0,I.jsx)(u,{className:`size-3.5`}):(0,I.jsx)(w,{className:`size-3.5`}),n?`Copied`:`Copy`]})}function z(){let e=typeof window<`u`?window.location.origin:``,[t,n]=(0,j.useState)(null),[r,i]=(0,j.useState)(null),[o,l]=(0,j.useState)(`Agent key`),[y,C]=(0,j.useState)(!1),[M,N]=(0,j.useState)(null),[P,z]=(0,j.useState)(null),[B,V]=(0,j.useState)(!1),[H,U]=L();(0,j.useEffect)(()=>{let t=!1;return(async()=>{try{let r=await(await fetch(`/api/v1/discovery`,{credentials:`include`})).json().catch(()=>({})),a=r?.data?.routes?.mcp??r?.routes?.mcp;if(t)return;a?(n(a.startsWith(`http`)?a:`${e}${a}`),i(!0)):i(!1)}catch{t||i(!1)}})(),()=>{t=!0}},[e]);let W=async()=>{C(!0),N(null);try{let e=await fetch(`/api/v1/keys`,{method:`POST`,credentials:`include`,headers:{"content-type":`application/json`},body:JSON.stringify({name:o.trim()||`Agent key`})}),t=await e.json().catch(()=>({})),n=t?.data;if(!e.ok||!n?.key)throw Error(t?.error?.message||`Request failed (${e.status})`);z(n),V(!0)}catch(e){N(e?.message??`Failed to generate key`)}finally{C(!1)}},G=()=>{let e=F({mcpUrl:t??void 0}),n=new Blob([e],{type:`text/markdown;charset=utf-8`}),r=document.createElement(`a`);r.href=URL.createObjectURL(n),r.download=`SKILL.md`,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(r.href),1e3)},K=t??`${e}/api/v1/mcp`;return(0,I.jsxs)(c,{children:[(0,I.jsxs)(b,{className:`pb-2`,children:[(0,I.jsxs)(d,{className:`text-base flex items-center gap-2`,children:[(0,I.jsx)(x,{className:`size-4`}),` Connect an AI agent (MCP)`]}),(0,I.jsx)(_,{className:`text-xs`,children:`Every app in this environment is an agent-ready toolset. Connect Claude, Cursor, Codex or any MCP client — one connection covers all your apps (new ones appear automatically).`})]}),(0,I.jsxs)(v,{className:`flex flex-col gap-4`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`MCP endpoint`}),r===!1?(0,I.jsxs)(E,{children:[(0,I.jsx)(k,{className:`size-4`}),(0,I.jsx)(O,{children:`MCP is not enabled for this environment`}),(0,I.jsxs)(S,{className:`text-xs`,children:[`Connecting agents is opt-in. An admin can enable it by setting`,` `,(0,I.jsx)(`code`,{className:`font-mono`,children:`OS_MCP_SERVER_ENABLED=true`}),`. You can still generate a key and download the skill below.`]})]}):(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`flex-1 truncate rounded bg-muted px-2 py-1.5 font-mono text-xs`,children:K}),(0,I.jsx)(R,{value:K,label:`MCP URL`})]})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,I.jsx)(g,{className:`size-3.5`}),` API key`]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(D,{value:o,onChange:e=>l(e.target.value),placeholder:`Key name (e.g. Claude desktop)`,className:`h-8 max-w-xs text-sm`}),(0,I.jsx)(T,{type:`button`,size:`sm`,onClick:W,disabled:y,children:y?`Generating…`:`Generate key`})]}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`The key acts as you (your permissions + row-level security). Shown once — copy it immediately. Revoke anytime from the API Keys list.`}),M&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:M})]}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`div`,{className:`mb-1 text-xs font-medium text-muted-foreground`,children:`Agent skill (portable)`}),(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(T,{type:`button`,variant:`outline`,size:`sm`,className:`gap-1.5`,onClick:G,children:[(0,I.jsx)(h,{className:`size-4`}),` Download SKILL.md`]}),(0,I.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Works with any skills-capable agent (Claude, Codex, Gemini, Cursor…).`})]})]}),(0,I.jsxs)(`div`,{className:`rounded-lg border bg-muted/30 p-3 text-xs leading-relaxed`,children:[(0,I.jsx)(`div`,{className:`mb-1 font-medium`,children:`Connect in 3 steps`}),(0,I.jsxs)(`ol`,{className:`list-decimal space-y-0.5 pl-4 text-muted-foreground`,children:[(0,I.jsx)(`li`,{children:`Add a remote MCP server pointing at the endpoint above.`}),(0,I.jsxs)(`li`,{children:[`Set the header `,(0,I.jsx)(`code`,{className:`font-mono`,children:`x-api-key: <your key>`}),` (a session Bearer is `,(0,I.jsx)(`em`,{children:`not`}),` an API key).`]}),(0,I.jsxs)(`li`,{children:[`Drop in `,(0,I.jsx)(`code`,{className:`font-mono`,children:`SKILL.md`}),` so the agent knows how to drive your data.`]})]})]})]}),(0,I.jsx)(f,{open:B,onOpenChange:V,children:(0,I.jsxs)(A,{children:[(0,I.jsxs)(s,{children:[(0,I.jsxs)(p,{className:`flex items-center gap-2`,children:[(0,I.jsx)(g,{className:`size-4`}),` Your new API key`]}),(0,I.jsxs)(a,{children:[`Copy this now — for your security it will `,(0,I.jsx)(`strong`,{children:`not be shown again`}),`.`]})]}),(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`code`,{className:`flex-1 break-all rounded bg-muted px-2 py-2 font-mono text-xs`,children:P?.key}),(0,I.jsxs)(T,{type:`button`,variant:`secondary`,size:`sm`,className:`gap-1.5`,onClick:()=>P&&U(P.key),children:[H?(0,I.jsx)(u,{className:`size-3.5`}):(0,I.jsx)(w,{className:`size-3.5`}),H?`Copied`:`Copy`]})]}),(0,I.jsxs)(E,{children:[(0,I.jsx)(k,{className:`size-4`}),(0,I.jsxs)(S,{className:`text-xs`,children:[`Send it as `,(0,I.jsx)(`code`,{className:`font-mono`,children:`x-api-key`}),`. It carries your permissions — store it like a password and revoke it if leaked.`]})]})]}),(0,I.jsx)(m,{children:(0,I.jsx)(T,{type:`button`,onClick:()=>V(!1),children:`Done`})})]})})]})}var B={GET:`bg-emerald-500/10 text-emerald-700 dark:text-emerald-400`,POST:`bg-blue-500/10 text-blue-700 dark:text-blue-400`,PATCH:`bg-amber-500/10 text-amber-700 dark:text-amber-400`,DELETE:`bg-red-500/10 text-red-700 dark:text-red-400`};function V({value:e,label:t}){let[n,r]=(0,j.useState)(!1);return(0,I.jsxs)(T,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 gap-1.5 px-2 text-xs`,onClick:()=>{navigator.clipboard?.writeText(e),r(!0),setTimeout(()=>r(!1),1500)},"aria-label":`Copy ${t??`value`}`,children:[n?(0,I.jsx)(u,{className:`size-3.5`}):(0,I.jsx)(w,{className:`size-3.5`}),n?`Copied`:`Copy`]})}function H(){let e=i(),{appName:t}=n(),r=t?`/apps/${t}`:``,a=typeof window<`u`?window.location.origin:``,[s,u]=(0,j.useState)([]),[f,p]=(0,j.useState)(!0),[m,h]=(0,j.useState)(null);(0,j.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch(`/api/v1/meta/object`,{credentials:`include`});if(!t.ok)throw Error(`meta/object ${t.status}`);let n=await t.json(),r=n?.data??n?.items??n??[],i=(Array.isArray(r)?r:[]).map(e=>({name:String(e.name??``),label:e.label||void 0})).filter(e=>e.name&&!e.name.startsWith(`sys_`));e||u(i)}catch(t){e||h(t?.message??`failed to load objects`)}finally{e||p(!1)}})(),()=>{e=!0}},[]);let x=s[0]?.name??`your_object`,S=(0,j.useMemo)(()=>`# List ${x} records\ncurl "${a}/api/v1/data/${x}?$top=10" \\\n -H "x-api-key: <YOUR_API_KEY>"`,[a,x]),w=e=>[{method:`GET`,path:`/api/v1/data/${e}`,desc:`List / query`},{method:`POST`,path:`/api/v1/data/${e}`,desc:`Create`},{method:`GET`,path:`/api/v1/data/${e}/:id`,desc:`Read one`},{method:`PATCH`,path:`/api/v1/data/${e}/:id`,desc:`Update`},{method:`DELETE`,path:`/api/v1/data/${e}/:id`,desc:`Delete`}];return(0,I.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,I.jsx)(o,{className:`size-5 text-primary`}),` Integrations & APIs`]}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Every object you build is instantly a REST API. Drive your app from code or an agent.`})]}),(0,I.jsxs)(c,{children:[(0,I.jsxs)(b,{className:`pb-2`,children:[(0,I.jsx)(d,{className:`text-base`,children:`Base URL`}),(0,I.jsx)(_,{className:`text-xs`,children:`This environment's API root.`})]}),(0,I.jsxs)(v,{className:`flex items-center gap-2`,children:[(0,I.jsxs)(`code`,{className:`flex-1 truncate rounded bg-muted px-2 py-1.5 font-mono text-xs`,children:[a,`/api/v1`]}),(0,I.jsx)(V,{value:`${a}/api/v1`,label:`base URL`})]})]}),(0,I.jsx)(z,{}),(0,I.jsxs)(c,{children:[(0,I.jsxs)(b,{className:`pb-2 flex flex-row items-center justify-between`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(d,{className:`text-base flex items-center gap-2`,children:[(0,I.jsx)(l,{className:`size-4`}),` REST endpoints`]}),(0,I.jsx)(_,{className:`text-xs`,children:`Auto-generated CRUD for every published object (OData query params on list).`})]}),(0,I.jsxs)(T,{type:`button`,variant:`outline`,size:`sm`,className:`gap-1.5`,onClick:()=>e(`${r}/developer/api-console`),children:[(0,I.jsx)(y,{className:`size-4`}),` Open API Console`]})]}),(0,I.jsxs)(v,{className:`flex flex-col gap-4`,children:[f&&(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading objects…`}),m&&(0,I.jsxs)(`p`,{className:`text-sm text-destructive`,children:[`Couldn't load objects: `,m]}),!f&&!m&&s.length===0&&(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No business objects yet — build one with the AI assistant, publish it, and it appears here as an API.`}),s.map(e=>(0,I.jsxs)(`div`,{className:`rounded-lg border`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-3 py-2`,children:[(0,I.jsx)(`span`,{className:`font-medium text-sm`,children:e.label||e.name}),(0,I.jsx)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground`,children:e.name})]}),(0,I.jsx)(`div`,{className:`divide-y`,children:w(e.name).map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1.5`,children:[(0,I.jsx)(C,{className:`w-16 justify-center font-mono text-[10px] ${B[e.method]??``}`,children:e.method}),(0,I.jsx)(`code`,{className:`flex-1 truncate font-mono text-xs`,children:e.path}),(0,I.jsx)(`span`,{className:`hidden shrink-0 text-xs text-muted-foreground sm:inline`,children:e.desc})]},e.method+e.path))})]},e.name))]})]}),(0,I.jsxs)(c,{children:[(0,I.jsx)(b,{className:`pb-2`,children:(0,I.jsxs)(d,{className:`text-base flex items-center gap-2`,children:[(0,I.jsx)(g,{className:`size-4`}),` Authentication`]})}),(0,I.jsxs)(v,{className:`flex flex-col gap-2 text-sm text-muted-foreground`,children:[(0,I.jsxs)(`p`,{children:[`In the console you're already authenticated — use `,(0,I.jsx)(`strong`,{children:`Open API Console`}),` above to call these endpoints now.`]}),(0,I.jsxs)(`p`,{children:[`For external programs and AI agents, generate a `,(0,I.jsx)(`strong`,{children:`self-serve API key`}),` in the `,(0,I.jsx)(`strong`,{children:`Connect an AI agent`}),` section above. Send it as the`,` `,(0,I.jsx)(`code`,{className:`font-mono text-xs`,children:`x-api-key`}),` header; it runs under your permissions and row-level security, and is revocable.`]})]})]}),(0,I.jsxs)(c,{children:[(0,I.jsxs)(b,{className:`pb-2 flex flex-row items-center justify-between`,children:[(0,I.jsx)(d,{className:`text-base`,children:`Sample (cURL)`}),(0,I.jsx)(V,{value:S,label:`cURL sample`})]}),(0,I.jsx)(v,{children:(0,I.jsx)(`pre`,{className:`overflow-x-auto rounded bg-muted p-3 font-mono text-xs leading-relaxed`,children:S})})]})]})}export{H as IntegrationsPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,p as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{A as a,B as o,H as s,i as c,k as l}from"./framework-DI54pxGD.js";import{H as u,I as d,Jo as f,R as p,z as m}from"./ui-components-BecTKcFn.js";import"./MetadataProvider-0eg8cMSY.js";import{t as h}from"./RecordDetailView-B11-8-pz.js";import{c as g}from"./plugins-views-FDlQfg4L.js";var _=e(t(),1),v=`uf_`;function y(e){let t={};return e.forEach((e,n)=>{if(n.startsWith(v)&&e!==``){let r=n.slice(3);t[r]=e.split(`,`).map(e=>{try{return decodeURIComponent(e)}catch{return e}})}}),Object.keys(t).length>0?t:void 0}function b(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t)){let t=v+e;r&&r.length>0?n.set(t,r.map(e=>encodeURIComponent(String(e))).join(`,`)):n.delete(t)}return n}var x=r();function S(e){return Array.isArray(e?.columns)&&e.columns.length>0}function C(e,t){let n=e?.listViews||e?.list_views||{},r=(t?[n[`${e?.name}.${t}`],n[t],...t==="default"||t===`list`?[e?.list]:[]]:[e?.list,...Object.values(n)]).filter(Boolean);return r.find(S)??r[0]}var w=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]);function ee(e){if(Array.isArray(e?.compactLayout)&&e.compactLayout.length>0)return e.compactLayout.filter(t=>e.fields?.[t]);let t=e?.fields;return t&&typeof t==`object`?Object.entries(t).filter(([e,t])=>t&&!t.hidden&&!w.has(e)).map(([e])=>e).slice(0,6):[]}function T(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!w.has(e)&&t(e,n))?.[0]}var E=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),D=new Set([`date`,`datetime`,`time`]),O=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function k(e){let t=T(e,(e,t)=>E.has(t.type))??T(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function A(e){return T(e,(e,t)=>D.has(t.type))??T(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function j(e){let t=A(e);return t?{startDateField:t}:void 0}function M(e){let t=T(e,(e,t)=>O.has(t.type));return t?{coverField:t}:void 0}var N=new Set([`location`,`geo`,`geolocation`,`geopoint`,`point`]);function P(e){let t=T(e,(e,t)=>D.has(t.type)&&/start|begin|kickoff/i.test(e))??T(e,(e,t)=>D.has(t.type));if(!t)return;let n=T(e,(e,n)=>D.has(n.type)&&e!==t&&/end|due|finish|deadline|close/i.test(e))??T(e,(e,n)=>D.has(n.type)&&e!==t);if(!n)return;let r=T(e,(e,t)=>(t.type===`number`||t.type===`percent`)&&/progress|percent|complete/i.test(e));return{startDateField:t,endDateField:n,...r?{progressField:r}:{}}}function F(e){let t=T(e,(e,t)=>N.has(t.type))??T(e,e=>/location|address|geo|coords?|place|venue/i.test(e));return t?{locationField:t}:void 0}function I({page:e,className:t,onConfigChange:r,reserveEditAffordance:v}){let{t:w}=c(),{objects:T}=a(),E=l(),D=i(),[O,A]=n(),[N]=_.useState(()=>y(new URLSearchParams(window.location.search))),I=_.useCallback(e=>{A(t=>b(t,e),{replace:!0})},[A]),L=e?.interfaceConfig||{},R=_.useMemo(()=>(T||[]).find(e=>e.name===L.source),[T,L.source]),z=_.useMemo(()=>C(R,L.sourceView),[R,L.sourceView]),B=L.recordAction===`page`||L.recordAction===`modal`||L.recordAction===`none`?L.recordAction:`drawer`,V=_.useCallback(e=>`/apps/${window.location.pathname.split(`/`)[2]||``}/${L.source}/record/${encodeURIComponent(String(e))}`,[L.source]),H=o({navigation:{mode:B===`none`?`none`:B},objectName:L.source,onNavigate:e=>D(V(e))}),U=O.get(`recordId`),W=_.useCallback((e,t)=>{if(B===`none`)return;let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(V(n),`_blank`);return}if((B===`drawer`||B===`modal`)&&n!=null){A(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t});return}H.handleClick(e,t)},[B,V,H,A]),G=_.useCallback(()=>{A(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[A]);_.useEffect(()=>{U&&!H.isOpen?H.open({id:U}):!U&&H.isOpen&&H.close()},[U]);let K=R?.name,q=!!z&&!S(z),J=z?.name??(L.sourceView?`${L.source}.${L.sourceView}`:void 0),[Y,X]=_.useState(null);_.useEffect(()=>{let e=!1;if(X(null),!(!K||!L.source||!q||!J))return(async()=>{try{let t=E,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(L.source))?.[J]??null),!S(n)&&typeof t?.getView==`function`&&(n=await t.getView(L.source,J)),!e&&n&&typeof n==`object`&&X(n)}catch{}})(),()=>{e=!0}},[K,L.source,L.sourceView,q,J,E]);let Z=_.useMemo(()=>Y?{...z,...Y}:z,[z,Y]),te=JSON.stringify(Z??null),Q=_.useMemo(()=>{if(!R)return;let e=Z||{},t=L.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=L.userActions||{},a=e.kanban??(r.has(`kanban`)?k(R):void 0),o=e.calendar??(r.has(`calendar`)?j(R):void 0),s=e.timeline??(r.has(`timeline`)?j(R):void 0),c=e.gallery??(r.has(`gallery`)?M(R):void 0),l=e.gantt??(r.has(`gantt`)?P(R):void 0),u=e.options?.map??(r.has(`map`)?F(R):void 0),d=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(L.filterBy)?L.filterBy:[]],f=S(L)?L.columns:S(e)?e.columns:ee(R),p=Array.isArray(L.sort)&&L.sort.length?L.sort:e.sort;return{type:`list-view`,objectName:R.name,viewType:n[0]??e.type??`grid`,fields:f,...d.length?{filters:d}:{},...p?.length?{sort:p}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:l,...u||e.options?{options:{...e.options??{},...u?{map:u}:{}}}:{},userFilters:L.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:L.showRecordCount,addRecord:L.addRecord,showSearch:i.search!==!1,showSort:i.sort!==!1,showFilters:i.filter===!0,showDensity:i.rowHeight===!0,showHideFields:!1,showGroup:!1,showColor:!1,allowExport:!1,inlineEdit:!1}},[K,te,L]);if(!R||!Q)return(0,x.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,x.jsxs)(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)(f,{className:`h-6 w-6 text-muted-foreground`})}),(0,x.jsx)(u,{children:w(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,x.jsx)(m,{children:w(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:L.source||`?`})})]})});let $=Array.isArray(L.buttons)&&L.buttons.length?L.buttons.map(e=>(R.actions||[]).find(t=>t?.name===e)).filter(Boolean).map(e=>({...e,locations:[`list_toolbar`]})):[];return(0,x.jsxs)(`div`,{className:t??`h-full flex flex-col`,"data-testid":`interface-list-page`,children:[(0,x.jsxs)(`div`,{className:`pl-4 pt-4 pb-2 shrink-0 flex items-start justify-between gap-3 ${v?`pr-12`:`pr-4`}`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h1`,{className:`text-lg font-semibold leading-tight`,children:typeof e.label==`string`?e.label:e.name}),typeof e.description==`string`&&e.description&&(0,x.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:e.description})]}),$.length>0&&(0,x.jsx)(`div`,{className:`shrink-0`,"data-testid":`interface-page-buttons`,children:(0,x.jsx)(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:E,userFilterSelections:N,onUserFilterSelectionsChange:I,onSortChange:r?e=>r({sort:e}):void 0,onColumnStateChange:r?e=>{e?.order?.length&&r({columns:e.order})}:void 0,onRowClick:B===`none`?void 0:W})}),H.isOverlay&&(0,x.jsx)(d,{...H,setIsOpen:e=>{e||G()},title:typeof e.label==`string`?e.label:L.source||`Record`,children:e=>(0,x.jsx)(h,{objectNameOverride:L.source,recordIdOverride:String(e?.id??e?._id??U??``),embedded:!0,dataSource:E,objects:T,onEdit:()=>{}})})]})}export{b as n,y as r,I as t};
1
+ import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,p as n,t as r,u as i}from"./vendor-react-ClIa1CJA.js";import{A as a,B as o,H as s,i as c,k as l}from"./framework-D5XqsLzE.js";import{H as u,I as d,Jo as f,R as p,z as m}from"./ui-components-DiLX53DV.js";import"./MetadataProvider-QdHbK1P5.js";import{t as h}from"./RecordDetailView-BgaxhKDF.js";import{c as g}from"./plugins-views-Ck67hsjt.js";var _=e(t(),1),v=`uf_`;function y(e){let t={};return e.forEach((e,n)=>{if(n.startsWith(v)&&e!==``){let r=n.slice(3);t[r]=e.split(`,`).map(e=>{try{return decodeURIComponent(e)}catch{return e}})}}),Object.keys(t).length>0?t:void 0}function b(e,t){let n=new URLSearchParams(e);for(let[e,r]of Object.entries(t)){let t=v+e;r&&r.length>0?n.set(t,r.map(e=>encodeURIComponent(String(e))).join(`,`)):n.delete(t)}return n}var x=r();function S(e){return Array.isArray(e?.columns)&&e.columns.length>0}function C(e,t){let n=e?.listViews||e?.list_views||{},r=(t?[n[`${e?.name}.${t}`],n[t],...t==="default"||t===`list`?[e?.list]:[]]:[e?.list,...Object.values(n)]).filter(Boolean);return r.find(S)??r[0]}var w=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]);function ee(e){if(Array.isArray(e?.compactLayout)&&e.compactLayout.length>0)return e.compactLayout.filter(t=>e.fields?.[t]);let t=e?.fields;return t&&typeof t==`object`?Object.entries(t).filter(([e,t])=>t&&!t.hidden&&!w.has(e)).map(([e])=>e).slice(0,6):[]}function T(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!w.has(e)&&t(e,n))?.[0]}var E=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),D=new Set([`date`,`datetime`,`time`]),O=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function k(e){let t=T(e,(e,t)=>E.has(t.type))??T(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function A(e){return T(e,(e,t)=>D.has(t.type))??T(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function j(e){let t=A(e);return t?{startDateField:t}:void 0}function M(e){let t=T(e,(e,t)=>O.has(t.type));return t?{coverField:t}:void 0}var N=new Set([`location`,`geo`,`geolocation`,`geopoint`,`point`]);function P(e){let t=T(e,(e,t)=>D.has(t.type)&&/start|begin|kickoff/i.test(e))??T(e,(e,t)=>D.has(t.type));if(!t)return;let n=T(e,(e,n)=>D.has(n.type)&&e!==t&&/end|due|finish|deadline|close/i.test(e))??T(e,(e,n)=>D.has(n.type)&&e!==t);if(!n)return;let r=T(e,(e,t)=>(t.type===`number`||t.type===`percent`)&&/progress|percent|complete/i.test(e));return{startDateField:t,endDateField:n,...r?{progressField:r}:{}}}function F(e){let t=T(e,(e,t)=>N.has(t.type))??T(e,e=>/location|address|geo|coords?|place|venue/i.test(e));return t?{locationField:t}:void 0}function I({page:e,className:t,onConfigChange:r,reserveEditAffordance:v}){let{t:w}=c(),{objects:T}=a(),E=l(),D=i(),[O,A]=n(),[N]=_.useState(()=>y(new URLSearchParams(window.location.search))),I=_.useCallback(e=>{A(t=>b(t,e),{replace:!0})},[A]),L=e?.interfaceConfig||{},R=_.useMemo(()=>(T||[]).find(e=>e.name===L.source),[T,L.source]),z=_.useMemo(()=>C(R,L.sourceView),[R,L.sourceView]),B=L.recordAction===`page`||L.recordAction===`modal`||L.recordAction===`none`?L.recordAction:`drawer`,V=_.useCallback(e=>`/apps/${window.location.pathname.split(`/`)[2]||``}/${L.source}/record/${encodeURIComponent(String(e))}`,[L.source]),H=o({navigation:{mode:B===`none`?`none`:B},objectName:L.source,onNavigate:e=>D(V(e))}),U=O.get(`recordId`),W=_.useCallback((e,t)=>{if(B===`none`)return;let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(V(n),`_blank`);return}if((B===`drawer`||B===`modal`)&&n!=null){A(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t});return}H.handleClick(e,t)},[B,V,H,A]),G=_.useCallback(()=>{A(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[A]);_.useEffect(()=>{U&&!H.isOpen?H.open({id:U}):!U&&H.isOpen&&H.close()},[U]);let K=R?.name,q=!!z&&!S(z),J=z?.name??(L.sourceView?`${L.source}.${L.sourceView}`:void 0),[Y,X]=_.useState(null);_.useEffect(()=>{let e=!1;if(X(null),!(!K||!L.source||!q||!J))return(async()=>{try{let t=E,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(L.source))?.[J]??null),!S(n)&&typeof t?.getView==`function`&&(n=await t.getView(L.source,J)),!e&&n&&typeof n==`object`&&X(n)}catch{}})(),()=>{e=!0}},[K,L.source,L.sourceView,q,J,E]);let Z=_.useMemo(()=>Y?{...z,...Y}:z,[z,Y]),te=JSON.stringify(Z??null),Q=_.useMemo(()=>{if(!R)return;let e=Z||{},t=L.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=L.userActions||{},a=e.kanban??(r.has(`kanban`)?k(R):void 0),o=e.calendar??(r.has(`calendar`)?j(R):void 0),s=e.timeline??(r.has(`timeline`)?j(R):void 0),c=e.gallery??(r.has(`gallery`)?M(R):void 0),l=e.gantt??(r.has(`gantt`)?P(R):void 0),u=e.options?.map??(r.has(`map`)?F(R):void 0),d=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(L.filterBy)?L.filterBy:[]],f=S(L)?L.columns:S(e)?e.columns:ee(R),p=Array.isArray(L.sort)&&L.sort.length?L.sort:e.sort;return{type:`list-view`,objectName:R.name,viewType:n[0]??e.type??`grid`,fields:f,...d.length?{filters:d}:{},...p?.length?{sort:p}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:l,...u||e.options?{options:{...e.options??{},...u?{map:u}:{}}}:{},userFilters:L.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:L.showRecordCount,addRecord:L.addRecord,showSearch:i.search!==!1,showSort:i.sort!==!1,showFilters:i.filter===!0,showDensity:i.rowHeight===!0,showHideFields:!1,showGroup:!1,showColor:!1,allowExport:!1,inlineEdit:!1}},[K,te,L]);if(!R||!Q)return(0,x.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,x.jsxs)(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)(f,{className:`h-6 w-6 text-muted-foreground`})}),(0,x.jsx)(u,{children:w(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,x.jsx)(m,{children:w(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:L.source||`?`})})]})});let $=Array.isArray(L.buttons)&&L.buttons.length?L.buttons.map(e=>(R.actions||[]).find(t=>t?.name===e)).filter(Boolean).map(e=>({...e,locations:[`list_toolbar`]})):[];return(0,x.jsxs)(`div`,{className:t??`h-full flex flex-col`,"data-testid":`interface-list-page`,children:[(0,x.jsxs)(`div`,{className:`pl-4 pt-4 pb-2 shrink-0 flex items-start justify-between gap-3 ${v?`pr-12`:`pr-4`}`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`h1`,{className:`text-lg font-semibold leading-tight`,children:typeof e.label==`string`?e.label:e.name}),typeof e.description==`string`&&e.description&&(0,x.jsx)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:e.description})]}),$.length>0&&(0,x.jsx)(`div`,{className:`shrink-0`,"data-testid":`interface-page-buttons`,children:(0,x.jsx)(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:E,userFilterSelections:N,onUserFilterSelectionsChange:I,onSortChange:r?e=>r({sort:e}):void 0,onColumnStateChange:r?e=>{e?.order?.length&&r({columns:e.order})}:void 0,onRowClick:B===`none`?void 0:W})}),H.isOverlay&&(0,x.jsx)(d,{...H,setIsOpen:e=>{e||G()},title:typeof e.label==`string`?e.label:L.source||`Record`,children:e=>(0,x.jsx)(h,{objectNameOverride:L.source,recordIdOverride:String(e?.id??e?._id??U??``),embedded:!0,dataSource:E,objects:T,onEdit:()=>{}})})]})}export{b as n,y as r,I as t};
@@ -1 +1 @@
1
- import{t as e}from"./vendor-react-ClIa1CJA.js";import{At as t,Na as n,Ot as r,bi as i,er as a,hc as o,jt as s,kt as c,vi as l,yc as u}from"./ui-components-BecTKcFn.js";var d=e(),f={config:{icon:i,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:n,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:o,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:l,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. Use the dedicated identity workflows instead (Invite User, Reset Password, Revoke Session, Rotate Key, …).`,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:n,className:i}){if(!e||e===`platform`)return null;let o=f[e];if(!o)return null;let l=o.icon,p=n??`better-auth`;return(0,d.jsx)(t,{delayDuration:200,children:(0,d.jsxs)(r,{children:[(0,d.jsx)(s,{asChild:!0,children:(0,d.jsxs)(a,{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`,o.tone,i),children:[(0,d.jsx)(l,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{children:o.short})]})}),(0,d.jsxs)(c,{side:`bottom`,align:`start`,className:`max-w-xs text-xs leading-relaxed`,children:[(0,d.jsx)(`p`,{className:`font-semibold mb-1`,children:o.title}),(0,d.jsx)(`p`,{className:`text-muted-foreground`,children:o.body(p)})]})]})})}export{p as t};
1
+ import{t as e}from"./vendor-react-ClIa1CJA.js";import{At as t,Na as n,Ot as r,bi as i,er as a,jt as o,kt as s,mc as c,vc as l,vi as u}from"./ui-components-DiLX53DV.js";var d=e(),f={config:{icon:i,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:n,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:u,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. Use the dedicated identity workflows instead (Invite User, Reset Password, Revoke Session, Rotate Key, …).`,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:n,className:i}){if(!e||e===`platform`)return null;let c=f[e];if(!c)return null;let u=c.icon,p=n??`better-auth`;return(0,d.jsx)(t,{delayDuration:200,children:(0,d.jsxs)(r,{children:[(0,d.jsx)(o,{asChild:!0,children:(0,d.jsxs)(a,{variant:`outline`,"data-testid":`managed-by-badge`,"data-bucket":e,className:l(`gap-1 font-normal text-[11px] leading-none py-0.5 px-1.5 cursor-help`,c.tone,i),children:[(0,d.jsx)(u,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{children:c.short})]})}),(0,d.jsxs)(s,{side:`bottom`,align:`start`,className:`max-w-xs text-xs leading-relaxed`,children:[(0,d.jsx)(`p`,{className:`font-semibold mb-1`,children:c.title}),(0,d.jsx)(`p`,{className:`text-muted-foreground`,children:c.body(p)})]})]})})}export{p as t};
@@ -1 +1 @@
1
- import{f as e,t,u as n}from"./vendor-react-ClIa1CJA.js";import{i as r}from"./framework-DI54pxGD.js";import{Jn as i,Na as a,Yn as o,gr as s}from"./ui-components-BecTKcFn.js";var c=t();function l(){let t=n(),{appName:l}=e(),{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:()=>t(d),children:u(`marketplace.action.backHome`)})]})})})}export{l as t};
1
+ import{f as e,t,u as n}from"./vendor-react-ClIa1CJA.js";import{i as r}from"./framework-D5XqsLzE.js";import{Jn as i,Na as a,Yn as o,gr as s}from"./ui-components-DiLX53DV.js";var c=t();function l(){let t=n(),{appName:l}=e(),{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:()=>t(d),children:u(`marketplace.action.backHome`)})]})})})}export{l as t};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-ClIa1CJA.js";import{d as o}from"./infrastructure-BsIvKvpW.js";import{Ct as s,i as c}from"./framework-DI54pxGD.js";import{Bo as l,Hr as u,Jn as d,Li as f,Mt as p,Qn as m,Yn as h,Zn as g,er as _,gr as v,pc as y,ti as b,ws as x}from"./ui-components-BecTKcFn.js";import{_ as S,l as C,u as w}from"./marketplaceApi-DL8PegzV.js";import{t as T}from"./MarketplaceAccessDenied-BfvByBjR.js";var E=e(n(),1),D=i();function O(){let e=a(),{appName:t}=r(),n=o(),{t:i,language:s}=c(),y=t?`/apps/${t}`:``,[b,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(i(`marketplace.uninstall.confirm`,{manifestId:e.manifestId,version:e.version}))){P(e.manifestId),I(null);try{await S(e.manifestId),I({ok:!0,message:i(`marketplace.uninstall.successInList`,{manifestId:e.manifestId})}),await L()}catch(e){I({ok:!1,message:e?.message??String(e)})}finally{P(null)}}};return n?(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:j,children:[(0,D.jsx)(f,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`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)(x,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{children:F.message})]})}),j&&b.length===0?(0,D.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(p,{className:`h-20 w-full`},t))}):b.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:i(`marketplace.installedEmpty`)}),(0,D.jsx)(v,{variant:`link`,className:`mt-2`,onClick:()=>e(`${y}/system/marketplace`),children:i(`marketplace.browseLink`)})]}):(0,D.jsx)(`div`,{className:`grid gap-3`,children:b.map(t=>(0,D.jsxs)(d,{children:[(0,D.jsxs)(g,{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)(m,{className:`text-base truncate flex items-center gap-2`,children:[t.manifestId,(0,D.jsx)(_,{variant:`outline`,children:i(`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:i(`marketplace.installedAt`,{when:new Date(t.installedAt).toLocaleString(s||void 0)})}),t.installedBy&&(0,D.jsx)(`span`,{children:i(`marketplace.installedBy`,{user:t.installedBy})}),(0,D.jsxs)(`span`,{children:[i(`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)(v,{variant:`ghost`,size:`sm`,onClick:()=>e(`${y}/system/marketplace/${t.packageId}`),children:[(0,D.jsx)(l,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.action.details`)]}),k===`local`&&(0,D.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>void R(t),disabled:N===t.manifestId,children:[(0,D.jsx)(u,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),N===t.manifestId?i(`marketplace.action.uninstalling`):i(`marketplace.action.uninstall`)]})]})]}),k===`local`&&(0,D.jsx)(h,{className:`pt-0 text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:i(`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:i(`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=a(),{appName:t}=r(),{t:n}=c(),i=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)(v,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>e(`${i}/system/marketplace`),children:[(0,D.jsx)(y,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),n(`marketplace.back`)]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(b,{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:n(`marketplace.installedTitle`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,dangerouslySetInnerHTML:{__html:n(`marketplace.installedSubtitle`)}})]}),(0,D.jsx)(O,{})]})}export{k as t};
1
+ import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-ClIa1CJA.js";import{d as o}from"./infrastructure-HR_Bc4bJ.js";import{i as s,wt as c}from"./framework-D5XqsLzE.js";import{Bo as l,Hr as u,Jn as d,Li as f,Mt as p,Qn as m,Yn as h,Zn as g,er as _,fc as v,gr as y,ti as b,ws as x}from"./ui-components-DiLX53DV.js";import{_ as S,l as C,u as w}from"./marketplaceApi-BEwXWaVr.js";import{t as T}from"./MarketplaceAccessDenied-BRaR8_1a.js";var E=e(n(),1),D=i();function O(){let e=a(),{appName:t}=r(),n=o(),{t:i,language:c}=s(),v=t?`/apps/${t}`:``,[b,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(i(`marketplace.uninstall.confirm`,{manifestId:e.manifestId,version:e.version}))){P(e.manifestId),I(null);try{await S(e.manifestId),I({ok:!0,message:i(`marketplace.uninstall.successInList`,{manifestId:e.manifestId})}),await L()}catch(e){I({ok:!1,message:e?.message??String(e)})}finally{P(null)}}};return n?(0,D.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,D.jsx)(`div`,{className:`flex justify-end`,children:(0,D.jsxs)(y,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:j,children:[(0,D.jsx)(f,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`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)(x,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{children:F.message})]})}),j&&b.length===0?(0,D.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(p,{className:`h-20 w-full`},t))}):b.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:i(`marketplace.installedEmpty`)}),(0,D.jsx)(y,{variant:`link`,className:`mt-2`,onClick:()=>e(`${v}/system/marketplace`),children:i(`marketplace.browseLink`)})]}):(0,D.jsx)(`div`,{className:`grid gap-3`,children:b.map(t=>(0,D.jsxs)(d,{children:[(0,D.jsxs)(g,{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)(m,{className:`text-base truncate flex items-center gap-2`,children:[t.manifestId,(0,D.jsx)(_,{variant:`outline`,children:i(`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:i(`marketplace.installedAt`,{when:new Date(t.installedAt).toLocaleString(c||void 0)})}),t.installedBy&&(0,D.jsx)(`span`,{children:i(`marketplace.installedBy`,{user:t.installedBy})}),(0,D.jsxs)(`span`,{children:[i(`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)(y,{variant:`ghost`,size:`sm`,onClick:()=>e(`${v}/system/marketplace/${t.packageId}`),children:[(0,D.jsx)(l,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.action.details`)]}),k===`local`&&(0,D.jsxs)(y,{variant:`outline`,size:`sm`,onClick:()=>void R(t),disabled:N===t.manifestId,children:[(0,D.jsx)(u,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),N===t.manifestId?i(`marketplace.action.uninstalling`):i(`marketplace.action.uninstall`)]})]})]}),k===`local`&&(0,D.jsx)(h,{className:`pt-0 text-xs text-muted-foreground`,dangerouslySetInnerHTML:{__html:i(`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:i(`marketplace.installedAdditiveNote`)}})]}):(0,D.jsx)(T,{})}c.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=a(),{appName:t}=r(),{t:n}=s(),i=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)(y,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>e(`${i}/system/marketplace`),children:[(0,D.jsx)(v,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),n(`marketplace.back`)]}),(0,D.jsxs)(`div`,{children:[(0,D.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,D.jsx)(b,{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:n(`marketplace.installedTitle`)})]}),(0,D.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,dangerouslySetInnerHTML:{__html:n(`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-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-ClIa1CJA.js";import{d as ee}from"./infrastructure-BsIvKvpW.js";import{A as te,i as ne}from"./framework-DI54pxGD.js";import{Bn as re,Bo as ie,Bt as ae,Cs as oe,Dr as o,Hn as se,Hr as ce,Ht as le,Jn as ue,Jo as de,Mt as s,Pa as c,Qn as fe,Rn as pe,Un as me,Ut as he,Vn as ge,Vo as _e,Vt as ve,Wo as ye,Wt as be,Xs as l,Yn as xe,Zn as Se,_i as u,cn as Ce,da as we,er as d,gn as Te,gr as f,is as p,on as m,pa as h,pc as Ee,qn as g,sn as De,un as _,vi as Oe,ws as v,xs as y,yo as ke,zn as Ae}from"./ui-components-BecTKcFn.js";import"./MetadataProvider-0eg8cMSY.js";import{n as je}from"./assistantBus-BMrg1uLy.js";import{_ as Me,a as Ne,b,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-DL8PegzV.js";import{n as We,t as Ge}from"./usePackageL10n-DIEe85Ot.js";import{t as Ke}from"./MarketplaceAccessDenied-BfvByBjR.js";var S=e(n(),1),C=i();function qe(e){let t=e.replace(/\r\n/g,`
1
+ import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-ClIa1CJA.js";import{d as ee}from"./infrastructure-HR_Bc4bJ.js";import{A as te,i as ne}from"./framework-D5XqsLzE.js";import{Bn as re,Bo as ie,Bt as ae,Cs as oe,Dr as o,Hn as se,Hr as ce,Ht as le,Jn as ue,Jo as de,Mt as s,Pa as c,Qn as fe,Rn as pe,Un as me,Ut as he,Vn as ge,Vo as _e,Vt as ve,Wo as ye,Wt as be,Yn as xe,Ys as l,Zn as Se,_i as u,cn as Ce,da as we,er as d,fc as Te,gn as Ee,gr as f,is as p,on as m,pa as h,qn as g,sn as De,un as _,vi as Oe,ws as v,xs as y,yo as ke,zn as Ae}from"./ui-components-DiLX53DV.js";import"./MetadataProvider-QdHbK1P5.js";import{n as je}from"./assistantBus-BMrg1uLy.js";import{_ as Me,a as Ne,b,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-BEwXWaVr.js";import{n as We,t as Ge}from"./usePackageL10n-DIEe85Ot.js";import{t as Ke}from"./MarketplaceAccessDenied-BRaR8_1a.js";var S=e(n(),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)(p,{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)(d,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:T[e.runtime]??e.runtime})}),e.platform_verified?(0,C.jsxs)(d,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,C.jsx)(u,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,C.jsxs)(d,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,C.jsx)(Oe,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,C.jsxs)(d,{variant:`outline`,className:`gap-1`,children:[(0,C.jsx)(y,{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:l,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,C.jsx)(E,{icon:o,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,C.jsx)(E,{icon:h,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,C.jsx)(E,{icon:ke,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=a(),{packageId:t,appName:n}=r(),i=ee(),{t:o,language:l}=ne(),u=n?`/apps/${n}`:``,{refresh:p}=te(),[h,Oe]=(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||Oe(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{it(((await ze({packageId:t,environmentId:M,seedSampleData:P}))?.installation?.version??h?.package?.latest_version?.version??h?.versions?.[0]?.version??``)||`installed`);try{let e=b().defaultEnvironmentId||M;if(e){let n=await x(t,e);n&&B(n)}}catch{}let e=b().defaultEnvironmentId;if(!e||e===M)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await p()}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 p(`app`)}catch{}Y({ok:!0,message:o(`marketplace.install.localSuccess`,{version:e.version,name:h?.package?Ge(h.package,l).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 p(`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)(s,{className:`h-8 w-32`}),(0,C.jsx)(s,{className:`h-16 w-full`}),(0,C.jsx)(s,{className:`h-64 w-full`})]});if(w||!h)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)(f,{variant:`ghost`,size:`sm`,onClick:()=>e(`${u}/system/marketplace`),children:[(0,C.jsx)(Ee,{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)(v,{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=h.package,Z=Ge(X,l),Q=X.latest_version?.version??h.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 i?(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)(f,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${u}/system/marketplace`),children:[(0,C.jsx)(Ee,{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)(ie,{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)(d,{variant:`outline`,children:o(`marketplace.versionBadge`,{version:Q})}),X.publisher&&X.publisher!==`private`&&(0,C.jsx)(d,{variant:X.publisher===`objectstack`?`default`:`secondary`,children:X.publisher}),yt&&(0,C.jsx)(d,{variant:`outline`,children:yt}),X.license&&(0,C.jsx)(d,{variant:`outline`,className:`font-normal`,children:X.license}),$&&(0,C.jsxs)(d,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(y,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:$.version})]}),!$&&R&&(0,C.jsxs)(d,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(y,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:R})]}),ht&&(0,C.jsxs)(d,{variant:`default`,className:`bg-amber-500 hover:bg-amber-500 gap-1`,children:[(0,C.jsx)(oe,{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)(f,{onClick:vt.onClick,disabled:_t,size:`lg`,className:`min-w-[8rem]`,children:[(0,C.jsx)(ye,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),vt.label]}),$&&(0,C.jsxs)(De,{children:[(0,C.jsx)(Te,{asChild:!0,children:(0,C.jsx)(f,{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)(Ce,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(_,{onSelect:ft,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(c,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(de,{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)(_,{onSelect:pt,disabled:V!==null||!$.withSampleData,className:`text-destructive focus:text-destructive`,children:[V===`purge`?(0,C.jsx)(c,{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`}),o(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,C.jsxs)(_,{onSelect:lt,disabled:K,className:`text-destructive focus:text-destructive`,children:[(0,C.jsx)(ce,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!$&&z&&!b().cloudUrl&&(0,C.jsxs)(De,{children:[(0,C.jsx)(Te,{asChild:!0,children:(0,C.jsx)(f,{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)(Ce,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(_,{onSelect:ut,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(c,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(de,{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)(_,{onSelect:dt,disabled:V!==null||!z.withSampleData,className:`text-destructive focus:text-destructive`,children:[V===`purge`?(0,C.jsx)(c,{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`}),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)(y,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(v,{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)(y,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(v,{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)(ue,{children:[(0,C.jsx)(Se,{children:(0,C.jsx)(fe,{className:`text-base`,children:o(`marketplace.detail.about`)})}),(0,C.jsx)(xe,{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)(ue,{children:[(0,C.jsx)(Se,{children:(0,C.jsx)(fe,{className:`text-base`,children:o(`marketplace.detail.versions`)})}),(0,C.jsx)(xe,{children:h.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:h.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)(we,{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)(d,{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)(pe,{open:E,onOpenChange:e=>{D(e),e||(L(null),nt(!1))},children:(0,C.jsxs)(Ae,{children:[(0,C.jsxs)(se,{children:[(0,C.jsx)(me,{children:o(`marketplace.install.dialogTitle`,{name:Z.displayName||X.manifest_id})}),(0,C.jsx)(re,{children:b().defaultEnvironmentId?o(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):o(`marketplace.install.dialogDescPicker`)})]}),Ze?(0,C.jsx)(s,{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)(v,{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)(f,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,C.jsx)(ie,{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)(g,{id:`seed`,checked:P,onCheckedChange:e=>et(e===!0)}),(0,C.jsx)(m,{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)(m,{htmlFor:`env-select`,children:o(`marketplace.install.environment`)}),(0,C.jsxs)(ae,{value:M,onValueChange:N,children:[(0,C.jsx)(he,{id:`env-select`,children:(0,C.jsx)(be,{placeholder:o(`marketplace.install.environmentPlaceholder`)})}),(0,C.jsx)(ve,{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)(g,{id:`seed`,checked:P,onCheckedChange:e=>et(e===!0)}),(0,C.jsx)(m,{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)(g,{id:`ack-perms`,checked:tt,onCheckedChange:e=>nt(e===!0)}),(0,C.jsx)(m,{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)(ge,{children:[(0,C.jsx)(f,{variant:`outline`,onClick:()=>D(!1),children:o(`marketplace.action.close`)}),!A&&(0,C.jsx)(f,{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)(p,{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)(d,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:T[e.runtime]??e.runtime})}),e.platform_verified?(0,C.jsxs)(d,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,C.jsx)(u,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,C.jsxs)(d,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,C.jsx)(Oe,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,C.jsxs)(d,{variant:`outline`,className:`gap-1`,children:[(0,C.jsx)(y,{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:l,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,C.jsx)(E,{icon:o,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,C.jsx)(E,{icon:h,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,C.jsx)(E,{icon:ke,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=a(),{packageId:t,appName:n}=r(),i=ee(),{t:o,language:l}=ne(),u=n?`/apps/${n}`:``,{refresh:p}=te(),[h,Oe]=(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||Oe(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{it(((await ze({packageId:t,environmentId:M,seedSampleData:P}))?.installation?.version??h?.package?.latest_version?.version??h?.versions?.[0]?.version??``)||`installed`);try{let e=b().defaultEnvironmentId||M;if(e){let n=await x(t,e);n&&B(n)}}catch{}let e=b().defaultEnvironmentId;if(!e||e===M)try{if(typeof sessionStorage<`u`)for(let e of Object.keys(sessionStorage))e.startsWith(`objectui:metadata:`)&&sessionStorage.removeItem(e);await p()}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 p(`app`)}catch{}Y({ok:!0,message:o(`marketplace.install.localSuccess`,{version:e.version,name:h?.package?Ge(h.package,l).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 p(`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)(s,{className:`h-8 w-32`}),(0,C.jsx)(s,{className:`h-16 w-full`}),(0,C.jsx)(s,{className:`h-64 w-full`})]});if(w||!h)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)(f,{variant:`ghost`,size:`sm`,onClick:()=>e(`${u}/system/marketplace`),children:[(0,C.jsx)(Te,{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)(v,{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=h.package,Z=Ge(X,l),Q=X.latest_version?.version??h.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 i?(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)(f,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${u}/system/marketplace`),children:[(0,C.jsx)(Te,{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)(ie,{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)(d,{variant:`outline`,children:o(`marketplace.versionBadge`,{version:Q})}),X.publisher&&X.publisher!==`private`&&(0,C.jsx)(d,{variant:X.publisher===`objectstack`?`default`:`secondary`,children:X.publisher}),yt&&(0,C.jsx)(d,{variant:`outline`,children:yt}),X.license&&(0,C.jsx)(d,{variant:`outline`,className:`font-normal`,children:X.license}),$&&(0,C.jsxs)(d,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(y,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:$.version})]}),!$&&R&&(0,C.jsxs)(d,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(y,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`marketplace.detail.installedV`,{version:R})]}),ht&&(0,C.jsxs)(d,{variant:`default`,className:`bg-amber-500 hover:bg-amber-500 gap-1`,children:[(0,C.jsx)(oe,{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)(f,{onClick:vt.onClick,disabled:_t,size:`lg`,className:`min-w-[8rem]`,children:[(0,C.jsx)(ye,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),vt.label]}),$&&(0,C.jsxs)(De,{children:[(0,C.jsx)(Ee,{asChild:!0,children:(0,C.jsx)(f,{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)(Ce,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(_,{onSelect:ft,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(c,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(de,{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)(_,{onSelect:pt,disabled:V!==null||!$.withSampleData,className:`text-destructive focus:text-destructive`,children:[V===`purge`?(0,C.jsx)(c,{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`}),o(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,C.jsxs)(_,{onSelect:lt,disabled:K,className:`text-destructive focus:text-destructive`,children:[(0,C.jsx)(ce,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),o(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!$&&z&&!b().cloudUrl&&(0,C.jsxs)(De,{children:[(0,C.jsx)(Ee,{asChild:!0,children:(0,C.jsx)(f,{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)(Ce,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(_,{onSelect:ut,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(c,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(de,{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)(_,{onSelect:dt,disabled:V!==null||!z.withSampleData,className:`text-destructive focus:text-destructive`,children:[V===`purge`?(0,C.jsx)(c,{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`}),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)(y,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(v,{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)(y,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(v,{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)(ue,{children:[(0,C.jsx)(Se,{children:(0,C.jsx)(fe,{className:`text-base`,children:o(`marketplace.detail.about`)})}),(0,C.jsx)(xe,{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)(ue,{children:[(0,C.jsx)(Se,{children:(0,C.jsx)(fe,{className:`text-base`,children:o(`marketplace.detail.versions`)})}),(0,C.jsx)(xe,{children:h.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:h.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)(we,{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)(d,{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)(pe,{open:E,onOpenChange:e=>{D(e),e||(L(null),nt(!1))},children:(0,C.jsxs)(Ae,{children:[(0,C.jsxs)(se,{children:[(0,C.jsx)(me,{children:o(`marketplace.install.dialogTitle`,{name:Z.displayName||X.manifest_id})}),(0,C.jsx)(re,{children:b().defaultEnvironmentId?o(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):o(`marketplace.install.dialogDescPicker`)})]}),Ze?(0,C.jsx)(s,{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)(v,{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)(f,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,C.jsx)(ie,{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)(g,{id:`seed`,checked:P,onCheckedChange:e=>et(e===!0)}),(0,C.jsx)(m,{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)(m,{htmlFor:`env-select`,children:o(`marketplace.install.environment`)}),(0,C.jsxs)(ae,{value:M,onValueChange:N,children:[(0,C.jsx)(he,{id:`env-select`,children:(0,C.jsx)(be,{placeholder:o(`marketplace.install.environmentPlaceholder`)})}),(0,C.jsx)(ve,{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)(g,{id:`seed`,checked:P,onCheckedChange:e=>et(e===!0)}),(0,C.jsx)(m,{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)(g,{id:`ack-perms`,checked:tt,onCheckedChange:e=>nt(e===!0)}),(0,C.jsx)(m,{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)(ge,{children:[(0,C.jsx)(f,{variant:`outline`,onClick:()=>D(!1),children:o(`marketplace.action.close`)}),!A&&(0,C.jsx)(f,{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-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-ClIa1CJA.js";import{d as o}from"./infrastructure-BsIvKvpW.js";import{i as s}from"./framework-DI54pxGD.js";import{Ci as ee,Jn as c,Li as l,Mt as u,Qn as d,Xn as f,Yn as p,Zn as m,da as h,er as g,gr as _,nn as v,ti as y,ws as te,xi as ne,xs as b}from"./ui-components-BecTKcFn.js";import{n as re}from"./assistantBus-BMrg1uLy.js";import{a as x,b as ie,d as ae,f as S,l as C,o as oe,u as se}from"./marketplaceApi-DL8PegzV.js";import{n as w,t as T}from"./usePackageL10n-DIEe85Ot.js";import{t as ce}from"./MarketplaceAccessDenied-BfvByBjR.js";var E=t({MarketplacePage:()=>A}),D=e(n(),1),O=i();function k(){let{language:e,t}=s();return n=>{if(!n)return``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=Math.floor((Date.now()-r.getTime())/864e5);if(i<1)return t(`marketplace.relativeTime.today`);try{let t=new Intl.RelativeTimeFormat(e||`en`,{numeric:`auto`});return i<30?t.format(-i,`day`):i<365?t.format(-Math.floor(i/30),`month`):t.format(-Math.floor(i/365),`year`)}catch{return i<30?t(`marketplace.relativeTime.daysAgo`,{count:i}):i<365?t(`marketplace.relativeTime.monthsAgo`,{count:Math.floor(i/30)}):t(`marketplace.relativeTime.yearsAgo`,{count:Math.floor(i/365)})}}}function A(){let e=a(),{appName:t}=r(),n=o(),{t:i,language:E}=s(),A=k(),j=t?`/apps/${t}`:``,[M,N]=(0,D.useState)([]),[P,F]=(0,D.useState)(!0),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(``),[H,U]=(0,D.useState)([]),[W,le]=(0,D.useState)([]),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(null),[Y,ue]=(0,D.useState)(new Set),de=(0,D.useMemo)(()=>{let e=new Map;for(let t of H)e.set(t.manifestId,t);return e},[H]),X=async()=>{F(!0),L(null);try{let[e,t,n,r]=await Promise.all([ae({limit:100}),se(),S(),C()]);N(e.items??[]),U(t),le(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);ue(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,D.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{ie().features.installLocal?await x({packageId:e.manifest_id||e.id,versionId:`latest`}):await oe({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:i(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X(),re()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,D.useMemo)(()=>{let e=new Set;for(let t of M)t.category&&e.add(t.category);return Array.from(e).sort()},[M]),Q=e=>{let t=`marketplace.category.${e}`,n=i(t,{defaultValue:e});return n===t?e:n},$=(0,D.useMemo)(()=>{let e=R.trim().toLowerCase();return M.filter(t=>{if(B&&t.category!==B)return!1;if(!e)return!0;let n=T(t,E);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,E]);return n?(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(y,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.title`)})]}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:i(`marketplace.subtitle`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,O.jsx)(ne,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?i(`marketplace.installedCount`,{count:H.length}):i(`marketplace.installed`)]}),(0,O.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,O.jsx)(l,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(ee,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,O.jsx)(v,{value:R,onChange:e=>z(e.target.value),placeholder:i(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":i(`marketplace.searchAria`)})]}),Z.length>0&&(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,O.jsx)(_,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:i(`marketplace.all`)}),Z.map(e=>(0,O.jsx)(_,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,O.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,O.jsx)(te,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`font-medium text-destructive`,children:i(`marketplace.load.failed`)}),(0,O.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:i(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,O.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(y,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,O.jsx)(g,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,O.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${q.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:q.text}),(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:W.map(e=>{let t=Y.has(e.manifest_id);return(0,O.jsxs)(c,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(d,{className:`text-base truncate`,children:e.display_name}),(0,O.jsx)(f,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,O.jsx)(g,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,O.jsxs)(p,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||i(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,O.jsxs)(g,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(h,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,O.jsx)(`div`,{className:`ml-auto`,children:t?(0,O.jsxs)(g,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,O.jsx)(_,{size:`sm`,onClick:()=>void fe(e),disabled:G===e.id,children:G===e.id?i(`marketplace.org.installing`,{defaultValue:`Installing…`}):i(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,O.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,O.jsxs)(c,{children:[(0,O.jsxs)(m,{className:`pb-2`,children:[(0,O.jsx)(u,{className:`h-10 w-10 rounded-lg mb-2`}),(0,O.jsx)(u,{className:`h-5 w-3/4`}),(0,O.jsx)(u,{className:`h-4 w-1/2 mt-1`})]}),(0,O.jsx)(p,{children:(0,O.jsx)(u,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,O.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?i(`marketplace.noApprovedYet`):i(`marketplace.noMatchFilters`)}):(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:$.map(t=>{let n=de.get(t.manifest_id),r=T(t,E);return(0,O.jsxs)(c,{className:`cursor-pointer transition-colors hover:bg-accent/50 flex flex-col`,onClick:()=>e(`${j}/system/marketplace/${t.id}`),role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(`${j}/system/marketplace/${t.id}`))},"data-testid":`marketplace-card-${t.manifest_id}`,children:[(0,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(d,{className:`text-base truncate`,children:r.displayName}),(0,O.jsx)(f,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,O.jsx)(g,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,O.jsxs)(p,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||i(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,O.jsxs)(g,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,O.jsxs)(g,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(h,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,O.jsx)(g,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,O.jsx)(ce,{})}export{E as t};
1
+ import{o as e,r as t}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-ClIa1CJA.js";import{d as o}from"./infrastructure-HR_Bc4bJ.js";import{i as s}from"./framework-D5XqsLzE.js";import{Ci as ee,Jn as c,Li as l,Mt as u,Qn as d,Xn as f,Yn as p,Zn as m,da as h,er as g,gr as _,nn as v,ti as y,ws as te,xi as ne,xs as b}from"./ui-components-DiLX53DV.js";import{n as re}from"./assistantBus-BMrg1uLy.js";import{a as x,b as ie,d as ae,f as S,l as C,o as oe,u as se}from"./marketplaceApi-BEwXWaVr.js";import{n as w,t as T}from"./usePackageL10n-DIEe85Ot.js";import{t as ce}from"./MarketplaceAccessDenied-BRaR8_1a.js";var E=t({MarketplacePage:()=>A}),D=e(n(),1),O=i();function k(){let{language:e,t}=s();return n=>{if(!n)return``;let r=new Date(n);if(Number.isNaN(r.getTime()))return``;let i=Math.floor((Date.now()-r.getTime())/864e5);if(i<1)return t(`marketplace.relativeTime.today`);try{let t=new Intl.RelativeTimeFormat(e||`en`,{numeric:`auto`});return i<30?t.format(-i,`day`):i<365?t.format(-Math.floor(i/30),`month`):t.format(-Math.floor(i/365),`year`)}catch{return i<30?t(`marketplace.relativeTime.daysAgo`,{count:i}):i<365?t(`marketplace.relativeTime.monthsAgo`,{count:Math.floor(i/30)}):t(`marketplace.relativeTime.yearsAgo`,{count:Math.floor(i/365)})}}}function A(){let e=a(),{appName:t}=r(),n=o(),{t:i,language:E}=s(),A=k(),j=t?`/apps/${t}`:``,[M,N]=(0,D.useState)([]),[P,F]=(0,D.useState)(!0),[I,L]=(0,D.useState)(null),[R,z]=(0,D.useState)(``),[B,V]=(0,D.useState)(``),[H,U]=(0,D.useState)([]),[W,le]=(0,D.useState)([]),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(null),[Y,ue]=(0,D.useState)(new Set),de=(0,D.useMemo)(()=>{let e=new Map;for(let t of H)e.set(t.manifestId,t);return e},[H]),X=async()=>{F(!0),L(null);try{let[e,t,n,r]=await Promise.all([ae({limit:100}),se(),S(),C()]);N(e.items??[]),U(t),le(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);ue(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,D.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{ie().features.installLocal?await x({packageId:e.manifest_id||e.id,versionId:`latest`}):await oe({packageId:e.id,environmentId:``,seedSampleData:!0}),J({ok:!0,text:i(`marketplace.org.installed`,{defaultValue:`Installed ${e.display_name}`,name:e.display_name})}),await X(),re()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,D.useMemo)(()=>{let e=new Set;for(let t of M)t.category&&e.add(t.category);return Array.from(e).sort()},[M]),Q=e=>{let t=`marketplace.category.${e}`,n=i(t,{defaultValue:e});return n===t?e:n},$=(0,D.useMemo)(()=>{let e=R.trim().toLowerCase();return M.filter(t=>{if(B&&t.category!==B)return!1;if(!e)return!0;let n=T(t,E);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,E]);return n?(0,O.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,O.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(y,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.title`)})]}),(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:i(`marketplace.subtitle`)})]}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,O.jsx)(ne,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?i(`marketplace.installedCount`,{count:H.length}):i(`marketplace.installed`)]}),(0,O.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,O.jsx)(l,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})]})]}),(0,O.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,O.jsxs)(`div`,{className:`relative flex-1`,children:[(0,O.jsx)(ee,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,O.jsx)(v,{value:R,onChange:e=>z(e.target.value),placeholder:i(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":i(`marketplace.searchAria`)})]}),Z.length>0&&(0,O.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,O.jsx)(_,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:i(`marketplace.all`)}),Z.map(e=>(0,O.jsx)(_,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,O.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,O.jsx)(te,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`div`,{className:`font-medium text-destructive`,children:i(`marketplace.load.failed`)}),(0,O.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,O.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:i(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,O.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(y,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,O.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,O.jsx)(g,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,O.jsx)(`div`,{className:`rounded-md border p-3 text-sm ${q.ok?`border-green-500/30 bg-green-500/5 text-green-700 dark:text-green-400`:`border-destructive/30 bg-destructive/5 text-destructive`}`,children:q.text}),(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:W.map(e=>{let t=Y.has(e.manifest_id);return(0,O.jsxs)(c,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(d,{className:`text-base truncate`,children:e.display_name}),(0,O.jsx)(f,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,O.jsx)(g,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,O.jsxs)(p,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||i(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,O.jsxs)(g,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(h,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,O.jsx)(`div`,{className:`ml-auto`,children:t?(0,O.jsxs)(g,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,O.jsx)(_,{size:`sm`,onClick:()=>void fe(e),disabled:G===e.id,children:G===e.id?i(`marketplace.org.installing`,{defaultValue:`Installing…`}):i(`marketplace.org.install`,{defaultValue:`Install`})})})]})]})]},e.id)})}),(0,O.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,O.jsxs)(c,{children:[(0,O.jsxs)(m,{className:`pb-2`,children:[(0,O.jsx)(u,{className:`h-10 w-10 rounded-lg mb-2`}),(0,O.jsx)(u,{className:`h-5 w-3/4`}),(0,O.jsx)(u,{className:`h-4 w-1/2 mt-1`})]}),(0,O.jsx)(p,{children:(0,O.jsx)(u,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,O.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?i(`marketplace.noApprovedYet`):i(`marketplace.noMatchFilters`)}):(0,O.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:$.map(t=>{let n=de.get(t.manifest_id),r=T(t,E);return(0,O.jsxs)(c,{className:`cursor-pointer transition-colors hover:bg-accent/50 flex flex-col`,onClick:()=>e(`${j}/system/marketplace/${t.id}`),role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(`${j}/system/marketplace/${t.id}`))},"data-testid":`marketplace-card-${t.manifest_id}`,children:[(0,O.jsxs)(m,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,O.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsx)(d,{className:`text-base truncate`,children:r.displayName}),(0,O.jsx)(f,{className:`text-xs truncate`,children:(0,O.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,O.jsx)(g,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,O.jsxs)(p,{className:`flex-1 flex flex-col gap-2`,children:[(0,O.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||i(`marketplace.noDescription`)}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,O.jsxs)(g,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,O.jsx)(b,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,O.jsxs)(g,{variant:`outline`,className:`text-xs`,children:[(0,O.jsx)(h,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,O.jsx)(g,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,O.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,O.jsx)(ce,{})}export{E as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{i as r,lt as i}from"./framework-DI54pxGD.js";import{As as a,Ms as o,Ns as s,es as c}from"./ui-components-BecTKcFn.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(t(),1),d=n();function f({sections:e,open:t}){if(!t)return null;let{t:n}=r(),[i,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 r=String(t),l=i.includes(r),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(r),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`?i(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-CMxvf4Kt.js";import{_ as t,t as n}from"./vendor-react-ClIa1CJA.js";import{i as r,ut as i}from"./framework-D5XqsLzE.js";import{As as a,Ms as o,Ns as s,es as c}from"./ui-components-DiLX53DV.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(t(),1),d=n();function f({sections:e,open:t}){if(!t)return null;let{t:n}=r(),[i,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 r=String(t),l=i.includes(r),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(r),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`?i(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};