@objectstack/console 12.2.0 → 12.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 (88) hide show
  1. package/dist/.objectui-sha +1 -1
  2. package/dist/assets/{AdapterProvider-ChCHN6h2.js → AdapterProvider-_4c7hk3d.js} +1 -1
  3. package/dist/assets/{AiPendingActionsPage-ClqCWFhX.js → AiPendingActionsPage-Gc2Wh8Kh.js} +1 -1
  4. package/dist/assets/{ApiConsolePage-DpoLdaGP.js → ApiConsolePage-CmiLmtuU.js} +1 -1
  5. package/dist/assets/{AppDocsIndex-ZARAa4-6.js → AppDocsIndex-CG7e4V2y.js} +1 -1
  6. package/dist/assets/{AppManagementPage-fv86i1EJ.js → AppManagementPage-C7T-9Exg.js} +1 -1
  7. package/dist/assets/{ApprovalsInboxPage-CXfOaS-0.js → ApprovalsInboxPage-D9PFFxKD.js} +1 -1
  8. package/dist/assets/{AuditLogPage-Dkoy1n_H.js → AuditLogPage-C-rDSpPt.js} +1 -1
  9. package/dist/assets/{ComponentNavView-BWQSnGEu.js → ComponentNavView-DX23dzZd.js} +1 -1
  10. package/dist/assets/{ConsoleFloatingChatbot-Dq3dsO2v.js → ConsoleFloatingChatbot-CmLazUxX.js} +1 -1
  11. package/dist/assets/{CreateViewDialog-C1CxZesL.js → CreateViewDialog-6JmiAMxS.js} +1 -1
  12. package/dist/assets/{DashboardView-BQG9YaAq.js → DashboardView-Al7ce4gm.js} +1 -1
  13. package/dist/assets/{DashboardWidgetInspector-BpU5bimE.js → DashboardWidgetInspector-BmIMgSGO.js} +1 -1
  14. package/dist/assets/{DeveloperHubPage-BRCN0NLA.js → DeveloperHubPage-D8eYekI9.js} +1 -1
  15. package/dist/assets/{ExpressionProvider-abtwTBsH.js → ExpressionProvider-w-HoWEV1.js} +1 -1
  16. package/dist/assets/{FlowRunsPage-BgcLefs2.js → FlowRunsPage-Hs5i7s3C.js} +1 -1
  17. package/dist/assets/{IntegrationsPage-BCklDgeZ.js → IntegrationsPage-COvUlRq2.js} +1 -1
  18. package/dist/assets/{InterfaceListPage-BS-RPt4J.js → InterfaceListPage-JNxR3qlQ.js} +1 -1
  19. package/dist/assets/{ManagedByBadge-j3ZfnZvE.js → ManagedByBadge-BZofhfqM.js} +1 -1
  20. package/dist/assets/{MarketplaceAccessDenied-CEfnLa3I.js → MarketplaceAccessDenied-Cur1UQ0U.js} +1 -1
  21. package/dist/assets/{MarketplaceInstalledPage-CWQTjUgZ.js → MarketplaceInstalledPage-D9ow2tlx.js} +1 -1
  22. package/dist/assets/{MarketplacePackagePage-Bfbul0CU.js → MarketplacePackagePage-0AKyKbMD.js} +1 -1
  23. package/dist/assets/{MarketplacePage-OJnmguF6.js → MarketplacePage-DUzZZa8D.js} +1 -1
  24. package/dist/assets/{MetadataInspector-BhsHTd-v.js → MetadataInspector-CpceGXDL.js} +1 -1
  25. package/dist/assets/{MetadataProvider-C6q8MMOb.js → MetadataProvider-MNkZn-bR.js} +1 -1
  26. package/dist/assets/{MonacoImpl-DFmzedsv.js → MonacoImpl-DoDns4Vj.js} +1 -1
  27. package/dist/assets/{ObjectDataPage-BS6o8mYp.js → ObjectDataPage-CUJksP8e.js} +1 -1
  28. package/dist/assets/{PageView-C9oZgX_T.js → PageView-AS6xg5z-.js} +1 -1
  29. package/dist/assets/{ProfilePage-ITmWpb2R.js → ProfilePage-iJeMD7FK.js} +1 -1
  30. package/dist/assets/{PublicFormsPage-sLkhcwEv.js → PublicFormsPage-C-wbtEXG.js} +1 -1
  31. package/dist/assets/RecordDetailView-Ba0xool8.js +9 -0
  32. package/dist/assets/{RecordFormPage-BgcPlnXv.js → RecordFormPage-CbvOD5UT.js} +1 -1
  33. package/dist/assets/ReportDefaultInspector-OSqdhKEL.js +11 -0
  34. package/dist/assets/{ReportView-BaP-JFjB.js → ReportView-Df7cdlQo.js} +1 -1
  35. package/dist/assets/{SearchResultsPage-BshI0Zmt.js → SearchResultsPage-D0nbmFox.js} +1 -1
  36. package/dist/assets/{SettingsHub-CfrSasWE.js → SettingsHub-BsZee-2C.js} +1 -1
  37. package/dist/assets/{SettingsView-C0tiT7Ro.js → SettingsView-CSBwd4YP.js} +1 -1
  38. package/dist/assets/{SystemHubPage-4IOffD9p.js → SystemHubPage-n41ly_cC.js} +1 -1
  39. package/dist/assets/{data-adapter-Cx47KDt0.js → data-adapter-W6WwA2ln.js} +1 -1
  40. package/dist/assets/dist-CfcbLQde.js +11 -0
  41. package/dist/assets/{framework-VeaoJc6L.js → framework-B9PMswdm.js} +8 -8
  42. package/dist/assets/{getIcon-DWShaytS.js → getIcon-DkcFniPV.js} +1 -1
  43. package/dist/assets/{highlighted-body-OFNGDK62-BVT4Ceg6.js → highlighted-body-OFNGDK62-CLUabCIi.js} +1 -1
  44. package/dist/assets/{index-lt4ddaZz.js → index-Oki50z-M.js} +1 -1
  45. package/dist/assets/index-rbBh03NP.css +2 -0
  46. package/dist/assets/mermaid-GHXKKRXX-Df_DEhBm.js +1 -0
  47. package/dist/assets/metadata-admin-DiOg8Tx8.js +22 -0
  48. package/dist/assets/{plugin-calendar-2kTJ0fc1.js → plugin-calendar-CVeG5Hhb.js} +1 -1
  49. package/dist/assets/{plugin-charts-CvFyMc_d.js → plugin-charts-BTfOaZVx.js} +2 -2
  50. package/dist/assets/{plugin-chatbot-BRmlCuRw.js → plugin-chatbot-COpsZSy4.js} +4 -4
  51. package/dist/assets/{plugin-dashboard-4HCwV8-X.js → plugin-dashboard-Bi5WrqPG.js} +2 -2
  52. package/dist/assets/plugin-form-CzotVFc-.js +1 -0
  53. package/dist/assets/{plugin-gantt-Dhuw4hkx.js → plugin-gantt-BUcqVYxX.js} +2 -2
  54. package/dist/assets/plugin-grid-BXfwTczT.js +8 -0
  55. package/dist/assets/{plugin-kanban-BTZHONsN.js → plugin-kanban-Dw_QTU-e.js} +1 -1
  56. package/dist/assets/{plugin-map-Depmdrg-.js → plugin-map-D89OX2_H.js} +1 -1
  57. package/dist/assets/{plugin-markdown-D3pwlK_U.js → plugin-markdown-CWbusz5W.js} +1 -1
  58. package/dist/assets/{plugin-report-IVabarJG.js → plugin-report-Cy6FwNfk.js} +1 -1
  59. package/dist/assets/{plugin-timeline-DKuFVmA_.js → plugin-timeline-BAImk_4t.js} +1 -1
  60. package/dist/assets/{plugin-tree-C6CVZ7Om.js → plugin-tree-CtakCCIf.js} +1 -1
  61. package/dist/assets/plugin-view-DZC_ZJtv.js +1 -0
  62. package/dist/assets/plugins-views-CxFTNQJ7.js +4 -0
  63. package/dist/assets/{skeletons-CCSQqh_1.js → skeletons-BK6x7CYd.js} +1 -1
  64. package/dist/assets/{src-CU1Z1Z_t.js → src-BPEDMjfw.js} +1 -1
  65. package/dist/assets/src-CCztNT-4.js +15 -0
  66. package/dist/assets/{types-6GJ5R1iS.js → types-X8W-qTHJ.js} +1 -1
  67. package/dist/assets/ui-components-DsYvPIox.js +42 -0
  68. package/dist/assets/{ui-layout-9b1em1pV.js → ui-layout-BdFgfR9C.js} +1 -1
  69. package/dist/assets/{useMetadata-Ja6XpRRW.js → useMetadata-DAEfn7ks.js} +1 -1
  70. package/dist/assets/{useOpenRecordList-B4pH3R6Y.js → useOpenRecordList-DL3H_OJi.js} +1 -1
  71. package/dist/assets/{useReconcileOnError-zJ0Ga5t1.js → useReconcileOnError-CtvIPgmD.js} +1 -1
  72. package/dist/assets/{useRecordApprovals-DXvdSyp8.js → useRecordApprovals-BHkgfYJW.js} +1 -1
  73. package/dist/assets/vendor-objectstack-sPlD8LgO.js +95 -0
  74. package/dist/index.html +4 -4
  75. package/package.json +1 -1
  76. package/dist/assets/RecordDetailView-DHsj44KH.js +0 -9
  77. package/dist/assets/ReportDefaultInspector-Cg2S1xbC.js +0 -11
  78. package/dist/assets/dist-BrXdcuve.js +0 -11
  79. package/dist/assets/index-B0iXZd_j.css +0 -2
  80. package/dist/assets/mermaid-GHXKKRXX-eYtP2Vcs.js +0 -1
  81. package/dist/assets/metadata-admin-Cy38fzV_.js +0 -22
  82. package/dist/assets/plugin-form-EGV_mlKM.js +0 -1
  83. package/dist/assets/plugin-grid-CddzO4VP.js +0 -8
  84. package/dist/assets/plugin-view-UIMlPguJ.js +0 -1
  85. package/dist/assets/plugins-views-BpBxqePX.js +0 -4
  86. package/dist/assets/src-DZBNpupP.js +0 -15
  87. package/dist/assets/ui-components-Pnfq_-xI.js +0 -42
  88. package/dist/assets/vendor-objectstack-BGWJwgbT.js +0 -95
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{l as r}from"./framework-VeaoJc6L.js";import{Ac as i,Fs as a,Gn as o,Ha as s,Jn as c,Kn as l,Pa as u,Qs as d,Sr as f,Wn as p,Xa as m,Yn as h,_s as g,cn as _,co as v,ec as y,hi as b,pi as x,qn as S}from"./ui-components-Pnfq_-xI.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./plugin-view-UIMlPguJ.js";var A=e(t(),1),j=n();function M({title:e,description:t,icon:n,actions:r,accentColor:a,sticky:o=!1,className:s,"data-testid":c}){return(0,j.jsxs)(`div`,{style:{"--page-header-accent":a||`hsl(var(--primary))`},className:i(`relative shrink-0 border-b bg-background z-10`,o&&`sticky top-0 bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/75`,s),"data-testid":c??`page-header`,children:[(0,j.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-80`,style:{background:`linear-gradient(90deg, transparent, var(--page-header-accent), transparent)`}}),(0,j.jsxs)(`div`,{className:`flex justify-between items-center gap-3 py-2.5 sm:py-3 px-4 sm:px-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[n&&(0,j.jsx)(`div`,{className:i(`shrink-0 inline-flex items-center justify-center rounded-lg`,`h-9 w-9 sm:h-10 sm:w-10`,`[&_svg]:h-[18px] [&_svg]:w-[18px] sm:[&_svg]:h-5 sm:[&_svg]:w-5`),style:{color:`var(--page-header-accent)`,background:`linear-gradient(135deg, color-mix(in srgb, var(--page-header-accent) 18%, transparent), color-mix(in srgb, var(--page-header-accent) 6%, transparent))`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, var(--page-header-accent) 22%, transparent)`},children:n}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h1`,{className:`text-base sm:text-lg lg:text-xl font-semibold tracking-tight text-foreground truncate leading-tight`,children:e}),t&&(0,j.jsx)(`p`,{className:`text-xs sm:text-sm text-muted-foreground truncate hidden sm:block max-w-xl mt-0.5`,children:t})]})]}),r&&(0,j.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:r})]})]})}function N(e){return[{type:`grid`,icon:m,label:e(`console.objectView.viewTypeGrid`),description:e(`console.objectView.viewTypeGridDesc`)},{type:`kanban`,icon:x,label:e(`console.objectView.viewTypeKanban`),description:e(`console.objectView.viewTypeKanbanDesc`)},{type:`calendar`,icon:y,label:e(`console.objectView.viewTypeCalendar`),description:e(`console.objectView.viewTypeCalendarDesc`)},{type:`gallery`,icon:v,label:e(`console.objectView.viewTypeGallery`),description:e(`console.objectView.viewTypeGalleryDesc`)},{type:`timeline`,icon:g,label:e(`console.objectView.viewTypeTimeline`),description:e(`console.objectView.viewTypeTimelineDesc`)},{type:`gantt`,icon:b,label:e(`console.objectView.viewTypeGantt`),description:e(`console.objectView.viewTypeGanttDesc`)},{type:`map`,icon:u,label:e(`console.objectView.viewTypeMap`),description:e(`console.objectView.viewTypeMapDesc`)},{type:`chart`,icon:d,label:e(`console.objectView.viewTypeChart`),description:e(`console.objectView.viewTypeChartDesc`)},{type:`tree`,icon:s,label:e(`console.objectView.viewTypeTree`),description:e(`console.objectView.viewTypeTreeDesc`)}]}function P(e,t){for(let n=1;n<1e3;n++){let r=`${e} ${n}`;if(!t.has(r))return r}return e}var F={kanban:[{key:`groupByField`,i18nKey:`console.objectView.groupByField`,helpI18nKey:`console.objectView.groupByFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`,preferred:T}],calendar:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.startDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],timeline:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.timelineDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gantt:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.ganttStartDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`endDateField`,i18nKey:`console.objectView.endDateField`,helpI18nKey:`console.objectView.ganttEndDateFieldHelp`,filter:e=>e.type===`date`,preferred:k},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gallery:[{key:`coverField`,i18nKey:`console.objectView.imageField`,helpI18nKey:`console.objectView.imageFieldHelp`,filter:e=>E(e)}],map:[{key:`latitudeField`,i18nKey:`console.objectView.latitudeField`,helpI18nKey:`console.objectView.latitudeFieldHelp`,filter:e=>e.type===`number`&&C(e,`latitude`)},{key:`longitudeField`,i18nKey:`console.objectView.longitudeField`,helpI18nKey:`console.objectView.longitudeFieldHelp`,filter:e=>e.type===`number`&&C(e,`longitude`)}],chart:[{key:`chartType`,i18nKey:`console.objectView.chartType`,helpI18nKey:`console.objectView.chartTypeHelp`,kind:`enum`,enumOptions:[{value:`bar`,i18nKey:`console.objectView.chartTypeBar`},{value:`line`,i18nKey:`console.objectView.chartTypeLine`},{value:`pie`,i18nKey:`console.objectView.chartTypePie`},{value:`area`,i18nKey:`console.objectView.chartTypeArea`},{value:`scatter`,i18nKey:`console.objectView.chartTypeScatter`}],defaultValue:`bar`},{key:`xAxisField`,i18nKey:`console.objectView.xAxisField`,helpI18nKey:`console.objectView.xAxisFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`||e.type===`date`||e.type===`text`,preferred:T},{key:`yAxisFields`,i18nKey:`console.objectView.yAxisField`,helpI18nKey:`console.objectView.yAxisFieldHelp`,filter:e=>e.type===`number`}],tree:[{key:`parentField`,i18nKey:`console.objectView.parentField`,helpI18nKey:`console.objectView.parentFieldHelp`,filter:e=>e.rawType===`tree`||e.rawType===`lookup`||e.rawType===`master_detail`}]};function I({open:e,onOpenChange:t,onCreate:n,existingLabels:s,availableTypes:u,objectDef:d}){let{t:m}=r(),g=(0,A.useMemo)(()=>N(m),[m]),v=(0,A.useMemo)(()=>u&&u.length>0?g.filter(e=>u.includes(e.type)):g,[g,u]),y=(0,A.useMemo)(()=>new Set(s??[]),[(s??[]).join(`\0`)]),b=(0,A.useMemo)(()=>d?w(d):[],[d]),[x,C]=(0,A.useState)(v[0]?.type??`grid`),[T,E]=(0,A.useState)(``),[D,k]=(0,A.useState)(!1),[M,I]=(0,A.useState)({});(0,A.useEffect)(()=>{e&&(C(v[0]?.type??`grid`),k(!1),I({}))},[e,v]),(0,A.useEffect)(()=>{D||E(P(v.find(e=>e.type===x)?.label??`View`,y))},[x,D,v,y]);let L=F[x]??[],R=e=>e.kind===`enum`?(e.enumOptions?.length??0)>0:d?(e.filter?b.filter(e.filter):b).length>0:!0,z=(0,A.useMemo)(()=>{let e={};return v.forEach(t=>{let n=(F[t.type]??[]).find(e=>!R(e));e[t.type]=n??null}),e},[v,b,d]),B=e=>M[`${x}.${e}`]??``,V=(e,t)=>I(n=>({...n,[`${x}.${e}`]:t})),H=T.trim(),U=H.length>0&&y.has(H),W=L.every(e=>B(e.key).length>0),G=H.length>0&&!U&&W;(0,A.useEffect)(()=>{L.length!==0&&L.forEach(e=>{if(B(e.key).length>0)return;if(e.kind===`enum`){e.defaultValue&&V(e.key,e.defaultValue);return}let t=e.filter?b.filter(e.filter):b;if(t.length===0)return;if(t.length===1){V(e.key,t[0].value);return}let n=O(t,e.preferred??[]);n&&V(e.key,n)})},[x,b]);let K=()=>{if(!G)return;let e={};L.forEach(t=>{let n=B(t.key);n&&(e[t.key]=t.key===`yAxisFields`?[n]:n)});let r={type:x,label:H};Object.keys(e).length>0&&(r[x]=e),n(r),t(!1)};return(0,j.jsx)(p,{open:e,onOpenChange:t,children:(0,j.jsxs)(o,{className:`sm:max-w-[560px]`,"data-testid":`create-view-dialog`,children:[(0,j.jsxs)(c,{children:[(0,j.jsx)(h,{children:m(`console.objectView.createView`)}),(0,j.jsx)(l,{children:m(`console.objectView.createViewDesc`)})]}),(0,j.jsx)(`div`,{className:`grid grid-cols-4 gap-2 py-2`,"data-testid":`create-view-type-grid`,children:v.map(({type:e,label:t,description:n,icon:r})=>{let a=e===x,o=z[e],s=!!o,c=s?m(`console.objectView.viewTypeUnavailable`,{field:m(o.i18nKey)}):void 0;return(0,j.jsxs)(`button`,{type:`button`,"data-testid":`create-view-type-${e}`,"aria-pressed":a,"aria-disabled":s,disabled:s,title:c,onClick:()=>{s||C(e)},className:i(`group flex flex-col items-start gap-1 rounded-lg border bg-background p-3 text-left transition-colors`,!s&&`hover:border-primary/60 hover:bg-accent/40`,a&&!s?`border-primary ring-2 ring-primary/30 bg-accent/40`:`border-border`,s&&`opacity-50 cursor-not-allowed`),children:[(0,j.jsx)(r,{className:i(`h-5 w-5`,a&&!s?`text-primary`:`text-muted-foreground group-hover:text-foreground`)}),(0,j.jsx)(`div`,{className:`text-xs font-medium leading-tight`,children:t}),(0,j.jsx)(`div`,{className:`text-[10px] leading-tight text-muted-foreground line-clamp-2`,children:s?m(`console.objectView.viewTypeUnavailableShort`):n})]},e)})}),L.length>0&&(0,j.jsx)(`div`,{className:`space-y-3 rounded-md border border-dashed bg-muted/30 p-3`,"data-testid":`create-view-required-fields`,children:L.map(e=>{let t=B(e.key),n=e.kind===`enum`,r=n?[]:e.filter?b.filter(e.filter):b,o=!n&&b.length>0&&r.length===0;return(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsxs)(`label`,{htmlFor:`create-view-required-${e.key}`,className:`text-xs font-medium`,children:[m(e.i18nKey),(0,j.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,j.jsxs)(`select`,{id:`create-view-required-${e.key}`,"data-testid":`create-view-required-${e.key}`,value:t,onChange:t=>V(e.key,t.target.value),disabled:o,className:i(`h-9 w-full rounded-md border bg-background px-2 text-xs`,`border-input`),children:[(0,j.jsx)(`option`,{value:``,children:m(n?`console.objectView.selectOption`:`console.objectView.selectField`)}),n?e.enumOptions.map(e=>(0,j.jsx)(`option`,{value:e.value,children:m(e.i18nKey)},e.value)):r.map(e=>(0,j.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),e.helpI18nKey&&!o&&(0,j.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:m(e.helpI18nKey)}),o&&(0,j.jsxs)(`p`,{className:`flex items-center gap-1 text-[11px] text-destructive`,"data-testid":`create-view-error-no-field-${e.key}`,children:[(0,j.jsx)(a,{className:`h-3 w-3`}),m(`console.objectView.noEligibleFieldForType`)]})]},e.key)})}),(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsxs)(`label`,{htmlFor:`create-view-name-input`,className:`text-xs font-medium`,children:[m(`console.objectView.title`),(0,j.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,j.jsx)(_,{id:`create-view-name-input`,"data-testid":`create-view-name-input`,autoFocus:!0,value:T,onChange:e=>{E(e.target.value),k(!0)},onKeyDown:e=>{e.key===`Enter`&&G&&K()},placeholder:m(`console.objectView.newView`),className:`h-9`}),U&&(0,j.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-duplicate`,children:m(`console.objectView.duplicateViewName`)})]}),(0,j.jsxs)(S,{className:`mt-2`,children:[(0,j.jsx)(f,{type:`button`,variant:`outline`,onClick:()=>t(!1),"data-testid":`create-view-cancel`,children:m(`console.objectView.cancel`)}),(0,j.jsx)(f,{type:`button`,disabled:!G,onClick:K,"data-testid":`create-view-submit`,children:m(`console.objectView.create`)})]})]})})}export{M as n,I as t};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{l as r}from"./framework-B9PMswdm.js";import{Ac as i,Fs as a,Gn as o,Ha as s,Jn as c,Kn as l,Pa as u,Qs as d,Sr as f,Wn as p,Xa as m,Yn as h,_s as g,cn as _,co as v,ec as y,hi as b,pi as x,qn as S}from"./ui-components-DsYvPIox.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./plugin-view-DZC_ZJtv.js";var A=e(t(),1),j=n();function M({title:e,description:t,icon:n,actions:r,accentColor:a,sticky:o=!1,className:s,"data-testid":c}){return(0,j.jsxs)(`div`,{style:{"--page-header-accent":a||`hsl(var(--primary))`},className:i(`relative shrink-0 border-b bg-background z-10`,o&&`sticky top-0 bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/75`,s),"data-testid":c??`page-header`,children:[(0,j.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-80`,style:{background:`linear-gradient(90deg, transparent, var(--page-header-accent), transparent)`}}),(0,j.jsxs)(`div`,{className:`flex justify-between items-center gap-3 py-2.5 sm:py-3 px-4 sm:px-6`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[n&&(0,j.jsx)(`div`,{className:i(`shrink-0 inline-flex items-center justify-center rounded-lg`,`h-9 w-9 sm:h-10 sm:w-10`,`[&_svg]:h-[18px] [&_svg]:w-[18px] sm:[&_svg]:h-5 sm:[&_svg]:w-5`),style:{color:`var(--page-header-accent)`,background:`linear-gradient(135deg, color-mix(in srgb, var(--page-header-accent) 18%, transparent), color-mix(in srgb, var(--page-header-accent) 6%, transparent))`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, var(--page-header-accent) 22%, transparent)`},children:n}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h1`,{className:`text-base sm:text-lg lg:text-xl font-semibold tracking-tight text-foreground truncate leading-tight`,children:e}),t&&(0,j.jsx)(`p`,{className:`text-xs sm:text-sm text-muted-foreground truncate hidden sm:block max-w-xl mt-0.5`,children:t})]})]}),r&&(0,j.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:r})]})]})}function N(e){return[{type:`grid`,icon:m,label:e(`console.objectView.viewTypeGrid`),description:e(`console.objectView.viewTypeGridDesc`)},{type:`kanban`,icon:x,label:e(`console.objectView.viewTypeKanban`),description:e(`console.objectView.viewTypeKanbanDesc`)},{type:`calendar`,icon:y,label:e(`console.objectView.viewTypeCalendar`),description:e(`console.objectView.viewTypeCalendarDesc`)},{type:`gallery`,icon:v,label:e(`console.objectView.viewTypeGallery`),description:e(`console.objectView.viewTypeGalleryDesc`)},{type:`timeline`,icon:g,label:e(`console.objectView.viewTypeTimeline`),description:e(`console.objectView.viewTypeTimelineDesc`)},{type:`gantt`,icon:b,label:e(`console.objectView.viewTypeGantt`),description:e(`console.objectView.viewTypeGanttDesc`)},{type:`map`,icon:u,label:e(`console.objectView.viewTypeMap`),description:e(`console.objectView.viewTypeMapDesc`)},{type:`chart`,icon:d,label:e(`console.objectView.viewTypeChart`),description:e(`console.objectView.viewTypeChartDesc`)},{type:`tree`,icon:s,label:e(`console.objectView.viewTypeTree`),description:e(`console.objectView.viewTypeTreeDesc`)}]}function P(e,t){for(let n=1;n<1e3;n++){let r=`${e} ${n}`;if(!t.has(r))return r}return e}var F={kanban:[{key:`groupByField`,i18nKey:`console.objectView.groupByField`,helpI18nKey:`console.objectView.groupByFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`,preferred:T}],calendar:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.startDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],timeline:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.timelineDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gantt:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.ganttStartDateFieldHelp`,filter:e=>e.type===`date`,preferred:D},{key:`endDateField`,i18nKey:`console.objectView.endDateField`,helpI18nKey:`console.objectView.ganttEndDateFieldHelp`,filter:e=>e.type===`date`,preferred:k},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gallery:[{key:`coverField`,i18nKey:`console.objectView.imageField`,helpI18nKey:`console.objectView.imageFieldHelp`,filter:e=>E(e)}],map:[{key:`latitudeField`,i18nKey:`console.objectView.latitudeField`,helpI18nKey:`console.objectView.latitudeFieldHelp`,filter:e=>e.type===`number`&&C(e,`latitude`)},{key:`longitudeField`,i18nKey:`console.objectView.longitudeField`,helpI18nKey:`console.objectView.longitudeFieldHelp`,filter:e=>e.type===`number`&&C(e,`longitude`)}],chart:[{key:`chartType`,i18nKey:`console.objectView.chartType`,helpI18nKey:`console.objectView.chartTypeHelp`,kind:`enum`,enumOptions:[{value:`bar`,i18nKey:`console.objectView.chartTypeBar`},{value:`line`,i18nKey:`console.objectView.chartTypeLine`},{value:`pie`,i18nKey:`console.objectView.chartTypePie`},{value:`area`,i18nKey:`console.objectView.chartTypeArea`},{value:`scatter`,i18nKey:`console.objectView.chartTypeScatter`}],defaultValue:`bar`},{key:`xAxisField`,i18nKey:`console.objectView.xAxisField`,helpI18nKey:`console.objectView.xAxisFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`||e.type===`date`||e.type===`text`,preferred:T},{key:`yAxisFields`,i18nKey:`console.objectView.yAxisField`,helpI18nKey:`console.objectView.yAxisFieldHelp`,filter:e=>e.type===`number`}],tree:[{key:`parentField`,i18nKey:`console.objectView.parentField`,helpI18nKey:`console.objectView.parentFieldHelp`,filter:e=>e.rawType===`tree`||e.rawType===`lookup`||e.rawType===`master_detail`}]};function I({open:e,onOpenChange:t,onCreate:n,existingLabels:s,availableTypes:u,objectDef:d}){let{t:m}=r(),g=(0,A.useMemo)(()=>N(m),[m]),v=(0,A.useMemo)(()=>u&&u.length>0?g.filter(e=>u.includes(e.type)):g,[g,u]),y=(0,A.useMemo)(()=>new Set(s??[]),[(s??[]).join(`\0`)]),b=(0,A.useMemo)(()=>d?w(d):[],[d]),[x,C]=(0,A.useState)(v[0]?.type??`grid`),[T,E]=(0,A.useState)(``),[D,k]=(0,A.useState)(!1),[M,I]=(0,A.useState)({});(0,A.useEffect)(()=>{e&&(C(v[0]?.type??`grid`),k(!1),I({}))},[e,v]),(0,A.useEffect)(()=>{D||E(P(v.find(e=>e.type===x)?.label??`View`,y))},[x,D,v,y]);let L=F[x]??[],R=e=>e.kind===`enum`?(e.enumOptions?.length??0)>0:d?(e.filter?b.filter(e.filter):b).length>0:!0,z=(0,A.useMemo)(()=>{let e={};return v.forEach(t=>{let n=(F[t.type]??[]).find(e=>!R(e));e[t.type]=n??null}),e},[v,b,d]),B=e=>M[`${x}.${e}`]??``,V=(e,t)=>I(n=>({...n,[`${x}.${e}`]:t})),H=T.trim(),U=H.length>0&&y.has(H),W=L.every(e=>B(e.key).length>0),G=H.length>0&&!U&&W;(0,A.useEffect)(()=>{L.length!==0&&L.forEach(e=>{if(B(e.key).length>0)return;if(e.kind===`enum`){e.defaultValue&&V(e.key,e.defaultValue);return}let t=e.filter?b.filter(e.filter):b;if(t.length===0)return;if(t.length===1){V(e.key,t[0].value);return}let n=O(t,e.preferred??[]);n&&V(e.key,n)})},[x,b]);let K=()=>{if(!G)return;let e={};L.forEach(t=>{let n=B(t.key);n&&(e[t.key]=t.key===`yAxisFields`?[n]:n)});let r={type:x,label:H};Object.keys(e).length>0&&(r[x]=e),n(r),t(!1)};return(0,j.jsx)(p,{open:e,onOpenChange:t,children:(0,j.jsxs)(o,{className:`sm:max-w-[560px]`,"data-testid":`create-view-dialog`,children:[(0,j.jsxs)(c,{children:[(0,j.jsx)(h,{children:m(`console.objectView.createView`)}),(0,j.jsx)(l,{children:m(`console.objectView.createViewDesc`)})]}),(0,j.jsx)(`div`,{className:`grid grid-cols-4 gap-2 py-2`,"data-testid":`create-view-type-grid`,children:v.map(({type:e,label:t,description:n,icon:r})=>{let a=e===x,o=z[e],s=!!o,c=s?m(`console.objectView.viewTypeUnavailable`,{field:m(o.i18nKey)}):void 0;return(0,j.jsxs)(`button`,{type:`button`,"data-testid":`create-view-type-${e}`,"aria-pressed":a,"aria-disabled":s,disabled:s,title:c,onClick:()=>{s||C(e)},className:i(`group flex flex-col items-start gap-1 rounded-lg border bg-background p-3 text-left transition-colors`,!s&&`hover:border-primary/60 hover:bg-accent/40`,a&&!s?`border-primary ring-2 ring-primary/30 bg-accent/40`:`border-border`,s&&`opacity-50 cursor-not-allowed`),children:[(0,j.jsx)(r,{className:i(`h-5 w-5`,a&&!s?`text-primary`:`text-muted-foreground group-hover:text-foreground`)}),(0,j.jsx)(`div`,{className:`text-xs font-medium leading-tight`,children:t}),(0,j.jsx)(`div`,{className:`text-[10px] leading-tight text-muted-foreground line-clamp-2`,children:s?m(`console.objectView.viewTypeUnavailableShort`):n})]},e)})}),L.length>0&&(0,j.jsx)(`div`,{className:`space-y-3 rounded-md border border-dashed bg-muted/30 p-3`,"data-testid":`create-view-required-fields`,children:L.map(e=>{let t=B(e.key),n=e.kind===`enum`,r=n?[]:e.filter?b.filter(e.filter):b,o=!n&&b.length>0&&r.length===0;return(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsxs)(`label`,{htmlFor:`create-view-required-${e.key}`,className:`text-xs font-medium`,children:[m(e.i18nKey),(0,j.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,j.jsxs)(`select`,{id:`create-view-required-${e.key}`,"data-testid":`create-view-required-${e.key}`,value:t,onChange:t=>V(e.key,t.target.value),disabled:o,className:i(`h-9 w-full rounded-md border bg-background px-2 text-xs`,`border-input`),children:[(0,j.jsx)(`option`,{value:``,children:m(n?`console.objectView.selectOption`:`console.objectView.selectField`)}),n?e.enumOptions.map(e=>(0,j.jsx)(`option`,{value:e.value,children:m(e.i18nKey)},e.value)):r.map(e=>(0,j.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),e.helpI18nKey&&!o&&(0,j.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:m(e.helpI18nKey)}),o&&(0,j.jsxs)(`p`,{className:`flex items-center gap-1 text-[11px] text-destructive`,"data-testid":`create-view-error-no-field-${e.key}`,children:[(0,j.jsx)(a,{className:`h-3 w-3`}),m(`console.objectView.noEligibleFieldForType`)]})]},e.key)})}),(0,j.jsxs)(`div`,{className:`space-y-1`,children:[(0,j.jsxs)(`label`,{htmlFor:`create-view-name-input`,className:`text-xs font-medium`,children:[m(`console.objectView.title`),(0,j.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,j.jsx)(_,{id:`create-view-name-input`,"data-testid":`create-view-name-input`,autoFocus:!0,value:T,onChange:e=>{E(e.target.value),k(!0)},onKeyDown:e=>{e.key===`Enter`&&G&&K()},placeholder:m(`console.objectView.newView`),className:`h-9`}),U&&(0,j.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-duplicate`,children:m(`console.objectView.duplicateViewName`)})]}),(0,j.jsxs)(S,{className:`mt-2`,children:[(0,j.jsx)(f,{type:`button`,variant:`outline`,onClick:()=>t(!1),"data-testid":`create-view-cancel`,children:m(`console.objectView.cancel`)}),(0,j.jsx)(f,{type:`button`,disabled:!G,onClick:K,"data-testid":`create-view-submit`,children:m(`console.objectView.create`)})]})]})})}export{M as n,I as t};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i}from"./vendor-react-slxo-5GC.js";import{d as a}from"./infrastructure-BnbfcrX8.js";import{E as o,L as s,R as c,l}from"./framework-VeaoJc6L.js";import{G as u,Gn as d,Ic as f,J as p,Jn as m,Jr as h,Kn as g,Kr as _,Qs as v,Sr as y,W as b,Wn as x,Xa as S,Xi as C,Yn as w,Za as T,Zs as E,ai as D,kr as O,qn as ee,qs as k,ra as te,wc as A}from"./ui-components-Pnfq_-xI.js";import{r as j}from"./vendor-ui-utils-C1OpMExs.js";import"./AdapterProvider-ChCHN6h2.js";import{n as ne}from"./plugin-form-EGV_mlKM.js";import"./MetadataProvider-C6q8MMOb.js";import{r as re}from"./ExpressionProvider-abtwTBsH.js";import{r as ie}from"./useMetadata-Ja6XpRRW.js";import{v as M}from"./ReportDefaultInspector-Cg2S1xbC.js";import{t as N}from"./utils-Bixzg6Bz.js";import{n as ae,r as oe,t as se}from"./MetadataInspector-BhsHTd-v.js";import{n as P,t as F}from"./DashboardWidgetInspector-BpU5bimE.js";import{r as ce}from"./runtime-metadata-persistence-D1KKivGr.js";import{n as I,t as le}from"./useOpenRecordList-B4pH3R6Y.js";import{n as ue}from"./skeletons-CCSQqh_1.js";import{n as de}from"./plugin-dashboard-4HCwV8-X.js";var L=e(n(),1),R=i();function fe({open:e,onClose:t,schema:n,selectedWidgetId:r,onSelectWidget:i,onSave:a,onChange:o,onRemoveWidget:s,name:c,metadataClient:u,onAfterChange:d}){let{t:f}=l(),p=(0,L.useMemo)(()=>M(),[]),[m,g]=(0,L.useState)(!1),[_,v]=(0,L.useState)(0),b=(0,L.useCallback)(e=>{g(!0),o({...n??{},...e})},[n,o]),x=(0,L.useCallback)(e=>{o(e),g(!1)},[o]),S=(0,L.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),C=Array.isArray(n?.widgets)?n.widgets:[],w=r?C.find(e=>e?.id===r):null;if(!e)return null;let T=typeof n?.name==`string`?n.name:``,E=w?f(`widget.editor.title`,{defaultValue:`Edit widget`}):f(`dashboard.editor.title`,{defaultValue:`Edit dashboard`});return(0,R.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`dashboard-config-panel`,role:`complementary`,"aria-label":E,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[w&&(0,R.jsx)(y,{variant:`ghost`,size:`sm`,onClick:()=>i(null),className:`h-7 w-7 p-0`,"aria-label":f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),title:f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),"data-testid":`dashboard-config-back`,children:(0,R.jsx)(A,{className:`h-4 w-4`})}),(0,R.jsx)(`div`,{className:`text-sm font-medium truncate`,children:E})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&s&&(0,R.jsx)(y,{variant:`ghost`,size:`sm`,onClick:()=>s(r),className:`h-7 w-7 p-0 text-destructive hover:text-destructive`,"aria-label":f(`widget.editor.delete`,{defaultValue:`Delete widget`}),title:f(`widget.editor.delete`,{defaultValue:`Delete widget`}),"data-testid":`widget-delete-button`,children:(0,R.jsx)(h,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(y,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":f(`common.close`,{defaultValue:`Close`}),"data-testid":`dashboard-config-close`,children:(0,R.jsx)(O,{className:`h-4 w-4`})})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:w?(0,R.jsx)(F,{type:`dashboard`,name:T,draft:n??{},selection:{kind:`widget`,id:r},onPatch:b,onClearSelection:()=>i(null),onSelectionChange:S,readOnly:!1,locale:p}):(0,R.jsx)(P,{type:`dashboard`,name:T,draft:n??{},onPatch:b,onSelectionChange:S,readOnly:!1,locale:p})}),(0,R.jsxs)(`div`,{"data-testid":`dashboard-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,R.jsx)(I,{type:`dashboard`,name:c||T||void 0,metadataClient:u,dirty:m,onResume:x,savedSignal:_,onAfterChange:d}),(0,R.jsx)(y,{size:`sm`,onClick:()=>{a(n??{}),g(!1),v(e=>e+1)},"data-testid":`dashboard-config-save`,children:f(`common.save`,{defaultValue:`Save`})})]})]})}var z=t({DashboardView:()=>U}),B=[{type:`metric`,label:`KPI Metric`,Icon:_},{type:`bar`,label:`Bar Chart`,Icon:v},{type:`line`,label:`Line Chart`,Icon:E},{type:`pie`,label:`Pie Chart`,Icon:k},{type:`table`,label:`Table`,Icon:D},{type:`pivot`,label:`Pivot`,Icon:S}],V=0;function H(){return V+=1,`widget_${Date.now()}_${V}`}function pe(e){return!e.widgets?.length||!e.widgets.some(e=>!e.id)?e:{...e,widgets:e.widgets.map(e=>e.id?e:{...e,id:H()})}}function me(e){let t=B.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function U({dataSource:e}){let t=le(),{dashboardName:n}=r(),{showDebug:i}=ae(),h=s(),_=ie(),{t:v}=l(),{dashboardLabel:S,dashboardDescription:E}=f(),D=a(),[O,k]=(0,L.useState)(!0),[A,M]=(0,L.useState)(!1),[P,F]=(0,L.useState)(null),[I,z]=(0,L.useState)(null),V=(0,L.useCallback)(e=>{z(t=>(t&&t.resolve(e),null))},[]),U=(0,L.useCallback)(e=>new Promise(t=>{let n;if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);if(t){let e=t[1];n={objectName:t[2],mode:e===`edit`||e===`update`?`edit`:`create`}}else n={objectName:e,mode:`create`}}else n=e;z({schema:n,resolve:t})}),[]),he=(0,L.useMemo)(()=>({export_dashboard_pdf:async()=>{j.info(v(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return j.error(v(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(j.info(v(`dashboardActions.forecastSoon`)),{success:!0})}),[v]);(0,L.useEffect)(()=>{k(!0),J(null),M(!1),F(null),queueMicrotask(()=>k(!1))},[n]);let{dashboards:ge,objects:W,refresh:G}=c(),{app:_e}=re(),K=oe(ge,n,_e?._packageId),[q,J]=(0,L.useState)(null);(0,L.useEffect)(()=>{A||J(null)},[K]);let Y=(0,L.useCallback)(async e=>{try{_&&await ce(`dashboard`,n,e,{metadataClient:_}),G().catch(()=>{})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[DashboardView] Auto-save failed:`,e),j.error(`Failed to save dashboard: ${t}`)}},[_,n,G]),ve=(0,L.useCallback)(()=>{J(pe(K)),M(!0)},[K]),ye=(0,L.useCallback)(()=>{M(!1),F(null)},[]),X=(0,L.useCallback)(e=>{if(!q)return;let t=H(),n={id:t,title:me(e),type:e,layout:{x:0,y:q.widgets?.length??0,w:q.columns??2,h:1}},r={...q,widgets:[...q.widgets||[],n]};J(r),Y(r),F(t)},[q,Y]),be=(0,L.useCallback)(e=>{if(!q)return;let t={...q,widgets:q.widgets.filter(t=>t.id!==e)};J(t),Y(t),P===e&&F(null)},[q,P,Y]),xe=(0,L.useCallback)(e=>{let t=q||K;if(!t)return;let n={...t,widgets:e};J(n),Y(n)},[q,K,Y]),Se=(q||K)??null,Z=(0,L.useMemo)(()=>new Set((W||[]).map(e=>e?.name).filter(Boolean)),[W]),Q=q||K,$=(0,L.useMemo)(()=>{if(!Q||Z.size===0)return Q;let e=Q.widgets;if(!Array.isArray(e)||e.length===0)return Q;let t=e.filter(e=>{let t=e?.requiresObject??e?.object;return t?Z.has(t):!0});return t.length===e.length?Q:{...Q,widgets:t}},[Q,Z]);return O?(0,R.jsx)(ue,{}):K?(0,R.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=N(($||K).title,v),t=N(K.label,v),n=S({name:K.name,label:t});return(0,R.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:e||n||K.name})})(),(()=>{let e=($||K).description??K.description,t=E({name:K.name,description:N(e,v)});return t?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]}),(0,R.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:[A&&(0,R.jsx)(`div`,{className:`flex items-center gap-1 mr-2`,role:`toolbar`,"aria-label":`Add widgets`,"data-testid":`dashboard-widget-toolbar`,children:B.map(({type:e,label:t,Icon:n})=>(0,R.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>X(e),className:`inline-flex items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,title:`Add ${t}`,"aria-label":`Add ${t} widget`,children:[(0,R.jsx)(C,{className:`h-3 w-3`}),(0,R.jsx)(n,{className:`h-3 w-3`})]},e))}),D&&(0,R.jsxs)(`button`,{type:`button`,onClick:ve,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`dashboard-edit-button`,children:[(0,R.jsx)(te,{className:`h-3.5 w-3.5`}),v(`common.edit`,{defaultValue:`Edit`})]})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,R.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,R.jsx)(o,{value:{openRecordList:t},children:(0,R.jsx)(de,{schema:$,dataSource:e,designMode:A,selectedWidgetId:P,onWidgetClick:F,onWidgetsReorder:xe,modalHandler:U,scriptHandlers:he,hideHeaderText:!0})})}),(0,R.jsx)(fe,{open:A&&D,onClose:ye,schema:Se,selectedWidgetId:P,onSelectWidget:F,onSave:Y,onChange:J,onRemoveWidget:be,name:n,metadataClient:_,onAfterChange:()=>G().catch(()=>{})}),(0,R.jsx)(se,{open:i,sections:[{title:`Dashboard Configuration`,data:$}]})]}),I&&I.schema?.objectName?(0,R.jsx)(ne,{schema:{type:`object-form`,formType:`modal`,objectName:I.schema.objectName,mode:I.schema.mode||`create`,recordId:I.schema.recordId,title:I.schema.title,description:I.schema.description,fields:I.schema.fields,open:!0,onOpenChange:e=>{e||V({success:!1})},onSuccess:e=>{V({success:!0,reload:!0,data:e})},onCancel:()=>{V({success:!1})},showSubmit:!0,showCancel:!0},dataSource:h}):I?(0,R.jsx)(x,{open:!0,onOpenChange:e=>{e||V({success:!1})},children:(0,R.jsxs)(d,{children:[(0,R.jsxs)(m,{children:[(0,R.jsx)(w,{children:I.schema?.title||v(`actionDialog.defaultActionTitle`)}),I.schema?.description&&(0,R.jsx)(g,{children:I.schema.description})]}),(0,R.jsxs)(ee,{children:[(0,R.jsx)(y,{variant:`outline`,onClick:()=>V({success:!1}),children:v(`actionDialog.cancel`)}),(0,R.jsx)(y,{onClick:()=>V({success:!0}),children:v(`actionDialog.ok`)})]})]})}):null]}):(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,R.jsxs)(b,{children:[(0,R.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,R.jsx)(T,{className:`h-6 w-6 text-muted-foreground`})}),(0,R.jsx)(p,{children:v(`empty.dashboardNotFound`)}),(0,R.jsx)(u,{children:v(`empty.dashboardNotFoundDescription`,{name:n})})]})})}export{z as t};
1
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i}from"./vendor-react-slxo-5GC.js";import{d as a}from"./infrastructure-BnbfcrX8.js";import{E as o,L as s,R as c,l}from"./framework-B9PMswdm.js";import{G as u,Gn as d,Ic as f,J as p,Jn as m,Jr as h,Kn as g,Kr as _,Qs as v,Sr as y,W as b,Wn as x,Xa as S,Xi as C,Yn as w,Za as T,Zs as E,ai as D,kr as O,qn as ee,qs as k,ra as te,wc as A}from"./ui-components-DsYvPIox.js";import{r as j}from"./vendor-ui-utils-C1OpMExs.js";import"./AdapterProvider-_4c7hk3d.js";import{n as ne}from"./plugin-form-CzotVFc-.js";import"./MetadataProvider-MNkZn-bR.js";import{r as re}from"./ExpressionProvider-w-HoWEV1.js";import{r as ie}from"./useMetadata-DAEfn7ks.js";import{v as M}from"./ReportDefaultInspector-OSqdhKEL.js";import{t as N}from"./utils-Bixzg6Bz.js";import{n as ae,r as oe,t as se}from"./MetadataInspector-CpceGXDL.js";import{n as P,t as F}from"./DashboardWidgetInspector-BmIMgSGO.js";import{r as ce}from"./runtime-metadata-persistence-D1KKivGr.js";import{n as I,t as le}from"./useOpenRecordList-DL3H_OJi.js";import{n as ue}from"./skeletons-BK6x7CYd.js";import{n as de}from"./plugin-dashboard-Bi5WrqPG.js";var L=e(n(),1),R=i();function fe({open:e,onClose:t,schema:n,selectedWidgetId:r,onSelectWidget:i,onSave:a,onChange:o,onRemoveWidget:s,name:c,metadataClient:u,onAfterChange:d}){let{t:f}=l(),p=(0,L.useMemo)(()=>M(),[]),[m,g]=(0,L.useState)(!1),[_,v]=(0,L.useState)(0),b=(0,L.useCallback)(e=>{g(!0),o({...n??{},...e})},[n,o]),x=(0,L.useCallback)(e=>{o(e),g(!1)},[o]),S=(0,L.useCallback)(e=>{i(e&&e.kind===`widget`?e.id:null)},[i]),C=Array.isArray(n?.widgets)?n.widgets:[],w=r?C.find(e=>e?.id===r):null;if(!e)return null;let T=typeof n?.name==`string`?n.name:``,E=w?f(`widget.editor.title`,{defaultValue:`Edit widget`}):f(`dashboard.editor.title`,{defaultValue:`Edit dashboard`});return(0,R.jsxs)(`aside`,{className:`hidden sm:flex w-[440px] shrink-0 flex-col border-l bg-background h-full`,"data-testid":`dashboard-config-panel`,role:`complementary`,"aria-label":E,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b px-4 py-2.5 shrink-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[w&&(0,R.jsx)(y,{variant:`ghost`,size:`sm`,onClick:()=>i(null),className:`h-7 w-7 p-0`,"aria-label":f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),title:f(`dashboard.editor.backToDashboard`,{defaultValue:`Back to dashboard`}),"data-testid":`dashboard-config-back`,children:(0,R.jsx)(A,{className:`h-4 w-4`})}),(0,R.jsx)(`div`,{className:`text-sm font-medium truncate`,children:E})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[w&&s&&(0,R.jsx)(y,{variant:`ghost`,size:`sm`,onClick:()=>s(r),className:`h-7 w-7 p-0 text-destructive hover:text-destructive`,"aria-label":f(`widget.editor.delete`,{defaultValue:`Delete widget`}),title:f(`widget.editor.delete`,{defaultValue:`Delete widget`}),"data-testid":`widget-delete-button`,children:(0,R.jsx)(h,{className:`h-3.5 w-3.5`})}),(0,R.jsx)(y,{variant:`ghost`,size:`sm`,onClick:t,className:`h-7 w-7 p-0`,"aria-label":f(`common.close`,{defaultValue:`Close`}),"data-testid":`dashboard-config-close`,children:(0,R.jsx)(O,{className:`h-4 w-4`})})]})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:w?(0,R.jsx)(F,{type:`dashboard`,name:T,draft:n??{},selection:{kind:`widget`,id:r},onPatch:b,onClearSelection:()=>i(null),onSelectionChange:S,readOnly:!1,locale:p}):(0,R.jsx)(P,{type:`dashboard`,name:T,draft:n??{},onPatch:b,onSelectionChange:S,readOnly:!1,locale:p})}),(0,R.jsxs)(`div`,{"data-testid":`dashboard-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5 shrink-0`,children:[(0,R.jsx)(I,{type:`dashboard`,name:c||T||void 0,metadataClient:u,dirty:m,onResume:x,savedSignal:_,onAfterChange:d}),(0,R.jsx)(y,{size:`sm`,onClick:()=>{a(n??{}),g(!1),v(e=>e+1)},"data-testid":`dashboard-config-save`,children:f(`common.save`,{defaultValue:`Save`})})]})]})}var z=t({DashboardView:()=>U}),B=[{type:`metric`,label:`KPI Metric`,Icon:_},{type:`bar`,label:`Bar Chart`,Icon:v},{type:`line`,label:`Line Chart`,Icon:E},{type:`pie`,label:`Pie Chart`,Icon:k},{type:`table`,label:`Table`,Icon:D},{type:`pivot`,label:`Pivot`,Icon:S}],V=0;function H(){return V+=1,`widget_${Date.now()}_${V}`}function pe(e){return!e.widgets?.length||!e.widgets.some(e=>!e.id)?e:{...e,widgets:e.widgets.map(e=>e.id?e:{...e,id:H()})}}function me(e){let t=B.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function U({dataSource:e}){let t=le(),{dashboardName:n}=r(),{showDebug:i}=ae(),h=s(),_=ie(),{t:v}=l(),{dashboardLabel:S,dashboardDescription:E}=f(),D=a(),[O,k]=(0,L.useState)(!0),[A,M]=(0,L.useState)(!1),[P,F]=(0,L.useState)(null),[I,z]=(0,L.useState)(null),V=(0,L.useCallback)(e=>{z(t=>(t&&t.resolve(e),null))},[]),U=(0,L.useCallback)(e=>new Promise(t=>{let n;if(typeof e==`string`){let t=e.match(/^(create|new|add|edit|update)_(.+)$/);if(t){let e=t[1];n={objectName:t[2],mode:e===`edit`||e===`update`?`edit`:`create`}}else n={objectName:e,mode:`create`}}else n=e;z({schema:n,resolve:t})}),[]),he=(0,L.useMemo)(()=>({export_dashboard_pdf:async()=>{j.info(v(`dashboardActions.pdfPreparing`));try{return window.print(),{success:!0}}catch(e){return j.error(v(`dashboardActions.exportFailed`,{message:e?.message||String(e)})),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(j.info(v(`dashboardActions.forecastSoon`)),{success:!0})}),[v]);(0,L.useEffect)(()=>{k(!0),J(null),M(!1),F(null),queueMicrotask(()=>k(!1))},[n]);let{dashboards:ge,objects:W,refresh:G}=c(),{app:_e}=re(),K=oe(ge,n,_e?._packageId),[q,J]=(0,L.useState)(null);(0,L.useEffect)(()=>{A||J(null)},[K]);let Y=(0,L.useCallback)(async e=>{try{_&&await ce(`dashboard`,n,e,{metadataClient:_}),G().catch(()=>{})}catch(e){let t=e instanceof Error?e.message:String(e);console.warn(`[DashboardView] Auto-save failed:`,e),j.error(`Failed to save dashboard: ${t}`)}},[_,n,G]),ve=(0,L.useCallback)(()=>{J(pe(K)),M(!0)},[K]),ye=(0,L.useCallback)(()=>{M(!1),F(null)},[]),X=(0,L.useCallback)(e=>{if(!q)return;let t=H(),n={id:t,title:me(e),type:e,layout:{x:0,y:q.widgets?.length??0,w:q.columns??2,h:1}},r={...q,widgets:[...q.widgets||[],n]};J(r),Y(r),F(t)},[q,Y]),be=(0,L.useCallback)(e=>{if(!q)return;let t={...q,widgets:q.widgets.filter(t=>t.id!==e)};J(t),Y(t),P===e&&F(null)},[q,P,Y]),xe=(0,L.useCallback)(e=>{let t=q||K;if(!t)return;let n={...t,widgets:e};J(n),Y(n)},[q,K,Y]),Se=(q||K)??null,Z=(0,L.useMemo)(()=>new Set((W||[]).map(e=>e?.name).filter(Boolean)),[W]),Q=q||K,$=(0,L.useMemo)(()=>{if(!Q||Z.size===0)return Q;let e=Q.widgets;if(!Array.isArray(e)||e.length===0)return Q;let t=e.filter(e=>{let t=e?.requiresObject??e?.object;return t?Z.has(t):!0});return t.length===e.length?Q:{...Q,widgets:t}},[Q,Z]);return O?(0,R.jsx)(ue,{}):K?(0,R.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col sm:flex-row justify-between sm:items-center gap-3 sm:gap-4 p-4 sm:p-6 border-b shrink-0`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(()=>{let e=N(($||K).title,v),t=N(K.label,v),n=S({name:K.name,label:t});return(0,R.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:e||n||K.name})})(),(()=>{let e=($||K).description??K.description,t=E({name:K.name,description:N(e,v)});return t?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:t}):null})()]}),(0,R.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:[A&&(0,R.jsx)(`div`,{className:`flex items-center gap-1 mr-2`,role:`toolbar`,"aria-label":`Add widgets`,"data-testid":`dashboard-widget-toolbar`,children:B.map(({type:e,label:t,Icon:n})=>(0,R.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>X(e),className:`inline-flex items-center gap-1 rounded-md border border-input bg-background px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,title:`Add ${t}`,"aria-label":`Add ${t} widget`,children:[(0,R.jsx)(C,{className:`h-3 w-3`}),(0,R.jsx)(n,{className:`h-3 w-3`})]},e))}),D&&(0,R.jsxs)(`button`,{type:`button`,onClick:ve,className:`inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-2.5 py-1.5 text-xs font-medium text-muted-foreground shadow-sm hover:bg-accent hover:text-accent-foreground`,"data-testid":`dashboard-edit-button`,children:[(0,R.jsx)(te,{className:`h-3.5 w-3.5`}),v(`common.edit`,{defaultValue:`Edit`})]})]})]}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,R.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,R.jsx)(o,{value:{openRecordList:t},children:(0,R.jsx)(de,{schema:$,dataSource:e,designMode:A,selectedWidgetId:P,onWidgetClick:F,onWidgetsReorder:xe,modalHandler:U,scriptHandlers:he,hideHeaderText:!0})})}),(0,R.jsx)(fe,{open:A&&D,onClose:ye,schema:Se,selectedWidgetId:P,onSelectWidget:F,onSave:Y,onChange:J,onRemoveWidget:be,name:n,metadataClient:_,onAfterChange:()=>G().catch(()=>{})}),(0,R.jsx)(se,{open:i,sections:[{title:`Dashboard Configuration`,data:$}]})]}),I&&I.schema?.objectName?(0,R.jsx)(ne,{schema:{type:`object-form`,formType:`modal`,objectName:I.schema.objectName,mode:I.schema.mode||`create`,recordId:I.schema.recordId,title:I.schema.title,description:I.schema.description,fields:I.schema.fields,open:!0,onOpenChange:e=>{e||V({success:!1})},onSuccess:e=>{V({success:!0,reload:!0,data:e})},onCancel:()=>{V({success:!1})},showSubmit:!0,showCancel:!0},dataSource:h}):I?(0,R.jsx)(x,{open:!0,onOpenChange:e=>{e||V({success:!1})},children:(0,R.jsxs)(d,{children:[(0,R.jsxs)(m,{children:[(0,R.jsx)(w,{children:I.schema?.title||v(`actionDialog.defaultActionTitle`)}),I.schema?.description&&(0,R.jsx)(g,{children:I.schema.description})]}),(0,R.jsxs)(ee,{children:[(0,R.jsx)(y,{variant:`outline`,onClick:()=>V({success:!1}),children:v(`actionDialog.cancel`)}),(0,R.jsx)(y,{onClick:()=>V({success:!0}),children:v(`actionDialog.ok`)})]})]})}):null]}):(0,R.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,R.jsxs)(b,{children:[(0,R.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,R.jsx)(T,{className:`h-6 w-6 text-muted-foreground`})}),(0,R.jsx)(p,{children:v(`empty.dashboardNotFound`)}),(0,R.jsx)(u,{children:v(`empty.dashboardNotFoundDescription`,{name:n})})]})})}export{z as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{R as r,l as i,m as a}from"./vendor-objectstack-BGWJwgbT.js";import{$s as o,Ac as s,Bn as c,Hn as l,In as u,Jt as d,Ks as f,Kt as p,Ls as m,Rn as h,Sr as g,Va as _,Vn as v,Ws as y,Xi as b,Xs as x,Xt as S,Ys as C,Yt as w,Zs as T,_o as E,ai as D,an as O,cn as k,es as A,fn as j,fs as M,kc as N,ki as P,kr as F,on as ee,or as te,po as ne,qr as re,qs as ie,qt as I,rs as ae,sn as oe,zn as L}from"./ui-components-Pnfq_-xI.js";import{r as R}from"./useMetadata-Ja6XpRRW.js";import{F as se,I as ce,M as z,N as le,P as B,W as ue,_ as de,a as fe,g as pe,i as me,j as he,k as ge,p as _e,r as ve,t as V,y as H}from"./ReportDefaultInspector-Cg2S1xbC.js";var U=e(t(),1),W=n();function ye(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 G({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:d,loading:f,allowCustom:p=!0,mono:_,className:b}){let[x,S]=U.useState(!1),[C,w]=U.useState(``),T=r.find(e=>e.value===t),E=T?T.label:t||(f?`Loading…`:i),D=U.useMemo(()=>r.filter(e=>ye(e,C)),[r,C]),k=U.useMemo(()=>{let e=[],t=new Map;for(let n of D){let r=n.group??``;t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return e.map(e=>({heading:e,items:t.get(e)}))},[D]),A=C.trim(),M=p&&!!A&&!r.some(e=>e.value===A),N=e=>{n(e),S(!1),w(``)},P=(0,W.jsxs)(O,{open:x,onOpenChange:e=>{S(e),e||w(``)},children:[(0,W.jsx)(oe,{asChild:!0,children:(0,W.jsxs)(g,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":x,disabled:d,className:s(`h-8 w-full justify-between px-2 text-sm font-normal`,b),children:[(0,W.jsx)(`span`,{className:s(`truncate`,_&&`font-mono`,!T&&!t&&`text-muted-foreground`),children:E}),(0,W.jsx)(m,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,W.jsx)(ee,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,W.jsxs)(u,{shouldFilter:!1,children:[(0,W.jsx)(c,{value:C,onValueChange:w,placeholder:a}),(0,W.jsxs)(l,{children:[!M&&D.length===0&&(0,W.jsx)(h,{children:o}),M&&(0,W.jsx)(L,{children:(0,W.jsx)(v,{value:`__custom__${A}`,onSelect:()=>N(A),children:(0,W.jsxs)(`span`,{className:`truncate`,children:[`Use `,(0,W.jsxs)(`span`,{className:`font-mono`,children:[`“`,A,`”`]})]})})}),k.map((e,n)=>(0,W.jsx)(L,{heading:e.heading||void 0,children:e.items.map(e=>(0,W.jsxs)(v,{value:e.value,onSelect:()=>N(e.value),children:[(0,W.jsx)(y,{className:s(`h-3.5 w-3.5`,e.value===t?`opacity-100`:`opacity-0`)}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,W.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,W.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${n}`))]})]})})]});return e?(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(j,{className:`text-xs text-muted-foreground`,children:e}),P]}):P}var be=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function K(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 xe(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 Se(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 q(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=K(e.label,t),r=ue(e.fields).entries.map(e=>({name:e.name,label:K(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&&be.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:xe(e.def)}))}}function J(e,t,n){let r=e,i=[];for(let e of t.split(`.`)){let t=r.relationships.find(t=>t.name===e);if(!t?.referenceTo)return;let a=n[t.referenceTo];if(!a)return;i.push(t.label),r=a}return{target:r,labels:i}}function Ce(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=J(e,i,n);if(!t)continue;let a=[...t.labels,t.target.label].join(` → `);for(let e of t.target.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:a})}return r}function Y(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>Y(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t?!0:Object.values(n).some(e=>e&&typeof e==`object`&&Y(e,t))}function we(){let e=R(),[t,n]=U.useState({options:[],loading:!0});return U.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:K(e.label,typeof e.name==`string`?e.name:``)})).filter(e=>!!e.name).sort((e,t)=>e.label.localeCompare(t.label)),loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function Te(e,t){let n=R(),r=t.join(`\0`),[i,a]=U.useState({relationships:[],fieldOptions:[],loading:!!e});return U.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=q(i,e),s=r?r.split(`\0`):[],c={[e]:o},l=async e=>{if(c[e])return c[e];let t;try{t=q(await n.get(`object`,e),e)}catch{t=q(null,e)}return c[e]=t,t};for(let e of s){let t=o;for(let n of e.split(`.`)){let e=t.relationships.find(e=>e.name===n);if(!e?.referenceTo)break;t=await l(e.referenceTo)}}if(t)return;let u=[...o.relationships];for(let e of s){if(e.split(`.`).length>=3)continue;let t=J(o,e,c);if(t)for(let n of t.target.relationships)u.push({name:`${e}.${n.name}`,label:`${e}.${n.name}`,referenceTo:n.referenceTo})}a({relationships:u,fieldOptions:Ce(o,s,c),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function Ee(e){let t=R(),[n,r]=U.useState({reports:0,dashboards:0,loading:!!e});return U.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=>Y(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>Y(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}var X={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:ne},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:x},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:C},line:{id:`line`,label:`Line chart`,category:`chart`,icon:T},area:{id:`area`,label:`Area chart`,category:`chart`,icon:o},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:ie},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:A},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:f},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:re},table:{id:`table`,label:`Data table`,category:`data`,icon:D},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:ae},list:{id:`list`,label:`Record list`,category:`data`,icon:_},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:M}},De={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},Oe=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(X).filter(t=>t.category===e)})),ke=N;function Ae({onAdd:e,label:t=`Add widget`}){let[n,r]=U.useState(!1),[i,a]=U.useState(``),o=U.useRef(null),s=U.useRef(null);U.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=U.useMemo(()=>{let e=i.trim().toLowerCase();return e?Oe.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):Oe},[i]);return(0,W.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,W.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,W.jsx)(b,{className:`h-3 w-3`}),t]}),n&&(0,W.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,W.jsx)(P,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,W.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,W.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):c.map(t=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:De[t.category]}),t.types.map(t=>(0,W.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,W.jsx)(X[t.id]?.icon??ke,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,W.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,W.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var je={io:`input`,unrepresentable:`any`},Me=new Set([`widgets`,`label`,`description`,`name`]),Z,Ne=!1;function Pe(){if(Z||Ne)return Z;try{Z=r(i,je)}catch(e){Ne=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return Z}var Q;function Fe(){if(Q)return Q;if(!(!a||typeof a!=`object`)){try{let e=JSON.parse(JSON.stringify(a));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!Me.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Q=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return Q}}var Ie=new Set([`name`,`label`,`description`,`widgets`]);function Le({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=U.useCallback(e=>H(e,r),[r]),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,l=U.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),u=e=>{let n=ce(`widget`,l.map(e=>e?.id).filter(Boolean)),r=X[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:le(l,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},d=e=>{t({widgets:se(l,e,null)})},f=(e,n)=>{e!==n&&t({widgets:B(l,e,n)})},p=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[m,h]=U.useState(null),[_,v]=U.useState(null),{schema:y,form:b}=U.useMemo(()=>fe({bundledSchema:Pe(),bundledForm:Fe(),serverSchema:a,excludeFields:Ie,sectionTitle:H(`engine.inspector.moreFields`,r)}),[a,r]);return(0,W.jsxs)(he,{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,W.jsx)(z,{label:o(`engine.inspector.dashboard.label`),value:s,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,W.jsx)(z,{label:o(`engine.inspector.dashboard.description`),value:c,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,W.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(j,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,W.jsx)(te,{variant:`outline`,className:`text-[10px]`,children:l.length})]}),l.length===0?(0,W.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,W.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let r=X[e?.type]?.icon??ke;return(0,W.jsxs)(`div`,{draggable:!n,onDragStart:()=>h(t),onDragEnd:()=>{h(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{m!=null&&m!==t&&f(m,t),h(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&m!==null&&m!==t?` border-primary`:``),children:[!n&&(0,W.jsx)(E,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,W.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,W.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>p(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,W.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,W.jsx)(g,{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,W.jsx)(F,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,W.jsx)(Ae,{onAdd:u,label:o(`engine.inspector.add.widget`)})]}),(0,W.jsx)(`div`,{className:`border-t pt-3`,children:y?(0,W.jsx)(_e,{schema:y,form:b,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var Re=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],ze=[`count`,`sum`,`avg`,`min`,`max`],Be=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function Ve(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function He({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){let s=Array.isArray(e.widgets)?e.widgets:[],c=t.kind===`widget`?t.id:void 0,l=c?Ve(e,c):null,u=l?.widget??{},f=typeof u.dataset==`string`?u.dataset:``,m=typeof u.object==`string`?u.object:``,h=Array.isArray(u.dimensions)?u.dimensions.filter(e=>typeof e==`string`):[],_=Array.isArray(u.values)?u.values.filter(e=>typeof e==`string`):[],v=ve(),y=me(f||void 0,v),{options:b,loading:x}=we(),{fields:C}=pe(m||void 0),T=U.useMemo(()=>{let e=v.datasets.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return f&&!e.some(e=>e.value===f)&&e.push({value:f,label:f}),e},[v.datasets,f]),E=U.useMemo(()=>b.map(e=>({value:e.name,label:e.label})),[b]),D=U.useMemo(()=>C.map(e=>({value:e.name,label:e.label,hint:e.type})),[C]),O=U.useMemo(()=>y.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[y.measures]),A=U.useMemo(()=>y.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[y.dimensions]);if(t.kind!==`widget`)return(0,W.jsx)(Ue,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});if(!l)return(0,W.jsx)(Ue,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:j,index:M}=l;function N(e){let t=[...s];t[M]={...t[M],...e},n({widgets:t})}function P(e){n({widgets:B(s,M,e)}),j.id&&i?.({kind:`widget`,id:j.id,label:j.title??void 0})}return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:H(`engine.inspector.widget.kind`,o)}),(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:j.title||t.label||`Widget ${M+1}`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,W.jsx)(ge,{index:M,total:s.length,onMove:P,upLabel:H(`engine.inspector.reorder.up`,o),downLabel:H(`engine.inspector.reorder.down`,o),disabled:a}),(0,W.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:H(`engine.inspector.widget.close`,o),"aria-label":H(`engine.inspector.widget.close`,o),children:(0,W.jsx)(F,{className:`h-3.5 w-3.5`})})]})]}),(0,W.jsx)($,{id:`widget-title`,label:H(`engine.inspector.widget.title`,o),children:(0,W.jsx)(k,{id:`widget-title`,value:j.title??``,onChange:e=>N({title:e.target.value}),disabled:a})}),(0,W.jsx)($,{id:`widget-type`,label:H(`engine.inspector.widget.type`,o),children:(0,W.jsxs)(p,{value:j.type??`metric`,onValueChange:e=>N({type:e}),disabled:a,children:[(0,W.jsx)(w,{id:`widget-type`,children:(0,W.jsx)(S,{})}),(0,W.jsx)(I,{children:Re.map(e=>(0,W.jsx)(d,{value:e.value,children:e.label},e.value))})]})}),(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:H(`engine.inspector.widget.datasetSection`,o)}),(0,W.jsxs)($,{id:`widget-dataset`,label:H(`engine.inspector.widget.dataset`,o),children:[(0,W.jsx)(G,{value:f,onCommit:e=>N({dataset:e||void 0}),options:T,loading:v.loading,placeholder:H(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:H(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:H(`engine.inspector.widget.datasetHint`,o)})]}),f&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(V,{label:H(`engine.inspector.widget.dimensions`,o),emptyText:H(`engine.inspector.widget.dimensionsHint`,o),names:h,options:A,loading:y.loading,error:y.error,readOnly:a,onCommit:e=>N({dimensions:e})}),(0,W.jsx)(V,{label:H(`engine.inspector.widget.values`,o),emptyText:H(`engine.inspector.widget.valuesHint`,o),names:_,options:O,loading:y.loading,error:y.error,readOnly:a,onCommit:e=>N({values:e})})]})]}),(0,W.jsx)($,{id:`widget-object`,label:H(`engine.inspector.widget.object`,o),children:(0,W.jsx)(G,{value:j.object??``,onCommit:e=>N({object:e||void 0}),options:E,loading:x,placeholder:`Select an object…`,searchPlaceholder:`Search objects…`,disabled:a,mono:!0})}),(0,W.jsx)($,{id:`widget-value-field`,label:H(`engine.inspector.widget.valueField`,o),children:(0,W.jsx)(G,{value:j.valueField??``,onCommit:e=>N({valueField:e||void 0}),options:D,placeholder:j.object?`Select a field…`:`e.g. amount`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,W.jsx)($,{id:`widget-category-field`,label:H(`engine.inspector.widget.categoryField`,o),children:(0,W.jsx)(G,{value:j.categoryField??``,onCommit:e=>N({categoryField:e||void 0}),options:D,placeholder:j.object?`Select a field…`:`e.g. status`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,W.jsx)($,{id:`widget-aggregate`,label:H(`engine.inspector.widget.aggregate`,o),children:(0,W.jsxs)(p,{value:j.aggregate??`count`,onValueChange:e=>N({aggregate:e}),disabled:a,children:[(0,W.jsx)(w,{id:`widget-aggregate`,children:(0,W.jsx)(S,{})}),(0,W.jsx)(I,{children:ze.map(e=>(0,W.jsx)(d,{value:e,children:e},e))})]})}),(0,W.jsx)($,{id:`widget-color`,label:H(`engine.inspector.widget.color`,o),children:(0,W.jsx)(de,{value:j.colorVariant??`default`,onChange:e=>N({colorVariant:e}),disabled:a,options:Be.map(e=>({value:e}))})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsx)($,{id:`widget-w`,label:H(`engine.inspector.widget.width`,o),children:(0,W.jsx)(k,{id:`widget-w`,type:`number`,min:1,value:j.layout?.w??1,onChange:e=>N({layout:{...j.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,W.jsx)($,{id:`widget-h`,label:H(`engine.inspector.widget.height`,o),children:(0,W.jsx)(k,{id:`widget-h`,type:`number`,min:1,value:j.layout?.h??1,onChange:e=>N({layout:{...j.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,W.jsx)(`div`,{className:`pt-2 border-t`,children:(0,W.jsx)(g,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(M,1),n({widgets:t}),r()},children:H(`engine.inspector.widget.remove`,o)})})]})}function $({id:e,label:t,children:n}){return(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(j,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function Ue({message:e,onClose:t,locale:n}){return(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,W.jsx)(`p`,{children:e}),(0,W.jsx)(g,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:H(`engine.inspector.widget.close`,n)})]})}export{Se as a,we as c,X as i,G as l,Le as n,Te as o,Ae as r,Ee as s,He as t};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{V as r,_ as i,f as a}from"./vendor-objectstack-sPlD8LgO.js";import{$s as o,Ac as s,Bn as c,Hn as l,In as u,Jt as d,Ks as f,Kt as p,Ls as m,Rn as h,Sr as g,Va as _,Vn as v,Ws as y,Xi as b,Xs as x,Xt as S,Ys as C,Yt as w,Zs as T,_o as E,ai as D,an as O,cn as k,es as A,fn as j,fs as M,kc as N,ki as P,kr as F,on as ee,or as te,po as ne,qr as re,qs as ie,qt as I,rs as ae,sn as oe,zn as L}from"./ui-components-DsYvPIox.js";import{r as R}from"./useMetadata-DAEfn7ks.js";import{F as se,I as ce,M as z,N as le,P as B,W as ue,_ as de,a as fe,g as pe,i as me,j as he,k as ge,p as _e,r as ve,t as V,y as H}from"./ReportDefaultInspector-OSqdhKEL.js";var U=e(t(),1),W=n();function ye(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 G({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:d,loading:f,allowCustom:p=!0,mono:_,className:b}){let[x,S]=U.useState(!1),[C,w]=U.useState(``),T=r.find(e=>e.value===t),E=T?T.label:t||(f?`Loading…`:i),D=U.useMemo(()=>r.filter(e=>ye(e,C)),[r,C]),k=U.useMemo(()=>{let e=[],t=new Map;for(let n of D){let r=n.group??``;t.has(r)||(t.set(r,[]),e.push(r)),t.get(r).push(n)}return e.map(e=>({heading:e,items:t.get(e)}))},[D]),A=C.trim(),M=p&&!!A&&!r.some(e=>e.value===A),N=e=>{n(e),S(!1),w(``)},P=(0,W.jsxs)(O,{open:x,onOpenChange:e=>{S(e),e||w(``)},children:[(0,W.jsx)(oe,{asChild:!0,children:(0,W.jsxs)(g,{type:`button`,variant:`outline`,role:`combobox`,"aria-expanded":x,disabled:d,className:s(`h-8 w-full justify-between px-2 text-sm font-normal`,b),children:[(0,W.jsx)(`span`,{className:s(`truncate`,_&&`font-mono`,!T&&!t&&`text-muted-foreground`),children:E}),(0,W.jsx)(m,{className:`ml-2 h-3.5 w-3.5 shrink-0 opacity-50`})]})}),(0,W.jsx)(ee,{align:`start`,className:`w-[var(--radix-popover-trigger-width)] min-w-[14rem] p-0`,children:(0,W.jsxs)(u,{shouldFilter:!1,children:[(0,W.jsx)(c,{value:C,onValueChange:w,placeholder:a}),(0,W.jsxs)(l,{children:[!M&&D.length===0&&(0,W.jsx)(h,{children:o}),M&&(0,W.jsx)(L,{children:(0,W.jsx)(v,{value:`__custom__${A}`,onSelect:()=>N(A),children:(0,W.jsxs)(`span`,{className:`truncate`,children:[`Use `,(0,W.jsxs)(`span`,{className:`font-mono`,children:[`“`,A,`”`]})]})})}),k.map((e,n)=>(0,W.jsx)(L,{heading:e.heading||void 0,children:e.items.map(e=>(0,W.jsxs)(v,{value:e.value,onSelect:()=>N(e.value),children:[(0,W.jsx)(y,{className:s(`h-3.5 w-3.5`,e.value===t?`opacity-100`:`opacity-0`)}),(0,W.jsx)(`span`,{className:`truncate font-mono`,children:e.value}),e.label&&e.label!==e.value&&(0,W.jsx)(`span`,{className:`ml-1 truncate text-muted-foreground`,children:e.label}),e.hint&&(0,W.jsx)(`span`,{className:`ml-auto pl-2 text-[10px] text-muted-foreground`,children:e.hint})]},e.value))},e.heading||`g${n}`))]})]})})]});return e?(0,W.jsxs)(`div`,{className:`space-y-1`,children:[(0,W.jsx)(j,{className:`text-xs text-muted-foreground`,children:e}),P]}):P}var be=new Set([`lookup`,`master_detail`,`masterdetail`,`master-detail`]);function K(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 xe(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 Se(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 q(e,t){if(!e)return{label:t,fields:[],relationships:[]};let n=K(e.label,t),r=ue(e.fields).entries.map(e=>({name:e.name,label:K(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&&be.has(e.type.toLowerCase())).map(e=>({name:e.name,label:e.label,referenceTo:xe(e.def)}))}}function J(e,t,n){let r=e,i=[];for(let e of t.split(`.`)){let t=r.relationships.find(t=>t.name===e);if(!t?.referenceTo)return;let a=n[t.referenceTo];if(!a)return;i.push(t.label),r=a}return{target:r,labels:i}}function Ce(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=J(e,i,n);if(!t)continue;let a=[...t.labels,t.target.label].join(` → `);for(let e of t.target.fields)r.push({value:`${i}.${e.name}`,label:e.label,type:e.type,group:a})}return r}function Y(e,t){if(!e||typeof e!=`object`)return!1;if(Array.isArray(e))return e.some(e=>Y(e,t));let n=e;return typeof n.dataset==`string`&&n.dataset===t?!0:Object.values(n).some(e=>e&&typeof e==`object`&&Y(e,t))}function we(){let e=R(),[t,n]=U.useState({options:[],loading:!0});return U.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:K(e.label,typeof e.name==`string`?e.name:``)})).filter(e=>!!e.name).sort((e,t)=>e.label.localeCompare(t.label)),loading:!1})}).catch(()=>{t||n({options:[],loading:!1})}),()=>{t=!0}},[e]),t}function Te(e,t){let n=R(),r=t.join(`\0`),[i,a]=U.useState({relationships:[],fieldOptions:[],loading:!!e});return U.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=q(i,e),s=r?r.split(`\0`):[],c={[e]:o},l=async e=>{if(c[e])return c[e];let t;try{t=q(await n.get(`object`,e),e)}catch{t=q(null,e)}return c[e]=t,t};for(let e of s){let t=o;for(let n of e.split(`.`)){let e=t.relationships.find(e=>e.name===n);if(!e?.referenceTo)break;t=await l(e.referenceTo)}}if(t)return;let u=[...o.relationships];for(let e of s){if(e.split(`.`).length>=3)continue;let t=J(o,e,c);if(t)for(let n of t.target.relationships)u.push({name:`${e}.${n.name}`,label:`${e}.${n.name}`,referenceTo:n.referenceTo})}a({relationships:u,fieldOptions:Ce(o,s,c),loading:!1})}catch{t||a({relationships:[],fieldOptions:[],loading:!1})}})(),()=>{t=!0}},[n,e,r]),i}function Ee(e){let t=R(),[n,r]=U.useState({reports:0,dashboards:0,loading:!!e});return U.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=>Y(t,e)).length,dashboards:(Array.isArray(a)?a:[]).filter(t=>Y(t,e)).length,loading:!1})})(),()=>{n=!0}},[t,e]),n}var X={metric:{id:`metric`,label:`Metric (KPI)`,category:`kpi`,icon:ne},bar:{id:`bar`,label:`Bar chart`,category:`chart`,icon:x},"horizontal-bar":{id:`horizontal-bar`,label:`Horizontal bar`,category:`chart`,icon:C},line:{id:`line`,label:`Line chart`,category:`chart`,icon:T},area:{id:`area`,label:`Area chart`,category:`chart`,icon:o},pie:{id:`pie`,label:`Pie chart`,category:`chart`,icon:ie},donut:{id:`donut`,label:`Donut chart`,category:`chart`,icon:A},scatter:{id:`scatter`,label:`Scatter plot`,category:`chart`,icon:f},funnel:{id:`funnel`,label:`Funnel`,category:`chart`,icon:re},table:{id:`table`,label:`Data table`,category:`data`,icon:D},pivot:{id:`pivot`,label:`Pivot table`,category:`data`,icon:ae},list:{id:`list`,label:`Record list`,category:`data`,icon:_},custom:{id:`custom`,label:`Custom widget`,category:`custom`,icon:M}},De={kpi:`Single value`,chart:`Charts`,data:`Tabular`,custom:`Custom`},Oe=[`kpi`,`chart`,`data`,`custom`].map(e=>({category:e,types:Object.values(X).filter(t=>t.category===e)})),ke=N;function Ae({onAdd:e,label:t=`Add widget`}){let[n,r]=U.useState(!1),[i,a]=U.useState(``),o=U.useRef(null),s=U.useRef(null);U.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=U.useMemo(()=>{let e=i.trim().toLowerCase();return e?Oe.map(t=>({category:t.category,types:t.types.filter(t=>t.id.toLowerCase().includes(e)||t.label.toLowerCase().includes(e))})).filter(e=>e.types.length):Oe},[i]);return(0,W.jsxs)(`div`,{ref:o,className:`relative`,children:[(0,W.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,W.jsx)(b,{className:`h-3 w-3`}),t]}),n&&(0,W.jsxs)(`div`,{className:`absolute right-0 top-full z-40 mt-1 w-72 rounded-md border bg-popover shadow-md`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 border-b px-2 py-1.5`,children:[(0,W.jsx)(P,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,W.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,W.jsx)(`div`,{className:`max-h-72 overflow-auto py-1`,children:c.length===0?(0,W.jsx)(`div`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:`No matches.`}):c.map(t=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`px-3 pt-2 pb-1 text-[10px] uppercase tracking-wider text-muted-foreground`,children:De[t.category]}),t.types.map(t=>(0,W.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,W.jsx)(X[t.id]?.icon??ke,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,W.jsx)(`span`,{className:`font-medium truncate`,children:t.label}),(0,W.jsx)(`code`,{className:`ml-auto text-[10px] text-muted-foreground`,children:t.id})]},t.id))]},t.category))})]})]})}var je={io:`input`,unrepresentable:`any`},Me=new Set([`widgets`,`label`,`description`,`name`]),Z,Ne=!1;function Pe(){if(Z||Ne)return Z;try{Z=r(a,je)}catch(e){Ne=!0,typeof console<`u`&&console.warn(`[dashboard-schema] failed to derive Dashboard JSONSchema from spec`,e)}return Z}var Q;function Fe(){if(Q)return Q;if(!(!i||typeof i!=`object`)){try{let e=JSON.parse(JSON.stringify(i));for(let t of e.sections??[])t.fields=(t.fields??[]).filter(e=>{let t=typeof e==`string`?e:e?.field;return!Me.has(t)});e.sections=(e.sections??[]).filter(e=>(e.fields??[]).length>0),Q=e}catch(e){typeof console<`u`&&console.warn(`[dashboard-schema] failed to prepare dashboardForm from spec`,e);return}return Q}}var Ie=new Set([`name`,`label`,`description`,`widgets`]);function Le({draft:e,onPatch:t,readOnly:n,locale:r,onSelectionChange:i,serverSchema:a}){let o=U.useCallback(e=>H(e,r),[r]),s=typeof e.label==`string`?e.label:``,c=typeof e.description==`string`?e.description:``,l=U.useMemo(()=>Array.isArray(e.widgets)?e.widgets:[],[e.widgets]),u=e=>{let n=ce(`widget`,l.map(e=>e?.id).filter(Boolean)),r=X[e],a=r?`New ${r.label.toLowerCase()}`:`New widget`;t({widgets:le(l,{id:n,type:e,title:a,...r?.defaults??{}})}),i?.({kind:`widget`,id:n,label:a})},d=e=>{t({widgets:se(l,e,null)})},f=(e,n)=>{e!==n&&t({widgets:B(l,e,n)})},p=(e,t)=>{e?.id&&i?.({kind:`widget`,id:e.id,label:e.title||e.id||`Widget ${t+1}`})},[m,h]=U.useState(null),[_,v]=U.useState(null),{schema:y,form:b}=U.useMemo(()=>fe({bundledSchema:Pe(),bundledForm:Fe(),serverSchema:a,excludeFields:Ie,sectionTitle:H(`engine.inspector.moreFields`,r)}),[a,r]);return(0,W.jsxs)(he,{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,W.jsx)(z,{label:o(`engine.inspector.dashboard.label`),value:s,onCommit:e=>t({label:e}),placeholder:o(`engine.inspector.dashboard.labelPlaceholder`),disabled:n}),(0,W.jsx)(z,{label:o(`engine.inspector.dashboard.description`),value:c,onCommit:e=>t({description:e}),placeholder:o(`engine.inspector.dashboard.descriptionPlaceholder`),disabled:n}),(0,W.jsxs)(`div`,{className:`border-t pt-3 space-y-1.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,W.jsx)(j,{className:`text-xs text-muted-foreground`,children:o(`engine.inspector.dashboard.widgets`)}),(0,W.jsx)(te,{variant:`outline`,className:`text-[10px]`,children:l.length})]}),l.length===0?(0,W.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,W.jsx)(`div`,{className:`space-y-1`,children:l.map((e,t)=>{let r=X[e?.type]?.icon??ke;return(0,W.jsxs)(`div`,{draggable:!n,onDragStart:()=>h(t),onDragEnd:()=>{h(null),v(null)},onDragOver:e=>{e.preventDefault(),v(t)},onDrop:()=>{m!=null&&m!==t&&f(m,t),h(null),v(null)},className:`group flex items-center gap-2 rounded-md border px-2 py-1.5 text-xs hover:bg-accent`+(_===t&&m!==null&&m!==t?` border-primary`:``),children:[!n&&(0,W.jsx)(E,{className:`h-3.5 w-3.5 shrink-0 cursor-grab text-muted-foreground`}),(0,W.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,W.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left font-medium`,onClick:()=>p(e,t),title:e?.title||e?.id,children:e?.title||e?.id||`Widget ${t+1}`}),(0,W.jsx)(`code`,{className:`text-[10px] text-muted-foreground`,children:e?.type}),!n&&(0,W.jsx)(g,{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,W.jsx)(F,{className:`h-3.5 w-3.5`})})]},e?.id??t)})}),!n&&(0,W.jsx)(Ae,{onAdd:u,label:o(`engine.inspector.add.widget`)})]}),(0,W.jsx)(`div`,{className:`border-t pt-3`,children:y?(0,W.jsx)(_e,{schema:y,form:b,value:e,hiddenFields:[`name`,`label`,`description`,`widgets`],readOnly:n,onChange:e=>t(e)}):(0,W.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(`engine.inspector.dashboard.noSchema`)})})]})}var Re=[{value:`metric`,label:`KPI Metric`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`table`,label:`Table`},{value:`grid`,label:`Grid`}],ze=[`count`,`sum`,`avg`,`min`,`max`],Be=[`default`,`blue`,`teal`,`orange`,`purple`,`success`,`warning`,`danger`];function Ve(e,t){let n=Array.isArray(e.widgets)?e.widgets:[],r=n.findIndex(e=>e?.id===t);return r<0?null:{widget:n[r],index:r}}function He({draft:e,selection:t,onPatch:n,onClearSelection:r,onSelectionChange:i,readOnly:a,locale:o}){let s=Array.isArray(e.widgets)?e.widgets:[],c=t.kind===`widget`?t.id:void 0,l=c?Ve(e,c):null,u=l?.widget??{},f=typeof u.dataset==`string`?u.dataset:``,m=typeof u.object==`string`?u.object:``,h=Array.isArray(u.dimensions)?u.dimensions.filter(e=>typeof e==`string`):[],_=Array.isArray(u.values)?u.values.filter(e=>typeof e==`string`):[],v=ve(),y=me(f||void 0,v),{options:b,loading:x}=we(),{fields:C}=pe(m||void 0),T=U.useMemo(()=>{let e=v.datasets.map(e=>({value:e.name,label:e.label&&e.label!==e.name?`${e.label} (${e.name})`:e.name}));return f&&!e.some(e=>e.value===f)&&e.push({value:f,label:f}),e},[v.datasets,f]),E=U.useMemo(()=>b.map(e=>({value:e.name,label:e.label})),[b]),D=U.useMemo(()=>C.map(e=>({value:e.name,label:e.label,hint:e.type})),[C]),O=U.useMemo(()=>y.measures.map(e=>({name:e.name,label:e.aggregate?`${e.name} · ${e.aggregate}`:e.name,type:`number`,hidden:!1})),[y.measures]),A=U.useMemo(()=>y.dimensions.map(e=>({name:e.name,label:e.name,type:e.type??`text`,hidden:!1})),[y.dimensions]);if(t.kind!==`widget`)return(0,W.jsx)(Ue,{message:`Unsupported selection kind: ${t.kind}`,onClose:r,locale:o});if(!l)return(0,W.jsx)(Ue,{message:`The selected widget was removed from the draft.`,onClose:r,locale:o});let{widget:j,index:M}=l;function N(e){let t=[...s];t[M]={...t[M],...e},n({widgets:t})}function P(e){n({widgets:B(s,M,e)}),j.id&&i?.({kind:`widget`,id:j.id,label:j.title??void 0})}return(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:H(`engine.inspector.widget.kind`,o)}),(0,W.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:j.title||t.label||`Widget ${M+1}`})]}),(0,W.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,W.jsx)(ge,{index:M,total:s.length,onMove:P,upLabel:H(`engine.inspector.reorder.up`,o),downLabel:H(`engine.inspector.reorder.down`,o),disabled:a}),(0,W.jsx)(g,{type:`button`,variant:`ghost`,size:`sm`,className:`h-7 w-7 p-0`,onClick:r,title:H(`engine.inspector.widget.close`,o),"aria-label":H(`engine.inspector.widget.close`,o),children:(0,W.jsx)(F,{className:`h-3.5 w-3.5`})})]})]}),(0,W.jsx)($,{id:`widget-title`,label:H(`engine.inspector.widget.title`,o),children:(0,W.jsx)(k,{id:`widget-title`,value:j.title??``,onChange:e=>N({title:e.target.value}),disabled:a})}),(0,W.jsx)($,{id:`widget-type`,label:H(`engine.inspector.widget.type`,o),children:(0,W.jsxs)(p,{value:j.type??`metric`,onValueChange:e=>N({type:e}),disabled:a,children:[(0,W.jsx)(w,{id:`widget-type`,children:(0,W.jsx)(S,{})}),(0,W.jsx)(I,{children:Re.map(e=>(0,W.jsx)(d,{value:e.value,children:e.label},e.value))})]})}),(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed border-primary/40 bg-primary/5 p-3`,children:[(0,W.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-primary/80`,children:H(`engine.inspector.widget.datasetSection`,o)}),(0,W.jsxs)($,{id:`widget-dataset`,label:H(`engine.inspector.widget.dataset`,o),children:[(0,W.jsx)(G,{value:f,onCommit:e=>N({dataset:e||void 0}),options:T,loading:v.loading,placeholder:H(`engine.inspector.widget.datasetPlaceholder`,o),searchPlaceholder:H(`engine.inspector.widget.datasetPlaceholder`,o),disabled:a,mono:!0}),(0,W.jsx)(`p`,{className:`text-[10px] leading-snug text-muted-foreground`,children:H(`engine.inspector.widget.datasetHint`,o)})]}),f&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(V,{label:H(`engine.inspector.widget.dimensions`,o),emptyText:H(`engine.inspector.widget.dimensionsHint`,o),names:h,options:A,loading:y.loading,error:y.error,readOnly:a,onCommit:e=>N({dimensions:e})}),(0,W.jsx)(V,{label:H(`engine.inspector.widget.values`,o),emptyText:H(`engine.inspector.widget.valuesHint`,o),names:_,options:O,loading:y.loading,error:y.error,readOnly:a,onCommit:e=>N({values:e})})]})]}),(0,W.jsx)($,{id:`widget-object`,label:H(`engine.inspector.widget.object`,o),children:(0,W.jsx)(G,{value:j.object??``,onCommit:e=>N({object:e||void 0}),options:E,loading:x,placeholder:`Select an object…`,searchPlaceholder:`Search objects…`,disabled:a,mono:!0})}),(0,W.jsx)($,{id:`widget-value-field`,label:H(`engine.inspector.widget.valueField`,o),children:(0,W.jsx)(G,{value:j.valueField??``,onCommit:e=>N({valueField:e||void 0}),options:D,placeholder:j.object?`Select a field…`:`e.g. amount`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,W.jsx)($,{id:`widget-category-field`,label:H(`engine.inspector.widget.categoryField`,o),children:(0,W.jsx)(G,{value:j.categoryField??``,onCommit:e=>N({categoryField:e||void 0}),options:D,placeholder:j.object?`Select a field…`:`e.g. status`,searchPlaceholder:`Search fields…`,disabled:a,mono:!0})}),(0,W.jsx)($,{id:`widget-aggregate`,label:H(`engine.inspector.widget.aggregate`,o),children:(0,W.jsxs)(p,{value:j.aggregate??`count`,onValueChange:e=>N({aggregate:e}),disabled:a,children:[(0,W.jsx)(w,{id:`widget-aggregate`,children:(0,W.jsx)(S,{})}),(0,W.jsx)(I,{children:ze.map(e=>(0,W.jsx)(d,{value:e,children:e},e))})]})}),(0,W.jsx)($,{id:`widget-color`,label:H(`engine.inspector.widget.color`,o),children:(0,W.jsx)(de,{value:j.colorVariant??`default`,onChange:e=>N({colorVariant:e}),disabled:a,options:Be.map(e=>({value:e}))})}),(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,W.jsx)($,{id:`widget-w`,label:H(`engine.inspector.widget.width`,o),children:(0,W.jsx)(k,{id:`widget-w`,type:`number`,min:1,value:j.layout?.w??1,onChange:e=>N({layout:{...j.layout??{},w:Number(e.target.value)||1}}),disabled:a})}),(0,W.jsx)($,{id:`widget-h`,label:H(`engine.inspector.widget.height`,o),children:(0,W.jsx)(k,{id:`widget-h`,type:`number`,min:1,value:j.layout?.h??1,onChange:e=>N({layout:{...j.layout??{},h:Number(e.target.value)||1}}),disabled:a})})]}),!a&&(0,W.jsx)(`div`,{className:`pt-2 border-t`,children:(0,W.jsx)(g,{type:`button`,variant:`outline`,size:`sm`,className:`w-full text-destructive hover:text-destructive`,onClick:()=>{let t=Array.isArray(e.widgets)?[...e.widgets]:[];t.splice(M,1),n({widgets:t}),r()},children:H(`engine.inspector.widget.remove`,o)})})]})}function $({id:e,label:t,children:n}){return(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,W.jsx)(j,{htmlFor:e,className:`text-xs font-medium text-muted-foreground`,children:t}),n]})}function Ue({message:e,onClose:t,locale:n}){return(0,W.jsxs)(`div`,{className:`space-y-3 rounded-md border border-dashed p-4 text-sm text-muted-foreground`,children:[(0,W.jsx)(`p`,{children:e}),(0,W.jsx)(g,{type:`button`,variant:`outline`,size:`sm`,onClick:t,children:H(`engine.inspector.widget.close`,n)})]})}export{Se as a,we as c,X as i,G as l,Le as n,Te as o,Ae as r,Ee as s,He as t};
@@ -1 +1 @@
1
- import{f as e,t,u as n}from"./vendor-react-slxo-5GC.js";import{Io as r,Zi as i,er as a,ir as o,jr as s,nr as c,rr as l,ti as u,tr as d}from"./ui-components-Pnfq_-xI.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)(l,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,f.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,f.jsx)(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)(d,{className:`pt-0`})]},e.title)})})]})}export{p as DeveloperHubPage};
1
+ import{f as e,t,u as n}from"./vendor-react-slxo-5GC.js";import{Io as r,Zi as i,er as a,ir as o,jr as s,nr as c,rr as l,ti as u,tr as d}from"./ui-components-DsYvPIox.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)(l,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,f.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,f.jsx)(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)(d,{className:`pt-0`})]},e.title)})})]})}export{p as DeveloperHubPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{$ as r,Lt as i}from"./framework-VeaoJc6L.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({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}},t={current_user:{},ctx:{user:{}},...e};return{...e,evaluator:new i(t)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{$ as r,Vt as i}from"./framework-B9PMswdm.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({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l})}),[t,n,c,l]),d=(0,a.useMemo)(()=>({current_user:t,user:t,ctx:{user:t},app:n,data:c,features:l}),[t,n,c,l]);return(0,o.jsx)(s.Provider,{value:u,children:(0,o.jsx)(r,{scope:d,children:e})})}function l(){let e=(0,a.useContext)(s);if(!e){let e={user:{},app:{},data:{},features:{}},t={current_user:{},ctx:{user:{}},...e};return{...e,evaluator:new i(t)}}return e}function u(e,t){if(e==null||e===!0||e===`true`)return!0;if(e===!1||e===`false`)return!1;if(typeof e==`string`&&e.includes("${"))try{return t.evaluateCondition(e)}catch{return!0}return!0}export{u as n,l as r,c as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{L as r}from"./framework-VeaoJc6L.js";import{Ba as i,Bt as a,Cs as o,Fs as s,Hi as c,Ht as l,Ms as u,Qi as d,Rt as f,Sr as p,Ut as m,Vt as h,Wt as g,Zt as _,_s as v,_t as y,cn as b,er as x,fn as S,ft as C,gt as w,ht as T,ir as E,jr as D,mt as O,nr as k,or as A,pt as j,rr as M,st as N,tr as P,vt as F}from"./ui-components-Pnfq_-xI.js";import"./src-DZBNpupP.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:u,cls:`text-emerald-600 border-emerald-300`},completed:{icon:u,cls:`text-emerald-600 border-emerald-300`},failed:{icon:o,cls:`text-red-600 border-red-300`},error:{icon:o,cls:`text-red-600 border-red-300`},running:{icon:i,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:v,cls:`text-amber-600 border-amber-300`},skipped:{icon:s,cls:`text-muted-foreground`}}[e]??{icon:s,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(A,{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),[o,s]=(0,I.useState)(null),[l,u]=(0,I.useState)(``),[d,m]=(0,I.useState)(0),h=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){s(`meta.getItems is not available on this client`),a(!1);return}a(!0),s(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!l&&r.length>0&&u(r[0].name)}catch(e){s(e?.message??String(e))}finally{a(!1)}},[e,l]);(0,I.useEffect)(()=>{h()},[h]);let g=(0,I.useMemo)(()=>t.find(e=>e.name===l)??null,[t,l]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(D,{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)(x,{children:[(0,L.jsx)(M,{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)(E,{className:`text-base`,children:`Flow`}),(0,L.jsx)(k,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(p,{variant:`outline`,size:`sm`,onClick:h,disabled:i,children:[(0,L.jsx)(c,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(P,{children:[i&&(0,L.jsx)(f,{className:`h-9 w-72`}),o&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:o}),!i&&!o&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!o&&t.length>0&&(0,L.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),g&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:g.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:g.name,refreshKey:d})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[a,s]=(0,I.useState)({}),[c,l]=(0,I.useState)(!1),[f,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(null);(0,I.useEffect)(()=>{s({}),m(null),g(null)},[t?.name]);let _=(e,t)=>s(n=>({...n,[e]:t}));return(0,L.jsxs)(x,{children:[(0,L.jsxs)(M,{className:`pb-3`,children:[(0,L.jsx)(E,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(k,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(P,{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)(S,{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)(A,{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)(F,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>_(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(N,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>_(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(b,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>_(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(p,{onClick:async()=>{if(!e?.automation?.execute){g(`automation.execute is not available on this client`);return}l(!0),g(null),m(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}m(await e.automation.execute(t.name,{params:i})),n?.()}catch(e){g(e?.message??String(e))}finally{l(!1)}},disabled:c,size:`sm`,children:[c?(0,L.jsx)(i,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(d,{className:`h-3.5 w-3.5 mr-2`}),c?`Running…`:`Run Flow`]})}),(f||h)&&(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:[h||f?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(o,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(u,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof f?.durationMs==`number`&&(0,L.jsxs)(A,{variant:`secondary`,className:`text-[10px] font-mono`,children:[f.durationMs,` ms`]})]}),h&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:h}),f&&(0,L.jsx)(V,{data:f})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,o]=(0,I.useState)([]),[s,u]=(0,I.useState)(!0),[d,v]=(0,I.useState)(null),[b,S]=(0,I.useState)(null),[D,N]=(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){v(`automation.listRuns is not available on this client`),u(!1);return}u(!0),v(null);try{let n=await e.automation.listRuns(t,{limit:20});o(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){v(e?.message??String(e))}finally{u(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{S(n),N(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);N(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(x,{children:[(0,L.jsx)(M,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(E,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(k,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(p,{variant:`outline`,size:`sm`,onClick:W,disabled:s,children:[s?(0,L.jsx)(i,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(c,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(P,{children:[s&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(f,{className:`h-8 w-full`}),(0,L.jsx)(f,{className:`h-8 w-full`}),(0,L.jsx)(f,{className:`h-8 w-full`})]}),!s&&d&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:d}),!s&&!d&&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.`}),!s&&!d&&r.length>0&&(0,L.jsxs)(C,{children:[(0,L.jsx)(w,{children:(0,L.jsxs)(y,{children:[(0,L.jsx)(T,{children:`Run`}),(0,L.jsx)(T,{children:`Status`}),(0,L.jsx)(T,{children:`Started`}),(0,L.jsx)(T,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(j,{children:r.map(e=>(0,L.jsxs)(y,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(O,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(O,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(O,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(O,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(a,{open:!!b,onOpenChange:e=>{e||(S(null),N(null))},children:(0,L.jsxs)(h,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(m,{className:`p-4 border-b`,children:[(0,L.jsxs)(g,{className:`font-mono text-sm break-all`,children:[`Run `,b]}),(0,L.jsx)(l,{children:D&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:D.status}),typeof D.durationMs==`number`&&(0,L.jsxs)(A,{variant:`secondary`,className:`text-[10px] font-mono`,children:[D.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(D.startedAt)})]})})]}),(0,L.jsxs)(_,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(f,{className:`h-16 w-full`}),(0,L.jsx)(f,{className:`h-16 w-full`}),(0,L.jsx)(f,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&D&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(D.steps)&&D.steps.length>0?D.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)(A,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(A,{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:D})]})})]})]})})]})}export{H as FlowRunsPage};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{L as r}from"./framework-B9PMswdm.js";import{Ba as i,Bt as a,Cs as o,Fs as s,Hi as c,Ht as l,Ms as u,Qi as d,Rt as f,Sr as p,Ut as m,Vt as h,Wt as g,Zt as _,_s as v,_t as y,cn as b,er as x,fn as S,ft as C,gt as w,ht as T,ir as E,jr as D,mt as O,nr as k,or as A,pt as j,rr as M,st as N,tr as P,vt as F}from"./ui-components-DsYvPIox.js";import"./src-CCztNT-4.js";var I=e(t(),1),L=n();function R({status:e}){let t={success:{icon:u,cls:`text-emerald-600 border-emerald-300`},completed:{icon:u,cls:`text-emerald-600 border-emerald-300`},failed:{icon:o,cls:`text-red-600 border-red-300`},error:{icon:o,cls:`text-red-600 border-red-300`},running:{icon:i,cls:`text-blue-600 border-blue-300 animate-pulse`},pending:{icon:v,cls:`text-amber-600 border-amber-300`},skipped:{icon:s,cls:`text-muted-foreground`}}[e]??{icon:s,cls:`text-muted-foreground`},n=t.icon;return(0,L.jsxs)(A,{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),[o,s]=(0,I.useState)(null),[l,u]=(0,I.useState)(``),[d,m]=(0,I.useState)(0),h=(0,I.useCallback)(async()=>{if(!e?.meta?.getItems){s(`meta.getItems is not available on this client`),a(!1);return}a(!0),s(null);try{let t=await e.meta.getItems(`flow`),r=(Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.spec?.name??e?.name,label:e?.spec?.label,spec:e?.spec??e,updatedAt:e?.updatedAt??e?.updated_at})).filter(e=>e.name);n(r),!l&&r.length>0&&u(r[0].name)}catch(e){s(e?.message??String(e))}finally{a(!1)}},[e,l]);(0,I.useEffect)(()=>{h()},[h]);let g=(0,I.useMemo)(()=>t.find(e=>e.name===l)??null,[t,l]);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight flex items-center gap-2`,children:[(0,L.jsx)(D,{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)(x,{children:[(0,L.jsx)(M,{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)(E,{className:`text-base`,children:`Flow`}),(0,L.jsx)(k,{children:`Select a flow definition to test`})]}),(0,L.jsxs)(p,{variant:`outline`,size:`sm`,onClick:h,disabled:i,children:[(0,L.jsx)(c,{className:`h-3.5 w-3.5 mr-2 ${i?`animate-spin`:``}`}),`Refresh`]})]})}),(0,L.jsxs)(P,{children:[i&&(0,L.jsx)(f,{className:`h-9 w-72`}),o&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:o}),!i&&!o&&t.length===0&&(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No flow definitions found.`}),!i&&!o&&t.length>0&&(0,L.jsx)(`select`,{value:l,onChange:e=>u(e.target.value),className:`flex h-9 w-full max-w-md rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm focus:outline-none focus:ring-1 focus:ring-ring`,children:t.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.label?`${e.label} (${e.name})`:e.name},e.name))})]})]}),g&&(0,L.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,L.jsx)(U,{client:e,flow:g.spec,onExecuted:()=>m(e=>e+1)}),(0,L.jsx)(W,{client:e,flowName:g.name,refreshKey:d})]})]})}function U({client:e,flow:t,onExecuted:n}){let r=(0,I.useMemo)(()=>(t?.variables??[]).filter(e=>e?.isInput),[t]),[a,s]=(0,I.useState)({}),[c,l]=(0,I.useState)(!1),[f,m]=(0,I.useState)(null),[h,g]=(0,I.useState)(null);(0,I.useEffect)(()=>{s({}),m(null),g(null)},[t?.name]);let _=(e,t)=>s(n=>({...n,[e]:t}));return(0,L.jsxs)(x,{children:[(0,L.jsxs)(M,{className:`pb-3`,children:[(0,L.jsx)(E,{className:`text-base`,children:`Test Run`}),(0,L.jsx)(k,{children:`Provide input values and invoke the flow`})]}),(0,L.jsxs)(P,{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)(S,{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)(A,{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)(F,{id:`var-${e.name}`,checked:a[e.name]===`true`,onCheckedChange:t=>_(e.name,t?`true`:`false`)}),(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a[e.name]===`true`?`true`:`false`})]}):e.type===`object`||e.type===`list`||e.type===`array`?(0,L.jsx)(N,{id:`var-${e.name}`,placeholder:`JSON ${e.type}`,value:a[e.name]??``,onChange:t=>_(e.name,t.target.value),className:`font-mono text-xs min-h-[80px]`}):(0,L.jsx)(b,{id:`var-${e.name}`,type:e.type===`number`?`number`:`text`,value:a[e.name]??``,onChange:t=>_(e.name,t.target.value)})]},e.name)),(0,L.jsx)(`div`,{className:`pt-1`,children:(0,L.jsxs)(p,{onClick:async()=>{if(!e?.automation?.execute){g(`automation.execute is not available on this client`);return}l(!0),g(null),m(null);try{let i={};for(let e of r){let t=a[e.name];t!==void 0&&(i[e.name]=B(t,e.type))}m(await e.automation.execute(t.name,{params:i})),n?.()}catch(e){g(e?.message??String(e))}finally{l(!1)}},disabled:c,size:`sm`,children:[c?(0,L.jsx)(i,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(d,{className:`h-3.5 w-3.5 mr-2`}),c?`Running…`:`Run Flow`]})}),(f||h)&&(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:[h||f?.success===!1?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(o,{className:`h-4 w-4 text-red-500`}),` Failed`]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(u,{className:`h-4 w-4 text-emerald-500`}),` Result`]}),typeof f?.durationMs==`number`&&(0,L.jsxs)(A,{variant:`secondary`,className:`text-[10px] font-mono`,children:[f.durationMs,` ms`]})]}),h&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:h}),f&&(0,L.jsx)(V,{data:f})]})]})]})}function W({client:e,flowName:t,refreshKey:n}){let[r,o]=(0,I.useState)([]),[s,u]=(0,I.useState)(!0),[d,v]=(0,I.useState)(null),[b,S]=(0,I.useState)(null),[D,N]=(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){v(`automation.listRuns is not available on this client`),u(!1);return}u(!0),v(null);try{let n=await e.automation.listRuns(t,{limit:20});o(Array.isArray(n)?n:n?.items??n?.runs??[])}catch(e){v(e?.message??String(e))}finally{u(!1)}},[e,t]);(0,I.useEffect)(()=>{W()},[W,n]);let G=async n=>{S(n),N(null),U(null),B(!0);try{let r=await e.automation.getRun(t,n);N(r?.run??r)}catch(e){U(e?.message??String(e))}finally{B(!1)}};return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(x,{children:[(0,L.jsx)(M,{className:`pb-3`,children:(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(E,{className:`text-base`,children:`Recent Runs`}),(0,L.jsx)(k,{className:`font-mono text-xs`,children:t})]}),(0,L.jsxs)(p,{variant:`outline`,size:`sm`,onClick:W,disabled:s,children:[s?(0,L.jsx)(i,{className:`h-3.5 w-3.5 mr-2 animate-spin`}):(0,L.jsx)(c,{className:`h-3.5 w-3.5 mr-2`}),`Refresh`]})]})}),(0,L.jsxs)(P,{children:[s&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(f,{className:`h-8 w-full`}),(0,L.jsx)(f,{className:`h-8 w-full`}),(0,L.jsx)(f,{className:`h-8 w-full`})]}),!s&&d&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:d}),!s&&!d&&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.`}),!s&&!d&&r.length>0&&(0,L.jsxs)(C,{children:[(0,L.jsx)(w,{children:(0,L.jsxs)(y,{children:[(0,L.jsx)(T,{children:`Run`}),(0,L.jsx)(T,{children:`Status`}),(0,L.jsx)(T,{children:`Started`}),(0,L.jsx)(T,{className:`text-right`,children:`Duration`})]})}),(0,L.jsx)(j,{children:r.map(e=>(0,L.jsxs)(y,{className:`cursor-pointer`,onClick:()=>G(e.id),children:[(0,L.jsxs)(O,{className:`font-mono text-xs`,children:[e.id.slice(0,12),`…`]}),(0,L.jsx)(O,{children:(0,L.jsx)(R,{status:e.status})}),(0,L.jsx)(O,{className:`text-xs text-muted-foreground`,children:z(e.startedAt)}),(0,L.jsx)(O,{className:`text-right font-mono text-xs`,children:typeof e.durationMs==`number`?`${e.durationMs} ms`:`—`})]},e.id))})]})]})]}),(0,L.jsx)(a,{open:!!b,onOpenChange:e=>{e||(S(null),N(null))},children:(0,L.jsxs)(h,{side:`right`,className:`w-full sm:max-w-2xl p-0 flex flex-col`,children:[(0,L.jsxs)(m,{className:`p-4 border-b`,children:[(0,L.jsxs)(g,{className:`font-mono text-sm break-all`,children:[`Run `,b]}),(0,L.jsx)(l,{children:D&&(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,L.jsx)(R,{status:D.status}),typeof D.durationMs==`number`&&(0,L.jsxs)(A,{variant:`secondary`,className:`text-[10px] font-mono`,children:[D.durationMs,` ms`]}),(0,L.jsx)(`span`,{className:`text-xs`,children:z(D.startedAt)})]})})]}),(0,L.jsxs)(_,{className:`flex-1 p-4`,children:[F&&(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(f,{className:`h-16 w-full`}),(0,L.jsx)(f,{className:`h-16 w-full`}),(0,L.jsx)(f,{className:`h-16 w-full`})]}),H&&(0,L.jsx)(`p`,{className:`text-sm text-red-500 font-mono break-all`,children:H}),!F&&D&&(0,L.jsx)(`div`,{className:`space-y-3`,children:Array.isArray(D.steps)&&D.steps.length>0?D.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)(A,{variant:`outline`,className:`text-[10px] font-mono`,children:e.nodeType}),(0,L.jsx)(R,{status:e.status}),typeof e.durationMs==`number`&&(0,L.jsxs)(A,{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:D})]})})]})]})})]})}export{H as FlowRunsPage};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{$o as a,Gn as o,Jn as s,Kn as c,Sr as l,Wn as u,Ws as d,Yn as f,Zi as p,cn as m,dr as h,er as g,fr as _,ir as v,lc as y,ls as b,no as x,nr as S,or as C,qn as w,rr as T,rs as E,ti as D,tr as O,ur as k,wi as A}from"./ui-components-Pnfq_-xI.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-DAXXjFlN.js";import{_ as t,f as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{$o as a,Gn as o,Jn as s,Kn as c,Sr as l,Wn as u,Ws as d,Yn as f,Zi as p,cn as m,dr as h,er as g,fr as _,ir as v,lc as y,ls as b,no as x,nr as S,or as C,qn as w,rr as T,rs as E,ti as D,tr as O,ur as k,wi as A}from"./ui-components-DsYvPIox.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
  ---
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,p as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{L as a,R as o,Y as s,l as c,q as l}from"./framework-VeaoJc6L.js";import{G as u,J as d,V as f,W as p,rs as m}from"./ui-components-Pnfq_-xI.js";import"./MetadataProvider-C6q8MMOb.js";import{t as h}from"./RecordDetailView-DHsj44KH.js";import{l as g}from"./plugins-views-BpBxqePX.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 T(e){let t=e?.highlightFields;if(Array.isArray(t)&&t.length>0)return t.filter(t=>e.fields?.[t]);let n=e?.fields;return n&&typeof n==`object`?Object.entries(n).filter(([e,t])=>t&&!t.hidden&&!w.has(e)).map(([e])=>e).slice(0,6):[]}function E(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!w.has(e)&&t(e,n))?.[0]}var D=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),O=new Set([`date`,`datetime`,`time`]),k=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function A(e){let t=E(e,(e,t)=>D.has(t.type))??E(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function j(e){return E(e,(e,t)=>O.has(t.type))??E(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function M(e){let t=j(e);return t?{startDateField:t}:void 0}function N(e){let t=E(e,(e,t)=>k.has(t.type));return t?{coverField:t}:void 0}var P=new Set([`location`,`geo`,`geolocation`,`geopoint`,`point`]);function F(e){let t=E(e,(e,t)=>O.has(t.type)&&/start|begin|kickoff/i.test(e))??E(e,(e,t)=>O.has(t.type));if(!t)return;let n=E(e,(e,n)=>O.has(n.type)&&e!==t&&/end|due|finish|deadline|close/i.test(e))??E(e,(e,n)=>O.has(n.type)&&e!==t);if(!n)return;let r=E(e,(e,t)=>(t.type===`number`||t.type===`percent`)&&/progress|percent|complete/i.test(e));return{startDateField:t,endDateField:n,...r?{progressField:r}:{}}}function I(e){let t=E(e,(e,t)=>P.has(t.type))??E(e,e=>/location|address|geo|coords?|place|venue/i.test(e));return t?{locationField:t}:void 0}function L({page:e,className:t,onConfigChange:r,reserveEditAffordance:v}){let{t:w}=c(),{objects:E}=o(),D=a(),O=i(),[k,j]=n(),[P]=_.useState(()=>y(new URLSearchParams(window.location.search))),L=_.useCallback(e=>{j(t=>b(t,e),{replace:!0})},[j]),R=e?.interfaceConfig||{},z=_.useMemo(()=>(E||[]).find(e=>e.name===R.source),[E,R.source]),B=_.useMemo(()=>C(z,R.sourceView),[z,R.sourceView]),V=R.recordAction===`page`||R.recordAction===`modal`||R.recordAction===`none`?R.recordAction:`drawer`,H=_.useCallback(e=>`/apps/${window.location.pathname.split(`/`)[2]||``}/${R.source}/record/${encodeURIComponent(String(e))}`,[R.source]),U=l({navigation:{mode:V===`none`?`none`:V},objectName:R.source,onNavigate:e=>O(H(e))}),W=k.get(`recordId`),G=_.useCallback((e,t)=>{if(V===`none`)return;let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(H(n),`_blank`);return}if((V===`drawer`||V===`modal`)&&n!=null){j(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t});return}U.handleClick(e,t)},[V,H,U,j]),ee=_.useCallback(()=>{j(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[j]);_.useEffect(()=>{W&&!U.isOpen?U.open({id:W}):!W&&U.isOpen&&U.close()},[W]);let K=z?.name,q=!!B&&!S(B),J=B?.name??(R.sourceView?`${R.source}.${R.sourceView}`:void 0),[Y,X]=_.useState(null);_.useEffect(()=>{let e=!1;if(X(null),!(!K||!R.source||!q||!J))return(async()=>{try{let t=D,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(R.source))?.[J]??null),!S(n)&&typeof t?.getView==`function`&&(n=await t.getView(R.source,J)),!e&&n&&typeof n==`object`&&X(n)}catch{}})(),()=>{e=!0}},[K,R.source,R.sourceView,q,J,D]);let Z=_.useMemo(()=>Y?{...B,...Y}:B,[B,Y]),te=JSON.stringify(Z??null),Q=_.useMemo(()=>{if(!z)return;let e=Z||{},t=R.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=R.userActions||{},a=e.kanban??(r.has(`kanban`)?A(z):void 0),o=e.calendar??(r.has(`calendar`)?M(z):void 0),s=e.timeline??(r.has(`timeline`)?M(z):void 0),c=e.gallery??(r.has(`gallery`)?N(z):void 0),l=e.gantt??(r.has(`gantt`)?F(z):void 0),u=e.options?.map??(r.has(`map`)?I(z):void 0),d=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(R.filterBy)?R.filterBy:[]],f=S(R)?R.columns:S(e)?e.columns:T(z),p=Array.isArray(R.sort)&&R.sort.length?R.sort:e.sort;return{type:`list-view`,objectName:z.name,viewType:n[0]??e.type??`grid`,fields:f,...d.length?{filters:d}:{},...p?.length?{sort:p}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:l,...u||e.options?{options:{...e.options??{},...u?{map:u}:{}}}:{},userFilters:R.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:R.showRecordCount,addRecord:R.addRecord,showSearch:i.search!==!1,showSort:i.sort!==!1,showFilters:i.filter===!0,showDensity:i.rowHeight===!0,showHideFields:!1,showGroup:!1,showColor:!1,allowExport:!1,inlineEdit:i.editInline===!0}},[K,te,R]);if(!z||!Q)return(0,x.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,x.jsxs)(p,{children:[(0,x.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,x.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,x.jsx)(d,{children:w(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,x.jsx)(u,{children:w(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:R.source||`?`})})]})});let $=Array.isArray(R.buttons)&&R.buttons.length?R.buttons.map(e=>(z.actions||[]).find(t=>t?.name===e)).filter(Boolean).map(e=>({...e,locations:[`list_toolbar`]})):[];return(0,x.jsxs)(`div`,{className: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:D,userFilterSelections:P,onUserFilterSelectionsChange:L,onSortChange:r?e=>r({sort:e}):void 0,onColumnStateChange:r?e=>{e?.order?.length&&r({columns:e.order})}:void 0,onRowClick:V===`none`?void 0:G})}),U.isOverlay&&(0,x.jsx)(f,{...U,setIsOpen:e=>{e||ee()},title:typeof e.label==`string`?e.label:R.source||`Record`,children:e=>(0,x.jsx)(h,{objectNameOverride:R.source,recordIdOverride:String(e?.id??e?._id??W??``),embedded:!0,dataSource:D,objects:E,onEdit:()=>{}})})]})}export{A as a,N as i,M as n,b as o,T as r,y as s,L as t};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,p as n,t as r,u as i}from"./vendor-react-slxo-5GC.js";import{L as a,R as o,Y as s,l as c,q as l}from"./framework-B9PMswdm.js";import{G as u,J as d,V as f,W as p,rs as m}from"./ui-components-DsYvPIox.js";import"./MetadataProvider-MNkZn-bR.js";import{t as h}from"./RecordDetailView-Ba0xool8.js";import{l as g}from"./plugins-views-CxFTNQJ7.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 T(e){let t=e?.highlightFields;if(Array.isArray(t)&&t.length>0)return t.filter(t=>e.fields?.[t]);let n=e?.fields;return n&&typeof n==`object`?Object.entries(n).filter(([e,t])=>t&&!t.hidden&&!w.has(e)).map(([e])=>e).slice(0,6):[]}function E(e,t){let n=e?.fields;if(!(!n||typeof n!=`object`))return Object.entries(n).find(([e,n])=>n&&!n.hidden&&!w.has(e)&&t(e,n))?.[0]}var D=new Set([`select`,`multiselect`,`radio`,`enum`,`boolean`]),O=new Set([`date`,`datetime`,`time`]),k=new Set([`image`,`file`,`attachment`,`avatar`,`photo`]);function A(e){let t=E(e,(e,t)=>D.has(t.type))??E(e,e=>/status|stage|state|priority|category|kind/i.test(e));return t?{groupField:t,groupByField:t}:void 0}function j(e){return E(e,(e,t)=>O.has(t.type))??E(e,e=>/date|due|start|end|deadline|schedule/i.test(e))}function M(e){let t=j(e);return t?{startDateField:t}:void 0}function N(e){let t=E(e,(e,t)=>k.has(t.type));return t?{coverField:t}:void 0}var P=new Set([`location`,`geo`,`geolocation`,`geopoint`,`point`]);function F(e){let t=E(e,(e,t)=>O.has(t.type)&&/start|begin|kickoff/i.test(e))??E(e,(e,t)=>O.has(t.type));if(!t)return;let n=E(e,(e,n)=>O.has(n.type)&&e!==t&&/end|due|finish|deadline|close/i.test(e))??E(e,(e,n)=>O.has(n.type)&&e!==t);if(!n)return;let r=E(e,(e,t)=>(t.type===`number`||t.type===`percent`)&&/progress|percent|complete/i.test(e));return{startDateField:t,endDateField:n,...r?{progressField:r}:{}}}function I(e){let t=E(e,(e,t)=>P.has(t.type))??E(e,e=>/location|address|geo|coords?|place|venue/i.test(e));return t?{locationField:t}:void 0}function L({page:e,className:t,onConfigChange:r,reserveEditAffordance:v}){let{t:w}=c(),{objects:E}=o(),D=a(),O=i(),[k,j]=n(),[P]=_.useState(()=>y(new URLSearchParams(window.location.search))),L=_.useCallback(e=>{j(t=>b(t,e),{replace:!0})},[j]),R=e?.interfaceConfig||{},z=_.useMemo(()=>(E||[]).find(e=>e.name===R.source),[E,R.source]),B=_.useMemo(()=>C(z,R.sourceView),[z,R.sourceView]),V=R.recordAction===`page`||R.recordAction===`modal`||R.recordAction===`none`?R.recordAction:`drawer`,H=_.useCallback(e=>`/apps/${window.location.pathname.split(`/`)[2]||``}/${R.source}/record/${encodeURIComponent(String(e))}`,[R.source]),U=l({navigation:{mode:V===`none`?`none`:V},objectName:R.source,onNavigate:e=>O(H(e))}),W=k.get(`recordId`),G=_.useCallback((e,t)=>{if(V===`none`)return;let n=e?.id??e?._id;if(t&&(t.metaKey||t.ctrlKey||t.button===1)&&n!=null){window.open(H(n),`_blank`);return}if((V===`drawer`||V===`modal`)&&n!=null){j(e=>{let t=new URLSearchParams(e);return t.set(`recordId`,String(n)),t});return}U.handleClick(e,t)},[V,H,U,j]),ee=_.useCallback(()=>{j(e=>{let t=new URLSearchParams(e);return t.delete(`recordId`),t})},[j]);_.useEffect(()=>{W&&!U.isOpen?U.open({id:W}):!W&&U.isOpen&&U.close()},[W]);let K=z?.name,q=!!B&&!S(B),J=B?.name??(R.sourceView?`${R.source}.${R.sourceView}`:void 0),[Y,X]=_.useState(null);_.useEffect(()=>{let e=!1;if(X(null),!(!K||!R.source||!q||!J))return(async()=>{try{let t=D,n=null;typeof t?.listViewOverrides==`function`&&(n=(await t.listViewOverrides(R.source))?.[J]??null),!S(n)&&typeof t?.getView==`function`&&(n=await t.getView(R.source,J)),!e&&n&&typeof n==`object`&&X(n)}catch{}})(),()=>{e=!0}},[K,R.source,R.sourceView,q,J,D]);let Z=_.useMemo(()=>Y?{...B,...Y}:B,[B,Y]),te=JSON.stringify(Z??null),Q=_.useMemo(()=>{if(!z)return;let e=Z||{},t=R.appearance??e.appearance,n=t?.allowedVisualizations||[],r=new Set(n),i=R.userActions||{},a=e.kanban??(r.has(`kanban`)?A(z):void 0),o=e.calendar??(r.has(`calendar`)?M(z):void 0),s=e.timeline??(r.has(`timeline`)?M(z):void 0),c=e.gallery??(r.has(`gallery`)?N(z):void 0),l=e.gantt??(r.has(`gantt`)?F(z):void 0),u=e.options?.map??(r.has(`map`)?I(z):void 0),d=[...Array.isArray(e.filter)?e.filter:[],...Array.isArray(R.filterBy)?R.filterBy:[]],f=S(R)?R.columns:S(e)?e.columns:T(z),p=Array.isArray(R.sort)&&R.sort.length?R.sort:e.sort;return{type:`list-view`,objectName:z.name,viewType:n[0]??e.type??`grid`,fields:f,...d.length?{filters:d}:{},...p?.length?{sort:p}:{},grouping:e.grouping,rowColor:e.rowColor,pagination:e.pagination,searchableFields:e.searchableFields,emptyState:e.emptyState,kanban:a,calendar:o,gallery:c,timeline:s,gantt:l,...u||e.options?{options:{...e.options??{},...u?{map:u}:{}}}:{},userFilters:R.userFilters??e.userFilters,appearance:t,showViewSwitcher:n.length>1,showRecordCount:R.showRecordCount,addRecord:R.addRecord,showSearch:i.search!==!1,showSort:i.sort!==!1,showFilters:i.filter===!0,showDensity:i.rowHeight===!0,showHideFields:!1,showGroup:!1,showColor:!1,allowExport:!1,inlineEdit:i.editInline===!0}},[K,te,R]);if(!z||!Q)return(0,x.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,x.jsxs)(p,{children:[(0,x.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,x.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,x.jsx)(d,{children:w(`empty.objectNotFound`,{defaultValue:`Source object not found`})}),(0,x.jsx)(u,{children:w(`empty.interfacePageSourceMissing`,{defaultValue:`This interface page references "{{name}}", which is not available.`,name:R.source||`?`})})]})});let $=Array.isArray(R.buttons)&&R.buttons.length?R.buttons.map(e=>(z.actions||[]).find(t=>t?.name===e)).filter(Boolean).map(e=>({...e,locations:[`list_toolbar`]})):[];return(0,x.jsxs)(`div`,{className: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:D,userFilterSelections:P,onUserFilterSelectionsChange:L,onSortChange:r?e=>r({sort:e}):void 0,onColumnStateChange:r?e=>{e?.order?.length&&r({columns:e.order})}:void 0,onRowClick:V===`none`?void 0:G})}),U.isOverlay&&(0,x.jsx)(f,{...U,setIsOpen:e=>{e||ee()},title:typeof e.label==`string`?e.label:R.source||`Record`,children:e=>(0,x.jsx)(h,{objectNameOverride:R.source,recordIdOverride:String(e?.id??e?._id??W??``),embedded:!0,dataSource:D,objects:E,onEdit:()=>{}})})]})}export{A as a,N as i,M as n,b as o,T as r,y as s,L as t};
@@ -1 +1 @@
1
- import{t as e}from"./vendor-react-slxo-5GC.js";import{Ac as t,Di as n,Ec as r,Ft as i,It as a,Lt as o,Pt as s,or as c,wi as l,za as u}from"./ui-components-Pnfq_-xI.js";var d=e(),f={config:{icon:n,short:`Admin config`,title:`Administrator configuration`,body:()=>`These rows define how the platform behaves at runtime. Author them here; the runtime data they produce lives in a separate table.`,tone:`border-sky-300/60 bg-sky-50 text-sky-900 hover:bg-sky-100 dark:border-sky-500/40 dark:bg-sky-950/40 dark:text-sky-100`},system:{icon:u,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:r,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. Manage these records through your authentication provider's sign-in, invitation, and security flows instead.`,tone:`border-amber-300/60 bg-amber-50 text-amber-900 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`}};function p({managedBy:e,label:n,className:r}){if(!e||e===`platform`)return null;let l=f[e];if(!l)return null;let u=l.icon,p=n??`better-auth`;return(0,d.jsx)(a,{delayDuration:200,children:(0,d.jsxs)(s,{children:[(0,d.jsx)(o,{asChild:!0,children:(0,d.jsxs)(c,{variant:`outline`,"data-testid":`managed-by-badge`,"data-bucket":e,className:t(`gap-1 font-normal text-[11px] leading-none py-0.5 px-1.5 cursor-help`,l.tone,r),children:[(0,d.jsx)(u,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{children:l.short})]})}),(0,d.jsxs)(i,{side:`bottom`,align:`start`,className:`max-w-xs text-xs leading-relaxed`,children:[(0,d.jsx)(`p`,{className:`font-semibold mb-1`,children:l.title}),(0,d.jsx)(`p`,{className:`text-muted-foreground`,children:l.body(p)})]})]})})}export{p as t};
1
+ import{t as e}from"./vendor-react-slxo-5GC.js";import{Ac as t,Di as n,Ec as r,Ft as i,It as a,Lt as o,Pt as s,or as c,wi as l,za as u}from"./ui-components-DsYvPIox.js";var d=e(),f={config:{icon:n,short:`Admin config`,title:`Administrator configuration`,body:()=>`These rows define how the platform behaves at runtime. Author them here; the runtime data they produce lives in a separate table.`,tone:`border-sky-300/60 bg-sky-50 text-sky-900 hover:bg-sky-100 dark:border-sky-500/40 dark:bg-sky-950/40 dark:text-sky-100`},system:{icon:u,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:r,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. Manage these records through your authentication provider's sign-in, invitation, and security flows instead.`,tone:`border-amber-300/60 bg-amber-50 text-amber-900 hover:bg-amber-100 dark:border-amber-500/40 dark:bg-amber-950/40 dark:text-amber-100`}};function p({managedBy:e,label:n,className:r}){if(!e||e===`platform`)return null;let l=f[e];if(!l)return null;let u=l.icon,p=n??`better-auth`;return(0,d.jsx)(a,{delayDuration:200,children:(0,d.jsxs)(s,{children:[(0,d.jsx)(o,{asChild:!0,children:(0,d.jsxs)(c,{variant:`outline`,"data-testid":`managed-by-badge`,"data-bucket":e,className:t(`gap-1 font-normal text-[11px] leading-none py-0.5 px-1.5 cursor-help`,l.tone,r),children:[(0,d.jsx)(u,{className:`h-3 w-3`,"aria-hidden":`true`}),(0,d.jsx)(`span`,{children:l.short})]})}),(0,d.jsxs)(i,{side:`bottom`,align:`start`,className:`max-w-xs text-xs leading-relaxed`,children:[(0,d.jsx)(`p`,{className:`font-semibold mb-1`,children:l.title}),(0,d.jsx)(`p`,{className:`text-muted-foreground`,children:l.body(p)})]})]})})}export{p as t};
@@ -1 +1 @@
1
- import{f as e,t,u as n}from"./vendor-react-slxo-5GC.js";import{l as r}from"./framework-VeaoJc6L.js";import{Sr as i,er as a,tr as o,za as s}from"./ui-components-Pnfq_-xI.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)(a,{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)(s,{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)(i,{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-slxo-5GC.js";import{l as r}from"./framework-B9PMswdm.js";import{Sr as i,er as a,tr as o,za as s}from"./ui-components-DsYvPIox.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)(a,{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)(s,{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)(i,{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-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as o}from"./infrastructure-BnbfcrX8.js";import{Ht as s,l as c}from"./framework-VeaoJc6L.js";import{Fs as l,Jr as u,Rt as d,Sr as f,Ui as p,Yo as m,er as h,ir as g,or as _,rr as v,si as y,tr as b,wc as x}from"./ui-components-Pnfq_-xI.js";import{_ as S,l as C,u as w}from"./marketplaceApi-BLyDDfGk.js";import{t as T}from"./MarketplaceAccessDenied-CEfnLa3I.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}`:``,[x,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)(f,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:j,children:[(0,D.jsx)(p,{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)(l,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{children:F.message})]})}),j&&x.length===0?(0,D.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(d,{className:`h-20 w-full`},t))}):x.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)(f,{variant:`link`,className:`mt-2`,onClick:()=>e(`${y}/system/marketplace`),children:i(`marketplace.browseLink`)})]}):(0,D.jsx)(`div`,{className:`grid gap-3`,children:x.map(t=>(0,D.jsxs)(h,{children:[(0,D.jsxs)(v,{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)(g,{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)(f,{variant:`ghost`,size:`sm`,onClick:()=>e(`${y}/system/marketplace/${t.packageId}`),children:[(0,D.jsx)(m,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.action.details`)]}),k===`local`&&(0,D.jsxs)(f,{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)(b,{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)(f,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>e(`${i}/system/marketplace`),children:[(0,D.jsx)(x,{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)(y,{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-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as o}from"./infrastructure-BnbfcrX8.js";import{Kt as s,l as c}from"./framework-B9PMswdm.js";import{Fs as l,Jr as u,Rt as d,Sr as f,Ui as p,Yo as m,er as h,ir as g,or as _,rr as v,si as y,tr as b,wc as x}from"./ui-components-DsYvPIox.js";import{_ as S,l as C,u as w}from"./marketplaceApi-BLyDDfGk.js";import{t as T}from"./MarketplaceAccessDenied-Cur1UQ0U.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}`:``,[x,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)(f,{variant:`outline`,size:`sm`,onClick:()=>void L(),disabled:j,children:[(0,D.jsx)(p,{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)(l,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}),(0,D.jsx)(`div`,{children:F.message})]})}),j&&x.length===0?(0,D.jsx)(`div`,{className:`grid gap-3`,children:Array.from({length:3}).map((e,t)=>(0,D.jsx)(d,{className:`h-20 w-full`},t))}):x.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)(f,{variant:`link`,className:`mt-2`,onClick:()=>e(`${y}/system/marketplace`),children:i(`marketplace.browseLink`)})]}):(0,D.jsx)(`div`,{className:`grid gap-3`,children:x.map(t=>(0,D.jsxs)(h,{children:[(0,D.jsxs)(v,{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)(g,{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)(f,{variant:`ghost`,size:`sm`,onClick:()=>e(`${y}/system/marketplace/${t.packageId}`),children:[(0,D.jsx)(m,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.action.details`)]}),k===`local`&&(0,D.jsxs)(f,{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)(b,{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)(f,{variant:`ghost`,size:`sm`,className:`self-start`,onClick:()=>e(`${i}/system/marketplace`),children:[(0,D.jsx)(x,{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)(y,{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-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as ee}from"./infrastructure-BnbfcrX8.js";import{R as te,l as ne}from"./framework-VeaoJc6L.js";import{$n as o,$o as re,Ba as s,Ci as c,Fs as l,Gn as ie,Jn as ae,Jr as u,Jt as oe,Kn as se,Kt as ce,Ms as d,Nr as f,Oo as le,Ps as ue,Rt as p,Sn as de,Sr as m,Wn as fe,Xo as pe,Xt as me,Yn as he,Yo as ge,Yt as _e,_a as ve,er as ye,fn as h,fs as g,gn as _,ir as be,mn as xe,or as v,pn as Se,qn as Ce,qt as we,rr as Te,rs as Ee,sc as y,tr as De,wc as Oe,wi as ke,ya as Ae}from"./ui-components-Pnfq_-xI.js";import"./MetadataProvider-C6q8MMOb.js";import{n as je}from"./assistantBus-DosfPCbN.js";import{_ as Me,a as Ne,c as Pe,g as Fe,h as Ie,i as Le,m as Re,o as ze,p as Be,r as b,s as Ve,t as He,u as Ue,x}from"./marketplaceApi-BLyDDfGk.js";import{n as We,t as Ge}from"./usePackageL10n-CasuagU5.js";import{t as Ke}from"./MarketplaceAccessDenied-CEfnLa3I.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-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as ee}from"./infrastructure-BnbfcrX8.js";import{R as te,l as ne}from"./framework-B9PMswdm.js";import{$n as o,$o as re,Ba as s,Ci as c,Fs as l,Gn as ie,Jn as ae,Jr as u,Jt as oe,Kn as se,Kt as ce,Ms as d,Nr as f,Oo as le,Ps as ue,Rt as p,Sn as de,Sr as m,Wn as fe,Xo as pe,Xt as me,Yn as he,Yo as ge,Yt as _e,_a as ve,er as ye,fn as h,fs as g,gn as _,ir as be,mn as xe,or as v,pn as Se,qn as Ce,qt as we,rr as Te,rs as Ee,sc as y,tr as De,wc as Oe,wi as ke,ya as Ae}from"./ui-components-DsYvPIox.js";import"./MetadataProvider-MNkZn-bR.js";import{n as je}from"./assistantBus-DosfPCbN.js";import{_ as Me,a as Ne,c as Pe,g as Fe,h as Ie,i as Le,m as Re,o as ze,p as Be,r as b,s as Ve,t as He,u as Ue,x}from"./marketplaceApi-BLyDDfGk.js";import{n as We,t as Ge}from"./usePackageL10n-CasuagU5.js";import{t as Ke}from"./MarketplaceAccessDenied-Cur1UQ0U.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
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)(g,{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)(v,{variant:`outline`,children:t(`marketplace.disclosure.runtime.${e.runtime}`,{defaultValue:T[e.runtime]??e.runtime})}),e.platform_verified?(0,C.jsxs)(v,{variant:`outline`,className:`gap-1 border-green-500/40 text-green-700 dark:text-green-400`,children:[(0,C.jsx)(c,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.reviewed`,{defaultValue:`Reviewed & approved`})]}):(0,C.jsxs)(v,{variant:`outline`,className:`gap-1 border-amber-500/40 text-amber-700 dark:text-amber-400`,children:[(0,C.jsx)(ke,{className:`h-3 w-3`,"aria-hidden":`true`}),t(`marketplace.disclosure.unreviewed`,{defaultValue:`Not yet reviewed`})]}),e.signed&&(0,C.jsxs)(v,{variant:`outline`,className:`gap-1`,children:[(0,C.jsx)(d,{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:y,label:t(`marketplace.disclosure.services`,{defaultValue:`Platform services`}),items:n.services??void 0}),(0,C.jsx)(E,{icon:f,label:t(`marketplace.disclosure.hooks`,{defaultValue:`Lifecycle hooks`}),items:n.hooks??void 0}),(0,C.jsx)(E,{icon:Ae,label:t(`marketplace.disclosure.network`,{defaultValue:`Network access`}),items:n.network??void 0}),(0,C.jsx)(E,{icon:le,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:c,language:f}=ne(),le=n?`/apps/${n}`:``,{refresh:g}=te(),[y,ke]=(0,S.useState)(null),[Ae,qe]=(0,S.useState)(!0),[w,T]=(0,S.useState)(null),[E,D]=(0,S.useState)(!1),[O,Xe]=(0,S.useState)([]),[Ze,k]=(0,S.useState)(!1),[A,j]=(0,S.useState)(null),[M,N]=(0,S.useState)(``),[Qe,$e]=(0,S.useState)({}),[P,et]=(0,S.useState)(!1),[tt,nt]=(0,S.useState)(!1),[F,rt]=(0,S.useState)(!1),[I,L]=(0,S.useState)(null),[R,it]=(0,S.useState)(null),[z,B]=(0,S.useState)(null),[V,H]=(0,S.useState)(null),[U,W]=(0,S.useState)(null),[at,G]=(0,S.useState)([]),[K,q]=(0,S.useState)(!1),[J,Y]=(0,S.useState)(null);(0,S.useEffect)(()=>{if(!x().features.installLocal)return;let e=!1;return(async()=>{let t=await Ue();e||G(t)})(),()=>{e=!0}},[t,J]),(0,S.useEffect)(()=>{if(!t)return;let e=x().defaultEnvironmentId??``,n=!1;return(async()=>{let r=await b(t,e);n||!r||(B(r),it(r.version))})(),()=>{n=!0}},[t]),(0,S.useEffect)(()=>{let e=!1;return(async()=>{if(t){qe(!0),T(null);try{let n=await Le(t);e||ke(n)}catch(t){e||T(t?.message??String(t))}finally{e||qe(!1)}}})(),()=>{e=!0}},[t]);let ot=async()=>{D(!0),L(null),j(null);let e=x().defaultEnvironmentId;if(e){k(!1),N(e),Xe([]);return}k(!0);try{let[e,n]=await Promise.all([Ve(),Pe()]),r=e.filter(e=>{let t=e.organization_id;return t?n.has(String(t)):!1});Xe(r),$e({});let i=t;i&&Promise.all(r.map(async e=>{try{let t=await b(i,e.id);return t?[e.id,t.version]:null}catch{return null}})).then(e=>{let t={};for(let n of e)n&&(t[n[0]]=n[1]);$e(t)}),e.length>0&&r.length===0?j(c(`marketplace.install.noPermission`)):r.length===1&&N(r[0].id)}catch(e){let t=e?.status;j(t===401||t===403?c(`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??y?.package?.latest_version?.version??y?.versions?.[0]?.version??``)||`installed`);try{let e=x().defaultEnvironmentId||M;if(e){let n=await b(t,e);n&&B(n)}}catch{}let e=x().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 g()}catch{}L({ok:!0,message:c(`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 g(`app`)}catch{}Y({ok:!0,message:c(`marketplace.install.localSuccess`,{version:e.version,name:y?.package?Ge(y.package,f).displayName:e.manifestId})}),je()}catch(e){let t=e?.code,n=e?.message??String(e);t===`manifest_conflict`?n=c(`marketplace.install.localManifestConflict`,{message:n}):t===`unauthorized`?n=c(`marketplace.install.localUnauthorized`):t===`marketplace_unavailable`&&(n=c(`marketplace.install.localMarketplaceUnavailable`)),Y({ok:!1,message:n})}finally{q(!1)}}},lt=async()=>{if($&&confirm(c(`marketplace.uninstall.confirm`,{manifestId:$.manifestId,version:$.version}))){q(!0),Y(null);try{await Me($.manifestId);try{await g(`app`)}catch{}Y({ok:!0,message:c(`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:c(`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(c(`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?c(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:c(`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=c(`marketplace.detail.reseedLocalSuccess`,{inserted:t,updated:n})||`Sample data re-seeded (inserted=${t}, updated=${n}).`;W(r>0?{ok:!1,text:`${i} ${c(`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(c(`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?c(`marketplace.detail.purgeSuccess`,{count:t})||`Removed ${t} sample record(s).`:c(`marketplace.detail.purgeNoData`)||`No sample records found to purge.`})}catch(e){W({ok:!1,text:e?.message||`Purge failed`})}finally{H(null)}}};if(Ae)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)(p,{className:`h-8 w-32`}),(0,C.jsx)(p,{className:`h-16 w-full`}),(0,C.jsx)(p,{className:`h-64 w-full`})]});if(w||!y)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)(m,{variant:`ghost`,size:`sm`,onClick:()=>e(`${le}/system/marketplace`),children:[(0,C.jsx)(Oe,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),c(`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)(l,{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:c(`marketplace.load.packageFailed`)}),(0,C.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:w??c(`marketplace.load.notFound`)})]})]})]});let X=y.package,Z=Ge(X,f),Q=X.latest_version?.version??y.versions[0]?.version??null,$=at.find(e=>e.manifestId===X.manifest_id)??null,mt=!!X.latest_version?.contains_code,ht=!!R&&R!==`installed`&&!!Q&&R!==Q,gt=x().features.installLocal,_t=!Q||K||F||!gt&&!!R&&!ht,vt=gt?{label:c(K?`marketplace.action.working`:$?`marketplace.action.reinstall`:`marketplace.action.install`),onClick:ct}:{label:F?c(`marketplace.action.installing`):R?ht?c(`marketplace.action.updateTo`,{defaultValue:`Update`,version:Q}):c(`marketplace.action.installed`,{defaultValue:`Installed`}):c(`marketplace.action.installToCloud`),onClick:ot},yt=X.category?c(`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)(m,{variant:`ghost`,size:`sm`,className:`self-start -ml-2 text-muted-foreground hover:text-foreground`,onClick:()=>e(`${le}/system/marketplace`),children:[(0,C.jsx)(Oe,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),c(`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:c(`marketplace.detail.homepage`),children:[(0,C.jsx)(ge,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),(0,C.jsx)(`span`,{className:`hidden sm:inline`,children:c(`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)(v,{variant:`outline`,children:c(`marketplace.versionBadge`,{version:Q})}),X.publisher&&X.publisher!==`private`&&(0,C.jsx)(v,{variant:X.publisher===`objectstack`?`default`:`secondary`,children:X.publisher}),yt&&(0,C.jsx)(v,{variant:`outline`,children:yt}),X.license&&(0,C.jsx)(v,{variant:`outline`,className:`font-normal`,children:X.license}),$&&(0,C.jsxs)(v,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(d,{className:`h-3 w-3`,"aria-hidden":`true`}),c(`marketplace.detail.installedV`,{version:$.version})]}),!$&&R&&(0,C.jsxs)(v,{variant:`default`,className:`bg-green-600 hover:bg-green-600 gap-1`,children:[(0,C.jsx)(d,{className:`h-3 w-3`,"aria-hidden":`true`}),c(`marketplace.detail.installedV`,{version:R})]}),ht&&(0,C.jsxs)(v,{variant:`default`,className:`bg-amber-500 hover:bg-amber-500 gap-1`,children:[(0,C.jsx)(ue,{className:`h-3 w-3`,"aria-hidden":`true`}),c(`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)(m,{onClick:vt.onClick,disabled:_t,size:`lg`,className:`min-w-[8rem]`,children:[(0,C.jsx)(re,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),vt.label]}),$&&(0,C.jsxs)(Se,{children:[(0,C.jsx)(de,{asChild:!0,children:(0,C.jsx)(m,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":c(`marketplace.detail.moreOptions`),children:(0,C.jsx)(pe,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(xe,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(_,{onSelect:ft,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(s,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(Ee,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),$.withSampleData?c(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:c(`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)(s,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(u,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),c(`marketplace.detail.purgeSampleData`)||`Purge sample data`]}),(0,C.jsxs)(_,{onSelect:lt,disabled:K,className:`text-destructive focus:text-destructive`,children:[(0,C.jsx)(u,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),c(`marketplace.detail.uninstallFromRuntime`)]})]})]}),!$&&z&&!x().cloudUrl&&(0,C.jsxs)(Se,{children:[(0,C.jsx)(de,{asChild:!0,children:(0,C.jsx)(m,{variant:`outline`,size:`lg`,className:`px-2.5`,"aria-label":c(`marketplace.detail.moreOptions`)||`More options`,children:(0,C.jsx)(pe,{className:`h-4 w-4`,"aria-hidden":`true`})})}),(0,C.jsxs)(xe,{align:`end`,className:`w-56`,children:[(0,C.jsxs)(_,{onSelect:ut,disabled:V!==null,children:[V===`reseed`?(0,C.jsx)(s,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(Ee,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),z.withSampleData?c(`marketplace.detail.reseedAgain`)||`Re-seed sample data`:c(`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)(s,{className:`h-4 w-4 mr-2 animate-spin`,"aria-hidden":`true`}):(0,C.jsx)(u,{className:`h-4 w-4 mr-2`,"aria-hidden":`true`}),c(`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)(d,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(l,{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:c(`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)(d,{className:`h-4 w-4 mt-0.5 shrink-0`,"aria-hidden":`true`}):(0,C.jsx)(l,{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:c(`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)(ye,{children:[(0,C.jsx)(Te,{children:(0,C.jsx)(be,{className:`text-base`,children:c(`marketplace.detail.about`)})}),(0,C.jsx)(De,{children:Z.readme?(0,C.jsx)(Je,{source:Z.readme}):(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c(`marketplace.detail.noReadme`)})})]})}),(0,C.jsx)(`div`,{className:`space-y-4`,children:(0,C.jsxs)(ye,{children:[(0,C.jsx)(Te,{children:(0,C.jsx)(be,{className:`text-base`,children:c(`marketplace.detail.versions`)})}),(0,C.jsx)(De,{children:y.versions.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c(`marketplace.detail.noApprovedVersions`)}):(0,C.jsx)(`ul`,{className:`space-y-3`,children:y.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)(ve,{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)(v,{variant:`outline`,className:`text-xs`,children:c(`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)(fe,{open:E,onOpenChange:e=>{D(e),e||(L(null),nt(!1))},children:(0,C.jsxs)(ie,{children:[(0,C.jsxs)(ae,{children:[(0,C.jsx)(he,{children:c(`marketplace.install.dialogTitle`,{name:Z.displayName||X.manifest_id})}),(0,C.jsx)(se,{children:x().defaultEnvironmentId?c(`marketplace.install.dialogDescCurrent`,{host:typeof window<`u`?window.location.host:``}):c(`marketplace.install.dialogDescPicker`)})]}),Ze?(0,C.jsx)(p,{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)(l,{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)(m,{variant:`outline`,size:`sm`,className:`w-full`,children:[(0,C.jsx)(ge,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),c(`marketplace.action.openOnCloud`)]})})]}):x().defaultEnvironmentId?(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(o,{id:`seed`,checked:P,onCheckedChange:e=>et(e===!0)}),(0,C.jsx)(h,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:c(`marketplace.install.includeSampleData`)})]}):O.length===0?(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:c(`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)(h,{htmlFor:`env-select`,children:c(`marketplace.install.environment`)}),(0,C.jsxs)(ce,{value:M,onValueChange:N,children:[(0,C.jsx)(_e,{id:`env-select`,children:(0,C.jsx)(me,{placeholder:c(`marketplace.install.environmentPlaceholder`)})}),(0,C.jsx)(we,{children:O.map(e=>{let t=Qe[e.id],n=!!t&&!!Q&&t!==`installed`&&t!==Q;return(0,C.jsxs)(oe,{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:[` · `,c(`marketplace.install.updateTo`,{defaultValue:`Update → v{{version}}`,version:Q})]}):(0,C.jsxs)(`span`,{className:`text-muted-foreground`,children:[` · `,c(`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)(o,{id:`seed`,checked:P,onCheckedChange:e=>et(e===!0)}),(0,C.jsx)(h,{htmlFor:`seed`,className:`text-sm font-normal cursor-pointer`,children:c(`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)(o,{id:`ack-perms`,checked:tt,onCheckedChange:e=>nt(e===!0)}),(0,C.jsx)(h,{htmlFor:`ack-perms`,className:`text-sm font-normal cursor-pointer leading-snug`,children:c(`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)(Ce,{children:[(0,C.jsx)(m,{variant:`outline`,onClick:()=>D(!1),children:c(`marketplace.action.close`)}),!A&&(0,C.jsx)(m,{onClick:st,disabled:!M||F||I?.ok===!0||mt&&!tt,children:c(F?`marketplace.action.installing`:`marketplace.action.install`)})]})]})})]}):(0,C.jsx)(Ke,{})}export{D as t};
@@ -1 +1 @@
1
- import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as o}from"./infrastructure-BnbfcrX8.js";import{l as s}from"./framework-VeaoJc6L.js";import{Ei as c,Fs as ee,Ms as l,Rt as u,Sr as d,Ui as f,_a as p,cn as te,er as m,ir as h,ki as g,nr as _,or as v,rr as y,si as b,tr as x}from"./ui-components-Pnfq_-xI.js";import{n as ne}from"./assistantBus-DosfPCbN.js";import{a as S,d as re,f as C,l as ie,o as ae,u as oe,x as se}from"./marketplaceApi-BLyDDfGk.js";import{n as w,t as T}from"./usePackageL10n-CasuagU5.js";import{t as E}from"./MarketplaceAccessDenied-CEfnLa3I.js";var D=t({MarketplacePage:()=>A}),O=e(n(),1),k=i();function ce(){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:D}=s(),A=ce(),j=t?`/apps/${t}`:``,[M,N]=(0,O.useState)([]),[P,F]=(0,O.useState)(!0),[I,L]=(0,O.useState)(null),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(``),[H,U]=(0,O.useState)([]),[W,le]=(0,O.useState)([]),[G,K]=(0,O.useState)(null),[q,J]=(0,O.useState)(null),[Y,ue]=(0,O.useState)(new Set),de=(0,O.useMemo)(()=>{let e=new Map;for(let t of H)e.set(t.manifestId,t);return e},[H]),X=async()=>{F(!0),L(null);try{let[e,t,n,r]=await Promise.all([re({limit:100}),oe(),C(),ie()]);N(e.items??[]),U(t),le(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);ue(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,O.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{se().features.installLocal?await S({packageId:e.manifest_id||e.id,versionId:`latest`}):await ae({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(),ne()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,O.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,O.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,D);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,D]);return n?(0,k.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(b,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,k.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.title`)})]}),(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:i(`marketplace.subtitle`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,k.jsx)(c,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?i(`marketplace.installedCount`,{count:H.length}):i(`marketplace.installed`)]}),(0,k.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,k.jsx)(f,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(g,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,k.jsx)(te,{value:R,onChange:e=>z(e.target.value),placeholder:i(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":i(`marketplace.searchAria`)})]}),Z.length>0&&(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,k.jsx)(d,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:i(`marketplace.all`)}),Z.map(e=>(0,k.jsx)(d,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,k.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,k.jsx)(ee,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`font-medium text-destructive`,children:i(`marketplace.load.failed`)}),(0,k.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,k.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:i(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,k.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(b,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,k.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,k.jsx)(v,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,k.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,k.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,k.jsxs)(m,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,k.jsxs)(y,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,k.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(h,{className:`text-base truncate`,children:e.display_name}),(0,k.jsx)(_,{className:`text-xs truncate`,children:(0,k.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,k.jsx)(v,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,k.jsxs)(x,{className:`flex-1 flex flex-col gap-2`,children:[(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||i(`marketplace.noDescription`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,k.jsxs)(v,{variant:`outline`,className:`text-xs`,children:[(0,k.jsx)(p,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,k.jsx)(`div`,{className:`ml-auto`,children:t?(0,k.jsxs)(v,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,k.jsx)(l,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,k.jsx)(d,{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,k.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,k.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,k.jsxs)(m,{children:[(0,k.jsxs)(y,{className:`pb-2`,children:[(0,k.jsx)(u,{className:`h-10 w-10 rounded-lg mb-2`}),(0,k.jsx)(u,{className:`h-5 w-3/4`}),(0,k.jsx)(u,{className:`h-4 w-1/2 mt-1`})]}),(0,k.jsx)(x,{children:(0,k.jsx)(u,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,k.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?i(`marketplace.noApprovedYet`):i(`marketplace.noMatchFilters`)}):(0,k.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,D);return(0,k.jsxs)(m,{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,k.jsxs)(y,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,k.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(h,{className:`text-base truncate`,children:r.displayName}),(0,k.jsx)(_,{className:`text-xs truncate`,children:(0,k.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,k.jsx)(v,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,k.jsxs)(x,{className:`flex-1 flex flex-col gap-2`,children:[(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||i(`marketplace.noDescription`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,k.jsxs)(v,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,k.jsx)(l,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,k.jsxs)(v,{variant:`outline`,className:`text-xs`,children:[(0,k.jsx)(p,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,k.jsx)(v,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,k.jsx)(E,{})}export{D as t};
1
+ import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,f as r,t as i,u as a}from"./vendor-react-slxo-5GC.js";import{d as o}from"./infrastructure-BnbfcrX8.js";import{l as s}from"./framework-B9PMswdm.js";import{Ei as c,Fs as ee,Ms as l,Rt as u,Sr as d,Ui as f,_a as p,cn as te,er as m,ir as h,ki as g,nr as _,or as v,rr as y,si as b,tr as x}from"./ui-components-DsYvPIox.js";import{n as ne}from"./assistantBus-DosfPCbN.js";import{a as S,d as re,f as C,l as ie,o as ae,u as oe,x as se}from"./marketplaceApi-BLyDDfGk.js";import{n as w,t as T}from"./usePackageL10n-CasuagU5.js";import{t as E}from"./MarketplaceAccessDenied-Cur1UQ0U.js";var D=t({MarketplacePage:()=>A}),O=e(n(),1),k=i();function ce(){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:D}=s(),A=ce(),j=t?`/apps/${t}`:``,[M,N]=(0,O.useState)([]),[P,F]=(0,O.useState)(!0),[I,L]=(0,O.useState)(null),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(``),[H,U]=(0,O.useState)([]),[W,le]=(0,O.useState)([]),[G,K]=(0,O.useState)(null),[q,J]=(0,O.useState)(null),[Y,ue]=(0,O.useState)(new Set),de=(0,O.useMemo)(()=>{let e=new Map;for(let t of H)e.set(t.manifestId,t);return e},[H]),X=async()=>{F(!0),L(null);try{let[e,t,n,r]=await Promise.all([re({limit:100}),oe(),C(),ie()]);N(e.items??[]),U(t),le(n.items??[]);let i=new Set;for(let e of t)i.add(e.manifestId);for(let e of r.items)i.add(e.manifestId);ue(i)}catch(e){L(e?.message??String(e)),N([])}finally{F(!1)}};(0,O.useEffect)(()=>{X()},[]);let fe=async e=>{K(e.id),J(null);try{se().features.installLocal?await S({packageId:e.manifest_id||e.id,versionId:`latest`}):await ae({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(),ne()}catch(e){J({ok:!1,text:e?.message??String(e)})}finally{K(null)}},Z=(0,O.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,O.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,D);return`${n.displayName} ${t.manifest_id} ${n.description??``}`.toLowerCase().includes(e)})},[M,R,B,D]);return n?(0,k.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,k.jsxs)(`div`,{className:`flex items-start justify-between gap-4 flex-wrap`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(b,{className:`h-6 w-6 text-primary`,"aria-hidden":`true`}),(0,k.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:i(`marketplace.title`)})]}),(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:i(`marketplace.subtitle`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>e(`${j}/system/marketplace/installed`),children:[(0,k.jsx)(c,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),H.length>0?i(`marketplace.installedCount`,{count:H.length}):i(`marketplace.installed`)]}),(0,k.jsxs)(d,{variant:`outline`,size:`sm`,onClick:()=>void X(),disabled:P,children:[(0,k.jsx)(f,{className:`h-4 w-4 mr-1.5`,"aria-hidden":`true`}),i(`marketplace.refresh`)]})]})]}),(0,k.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3`,children:[(0,k.jsxs)(`div`,{className:`relative flex-1`,children:[(0,k.jsx)(g,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,k.jsx)(te,{value:R,onChange:e=>z(e.target.value),placeholder:i(`marketplace.searchPlaceholder`),className:`pl-9`,"aria-label":i(`marketplace.searchAria`)})]}),Z.length>0&&(0,k.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,k.jsx)(d,{size:`sm`,variant:B===``?`default`:`outline`,onClick:()=>V(``),children:i(`marketplace.all`)}),Z.map(e=>(0,k.jsx)(d,{size:`sm`,variant:B===e?`default`:`outline`,onClick:()=>V(e),children:Q(e)},e))]})]}),I&&(0,k.jsxs)(`div`,{className:`flex items-start gap-3 rounded-md border border-destructive/30 bg-destructive/5 p-4 text-sm`,children:[(0,k.jsx)(ee,{className:`h-4 w-4 mt-0.5 text-destructive`,"aria-hidden":`true`}),(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`div`,{className:`font-medium text-destructive`,children:i(`marketplace.load.failed`)}),(0,k.jsx)(`div`,{className:`text-muted-foreground mt-1`,children:I}),(0,k.jsx)(`div`,{className:`text-xs text-muted-foreground mt-2`,dangerouslySetInnerHTML:{__html:i(`marketplace.load.failedHint`)}})]})]}),W.length>0&&(0,k.jsxs)(`section`,{className:`flex flex-col gap-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,k.jsx)(b,{className:`h-5 w-5 text-primary`,"aria-hidden":`true`}),(0,k.jsx)(`h2`,{className:`text-sm font-semibold`,children:i(`marketplace.org.heading`,{defaultValue:`Your organization`})}),(0,k.jsx)(v,{variant:`secondary`,className:`text-xs`,children:W.length})]}),q&&(0,k.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,k.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,k.jsxs)(m,{className:`flex flex-col`,"data-testid":`org-card-${e.manifest_id}`,children:[(0,k.jsxs)(y,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,k.jsx)(w,{iconUrl:e.icon_url,displayName:e.display_name,manifestId:e.manifest_id}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(h,{className:`text-base truncate`,children:e.display_name}),(0,k.jsx)(_,{className:`text-xs truncate`,children:(0,k.jsx)(`code`,{className:`font-mono`,children:e.manifest_id})})]}),e.visibility&&(0,k.jsx)(v,{variant:`outline`,className:`shrink-0 text-xs`,children:e.visibility})]}),(0,k.jsxs)(x,{className:`flex-1 flex flex-col gap-2`,children:[(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:e.description||i(`marketplace.noDescription`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[e.latest_version&&(0,k.jsxs)(v,{variant:`outline`,className:`text-xs`,children:[(0,k.jsx)(p,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:e.latest_version})]}),(0,k.jsx)(`div`,{className:`ml-auto`,children:t?(0,k.jsxs)(v,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,k.jsx)(l,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.org.installedBadge`,{defaultValue:`Installed`})]}):(0,k.jsx)(d,{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,k.jsx)(`div`,{className:`border-b pt-2`})]}),P&&M.length===0?(0,k.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,k.jsxs)(m,{children:[(0,k.jsxs)(y,{className:`pb-2`,children:[(0,k.jsx)(u,{className:`h-10 w-10 rounded-lg mb-2`}),(0,k.jsx)(u,{className:`h-5 w-3/4`}),(0,k.jsx)(u,{className:`h-4 w-1/2 mt-1`})]}),(0,k.jsx)(x,{children:(0,k.jsx)(u,{className:`h-12 w-full`})})]},t))}):$.length===0?(0,k.jsx)(`div`,{className:`text-center py-12 text-sm text-muted-foreground`,children:M.length===0?i(`marketplace.noApprovedYet`):i(`marketplace.noMatchFilters`)}):(0,k.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,D);return(0,k.jsxs)(m,{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,k.jsxs)(y,{className:`flex flex-row items-start gap-3 pb-2`,children:[(0,k.jsx)(w,{iconUrl:t.icon_url,displayName:r.displayName,manifestId:t.manifest_id}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(h,{className:`text-base truncate`,children:r.displayName}),(0,k.jsx)(_,{className:`text-xs truncate`,children:(0,k.jsx)(`code`,{className:`font-mono`,children:t.manifest_id})})]}),t.publisher&&t.publisher!==`private`&&(0,k.jsx)(v,{variant:t.publisher===`objectstack`?`default`:`secondary`,className:`shrink-0`,children:t.publisher})]}),(0,k.jsxs)(x,{className:`flex-1 flex flex-col gap-2`,children:[(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground line-clamp-2`,children:r.description||i(`marketplace.noDescription`)}),(0,k.jsxs)(`div`,{className:`flex items-center gap-2 mt-auto pt-2 flex-wrap`,children:[n&&(0,k.jsxs)(v,{variant:`default`,className:`text-xs bg-green-600 hover:bg-green-600`,children:[(0,k.jsx)(l,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.installedBadge`,{version:n.version})]}),t.latest_version?.version&&(0,k.jsxs)(v,{variant:`outline`,className:`text-xs`,children:[(0,k.jsx)(p,{className:`h-3 w-3 mr-1`,"aria-hidden":`true`}),i(`marketplace.versionBadge`,{version:t.latest_version.version})]}),t.category&&(0,k.jsx)(v,{variant:`outline`,className:`text-xs`,children:Q(t.category)}),t.latest_version?.published_at&&(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:A(t.latest_version.published_at)})]})]})]},t.id)})})]}):(0,k.jsx)(E,{})}export{D as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{Dt as r,l as i}from"./framework-VeaoJc6L.js";import{Us as a,Vs as o,Ws as s,ls as c}from"./ui-components-Pnfq_-xI.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}=i(),[r,l]=(0,u.useState)([`0`]),[f,p]=(0,u.useState)(null),m=async(e,t)=>{try{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),p(t),setTimeout(()=>p(null),2e3)}catch(e){console.error(`Failed to copy:`,e)}},h=e=>{l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,d.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,d.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`layout.metadata.panelTitle`)}),(0,d.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:n(`layout.metadata.jsonBadge`)})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let i=String(t),l=r.includes(i),u=f===t;return(0,d.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,d.jsxs)(`button`,{onClick:()=>h(i),className:`flex-1 flex items-center justify-between text-left`,children:[(0,d.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),l?(0,d.jsx)(a,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,d.jsx)(o,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,d.jsx)(`button`,{onClick:()=>m(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:n(`layout.metadata.copyJson`),children:u?(0,d.jsx)(s,{className:`h-3 w-3 text-green-600`}):(0,d.jsx)(c,{className:`h-3 w-3 text-muted-foreground`})})]}),l&&(0,d.jsx)(`div`,{className:`px-4 pb-4`,children:(0,d.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,d.jsx)(`pre`,{className:`text-[11px] leading-relaxed p-3 overflow-auto max-h-96 font-mono text-foreground/90`,children:JSON.stringify(e.data,null,2)})})})]},t)})})]})}function p(){let[e,t]=(0,u.useState)((0,u.useMemo)(()=>{try{return typeof window<`u`?r(window.location.search).enabled:!1}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}export{p as n,l as r,f as t};
1
+ import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{_ as t,t as n}from"./vendor-react-slxo-5GC.js";import{Dt as r,l as i}from"./framework-B9PMswdm.js";import{Us as a,Vs as o,Ws as s,ls as c}from"./ui-components-DsYvPIox.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}=i(),[r,l]=(0,u.useState)([`0`]),[f,p]=(0,u.useState)(null),m=async(e,t)=>{try{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),p(t),setTimeout(()=>p(null),2e3)}catch(e){console.error(`Failed to copy:`,e)}},h=e=>{l(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,d.jsxs)(`div`,{className:`w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all`,children:[(0,d.jsxs)(`div`,{className:`px-4 py-3 border-b bg-muted/5 flex items-center justify-between`,children:[(0,d.jsx)(`span`,{className:`text-xs font-semibold uppercase tracking-wider text-muted-foreground`,children:n(`layout.metadata.panelTitle`)}),(0,d.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:n(`layout.metadata.jsonBadge`)})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let i=String(t),l=r.includes(i),u=f===t;return(0,d.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors`,children:[(0,d.jsxs)(`button`,{onClick:()=>h(i),className:`flex-1 flex items-center justify-between text-left`,children:[(0,d.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),l?(0,d.jsx)(a,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,d.jsx)(o,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,d.jsx)(`button`,{onClick:()=>m(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:n(`layout.metadata.copyJson`),children:u?(0,d.jsx)(s,{className:`h-3 w-3 text-green-600`}):(0,d.jsx)(c,{className:`h-3 w-3 text-muted-foreground`})})]}),l&&(0,d.jsx)(`div`,{className:`px-4 pb-4`,children:(0,d.jsx)(`div`,{className:`relative rounded-md border border-border/50 bg-muted/5 overflow-hidden`,children:(0,d.jsx)(`pre`,{className:`text-[11px] leading-relaxed p-3 overflow-auto max-h-96 font-mono text-foreground/90`,children:JSON.stringify(e.data,null,2)})})})]},t)})})]})}function p(){let[e,t]=(0,u.useState)((0,u.useMemo)(()=>{try{return typeof window<`u`?r(window.location.search).enabled:!1}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>t(e=>!e)}}export{p as n,l as r,f as t};