@object-ui/console 3.3.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/README.md +16 -0
  2. package/dist/assets/AdapterProvider-Cd4HYb7q.js +1 -0
  3. package/dist/assets/{AdvancedChartImpl-BWWiRBQV.js → AdvancedChartImpl-AY6sVw1n.js} +2 -2
  4. package/dist/assets/AppManagementPage-6l5ZKnv5.js +1 -0
  5. package/dist/assets/ChartImpl-DiKY5voi.js +1 -0
  6. package/dist/assets/DashboardView-BnX2k5Kx.js +1 -0
  7. package/dist/assets/KanbanEnhanced-BKCx2XIr.js +1 -0
  8. package/dist/assets/KanbanImpl-e9jzV-UD.js +1 -0
  9. package/dist/assets/MarkdownImpl-B-r7jSIS.js +1 -0
  10. package/dist/assets/MetadataDetailPage--3o8VI1T.js +1 -0
  11. package/dist/assets/MetadataFormDialog-Cy7k0Y55.js +1 -0
  12. package/dist/assets/MetadataInspector-DVtCDQtx.js +1 -0
  13. package/dist/assets/MetadataManagerPage-CYfvXG6X.js +1 -0
  14. package/dist/assets/MetadataProvider-Dvc9BxbC.js +1 -0
  15. package/dist/assets/PageView-CUDEz8Xo.js +2 -0
  16. package/dist/assets/ProfilePage-B0BXoAus.js +1 -0
  17. package/dist/assets/RecordDetailView-CYgcTNQp.js +1 -0
  18. package/dist/assets/ReportView-ovWyjJsZ.js +1 -0
  19. package/dist/assets/SearchResultsPage-B-NchFoJ.js +1 -0
  20. package/dist/assets/SystemHubPage-D8S1hN1a.js +1 -0
  21. package/dist/assets/data-adapter-v22lWuhc.js +39 -0
  22. package/dist/assets/framework-BW6KsEI0.js +2 -0
  23. package/dist/assets/getIcon-N5xWCMJy.js +1 -0
  24. package/dist/assets/index-DATdOX6r.js +59 -0
  25. package/dist/assets/index-nwlbpqhl.css +2 -0
  26. package/dist/assets/infrastructure-94fpO8jL.js +3 -0
  27. package/dist/assets/maplibre-gl-BR3qC6SX.js +748 -0
  28. package/dist/assets/plugins-core-B5ROGaJH.css +1 -0
  29. package/dist/assets/plugins-core-Ccvbi6db.js +105 -0
  30. package/dist/assets/plugins-views-CbLIJkBs.js +62 -0
  31. package/dist/assets/rolldown-runtime-S-ySWqyJ.js +1 -0
  32. package/dist/assets/{skeletons-Dxs6Di3L.js → skeletons-CIQE_YYE.js} +1 -1
  33. package/dist/assets/src-BGoL_8qF.js +1 -0
  34. package/dist/assets/ui-layout-CYz0tyDf.js +3 -0
  35. package/dist/assets/vendor-charts-D1AP0-EV.js +33 -0
  36. package/dist/assets/vendor-icons-CrSf7tAH.js +1 -0
  37. package/dist/assets/vendor-objectstack-Dhrq31KF.js +1 -0
  38. package/dist/assets/{vendor-react-DmY3YWtk.js → vendor-react-ryfytPb-.js} +1 -1
  39. package/dist/assets/vendor-zod-Dfb8LXKF.js +64 -0
  40. package/dist/index.html +26 -27
  41. package/package.json +44 -63
  42. package/dist/assets/ActionParamDialog-FoHiwOv1.js +0 -1
  43. package/dist/assets/AdapterProvider-BMMNYOio.js +0 -1
  44. package/dist/assets/AddressField-cixYGlNB.js +0 -1
  45. package/dist/assets/AppManagementPage-bOyAnjhU.js +0 -1
  46. package/dist/assets/AuditLogPage-CYbk9eg-.js +0 -1
  47. package/dist/assets/AuthPageLayout-BxIX5ebE.js +0 -1
  48. package/dist/assets/AutoNumberField-ZhMKpjBg.js +0 -1
  49. package/dist/assets/AvatarField-CyFyTMU0.js +0 -1
  50. package/dist/assets/BooleanField-BfvYM6AV.js +0 -1
  51. package/dist/assets/ChartImpl-DC6hwSlw.js +0 -1
  52. package/dist/assets/CodeField-E_gkep6y.js +0 -1
  53. package/dist/assets/ColorField-Cx-A5Lt0.js +0 -1
  54. package/dist/assets/CreateAppPage-BWPsgJjt.js +0 -1
  55. package/dist/assets/CurrencyField-De8eUBZn.js +0 -1
  56. package/dist/assets/DashboardDesignPage-D5PK-DCt.js +0 -1
  57. package/dist/assets/DashboardView-DHicI3QF.js +0 -1
  58. package/dist/assets/DateField-DEX8P85a.js +0 -1
  59. package/dist/assets/DateTimeField-7-OLEv75.js +0 -1
  60. package/dist/assets/EditAppPage-D5zTwJlk.js +0 -1
  61. package/dist/assets/EmailField-PxbTAuYC.js +0 -1
  62. package/dist/assets/FileField-BgYkkxBp.js +0 -1
  63. package/dist/assets/ForgotPasswordPage-B-SC0EDQ.js +0 -1
  64. package/dist/assets/FormulaField-DtcAppqd.js +0 -1
  65. package/dist/assets/GeolocationField-C8Vv3Q9T.js +0 -1
  66. package/dist/assets/GridField-HGVRXmPw.js +0 -1
  67. package/dist/assets/HomeLayout-DiAhEUcQ.js +0 -1
  68. package/dist/assets/HomePage-D0mu1KhN.js +0 -1
  69. package/dist/assets/ImageField-DonGxYyR.js +0 -1
  70. package/dist/assets/KanbanEnhanced-dVJHM0Vq.js +0 -1
  71. package/dist/assets/KanbanImpl-Du7bmAIp.js +0 -1
  72. package/dist/assets/LocationField-y31Q9OYm.js +0 -1
  73. package/dist/assets/LoginPage-CK-e0NKb.js +0 -1
  74. package/dist/assets/LookupField-cs9NaWXw.js +0 -1
  75. package/dist/assets/MarkdownImpl-DLQW-V1y.js +0 -1
  76. package/dist/assets/MasterDetailField-BI3uiZgR.js +0 -1
  77. package/dist/assets/MetadataDetailPage-C7MBEpTZ.js +0 -1
  78. package/dist/assets/MetadataFormDialog-C6kZu-tl.js +0 -1
  79. package/dist/assets/MetadataInspector-DAb5pYOH.js +0 -1
  80. package/dist/assets/MetadataManagerPage-KqCTlrFw.js +0 -1
  81. package/dist/assets/MetadataProvider-B6Zo_H9g.js +0 -1
  82. package/dist/assets/NumberField-CAPsyF5_.js +0 -1
  83. package/dist/assets/ObjectField-BXs-P94B.js +0 -1
  84. package/dist/assets/OrgManagementPage-Bd5hFjFA.js +0 -1
  85. package/dist/assets/PageDesignPage-CQKuBMSG.js +0 -1
  86. package/dist/assets/PageView-DzAF-4xC.js +0 -2
  87. package/dist/assets/PasswordField-66M8i1cP.js +0 -1
  88. package/dist/assets/PercentField-B4-Z2cl-.js +0 -1
  89. package/dist/assets/PermissionManagementPage-BohlfBZM.js +0 -1
  90. package/dist/assets/PhoneField-CbEqbBrO.js +0 -1
  91. package/dist/assets/ProfilePage-B2B5Vwiv.js +0 -1
  92. package/dist/assets/QRCodeField-BMVgCKPB.js +0 -1
  93. package/dist/assets/RatingField-DT67gTVp.js +0 -1
  94. package/dist/assets/RecordDetailView-KuRefR4o.js +0 -1
  95. package/dist/assets/RegisterPage-BR28zo3Z.js +0 -1
  96. package/dist/assets/ReportView-Dud74EeY.js +0 -1
  97. package/dist/assets/RichTextField-BJ3qOJu3.js +0 -1
  98. package/dist/assets/RoleManagementPage-CSrM1CTg.js +0 -1
  99. package/dist/assets/SearchResultsPage-CziEvfRB.js +0 -1
  100. package/dist/assets/SelectField-BIh8RBU2.js +0 -1
  101. package/dist/assets/SignatureField-DeTRlABT.js +0 -1
  102. package/dist/assets/SliderField-DZ4Q6eTl.js +0 -1
  103. package/dist/assets/SummaryField-DIOlQfN3.js +0 -1
  104. package/dist/assets/SystemHubPage-CT0edisJ.js +0 -1
  105. package/dist/assets/SystemObjectViewPage-D2qKWQRW.js +0 -1
  106. package/dist/assets/TextAreaField-C4XjBoOs.js +0 -1
  107. package/dist/assets/TextField-BcXMv3xe.js +0 -1
  108. package/dist/assets/TimeField-CHh1ZLFD.js +0 -1
  109. package/dist/assets/UrlField-DiTncT6s.js +0 -1
  110. package/dist/assets/UserField-mFk7qkDu.js +0 -1
  111. package/dist/assets/UserManagementPage-CicLMv53.js +0 -1
  112. package/dist/assets/VectorField-BsaAAFSl.js +0 -1
  113. package/dist/assets/data-adapter-DPqgzJ64.js +0 -39
  114. package/dist/assets/framework-B0ex8RpF.js +0 -2
  115. package/dist/assets/getIcon-DUhh_MlU.js +0 -1
  116. package/dist/assets/index-KDzKK6UM.js +0 -26
  117. package/dist/assets/index-jP1vuxyn.css +0 -2
  118. package/dist/assets/infrastructure-88EEJ8ZY.js +0 -3
  119. package/dist/assets/lib-CQxQAzx9.js +0 -29
  120. package/dist/assets/maplibre-gl-tCaFQWyX.js +0 -748
  121. package/dist/assets/metadataTypeRegistry-D4RkPQA-.js +0 -1
  122. package/dist/assets/plugins-core-B8C8BUw8.js +0 -135
  123. package/dist/assets/plugins-core-Dpq2d-QS.css +0 -2
  124. package/dist/assets/plugins-views-Csz847hc.js +0 -62
  125. package/dist/assets/rolldown-runtime-Dw2cE7zH.js +0 -1
  126. package/dist/assets/src-BY3UmUTR.js +0 -1
  127. package/dist/assets/src-CZnjIqJM.js +0 -1
  128. package/dist/assets/src-ZtN-VRcF.js +0 -1
  129. package/dist/assets/ui-layout-CvxBdH1V.js +0 -3
  130. package/dist/assets/useFavorites--Hq-4pMF.js +0 -1
  131. package/dist/assets/useMetadataService-CC_uGGZw.js +0 -1
  132. package/dist/assets/useResponsiveSidebar-DB8TNfQv.js +0 -1
  133. package/dist/assets/utils-auqIw3t-.js +0 -1
  134. package/dist/assets/vendor-charts-7pRhwWOA.js +0 -3
  135. package/dist/assets/vendor-objectstack-C8-rZ_sh.js +0 -1
  136. package/dist/assets/vendor-zod-Cu1XCR5v.js +0 -1
  137. package/dist/mockServiceWorker.js +0 -349
package/README.md CHANGED
@@ -58,6 +58,22 @@ The console supports two distinct running modes:
58
58
 
59
59
  Both modes support the same features and use the same codebase. Choose development mode for fast iteration, and plugin mode to verify deployment behavior.
60
60
 
61
+ ## Vercel Deployment
62
+
63
+ The console can be deployed as a standalone static SPA (e.g. to Vercel) that connects to a remote ObjectStack backend. The build configured in `vercel.json` disables the MSW mock worker (`VITE_USE_MOCK_SERVER=false`) so that all `/api/v1/*` requests go to the real backend.
64
+
65
+ **Required environment variable** (set in the Vercel project's *Environment Variables* panel):
66
+
67
+ | Variable | Example | Description |
68
+ | --- | --- | --- |
69
+ | `VITE_SERVER_URL` | `https://demo.objectstack.ai` | Absolute URL of the ObjectStack backend. When unset, requests default to the same origin — which will 404 on a static SPA host. |
70
+
71
+ Additional backend requirements for cross-origin deployments:
72
+
73
+ 1. The backend must allow CORS from the SPA origin (`Access-Control-Allow-Origin: <spa-origin>`, `Access-Control-Allow-Credentials: true`).
74
+ 2. Auth cookies must use `SameSite=None; Secure` so they are sent on cross-site requests.
75
+ 3. The apps and objects referenced in URLs (e.g. `crm_enterprise`, `lead`) must actually exist in the backend metadata — otherwise the console will render its *object not found* empty state.
76
+
61
77
  ## ObjectStack Spec Compliance
62
78
 
63
79
  ### AppSchema Support
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{U as t,W as n,d as r}from"./framework-BW6KsEI0.js";import{t as i}from"./data-adapter-v22lWuhc.js";import{u as a}from"./infrastructure-94fpO8jL.js";var o=e(n(),1),s=t();function c({children:e,adapter:t}){let[n,c]=(0,o.useState)(t??null);return(0,o.useEffect)(()=>{if(t){c(t);return}let e=!1;async function n(){try{let t=new i({baseUrl:`https://demo.objectstack.ai`,fetch:a(),autoReconnect:!0,maxReconnectAttempts:5,reconnectDelay:1e3,cache:{maxSize:50,ttl:3e5}});await t.connect(),e||c(t)}catch(t){e||console.error(`[Console] Failed to initialize:`,t)}}return n(),()=>{e=!0}},[t]),(0,s.jsx)(r.Provider,{value:n,children:e})}export{c as t};
@@ -1,7 +1,7 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{k as t,z as n}from"./framework-B0ex8RpF.js";import{Ki as r,Nn as i,ua as a}from"./plugins-core-B8C8BUw8.js";import{_ as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as b,s as x,t as S,u as C,v as w,y as T}from"./vendor-charts-7pRhwWOA.js";var E=e(n(),1),D=t(),O=(...e)=>e.filter(Boolean).join(` `),k={light:``,dark:`.dark`},A=E.createContext(null);function j(){let e=E.useContext(A);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function M({id:e,className:t,children:n,config:r,...i}){let o=E.useId(),s=`chart-${e||o.replace(/:/g,``)}`;return(0,D.jsx)(A.Provider,{value:{config:r},children:(0,D.jsxs)(`div`,{"data-slot":`chart`,"data-chart":s,className:O(`flex w-full h-[350px] justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground`,t),...i,children:[(0,D.jsx)(N,{id:s,config:r}),(0,D.jsx)(a,{width:`100%`,height:`100%`,children:n})]})})}var N=({id:e,config:t})=>{let n=Object.entries(t).filter(([,e])=>e.theme||e.color);return n.length?(0,D.jsx)(`style`,{dangerouslySetInnerHTML:{__html:Object.entries(k).map(([t,r])=>`
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{U as t,W as n}from"./framework-BW6KsEI0.js";import{Fn as r}from"./plugins-core-Ccvbi6db.js";import{S as i,_ as a,a as o,b as s,c,d as l,f as u,g as d,h as f,i as p,l as m,m as h,n as g,o as _,p as v,r as y,s as b,t as x,u as S,v as C,x as w,y as T}from"./vendor-charts-D1AP0-EV.js";var E=e(n(),1),D=t(),O=(...e)=>e.filter(Boolean).join(` `),k={light:``,dark:`.dark`},A=E.createContext(null);function j(){let e=E.useContext(A);if(!e)throw Error(`useChart must be used within a <ChartContainer />`);return e}function M({id:e,className:t,children:n,config:i,...a}){let o=E.useId(),s=`chart-${e||o.replace(/:/g,``)}`;return(0,D.jsx)(A.Provider,{value:{config:i},children:(0,D.jsxs)(`div`,{"data-slot":`chart`,"data-chart":s,className:O(`flex w-full h-[350px] justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground`,t),...a,children:[(0,D.jsx)(N,{id:s,config:i}),(0,D.jsx)(r,{width:`100%`,height:`100%`,children:n})]})})}var N=({id:e,config:t})=>{let n=Object.entries(t).filter(([,e])=>e.theme||e.color);return n.length?(0,D.jsx)(`style`,{dangerouslySetInnerHTML:{__html:Object.entries(k).map(([t,r])=>`
2
2
  ${r} [data-chart=${e}] {
3
3
  ${n.map(([e,n])=>{let r=n.theme?.[t]||n.color;return r?` --color-${e}: ${r};`:null}).join(`
4
4
  `)}
5
5
  }
6
6
  `).join(`
7
- `)}}):null},P=i;function F({active:e,payload:t,className:n,indicator:r=`dot`,hideLabel:i=!1,hideIndicator:a=!1,label:o,labelFormatter:s,labelClassName:c,formatter:l,color:u,nameKey:d,labelKey:f}){let{config:p}=j(),m=E.useMemo(()=>{if(i||!t?.length)return null;let[e]=t,n=R(p,e,`${f||e?.dataKey||e?.name||`value`}`),r=!f&&typeof o==`string`?p[o]?.label||o:n?.label;return s?(0,D.jsx)(`div`,{className:O(`font-medium`,c),children:s(r,t)}):r?(0,D.jsx)(`div`,{className:O(`font-medium`,c),children:r}):null},[o,s,t,i,c,p,f]);if(!e||!t?.length)return null;let h=t.length===1&&r!==`dot`;return(0,D.jsxs)(`div`,{className:O(`border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl`,n),children:[h?null:m,(0,D.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=R(p,e,`${d||e.name||e.dataKey||`value`}`),i=u||e.payload.fill||e.color;return(0,D.jsx)(`div`,{className:O(`[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5`,r===`dot`?`items-center`:``),children:l&&e?.value!==void 0&&e.name?l(e.value,e.name,e,t,e.payload):(0,D.jsxs)(D.Fragment,{children:[n?.icon?(0,D.jsx)(n.icon,{}):!a&&(0,D.jsx)(`div`,{className:O(`shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)`,r===`dot`?`h-2.5 w-2.5`:``,r===`line`?`w-1`:``,r===`dashed`?`w-0 border-[1.5px] border-dashed bg-transparent`:``,h&&r===`dashed`?`my-0.5`:``),style:{"--color-bg":i,"--color-border":i}}),(0,D.jsxs)(`div`,{className:O(`flex flex-1 justify-between leading-none`,h?`items-end`:`items-center`),children:[(0,D.jsxs)(`div`,{className:`grid gap-1.5`,children:[h?m:null,(0,D.jsx)(`span`,{className:`text-muted-foreground`,children:n?.label||e.name})]}),e.value&&(0,D.jsx)(`span`,{className:`text-foreground font-mono font-medium tabular-nums`,children:e.value.toLocaleString()})]})]})},e.dataKey)})})]})}var I=r;function L({className:e,hideIcon:t=!1,payload:n,verticalAlign:r=`bottom`,nameKey:i}){let{config:a}=j();return n?.length?(0,D.jsx)(`div`,{className:O(`flex items-center justify-center gap-4`,r===`top`?`pb-3`:`pt-3`,e),children:n.filter(e=>e.type!==`none`).map(e=>{let n=R(a,e,`${i||e.dataKey||`value`}`);return(0,D.jsxs)(`div`,{className:O(`[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3`),children:[n?.icon&&!t?(0,D.jsx)(n.icon,{}):(0,D.jsx)(`div`,{className:`h-2 w-2 shrink-0 rounded-[2px]`,style:{backgroundColor:e.color}}),n?.label]},e.value)})}):null}function R(e,t,n){if(typeof t!=`object`||!t)return;let r=`payload`in t&&typeof t.payload==`object`&&t.payload!==null?t.payload:void 0,i=n;return n in t&&typeof t[n]==`string`?i=t[n]:r&&n in r&&typeof r[n]==`string`&&(i=r[n]),i in e?e[i]:e[n]}var z=`hsl(var(--primary))`,B={slate:`#64748b`,gray:`#6b7280`,zinc:`#71717a`,neutral:`#737373`,stone:`#78716c`,red:`#ef4444`,orange:`#f97316`,amber:`#f59e0b`,yellow:`#eab308`,lime:`#84cc16`,green:`#22c55e`,emerald:`#10b981`,teal:`#14b8a6`,cyan:`#06b6d4`,sky:`#0ea5e9`,blue:`#3b82f6`,indigo:`#6366f1`,violet:`#8b5cf6`,purple:`#a855f7`,fuchsia:`#d946ef`,pink:`#ec4899`,rose:`#f43f5e`},V=e=>B[e]||e;function H({chartType:e=`bar`,data:t=[],config:n={},xAxisKey:r=`name`,series:i=[],className:a=``}){let O=Array.isArray(t)?t:[],[k,A]=E.useState(!1);E.useEffect(()=>{let e=()=>A(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let j={bar:s,line:v,area:S,pie:m,donut:m,radar:b,scatter:_,combo:s}[e]||s,N=E.useMemo(()=>O.some(e=>String(e[r]||``).length>5),[O,r]),R=()=>[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`];if(e===`pie`||e===`donut`){let t=e===`donut`?60:0;return(0,D.jsx)(M,{config:n,className:a,children:(0,D.jsxs)(m,{children:[(0,D.jsx)(P,{cursor:!1,content:(0,D.jsx)(F,{hideLabel:!0})}),(0,D.jsx)(f,{data:O,dataKey:i[0]?.dataKey||`value`,nameKey:r||`name`,innerRadius:t,strokeWidth:5,paddingAngle:2,outerRadius:80,children:O.map((e,t)=>{let i=n[e[r]]?.color;if(!i){let e=R();i=e[t%e.length]}return(0,D.jsx)(c,{fill:V(i)},`cell-${t}`)})}),(0,D.jsx)(I,{content:(0,D.jsx)(L,{nameKey:r}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}})]})})}return e===`radar`?(0,D.jsx)(M,{config:n,className:a,children:(0,D.jsxs)(b,{data:O,children:[(0,D.jsx)(T,{}),(0,D.jsx)(o,{dataKey:r}),(0,D.jsx)(w,{}),(0,D.jsx)(P,{content:(0,D.jsx)(F,{})}),(0,D.jsx)(I,{content:(0,D.jsx)(L,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map(e=>{let t=V(n[e.dataKey]?.color||z);return(0,D.jsx)(p,{dataKey:e.dataKey,stroke:t,fill:t,fillOpacity:.6},e.dataKey)})]})}):e===`scatter`?(0,D.jsx)(M,{config:n,className:a,children:(0,D.jsxs)(_,{children:[(0,D.jsx)(g,{vertical:!1}),(0,D.jsx)(h,{type:`number`,dataKey:r,name:String(n[r]?.label||r),tickLine:!1,axisLine:!1,interval:k?Math.ceil(O.length/5):0}),(0,D.jsx)(l,{type:`number`,dataKey:i[0]?.dataKey||`value`,name:String(n[i[0]?.dataKey]?.label||i[0]?.dataKey),tickLine:!1,axisLine:!1}),(0,D.jsx)(x,{type:`number`,range:[60,400]}),(0,D.jsx)(P,{content:(0,D.jsx)(F,{})}),(0,D.jsx)(I,{content:(0,D.jsx)(L,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map((e,t)=>{let r=R(),i=V(n[e.dataKey]?.color||r[t%r.length]);return(0,D.jsx)(C,{name:n[e.dataKey]?.label||e.dataKey,data:O,fill:i},e.dataKey)})]})}):e===`combo`?(0,D.jsx)(M,{config:n,className:a,children:(0,D.jsxs)(s,{data:O,children:[(0,D.jsx)(g,{vertical:!1}),(0,D.jsx)(h,{dataKey:r,tickLine:!1,tickMargin:10,axisLine:!1,interval:k?Math.ceil(O.length/5):0,tickFormatter:e=>!e||typeof e!=`string`?e:k&&e.length>8?e.slice(0,8)+`…`:e,...!k&&N&&{angle:-35,textAnchor:`end`,height:60}}),(0,D.jsx)(l,{yAxisId:`left`,tickLine:!1,axisLine:!1}),(0,D.jsx)(l,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1}),(0,D.jsx)(P,{content:(0,D.jsx)(F,{})}),(0,D.jsx)(I,{content:(0,D.jsx)(L,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map((e,t)=>{let r=V(n[e.dataKey]?.color||z),i=e.chartType||(t===0?`bar`:`line`),a=i===`bar`?`left`:`right`;return i===`line`?(0,D.jsx)(y,{yAxisId:a,type:`monotone`,dataKey:e.dataKey,stroke:r,strokeWidth:2,dot:!1},e.dataKey):i===`area`?(0,D.jsx)(d,{yAxisId:a,type:`monotone`,dataKey:e.dataKey,fill:r,stroke:r,fillOpacity:.4},e.dataKey):(0,D.jsx)(u,{yAxisId:a,dataKey:e.dataKey,fill:r,radius:4},e.dataKey)})]})}):(0,D.jsx)(M,{config:n,className:a,children:(0,D.jsxs)(j,{data:O,children:[(0,D.jsx)(g,{vertical:!1}),(0,D.jsx)(h,{dataKey:r,tickLine:!1,tickMargin:10,axisLine:!1,interval:k?Math.ceil(O.length/5):0,tickFormatter:e=>!e||typeof e!=`string`?e:k&&e.length>8?e.slice(0,8)+`…`:e,...!k&&N&&{angle:-35,textAnchor:`end`,height:60}}),(0,D.jsx)(P,{content:(0,D.jsx)(F,{})}),(0,D.jsx)(I,{content:(0,D.jsx)(L,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map(t=>{let r=V(n[t.dataKey]?.color||z);return e===`bar`?(0,D.jsx)(u,{dataKey:t.dataKey,fill:r,radius:4},t.dataKey):e===`line`?(0,D.jsx)(y,{type:`monotone`,dataKey:t.dataKey,stroke:r,strokeWidth:2,dot:!1},t.dataKey):e===`area`?(0,D.jsx)(d,{type:`monotone`,dataKey:t.dataKey,fill:r,stroke:r,fillOpacity:.4},t.dataKey):null})]})})}export{H as default};
7
+ `)}}):null},P=w;function F({active:e,payload:t,className:n,indicator:r=`dot`,hideLabel:i=!1,hideIndicator:a=!1,label:o,labelFormatter:s,labelClassName:c,formatter:l,color:u,nameKey:d,labelKey:f}){let{config:p}=j(),m=E.useMemo(()=>{if(i||!t?.length)return null;let[e]=t,n=R(p,e,`${f||e?.dataKey||e?.name||`value`}`),r=!f&&typeof o==`string`?p[o]?.label||o:n?.label;return s?(0,D.jsx)(`div`,{className:O(`font-medium`,c),children:s(r,t)}):r?(0,D.jsx)(`div`,{className:O(`font-medium`,c),children:r}):null},[o,s,t,i,c,p,f]);if(!e||!t?.length)return null;let h=t.length===1&&r!==`dot`;return(0,D.jsxs)(`div`,{className:O(`border-border/50 bg-background grid min-w-[8rem] items-start gap-1.5 rounded-lg border px-2.5 py-1.5 text-xs shadow-xl`,n),children:[h?null:m,(0,D.jsx)(`div`,{className:`grid gap-1.5`,children:t.filter(e=>e.type!==`none`).map((e,t)=>{let n=R(p,e,`${d||e.name||e.dataKey||`value`}`),i=u||e.payload.fill||e.color;return(0,D.jsx)(`div`,{className:O(`[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5`,r===`dot`?`items-center`:``),children:l&&e?.value!==void 0&&e.name?l(e.value,e.name,e,t,e.payload):(0,D.jsxs)(D.Fragment,{children:[n?.icon?(0,D.jsx)(n.icon,{}):!a&&(0,D.jsx)(`div`,{className:O(`shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)`,r===`dot`?`h-2.5 w-2.5`:``,r===`line`?`w-1`:``,r===`dashed`?`w-0 border-[1.5px] border-dashed bg-transparent`:``,h&&r===`dashed`?`my-0.5`:``),style:{"--color-bg":i,"--color-border":i}}),(0,D.jsxs)(`div`,{className:O(`flex flex-1 justify-between leading-none`,h?`items-end`:`items-center`),children:[(0,D.jsxs)(`div`,{className:`grid gap-1.5`,children:[h?m:null,(0,D.jsx)(`span`,{className:`text-muted-foreground`,children:n?.label||e.name})]}),e.value&&(0,D.jsx)(`span`,{className:`text-foreground font-mono font-medium tabular-nums`,children:e.value.toLocaleString()})]})]})},e.dataKey)})})]})}var I=i;function L({className:e,hideIcon:t=!1,payload:n,verticalAlign:r=`bottom`,nameKey:i}){let{config:a}=j();return n?.length?(0,D.jsx)(`div`,{className:O(`flex items-center justify-center gap-4`,r===`top`?`pb-3`:`pt-3`,e),children:n.filter(e=>e.type!==`none`).map(e=>{let n=R(a,e,`${i||e.dataKey||`value`}`);return(0,D.jsxs)(`div`,{className:O(`[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3`),children:[n?.icon&&!t?(0,D.jsx)(n.icon,{}):(0,D.jsx)(`div`,{className:`h-2 w-2 shrink-0 rounded-[2px]`,style:{backgroundColor:e.color}}),n?.label]},e.value)})}):null}function R(e,t,n){if(typeof t!=`object`||!t)return;let r=`payload`in t&&typeof t.payload==`object`&&t.payload!==null?t.payload:void 0,i=n;return n in t&&typeof t[n]==`string`?i=t[n]:r&&n in r&&typeof r[n]==`string`&&(i=r[n]),i in e?e[i]:e[n]}var z=`hsl(var(--primary))`,B={slate:`#64748b`,gray:`#6b7280`,zinc:`#71717a`,neutral:`#737373`,stone:`#78716c`,red:`#ef4444`,orange:`#f97316`,amber:`#f59e0b`,yellow:`#eab308`,lime:`#84cc16`,green:`#22c55e`,emerald:`#10b981`,teal:`#14b8a6`,cyan:`#06b6d4`,sky:`#0ea5e9`,blue:`#3b82f6`,indigo:`#6366f1`,violet:`#8b5cf6`,purple:`#a855f7`,fuchsia:`#d946ef`,pink:`#ec4899`,rose:`#f43f5e`},V=e=>B[e]||e;function H({chartType:e=`bar`,data:t=[],config:n={},xAxisKey:r=`name`,series:i=[],className:w=``}){let O=Array.isArray(t)?t:[],[k,A]=E.useState(!1);E.useEffect(()=>{let e=()=>A(window.innerWidth<640);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let j={bar:o,line:_,area:x,pie:p,donut:p,radar:y,scatter:g,combo:o}[e]||o,N=E.useMemo(()=>O.some(e=>String(e[r]||``).length>5),[O,r]),R=()=>[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`];if(e===`pie`||e===`donut`){let t=e===`donut`?60:0;return(0,D.jsx)(M,{config:n,className:w,children:(0,D.jsxs)(p,{children:[(0,D.jsx)(P,{cursor:!1,content:(0,D.jsx)(F,{hideLabel:!0})}),(0,D.jsx)(d,{data:O,dataKey:i[0]?.dataKey||`value`,nameKey:r||`name`,innerRadius:t,strokeWidth:5,paddingAngle:2,outerRadius:80,children:O.map((e,t)=>{let i=n[e[r]]?.color;if(!i){let e=R();i=e[t%e.length]}return(0,D.jsx)(s,{fill:V(i)},`cell-${t}`)})}),(0,D.jsx)(I,{content:(0,D.jsx)(L,{nameKey:r}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}})]})})}return e===`radar`?(0,D.jsx)(M,{config:n,className:w,children:(0,D.jsxs)(y,{data:O,children:[(0,D.jsx)(T,{}),(0,D.jsx)(a,{dataKey:r}),(0,D.jsx)(C,{}),(0,D.jsx)(P,{content:(0,D.jsx)(F,{})}),(0,D.jsx)(I,{content:(0,D.jsx)(L,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map(e=>{let t=V(n[e.dataKey]?.color||z);return(0,D.jsx)(f,{dataKey:e.dataKey,stroke:t,fill:t,fillOpacity:.6},e.dataKey)})]})}):e===`scatter`?(0,D.jsx)(M,{config:n,className:w,children:(0,D.jsxs)(g,{children:[(0,D.jsx)(h,{vertical:!1}),(0,D.jsx)(m,{type:`number`,dataKey:r,name:String(n[r]?.label||r),tickLine:!1,axisLine:!1,interval:k?Math.ceil(O.length/5):0}),(0,D.jsx)(c,{type:`number`,dataKey:i[0]?.dataKey||`value`,name:String(n[i[0]?.dataKey]?.label||i[0]?.dataKey),tickLine:!1,axisLine:!1}),(0,D.jsx)(b,{type:`number`,range:[60,400]}),(0,D.jsx)(P,{content:(0,D.jsx)(F,{})}),(0,D.jsx)(I,{content:(0,D.jsx)(L,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map((e,t)=>{let r=R(),i=V(n[e.dataKey]?.color||r[t%r.length]);return(0,D.jsx)(S,{name:n[e.dataKey]?.label||e.dataKey,data:O,fill:i},e.dataKey)})]})}):e===`combo`?(0,D.jsx)(M,{config:n,className:w,children:(0,D.jsxs)(o,{data:O,children:[(0,D.jsx)(h,{vertical:!1}),(0,D.jsx)(m,{dataKey:r,tickLine:!1,tickMargin:10,axisLine:!1,interval:k?Math.ceil(O.length/5):0,tickFormatter:e=>!e||typeof e!=`string`?e:k&&e.length>8?e.slice(0,8)+`…`:e,...!k&&N&&{angle:-35,textAnchor:`end`,height:60}}),(0,D.jsx)(c,{yAxisId:`left`,tickLine:!1,axisLine:!1}),(0,D.jsx)(c,{yAxisId:`right`,orientation:`right`,tickLine:!1,axisLine:!1}),(0,D.jsx)(P,{content:(0,D.jsx)(F,{})}),(0,D.jsx)(I,{content:(0,D.jsx)(L,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map((e,t)=>{let r=V(n[e.dataKey]?.color||z),i=e.chartType||(t===0?`bar`:`line`),a=i===`bar`?`left`:`right`;return i===`line`?(0,D.jsx)(v,{yAxisId:a,type:`monotone`,dataKey:e.dataKey,stroke:r,strokeWidth:2,dot:!1},e.dataKey):i===`area`?(0,D.jsx)(u,{yAxisId:a,type:`monotone`,dataKey:e.dataKey,fill:r,stroke:r,fillOpacity:.4},e.dataKey):(0,D.jsx)(l,{yAxisId:a,dataKey:e.dataKey,fill:r,radius:4},e.dataKey)})]})}):(0,D.jsx)(M,{config:n,className:w,children:(0,D.jsxs)(j,{data:O,children:[(0,D.jsx)(h,{vertical:!1}),(0,D.jsx)(m,{dataKey:r,tickLine:!1,tickMargin:10,axisLine:!1,interval:k?Math.ceil(O.length/5):0,tickFormatter:e=>!e||typeof e!=`string`?e:k&&e.length>8?e.slice(0,8)+`…`:e,...!k&&N&&{angle:-35,textAnchor:`end`,height:60}}),(0,D.jsx)(P,{content:(0,D.jsx)(F,{})}),(0,D.jsx)(I,{content:(0,D.jsx)(L,{}),...k&&{verticalAlign:`bottom`,wrapperStyle:{fontSize:`11px`,paddingTop:`8px`}}}),i.map((t,r)=>{let a=R(),o=V(n[t.dataKey]?.color||a[r%a.length]||z);if(e===`bar`){let e=i.length===1&&O.length>1;return(0,D.jsx)(l,{dataKey:t.dataKey,fill:o,radius:4,children:e&&O.map((e,t)=>(0,D.jsx)(s,{fill:V(a[t%a.length])},`cell-${t}`))},t.dataKey)}return e===`line`?(0,D.jsx)(v,{type:`monotone`,dataKey:t.dataKey,stroke:o,strokeWidth:2,dot:!1},t.dataKey):e===`area`?(0,D.jsx)(u,{type:`monotone`,dataKey:t.dataKey,fill:o,stroke:o,fillOpacity:.4},t.dataKey):null})]})})}export{H as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{U as t,W as n,m as r}from"./framework-BW6KsEI0.js";import{Gr as i,Ji as a,Or as o,Pn as s,Ur as c,Wr as l,Xr as u,cr as d,eo as f,gi as p,ha as m,li as h,ln as g,lr as _,mr as v,xi as y}from"./plugins-core-Ccvbi6db.js";import{d as b,p as x}from"./ui-layout-CYz0tyDf.js";import"./index-DATdOX6r.js";var S=e(n(),1);function C(e,t){if(e!=null){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}}var w=t();function T(){let e=b(),{appName:t}=x(),n=t?`/apps/${t}`:``,{apps:T,refresh:E}=r(),[D,O]=(0,S.useState)(``),[k,A]=(0,S.useState)(new Set),[j,M]=(0,S.useState)(null),[N,P]=(0,S.useState)(!1),F=(T||[]).filter(e=>{if(!D)return!0;let t=D.toLowerCase();return(e.name||``).toLowerCase().includes(t)||(e.label||``).toLowerCase().includes(t)||(e.description||``).toLowerCase().includes(t)}),I=(0,S.useCallback)(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),L=(0,S.useCallback)(()=>{k.size===F.length?A(new Set):A(new Set(F.map(e=>e.name)))},[k.size,F]),R=(0,S.useCallback)(async e=>{P(!0);try{let t=e.active===!1;f.success(`${e.label||e.name} ${t?`enabled`:`disabled`}`),await E()}catch{f.error(`Failed to toggle app status`)}finally{P(!1)}},[E]),z=(0,S.useCallback)(async e=>{P(!0);try{f.success(`${e.label||e.name} set as default`),await E()}catch{f.error(`Failed to set default app`)}finally{P(!1)}},[E]),B=(0,S.useCallback)(async e=>{if(j!==e.name){M(e.name);return}P(!0);try{f.success(`${e.label||e.name} deleted`),M(null),await E()}catch{f.error(`Failed to delete app`)}finally{P(!1)}},[j,E]),V=(0,S.useCallback)(async e=>{P(!0);try{f.success(`${k.size} apps ${e?`enabled`:`disabled`}`),A(new Set),await E()}catch{f.error(`Bulk operation failed`)}finally{P(!1)}},[k,E]);return(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,children:[(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Applications`}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage all configured applications`})]}),(0,w.jsxs)(o,{onClick:()=>e(`${n}/create-app`),"data-testid":`create-app-btn`,children:[(0,w.jsx)(p,{className:`h-4 w-4 mr-2`}),`New App`]})]}),(0,w.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[(0,w.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,w.jsx)(`label`,{htmlFor:`app-search`,className:`sr-only`,children:`Search apps`}),(0,w.jsx)(h,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,w.jsx)(g,{id:`app-search`,placeholder:`Search apps...`,value:D,onChange:e=>O(e.target.value),className:`pl-8`,"data-testid":`app-search-input`})]}),k.size>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsxs)(v,{variant:`secondary`,children:[k.size,` selected`]}),(0,w.jsx)(o,{variant:`outline`,size:`sm`,onClick:()=>V(!0),disabled:N,children:`Enable`}),(0,w.jsx)(o,{variant:`outline`,size:`sm`,onClick:()=>V(!1),disabled:N,children:`Disable`})]})]}),F.length>0&&(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,w.jsx)(s,{id:`select-all-apps`,checked:k.size===F.length&&F.length>0,onCheckedChange:()=>L()}),(0,w.jsxs)(`label`,{htmlFor:`select-all-apps`,className:`cursor-pointer`,children:[`Select all (`,F.length,`)`]})]}),F.length===0?(0,w.jsxs)(`div`,{className:`text-center py-12 text-muted-foreground`,"data-testid":`no-apps-message`,children:[(0,w.jsx)(a,{className:`h-12 w-12 mx-auto mb-3 opacity-30`}),(0,w.jsx)(`p`,{children:`No apps found.`})]}):(0,w.jsx)(`div`,{className:`grid gap-3`,children:F.map(t=>{let r=t.active!==!1,f=t.isDefault===!0,p=j===t.name;return(0,w.jsx)(d,{className:r?``:`opacity-60`,"data-testid":`app-card-${t.name}`,children:(0,w.jsxs)(_,{className:`flex items-center gap-3 py-3 px-4`,children:[(0,w.jsx)(s,{id:`select-app-${t.name}`,checked:k.has(t.name),onCheckedChange:()=>I(t.name),"aria-label":`Select ${t.label||t.name}`,className:`shrink-0`}),(0,w.jsx)(`div`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,w.jsx)(a,{className:`h-4 w-4`})}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`span`,{className:`font-medium truncate`,children:C(t.label)||t.name}),f&&(0,w.jsx)(v,{variant:`default`,className:`text-xs`,children:`Default`}),(0,w.jsx)(v,{variant:r?`secondary`:`outline`,className:`text-xs`,children:r?`Active`:`Inactive`})]}),t.description&&(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:C(t.description)})]}),(0,w.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,w.jsx)(o,{variant:`ghost`,size:`icon`,title:`Open app`,"aria-label":`Open ${t.label||t.name}`,onClick:()=>e(`/apps/${t.name}`),children:(0,w.jsx)(m,{className:`h-4 w-4`})}),(0,w.jsx)(o,{variant:`ghost`,size:`icon`,title:`Edit app`,"aria-label":`Edit ${t.label||t.name}`,onClick:()=>e(`${n}/edit-app/${t.name}`),children:(0,w.jsx)(y,{className:`h-4 w-4`})}),(0,w.jsx)(o,{variant:`ghost`,size:`icon`,title:r?`Disable app`:`Enable app`,"aria-label":r?`Disable ${t.label||t.name}`:`Enable ${t.label||t.name}`,onClick:()=>R(t),disabled:N,children:r?(0,w.jsx)(l,{className:`h-4 w-4`}):(0,w.jsx)(i,{className:`h-4 w-4`})}),(0,w.jsx)(o,{variant:`ghost`,size:`icon`,title:`Set as default`,"aria-label":`Set ${t.label||t.name} as default`,onClick:()=>z(t),disabled:N||f,children:(0,w.jsx)(u,{className:`h-4 w-4 ${f?`fill-current text-yellow-500`:``}`})}),(0,w.jsx)(o,{variant:`ghost`,size:`icon`,title:p?`Click again to confirm delete`:`Delete app`,"aria-label":p?`Confirm delete ${t.label||t.name}`:`Delete ${t.label||t.name}`,onClick:()=>B(t),disabled:N,className:p?`text-destructive`:``,children:(0,w.jsx)(c,{className:`h-4 w-4`})})]})]})},t.name)})})]})}export{T as AppManagementPage};
@@ -0,0 +1 @@
1
+ import{U as e}from"./framework-BW6KsEI0.js";import{Fn as t}from"./plugins-core-Ccvbi6db.js";import{S as n,a as r,c as i,d as a,l as o,m as s,x as c}from"./vendor-charts-D1AP0-EV.js";var l=e();function u({data:e=[],dataKey:u=`value`,xAxisKey:d=`name`,height:f=400,className:p=``,color:m=`hsl(var(--primary))`}){return(0,l.jsx)(`div`,{className:`p-2 sm:p-3 md:p-4 rounded-xl border border-border bg-card/40 backdrop-blur-sm shadow-lg shadow-background/5 ${p}`,children:(0,l.jsx)(t,{width:`100%`,height:f,children:(0,l.jsxs)(r,{data:e,margin:{top:10,right:10,left:10,bottom:5},children:[(0,l.jsxs)(`defs`,{children:[(0,l.jsxs)(`linearGradient`,{id:`barGradient`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,l.jsx)(`stop`,{offset:`0%`,stopColor:m,stopOpacity:1}),(0,l.jsx)(`stop`,{offset:`90%`,stopColor:m,stopOpacity:.6}),(0,l.jsx)(`stop`,{offset:`100%`,stopColor:m,stopOpacity:.3})]}),(0,l.jsxs)(`filter`,{id:`glow`,height:`130%`,children:[(0,l.jsx)(`feGaussianBlur`,{in:`SourceAlpha`,stdDeviation:`3`,result:`blur`}),(0,l.jsx)(`feOffset`,{in:`blur`,dx:`0`,dy:`0`,result:`offsetBlur`}),(0,l.jsx)(`feFlood`,{floodColor:m,floodOpacity:`0.5`,result:`offsetColor`}),(0,l.jsx)(`feComposite`,{in:`offsetColor`,in2:`offsetBlur`,operator:`in`,result:`offsetBlur`}),(0,l.jsxs)(`feMerge`,{children:[(0,l.jsx)(`feMergeNode`,{in:`offsetBlur`}),(0,l.jsx)(`feMergeNode`,{in:`SourceGraphic`})]})]})]}),(0,l.jsx)(s,{strokeDasharray:`3 3`,stroke:`hsl(var(--border))`,vertical:!1}),(0,l.jsx)(o,{dataKey:d,tick:{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:{stroke:`hsl(var(--border))`},dy:10}),(0,l.jsx)(i,{tick:{fill:`hsl(var(--muted-foreground))`,fontSize:12,fontFamily:`monospace`},tickLine:!1,axisLine:!1}),(0,l.jsx)(c,{cursor:{fill:`hsl(var(--muted))`,opacity:.2},contentStyle:{backgroundColor:`hsl(var(--popover))`,borderColor:`hsl(var(--border))`,color:`hsl(var(--popover-foreground))`,borderRadius:`8px`,fontFamily:`monospace`,boxShadow:`0 4px 6px -1px rgb(0 0 0 / 0.1)`},itemStyle:{color:`hsl(var(--primary))`}}),(0,l.jsx)(n,{wrapperStyle:{paddingTop:`20px`,fontFamily:`monospace`}}),(0,l.jsx)(a,{dataKey:u,fill:`url(#barGradient)`,radius:[4,4,0,0],filter:`url(#glow)`,animationDuration:1500})]})})})}export{u as default};
@@ -0,0 +1 @@
1
+ import{n as e,r as t}from"./rolldown-runtime-S-ySWqyJ.js";import{U as n,W as r,a as i,m as a,p as ee}from"./framework-BW6KsEI0.js";import{An as o,Dn as te,En as s,On as c,Or as l,Tn as u,c as d,eo as f,gt as ne,ht as re,kn as ie,mt as ae}from"./plugins-core-Ccvbi6db.js";import{p as oe}from"./ui-layout-CYz0tyDf.js";import"./AdapterProvider-Cd4HYb7q.js";import"./MetadataProvider-Dvc9BxbC.js";import{C as p,N as m,P as h,et as g,f as _,l as v,nt as y,rt as b,u as x,w as S}from"./vendor-icons-CrSf7tAH.js";import{a as C,i as w,r as T}from"./plugins-views-CbLIJkBs.js";import{r as E,t as se}from"./MetadataInspector-DVtCDQtx.js";import{n as ce}from"./skeletons-CIQE_YYE.js";var D=t(r(),1);function O(e,t){if(e!=null){if(typeof e==`string`)return e;if(t){let n=t(e.key,{defaultValue:e.defaultValue,...e.params});if(n&&n!==e.key)return n}return e.defaultValue||e.key}}function k(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}var A=e({DashboardView:()=>B}),j=n(),M=[{type:`metric`,label:`KPI Metric`,Icon:v},{type:`bar`,label:`Bar Chart`,Icon:b},{type:`line`,label:`Line Chart`,Icon:y},{type:`pie`,label:`Pie Chart`,Icon:g},{type:`table`,label:`Table`,Icon:_},{type:`grid`,label:`Grid`,Icon:h}],N=0;function P(){return N+=1,`widget_${Date.now()}_${N}`}function F(e){return!e.widgets?.length||!e.widgets.some(e=>!e.id)?e:{...e,widgets:e.widgets.map(e=>e.id?e:{...e,id:P()})}}function I(e){let t=M.find(t=>t.type===e);return t?`New ${t.label}`:`New Widget`}function L(e){return{title:e.title??``,description:e.description??``,type:e.type??`metric`,object:e.object??``,categoryField:e.categoryField??``,valueField:e.valueField??``,aggregate:e.aggregate??`count`,layoutW:e.layout?.w??1,layoutH:e.layout?.h??1,colorVariant:e.colorVariant??`default`,actionUrl:e.actionUrl??``}}function R(e,t){return{title:e.title,description:e.description,type:e.type,object:e.object,categoryField:e.categoryField,valueField:e.valueField,aggregate:e.aggregate,layout:{...t.layout||{},w:e.layoutW,h:e.layoutH},colorVariant:e.colorVariant,actionUrl:e.actionUrl}}function z(e){return{columns:e.columns??3,gap:e.gap??4,rowHeight:String(e.rowHeight??`120`),refreshInterval:String(e.refreshInterval??`0`),title:e.title??``,showDescription:e.showDescription??!0,theme:e.theme??`auto`}}function B({dataSource:e}){let{dashboardName:t}=oe(),{showDebug:n}=E(),r=ee(),{t:h}=i(),[g,_]=(0,D.useState)(!0),[v,y]=(0,D.useState)(!1),[b,k]=(0,D.useState)(null),[A,N]=(0,D.useState)(0),[B,V]=(0,D.useState)(null),H=(0,D.useCallback)(e=>{V(t=>(t&&t.resolve(e),null))},[]),U=(0,D.useCallback)(e=>new Promise(t=>{V({schema:typeof e==`string`?{objectName:e,mode:`create`}:e,resolve:t})}),[]),le=(0,D.useMemo)(()=>({export_dashboard_pdf:async()=>{f.info(`Preparing PDF export…`);try{return window.print(),{success:!0}}catch(e){return f.error(`Export failed: ${e?.message||String(e)}`),{success:!1,error:e?.message||String(e)}}},forecast_dashboard:async()=>(f.info(`Forecast view coming soon`),{success:!0})}),[]);(0,D.useEffect)(()=>{_(!0),Y(null),y(!1),k(null),queueMicrotask(()=>_(!1))},[t]);let{dashboards:W,objects:G,refresh:K}=a(),q=W?.find(e=>e.name===t),[J,Y]=(0,D.useState)(null);(0,D.useEffect)(()=>{v||Y(null)},[q]);let X=(0,D.useCallback)(async e=>{try{r&&(await r.update(`sys_dashboard`,t,e),K().catch(()=>{}))}catch(e){console.warn(`[DashboardView] Auto-save failed:`,e)}},[r,t,K]),ue=(0,D.useCallback)(()=>{Y(F(q)),y(!0),N(e=>e+1)},[q]),Z=(0,D.useCallback)(()=>{y(!1),k(null)},[]),de=(0,D.useCallback)(e=>{if(!J)return;let t=P(),n={id:t,title:I(e),type:e,layout:{x:0,y:J.widgets?.length??0,w:J.columns??2,h:1}},r={...J,widgets:[...J.widgets||[],n]};Y(r),X(r),k(t),N(e=>e+1)},[J,X]),fe=(0,D.useCallback)(e=>{if(!J)return;let t={...J,widgets:J.widgets.filter(t=>t.id!==e)};Y(t),X(t),b===e&&k(null)},[J,b,X]),pe=(0,D.useMemo)(()=>z(J||q),[A]),me=(0,D.useCallback)(e=>{if(!J)return;let t={...J,columns:e.columns,gap:e.gap,rowHeight:e.rowHeight,refreshInterval:Number(e.refreshInterval)||0,title:e.title,showDescription:e.showDescription,theme:e.theme};Y(t),X(t),N(e=>e+1)},[J,X]),he=(0,D.useCallback)((e,t)=>{J&&Y(n=>n&&(e===`refreshInterval`?{...n,refreshInterval:Number(t)||0}:{...n,[e]:t}))},[J]),Q=J?.widgets?.find(e=>e.id===b),ge=(0,D.useMemo)(()=>Q?L(Q):{},[b,A]),_e=(0,D.useCallback)(e=>{if(!J||!b||!Q)return;let t=R(e,Q),n={...J,widgets:J.widgets.map(e=>e.id===b?{...e,...t}:e)};Y(n),X(n),N(e=>e+1)},[J,b,Q,X]),ve=(0,D.useCallback)((e,t)=>{b&&Y(n=>{if(!n)return n;let r=n.widgets?.find(e=>e.id===b);if(!r)return n;let i=L(r);i[e]=t;let a=R(i,r);return{...n,widgets:n.widgets.map(e=>e.id===b?{...e,...a}:e)}})},[b]),ye=(0,D.useMemo)(()=>{if(G?.length)return G.map(e=>({value:e.name,label:e.label||e.name}))},[G]),be=(0,D.useMemo)(()=>{let e=Q?.object;if(!e||!G?.length)return;let t=G.find(t=>t.name===e);if(!t?.fields)return;let n=t.fields;return Array.isArray(n)?n.filter(e=>e.name).map(e=>({value:e.name,label:e.label||e.name})):Object.entries(n).map(([e,t])=>({value:e,label:t.label||e}))},[Q?.object,G]);if(g)return(0,j.jsx)(ce,{});if(!q)return(0,j.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,j.jsxs)(ae,{children:[(0,j.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,j.jsx)(m,{className:`h-6 w-6 text-muted-foreground`})}),(0,j.jsx)(ne,{children:`Dashboard Not Found`}),(0,j.jsxs)(re,{children:[`The dashboard "`,t,`" could not be found. It may have been removed or renamed.`]})]})});let $=J||q;return(0,j.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,j.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,j.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,j.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:O(q.label,h)||q.name}),q.description&&(0,j.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:O(q.description,h)})]}),(0,j.jsxs)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:[v&&(0,j.jsx)(`div`,{className:`flex items-center gap-1 mr-2`,role:`toolbar`,"aria-label":`Add widgets`,"data-testid":`dashboard-widget-toolbar`,children:M.map(({type:e,label:t,Icon:n})=>(0,j.jsxs)(`button`,{type:`button`,"data-testid":`dashboard-add-${e}`,onClick:()=>de(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,j.jsx)(p,{className:`h-3 w-3`}),(0,j.jsx)(n,{className:`h-3 w-3`})]},e))}),(0,j.jsxs)(`button`,{type:`button`,onClick:ue,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,j.jsx)(S,{className:`h-3.5 w-3.5`}),`Edit`]})]})]}),(0,j.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,j.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-2 sm:p-4 md:p-6`,children:(0,j.jsx)(C,{schema:$,dataSource:e,designMode:v,selectedWidgetId:b,onWidgetClick:k,modalHandler:U,scriptHandlers:le})}),Q?(0,j.jsx)(T,{open:v,onClose:Z,config:ge,onSave:_e,onFieldChange:ve,availableObjects:ye,availableFields:be,headerExtra:(0,j.jsx)(l,{size:`sm`,variant:`ghost`,onClick:()=>fe(b),className:`h-7 w-7 p-0 text-destructive hover:text-destructive`,"data-testid":`widget-delete-button`,title:`Delete widget`,children:(0,j.jsx)(x,{className:`h-3.5 w-3.5`})})},b):(0,j.jsx)(w,{open:v,onClose:Z,config:pe,onSave:me,onFieldChange:he}),(0,j.jsx)(se,{open:n,sections:[{title:`Dashboard Configuration`,data:$}]})]}),B&&B.schema?.objectName?(0,j.jsx)(d,{schema:{type:`object-form`,formType:`modal`,objectName:B.schema.objectName,mode:B.schema.mode||`create`,recordId:B.schema.recordId,title:B.schema.title,description:B.schema.description,fields:B.schema.fields,open:!0,onOpenChange:e=>{e||H({success:!1})},onSuccess:e=>{H({success:!0,reload:!0,data:e})},onCancel:()=>{H({success:!1})},showSubmit:!0,showCancel:!0},dataSource:r}):B?(0,j.jsx)(u,{open:!0,onOpenChange:e=>{e||H({success:!1})},children:(0,j.jsxs)(s,{children:[(0,j.jsxs)(ie,{children:[(0,j.jsx)(o,{children:B.schema?.title||`Action`}),B.schema?.description&&(0,j.jsx)(te,{children:B.schema.description})]}),(0,j.jsxs)(c,{children:[(0,j.jsx)(l,{variant:`outline`,onClick:()=>H({success:!1}),children:`Cancel`}),(0,j.jsx)(l,{onClick:()=>H({success:!0}),children:`OK`})]})]})}):null]})}export{k as n,O as r,A as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{U as t,W as n}from"./framework-BW6KsEI0.js";import{$ as r,Aa as i,Oa as a,Or as o,Q as s,Vr as c,Z as l,cr as u,ct as d,dr as f,et as p,fr as m,gi as h,it as g,ln as _,lr as v,lt as y,mr as b,nt as x,st as S,tt as C,u as w,ur as T,ut as E}from"./plugins-core-Ccvbi6db.js";var D=e(n(),1),O=t(),k=(...e)=>e.filter(Boolean).join(` `);function A(e,t){if(!t||t.length===0)return{};for(let n of t){let t=e[n.field];if(t==null)continue;let r=!1,i=String(t);switch(n.operator){case`equals`:r=i===String(n.value);break;case`not_equals`:r=i!==String(n.value);break;case`contains`:r=i.toLowerCase().includes(String(n.value).toLowerCase());break;case`in`:r=Array.isArray(n.value)&&n.value.includes(i);break}if(r)return{...n.backgroundColor?{backgroundColor:n.backgroundColor}:{},...n.borderColor?{borderColor:n.borderColor}:{}}}return{}}function j({card:e,conditionalFormatting:t}){let{attributes:n,listeners:i,setNodeRef:a,transform:o,transition:s,isDragging:c}=r({id:e.id}),l={transform:E.Transform.toString(o),transition:s,opacity:c?.5:void 0},d=A(e,t);return(0,O.jsx)(`div`,{ref:a,style:l,...n,...i,children:(0,O.jsxs)(u,{className:`mb-2 cursor-grab active:cursor-grabbing border-border bg-card/60 hover:border-primary/40 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300 group`,style:d,children:[e.coverImage&&(0,O.jsx)(`div`,{className:`w-full h-32 overflow-hidden rounded-t-lg`,children:(0,O.jsx)(`img`,{src:e.coverImage,alt:``,className:`w-full h-full object-cover`,loading:`lazy`})}),(0,O.jsxs)(f,{className:`p-4`,children:[(0,O.jsx)(m,{className:`text-sm font-medium font-mono tracking-tight text-foreground group-hover:text-primary transition-colors`,children:e.title}),e.description&&(0,O.jsx)(T,{className:`text-xs text-muted-foreground font-mono`,children:e.description})]}),e.badges&&e.badges.length>0&&(0,O.jsx)(v,{className:`p-4 pt-0`,children:(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.badges.map((e,t)=>(0,O.jsx)(b,{variant:e.variant||`default`,className:`text-xs`,children:e.label},t))})})]})})}function M({cards:e,parentRef:t,conditionalFormatting:n}){let r=w({count:e.length,getScrollElement:()=>t.current,estimateSize:()=>120,overscan:5});return(0,O.jsx)(`div`,{style:{height:`${r.getTotalSize()}px`,width:`100%`,position:`relative`},children:r.getVirtualItems().map(t=>{let r=e[t.index];return(0,O.jsx)(`div`,{style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${t.start}px)`},children:(0,O.jsx)(j,{card:r,conditionalFormatting:n})},r.id)})})}function N({columnId:e,onAdd:t}){let[n,r]=D.useState(!1),[i,a]=D.useState(``),s=D.useRef(null),c=()=>{let n=i.trim();n&&(t(e,n),a(``)),r(!1)};return n?(0,O.jsx)(`div`,{className:`mt-2 space-y-2`,children:(0,O.jsx)(_,{ref:s,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),c()):e.key===`Escape`&&(a(``),r(!1))},onBlur:c,placeholder:`Enter card title...`,className:`text-sm`,autoFocus:!0})}):(0,O.jsxs)(o,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-muted-foreground hover:text-foreground`,onClick:()=>{r(!0),setTimeout(()=>s.current?.focus(),0)},children:[(0,O.jsx)(h,{className:`h-4 w-4 mr-1`}),`Add Card`]})}function P({column:e,cards:t,onToggle:n,enableVirtual:s,quickAdd:u,onQuickAdd:d,conditionalFormatting:f}){let m=t||[],h=D.useRef(null),{setNodeRef:g}=r({id:e.id,data:{type:`column`}}),_=e.limit&&m.length>=e.limit,v=e.limit&&m.length>=e.limit*.8;return(0,O.jsxs)(`div`,{ref:g,className:k(`flex flex-col flex-shrink-0 rounded-lg border border-border bg-card/20 backdrop-blur-sm shadow-xl transition-all`,e.collapsed?`w-16`:`w-80`,e.className),children:[(0,O.jsxs)(`div`,{className:`p-4 border-b border-border/50 bg-muted/20 flex items-center justify-between`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0`,children:[(0,O.jsx)(o,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0`,onClick:()=>n(!e.collapsed),children:e.collapsed?(0,O.jsx)(a,{className:`h-4 w-4`}):(0,O.jsx)(i,{className:`h-4 w-4`})}),!e.collapsed&&(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`h3`,{className:`font-mono text-sm font-semibold tracking-wider text-primary/90 uppercase truncate`,children:e.title}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(`span`,{className:k(`font-mono text-xs`,_?`text-destructive`:v?`text-yellow-500`:`text-muted-foreground`),children:[m.length,e.limit&&` / ${e.limit}`]}),_&&(0,O.jsx)(b,{variant:`destructive`,className:`text-xs`,children:`Full`}),v&&!_&&(0,O.jsx)(c,{className:`h-3 w-3 text-yellow-500`})]})]})]}),e.collapsed&&(0,O.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,O.jsx)(`span`,{className:`font-mono text-xs font-bold text-primary/90 [writing-mode:vertical-rl] rotate-180`,children:e.title}),(0,O.jsx)(b,{variant:`secondary`,className:`text-xs`,children:m.length})]})]}),!e.collapsed&&(0,O.jsxs)(`div`,{ref:h,className:`flex-1 p-4 overflow-y-auto`,style:{maxHeight:`600px`},children:[(0,O.jsx)(l,{items:m.map(e=>e.id),strategy:p,children:s?(0,O.jsx)(M,{cards:m,parentRef:h,conditionalFormatting:f}):(0,O.jsx)(`div`,{className:`space-y-2`,children:m.map(e=>(0,O.jsx)(j,{card:e,conditionalFormatting:f},e.id))})}),u&&d&&(0,O.jsx)(N,{columnId:e.id,onAdd:d})]})]})}function F({columns:e,onCardMove:t,onColumnToggle:n,enableVirtualScrolling:r=!1,virtualScrollThreshold:i=50,className:a,quickAdd:o,onQuickAdd:c,conditionalFormatting:l}){let[u,f]=D.useState(null),p=D.useMemo(()=>(e||[]).map(e=>({...e,cards:e.cards||[]})),[e]),[m,h]=D.useState(p);D.useEffect(()=>{h(p)},[p]);let _=y(d(g,{activationConstraint:{distance:8}})),v=e=>{let{active:t}=e;f(w(t.id))},b=e=>{let{active:n,over:r}=e;if(f(null),!r)return;let i=n.id,a=r.id;if(i===a)return;let o=T(i),c=T(a)||E(a);if(!(!o||!c))if(o.id===c.id){let e=[...o.cards],t=s(e,e.findIndex(e=>e.id===i),e.findIndex(e=>e.id===a));h(e=>e.map(e=>e.id===o.id?{...e,cards:t}:e))}else{let e=[...o.cards],n=[...c.cards],r=e.findIndex(e=>e.id===i),s=a===c.id?n.length:n.findIndex(e=>e.id===a),[l]=e.splice(r,1);n.splice(s,0,l),h(t=>t.map(t=>t.id===o.id?{...t,cards:e}:t.id===c.id?{...t,cards:n}:t)),t&&t(i,o.id,c.id,s)}},w=D.useCallback(e=>{for(let t of m){let n=t.cards.find(t=>t.id===e);if(n)return n}return null},[m]),T=D.useCallback(e=>m.find(t=>t.cards.some(t=>t.id===e))||null,[m]),E=D.useCallback(e=>m.find(t=>t.id===e)||null,[m]),A=D.useCallback((e,t)=>{h(n=>n.map(n=>n.id===e?{...n,collapsed:t}:n)),n?.(e,t)},[n]);return(0,O.jsxs)(C,{sensors:_,collisionDetection:S,onDragStart:v,onDragEnd:b,children:[(0,O.jsx)(`div`,{className:k(`flex gap-4 overflow-x-auto p-4`,a),children:m.map(e=>{let t=r&&e.cards.length>i;return(0,O.jsx)(P,{column:e,cards:e.cards,onToggle:t=>A(e.id,t),enableVirtual:t,quickAdd:o,onQuickAdd:c,conditionalFormatting:l},e.id)})}),(0,O.jsx)(x,{children:u?(0,O.jsx)(j,{card:u,conditionalFormatting:l}):null})]})}export{F as KanbanEnhanced,F as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{U as t,W as n,g as r,h as i}from"./framework-BW6KsEI0.js";import{$ as a,Or as o,Q as s,Z as c,an as l,at as u,cr as d,ct as f,dr as p,et as m,fr as h,gi as g,it as _,ln as v,lr as y,lt as b,mr as x,nt as S,st as C,tt as w,ur as T,ut as E}from"./plugins-core-Ccvbi6db.js";var D=e(n(),1),O=t(),k=(...e)=>e.filter(Boolean).join(` `),A=`Uncategorized`;function j(e,t){if(!t||t.length===0)return{};for(let n of t){let t=e[n.field];if(t==null)continue;let r=!1,i=String(t);switch(n.operator){case`equals`:r=i===String(n.value);break;case`not_equals`:r=i!==String(n.value);break;case`contains`:r=i.toLowerCase().includes(String(n.value).toLowerCase());break;case`in`:r=Array.isArray(n.value)&&n.value.includes(i);break}if(r)return{...n.backgroundColor?{backgroundColor:n.backgroundColor}:{},...n.borderColor?{borderColor:n.borderColor}:{}}}return{}}function M({card:e,onCardClick:t,conditionalFormatting:n}){let{attributes:r,listeners:i,setNodeRef:o,transform:s,transition:c,isDragging:l}=a({id:e.id}),u={transform:E.Transform.toString(s),transition:c,opacity:l?.5:void 0},f=j(e,n);return(0,O.jsx)(`div`,{ref:o,style:u,...r,...i,role:`listitem`,"aria-label":e.title,onClick:()=>t?.(e),children:(0,O.jsxs)(d,{className:`mb-2 cursor-grab active:cursor-grabbing border-border border-l-4 border-l-primary/40 bg-card/60 hover:border-primary/40 hover:shadow-lg hover:shadow-primary/10 transition-all duration-300 group touch-manipulation`,style:f,children:[e.coverImage&&(0,O.jsx)(`div`,{className:`w-full h-32 overflow-hidden rounded-t-lg`,children:(0,O.jsx)(`img`,{src:e.coverImage,alt:``,className:`w-full h-full object-cover`,loading:`lazy`})}),(0,O.jsxs)(p,{className:`p-2 sm:p-4`,children:[(0,O.jsx)(h,{className:`text-xs sm:text-sm font-medium font-mono tracking-tight text-foreground group-hover:text-primary transition-colors`,children:e.title}),e.description&&(0,O.jsx)(T,{className:`text-xs text-muted-foreground font-mono line-clamp-2 sm:line-clamp-none`,children:e.description})]}),e.badges&&e.badges.length>0&&(0,O.jsx)(y,{className:`p-2 sm:p-4 pt-0`,children:(0,O.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.badges.map((e,t)=>(0,O.jsx)(x,{variant:e.variant||`default`,className:`text-xs`,children:e.label},t))})})]})})}function N({columnId:e,onAdd:t}){let[n,r]=D.useState(!1),[i,a]=D.useState(``),s=D.useRef(null),c=()=>{let n=i.trim();n&&(t(e,n),a(``)),r(!1)};return n?(0,O.jsx)(`div`,{className:`mt-2 space-y-2`,children:(0,O.jsx)(v,{ref:s,value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),c()):e.key===`Escape`&&(a(``),r(!1))},onBlur:c,placeholder:`Enter card title...`,className:`text-sm`,autoFocus:!0})}):(0,O.jsxs)(o,{variant:`ghost`,size:`sm`,className:`w-full mt-2 text-muted-foreground hover:text-foreground`,onClick:()=>{r(!0),setTimeout(()=>s.current?.focus(),0)},children:[(0,O.jsx)(g,{className:`h-4 w-4 mr-1`}),`Add Card`]})}function P({column:e,cards:t,onCardClick:n,quickAdd:r,onQuickAdd:i,conditionalFormatting:o}){let s=t||[],{setNodeRef:u}=a({id:e.id,data:{type:`column`}}),d=e.limit&&s.length>=e.limit;return(0,O.jsxs)(`div`,{ref:u,role:`group`,"aria-label":e.title,className:k(`flex flex-col w-[85vw] sm:w-80 flex-shrink-0 rounded-lg border border-border bg-card/20 backdrop-blur-sm shadow-xl snap-start`,e.className),children:[(0,O.jsx)(`div`,{className:`p-3 sm:p-4 border-b border-border/50 bg-muted/30 rounded-t-lg`,children:(0,O.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,O.jsx)(`h3`,{id:`kanban-col-${e.id}`,className:`font-mono text-xs sm:text-sm font-semibold tracking-wider text-primary/90 uppercase truncate`,children:e.title}),(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsxs)(x,{variant:`secondary`,className:`text-xs font-mono tabular-nums`,children:[s.length,e.limit&&` / ${e.limit}`]}),d&&(0,O.jsx)(x,{variant:`destructive`,className:`text-xs`,children:`Full`})]})]})}),(0,O.jsxs)(l,{className:`flex-1 p-4`,children:[(0,O.jsx)(c,{items:s.map(e=>e.id),strategy:m,children:(0,O.jsxs)(`div`,{className:`space-y-2`,role:`list`,"aria-label":`${e.title} cards`,children:[s.length===0&&(0,O.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground/50`,children:(0,O.jsx)(`span`,{className:`text-xs font-mono`,children:`No cards`})}),s.map(e=>(0,O.jsx)(M,{card:e,onCardClick:n,conditionalFormatting:o},e.id))]})}),r&&i&&(0,O.jsx)(N,{columnId:e.id,onAdd:i})]})]})}function F({children:e}){return(0,O.jsx)(O.Fragment,{children:e(i())})}function I({columns:e,onCardMove:t,onCardClick:n,className:i,quickAdd:a,onQuickAdd:o,coverImageField:s,conditionalFormatting:c,swimlaneField:l}){return r()?(0,O.jsx)(F,{children:r=>(0,O.jsx)(L,{columns:e,onCardMove:t,onCardClick:n,className:i,dnd:r,quickAdd:a,onQuickAdd:o,coverImageField:s,conditionalFormatting:c,swimlaneField:l})}):(0,O.jsx)(L,{columns:e,onCardMove:t,onCardClick:n,className:i,dnd:null,quickAdd:a,onQuickAdd:o,coverImageField:s,conditionalFormatting:c,swimlaneField:l})}function L({columns:e,onCardMove:t,onCardClick:n,className:r,dnd:i,quickAdd:a,onQuickAdd:o,coverImageField:l,conditionalFormatting:d,swimlaneField:p}){let[h,g]=D.useState(null),v=p?`objectui:kanban-collapsed:${p}`:null,[y,x]=D.useState(()=>{if(!v)return new Set;try{let e=localStorage.getItem(v);if(e){let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}}catch{}return new Set}),T=D.useMemo(()=>(e||[]).map(e=>({...e,cards:e.cards||[]})),[e]),[E,j]=D.useState(T);D.useEffect(()=>{j(T)},[T]);let N=D.useMemo(()=>{if(!p)return null;let e=E.flatMap(e=>e.cards),t=new Set;return e.forEach(e=>{let n=e[p];t.add(n==null?A:String(n))}),Array.from(t).sort()},[E,p]),F=D.useCallback(e=>{x(t=>{let n=new Set(t);if(n.has(e)?n.delete(e):n.add(e),v)try{localStorage.setItem(v,JSON.stringify([...n]))}catch{}return n})},[v]),I=b(f(_,{activationConstraint:{distance:5}}),f(u,{activationConstraint:{delay:200,tolerance:5}})),L=e=>{let{active:t}=e,n=z(t.id);if(g(n),i&&n){let e=B(n.id);e&&i.startDrag({id:n.id,type:`kanban-card`,data:n,sourceId:e.id})}},R=e=>{let{active:n,over:r}=e;if(g(null),!r){i&&i.endDrag();return}let a=n.id,o=r.id;if(a===o){i&&i.endDrag();return}let c=B(a),l=B(o)||V(o);if(!c||!l){i&&i.endDrag();return}if(c.id===l.id){let e=[...c.cards],t=s(e,e.findIndex(e=>e.id===a),e.findIndex(e=>e.id===o));j(e=>e.map(e=>e.id===c.id?{...e,cards:t}:e))}else{let e=[...c.cards],n=[...l.cards],r=e.findIndex(e=>e.id===a),i=o===l.id?n.length:n.findIndex(e=>e.id===o),[s]=e.splice(r,1);n.splice(i,0,s),j(t=>t.map(t=>t.id===c.id?{...t,cards:e}:t.id===l.id?{...t,cards:n}:t)),t&&t(a,c.id,l.id,i)}i&&i.endDrag(l.id)},z=D.useCallback(e=>{for(let t of E){let n=t.cards.find(t=>t.id===e);if(n)return n}return null},[E]),B=D.useCallback(e=>E.find(t=>t.cards.some(t=>t.id===e))||null,[E]),V=D.useCallback(e=>E.find(t=>t.id===e)||null,[E]);return(0,O.jsxs)(w,{sensors:I,collisionDetection:C,onDragStart:L,onDragEnd:R,children:[(0,O.jsxs)(`div`,{className:`flex sm:hidden items-center justify-between px-3 pb-2 text-xs text-muted-foreground`,children:[(0,O.jsxs)(`span`,{children:[E.length,` columns`]}),(0,O.jsx)(`span`,{children:`← Swipe to navigate →`})]}),N?(0,O.jsxs)(`div`,{className:k(`flex flex-col gap-1 p-2 sm:p-4 min-w-0 overflow-hidden`,r),role:`region`,"aria-label":`Kanban board with swimlanes`,children:[(0,O.jsx)(`div`,{className:`flex gap-3 sm:gap-4 pl-36 sm:pl-44 overflow-x-auto`,children:E.map(e=>(0,O.jsxs)(`div`,{className:`w-[85vw] sm:w-80 flex-shrink-0 text-center`,children:[(0,O.jsx)(`span`,{className:`font-mono text-xs sm:text-sm font-semibold tracking-wider text-primary/90 uppercase`,children:e.title}),(0,O.jsxs)(`span`,{className:`ml-2 font-mono text-xs text-muted-foreground`,children:[`(`,e.cards.length,`)`]})]},e.id))}),N.map(e=>{let t=y.has(e),r=E.reduce((t,n)=>t+n.cards.filter(t=>(t[p]==null?A:String(t[p]))===e).length,0);return(0,O.jsxs)(`div`,{className:`border rounded-lg bg-muted/10`,children:[(0,O.jsxs)(`button`,{className:`w-full flex items-center gap-2 px-3 py-2 text-left hover:bg-muted/30 transition-colors`,onClick:()=>F(e),"aria-expanded":!t,children:[(0,O.jsx)(`span`,{className:k(`transition-transform text-xs`,t?``:`rotate-90`),children:`▶`}),(0,O.jsx)(`span`,{className:`font-mono text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e}),(0,O.jsxs)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:[`(`,r,`)`]})]}),!t&&(0,O.jsx)(`div`,{className:`flex gap-3 sm:gap-4 overflow-x-auto px-2 pb-3 pl-36 sm:pl-44`,children:E.map(t=>{let r=t.cards.filter(t=>(t[p]==null?A:String(t[p]))===e);return(0,O.jsx)(`div`,{className:`w-[85vw] sm:w-80 flex-shrink-0 min-h-[60px] rounded-md bg-card/20 p-2`,children:(0,O.jsx)(c,{items:r.map(e=>e.id),strategy:m,children:(0,O.jsx)(`div`,{className:`space-y-2`,role:`list`,"aria-label":`${t.title} - ${e} cards`,children:r.map(e=>(0,O.jsx)(M,{card:e,onCardClick:n,conditionalFormatting:d},e.id))})})},t.id)})})]},e)})]}):(0,O.jsx)(`div`,{className:k(`flex gap-3 sm:gap-4 overflow-x-auto snap-x snap-mandatory p-2 sm:p-4 bg-muted/10 rounded-lg [-webkit-overflow-scrolling:touch] min-w-0`,r),role:`region`,"aria-label":`Kanban board`,children:E.map(e=>(0,O.jsx)(P,{column:e,cards:e.cards,onCardClick:n,quickAdd:a,onQuickAdd:o,conditionalFormatting:d},e.id))}),(0,O.jsx)(S,{children:(0,O.jsx)(`div`,{"aria-live":`assertive`,"aria-label":h?`Dragging ${h.title}`:void 0,children:h?(0,O.jsx)(M,{card:h,conditionalFormatting:d}):null})})]})}export{I as default};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-S-ySWqyJ.js";import{U as e,W as t}from"./framework-BW6KsEI0.js";import{a as n,i as r,o as i,s as a}from"./index-DATdOX6r.js";var o=[`ariaDescribedBy`,`ariaLabel`,`ariaLabelledBy`],s={ancestors:{tbody:[`table`],td:[`table`],th:[`table`],thead:[`table`],tfoot:[`table`],tr:[`table`]},attributes:{a:[...o,`dataFootnoteBackref`,`dataFootnoteRef`,[`className`,`data-footnote-backref`],`href`],blockquote:[`cite`],code:[[`className`,/^language-./]],del:[`cite`],div:[`itemScope`,`itemType`],dl:[...o],h2:[[`className`,`sr-only`]],img:[...o,`longDesc`,`src`],input:[[`disabled`,!0],[`type`,`checkbox`]],ins:[`cite`],li:[[`className`,`task-list-item`]],ol:[...o,[`className`,`contains-task-list`]],q:[`cite`],section:[`dataFootnotes`,[`className`,`footnotes`]],source:[`srcSet`],summary:[...o],table:[...o],ul:[...o,[`className`,`contains-task-list`]],"*":`abbr.accept.acceptCharset.accessKey.action.align.alt.axis.border.cellPadding.cellSpacing.char.charOff.charSet.checked.clear.colSpan.color.cols.compact.coords.dateTime.dir.encType.frame.hSpace.headers.height.hrefLang.htmlFor.id.isMap.itemProp.label.lang.maxLength.media.method.multiple.name.noHref.noShade.noWrap.open.prompt.readOnly.rev.rowSpan.rows.rules.scope.selected.shape.size.span.start.summary.tabIndex.title.useMap.vAlign.value.width`.split(`.`)},clobber:[`ariaDescribedBy`,`ariaLabelledBy`,`id`,`name`],clobberPrefix:`user-content-`,protocols:{cite:[`http`,`https`],href:[`http`,`https`,`irc`,`ircs`,`mailto`,`xmpp`],longDesc:[`http`,`https`],src:[`http`,`https`]},required:{input:{disabled:!0,type:`checkbox`}},strip:[`script`],tagNames:`a.b.blockquote.br.code.dd.del.details.div.dl.dt.em.h1.h2.h3.h4.h5.h6.hr.i.img.input.ins.kbd.li.ol.p.picture.pre.q.rp.rt.ruby.s.samp.section.source.span.strike.strong.sub.summary.sup.table.tbody.td.tfoot.th.thead.tr.tt.ul.var`.split(`.`)},c={}.hasOwnProperty;function l(e,t){let n={type:`root`,children:[]},r=u({schema:t?{...s,...t}:s,stack:[]},e);return r&&(Array.isArray(r)?r.length===1?n=r[0]:n.children=r:n=r),n}function u(e,t){if(t&&typeof t==`object`){let n=t;switch(typeof n.type==`string`?n.type:``){case`comment`:return d(e,n);case`doctype`:return f(e,n);case`element`:return p(e,n);case`root`:return m(e,n);case`text`:return h(e,n);default:}}}function d(e,t){if(e.schema.allowComments){let e=typeof t.value==`string`?t.value:``,n=e.indexOf(`-->`),r={type:`comment`,value:n<0?e:e.slice(0,n)};return S(r,t),r}}function f(e,t){if(e.schema.allowDoctypes){let e={type:`doctype`};return S(e,t),e}}function p(e,t){let n=typeof t.tagName==`string`?t.tagName:``;e.stack.push(n);let r=g(e,t.children),i=_(e,t.properties);e.stack.pop();let a=!1;if(n&&n!==`*`&&(!e.schema.tagNames||e.schema.tagNames.includes(n))&&(a=!0,e.schema.ancestors&&c.call(e.schema.ancestors,n))){let t=e.schema.ancestors[n],r=-1;for(a=!1;++r<t.length;)e.stack.includes(t[r])&&(a=!0)}if(!a)return e.schema.strip&&!e.schema.strip.includes(n)?r:void 0;let o={type:`element`,tagName:n,properties:i,children:r};return S(o,t),o}function m(e,t){let n={type:`root`,children:g(e,t.children)};return S(n,t),n}function h(e,t){let n={type:`text`,value:typeof t.value==`string`?t.value:``};return S(n,t),n}function g(e,t){let n=[];if(Array.isArray(t)){let r=t,i=-1;for(;++i<r.length;){let t=u(e,r[i]);t&&(Array.isArray(t)?n.push(...t):n.push(t))}}return n}function _(e,t){let n=e.stack[e.stack.length-1],r=e.schema.attributes,i=e.schema.required,a=r&&c.call(r,n)?r[n]:void 0,o=r&&c.call(r,`*`)?r[`*`]:void 0,s=t&&typeof t==`object`?t:{},l={},u;for(u in s)if(c.call(s,u)){let t=s[u],n=v(e,C(a,u),u,t);n??=v(e,C(o,u),u,t),n!=null&&(l[u]=n)}if(i&&c.call(i,n)){let e=i[n];for(u in e)c.call(e,u)&&!c.call(l,u)&&(l[u]=e[u])}return l}function v(e,t,n,r){return t?Array.isArray(r)?y(e,t,n,r):b(e,t,n,r):void 0}function y(e,t,n,r){let i=-1,a=[];for(;++i<r.length;){let o=b(e,t,n,r[i]);(typeof o==`number`||typeof o==`string`)&&a.push(o)}return a}function b(e,t,n,r){if(!(typeof r!=`boolean`&&typeof r!=`number`&&typeof r!=`string`)&&x(e,n,r)){if(typeof t==`object`&&t.length>1){let e=!1,n=0;for(;++n<t.length;){let i=t[n];if(i&&typeof i==`object`&&`flags`in i){if(i.test(String(r))){e=!0;break}}else if(i===r){e=!0;break}}if(!e)return}return e.schema.clobber&&e.schema.clobberPrefix&&e.schema.clobber.includes(n)?e.schema.clobberPrefix+r:r}}function x(e,t,n){let r=e.schema.protocols&&c.call(e.schema.protocols,t)?e.schema.protocols[t]:void 0;if(!r||r.length===0)return!0;let i=String(n),a=i.indexOf(`:`),o=i.indexOf(`?`),s=i.indexOf(`#`),l=i.indexOf(`/`);if(a<0||l>-1&&a>l||o>-1&&a>o||s>-1&&a>s)return!0;let u=-1;for(;++u<r.length;){let e=r[u];if(a===e.length&&i.slice(0,e.length)===e)return!0}return!1}function S(e,t){let n=a(t);t.data&&(e.data=i(t.data)),n&&(e.position=n)}function C(e,t){let n,r=-1;if(e)for(;++r<e.length;){let i=e[r],a=typeof i==`string`?i:i[0];if(a===t)return i;a===`data*`&&(n=i)}if(t.length>4&&t.slice(0,4).toLowerCase()===`data`)return n}function w(e){return function(t){return l(t,e)}}t();var T=e();function E({content:e,className:t}){return(0,T.jsx)(`div`,{"data-slot":`markdown`,className:((...e)=>e.filter(Boolean).join(` `))(`prose prose-sm dark:prose-invert max-w-none`,`prose-headings:font-semibold prose-headings:tracking-tight`,`prose-h1:text-3xl prose-h2:text-2xl prose-h3:text-xl`,`prose-p:leading-relaxed prose-p:text-foreground`,`prose-a:text-primary prose-a:no-underline hover:prose-a:underline`,`prose-code:text-foreground prose-code:bg-muted prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:before:content-none prose-code:after:content-none`,`prose-pre:bg-muted prose-pre:text-foreground prose-pre:border`,`prose-blockquote:border-l-primary prose-blockquote:text-muted-foreground`,`prose-strong:text-foreground prose-strong:font-semibold`,`prose-ul:list-disc prose-ol:list-decimal`,`prose-li:text-foreground prose-li:marker:text-muted-foreground`,`prose-table:border prose-th:border prose-th:bg-muted prose-td:border`,`prose-img:rounded-md prose-img:border`,t),children:(0,T.jsx)(n,{remarkPlugins:[r],rehypePlugins:[w],disallowedElements:[`script`,`style`,`iframe`,`object`,`embed`],unwrapDisallowed:!0,children:e})})}export{E as default};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{O as t,U as n,W as r,m as i}from"./framework-BW6KsEI0.js";import{Hi as a,Ka as o,Or as s,Vr as c,cr as l,dr as u,eo as d,fr as f,lr as p,mr as m,xi as h}from"./plugins-core-Ccvbi6db.js";import{d as g,p as _}from"./ui-layout-CYz0tyDf.js";import{c as v}from"./infrastructure-94fpO8jL.js";import{r as y}from"./index-DATdOX6r.js";import{i as b,n as x,t as S}from"./getIcon-N5xWCMJy.js";import{t as C}from"./MetadataFormDialog-Cy7k0Y55.js";var w=e(r(),1),T=n(),E=class extends w.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[MetadataDetailPage] Schema rendering error:`,e,t.componentStack)}render(){return this.state.hasError?(0,T.jsxs)(`div`,{className:`rounded-lg border border-destructive/50 bg-destructive/5 p-6 text-center`,"data-testid":`schema-render-error`,children:[(0,T.jsx)(c,{className:`h-8 w-8 mx-auto mb-3 text-destructive`}),(0,T.jsxs)(`p`,{className:`text-sm font-medium text-destructive`,children:[`Failed to render `,this.props.fallbackLabel||`detail`,` page`]}),(0,T.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:this.state.error?.message||`An unexpected error occurred.`})]}):this.props.children}};function D({schema:e}){let n=e.body||[];return n.length===0?null:(0,T.jsx)(`div`,{className:`flex flex-col gap-6`,"data-testid":`schema-detail-content`,children:n.map((e,n)=>(0,T.jsx)(t,{schema:e},e?.id||n))})}function O(){let e=g(),{appName:t,metadataType:n,itemName:r}=_(),c=t?`/apps/${t}`:``,O=y(),{refresh:k}=i(),{user:A}=v(),j=A?.role===`admin`,M=n?b(n):void 0,[N,P]=(0,w.useState)(null),[F,I]=(0,w.useState)(!0),[L,R]=(0,w.useState)(!1),[z,B]=(0,w.useState)(!1),V=(0,w.useCallback)(async()=>{if(!(!O||!n||!r)){I(!0);try{P((await O.getItems(n)).find(e=>String(e.name)===r&&!e._deleted)??null)}catch{d.error(`Failed to load ${M?.label??n}`)}finally{I(!1)}}},[O,n,r,M?.label]);(0,w.useEffect)(()=>{V()},[V]);let H=(0,w.useCallback)(async e=>{if(!(!O||!n||!r)){B(!0);try{let t={...N,...e};await O.saveMetadataItem(n,r,t),await k(),await V(),d.success(`${M?.label??`Item`} "${r}" updated`)}catch{throw d.error(`Failed to update "${r}"`),Error(`Failed to save ${M?.label??`item`} "${r}"`)}finally{B(!1)}}},[O,n,r,N,M?.label,k,V]),U=M?.customRoute?`${c}${M.customRoute}`:`${c}/system/metadata/${n??``}`;if(!M)return(0,T.jsx)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,"data-testid":`metadata-detail-page`,children:(0,T.jsxs)(`div`,{className:`text-center text-muted-foreground py-12`,children:[(0,T.jsxs)(`p`,{className:`text-lg font-medium`,children:[`Unknown metadata type: `,n]}),(0,T.jsx)(s,{variant:`outline`,className:`mt-4`,onClick:()=>e(`${c}/system`),children:`Back to System Settings`})]})});if(M.pageSchemaFactory){let t=M.pageSchemaFactory(r,N),n=S(M.icon);return(0,T.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,"data-testid":`metadata-detail-page`,children:[(0,T.jsx)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:(0,T.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,T.jsx)(s,{variant:`ghost`,size:`icon`,onClick:()=>e(U),"data-testid":`back-to-list-btn`,children:(0,T.jsx)(o,{className:`h-4 w-4`})}),(0,T.jsx)(`div`,{className:`bg-primary/10 p-2 rounded-md shrink-0`,children:(0,T.jsx)(n,{className:`h-5 w-5 text-primary`})}),(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:t.title||r}),(0,T.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:[M.label,` · `,(0,T.jsx)(`span`,{className:`font-mono text-xs`,children:r})]})]})]})}),(0,T.jsx)(E,{fallbackLabel:M.label,children:(0,T.jsx)(D,{schema:t})})]})}let W=S(M.icon),G=M.editable!==!1&&j,K=M.formFields??x,q=M.detailComponent;return(0,T.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,"data-testid":`metadata-detail-page`,children:[(0,T.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,T.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,T.jsx)(s,{variant:`ghost`,size:`icon`,onClick:()=>e(U),"data-testid":`back-to-list-btn`,children:(0,T.jsx)(o,{className:`h-4 w-4`})}),(0,T.jsx)(`div`,{className:`bg-primary/10 p-2 rounded-md shrink-0`,children:(0,T.jsx)(W,{className:`h-5 w-5 text-primary`})}),(0,T.jsxs)(`div`,{className:`min-w-0`,children:[(0,T.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:F?`Loading...`:String(N?.label??N?.name??r)}),(0,T.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:[M.label,` Details`]})]})]}),G&&!F&&N&&(0,T.jsxs)(s,{variant:`outline`,onClick:()=>R(!0),disabled:z,"data-testid":`detail-edit-btn`,children:[(0,T.jsx)(h,{className:`mr-2 h-4 w-4`}),`Edit`]})]}),F&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,"data-testid":`detail-loading`,children:[(0,T.jsx)(a,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),`Loading...`]}),!F&&!N&&(0,T.jsxs)(`div`,{className:`text-center text-muted-foreground py-12`,"data-testid":`detail-not-found`,children:[(0,T.jsxs)(`p`,{className:`text-lg font-medium`,children:[M.label,` "`,r,`" not found.`]}),(0,T.jsxs)(s,{variant:`outline`,className:`mt-4`,onClick:()=>e(U),children:[`Back to `,M.pluralLabel]})]}),!F&&N&&(0,T.jsx)(T.Fragment,{children:q?(0,T.jsx)(q,{item:N}):(0,T.jsxs)(l,{"data-testid":`detail-card`,children:[(0,T.jsx)(u,{children:(0,T.jsxs)(f,{className:`flex items-center gap-2`,children:[(0,T.jsx)(m,{variant:`secondary`,children:M.label}),String(N.name??``)]})}),(0,T.jsx)(p,{children:(0,T.jsx)(`dl`,{className:`grid gap-3 sm:grid-cols-2`,children:K.map(e=>(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`dt`,{className:`text-sm font-medium text-muted-foreground`,children:e.label}),(0,T.jsx)(`dd`,{className:`mt-1 text-sm`,children:String(N[e.key]??`—`)})]},e.key))})})]})}),G&&N&&(0,T.jsx)(C,{open:L,onOpenChange:R,mode:`edit`,typeLabel:M.label,formFields:M.formFields,initialValues:N,onSubmit:H})]})}export{O as MetadataDetailPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{U as t,W as n}from"./framework-BW6KsEI0.js";import{An as r,Dn as i,Dt as a,En as o,Hi as s,On as c,Or as l,St as u,Tn as d,kn as f,ln as p,un as m}from"./plugins-core-Ccvbi6db.js";import{n as h}from"./getIcon-N5xWCMJy.js";var g=e(n(),1),_=t();function v({open:e,onOpenChange:t,mode:n,typeLabel:v,formFields:y,initialValues:b,onSubmit:x}){let S=y??h,C=n===`edit`,[w,T]=(0,g.useState)({}),[E,D]=(0,g.useState)(!1);(0,g.useEffect)(()=>{if(e){let e={};for(let t of S)e[t.key]=String(b?.[t.key]??``);T(e)}},[e,b,S]);let O=(0,g.useCallback)((e,t)=>{T(n=>({...n,[e]:t}))},[]),k=(0,g.useCallback)(async()=>{D(!0);try{await x(w),t(!1)}catch{}finally{D(!1)}},[w,x,t]),A=S.filter(e=>e.required).every(e=>(w[e.key]??``).trim().length>0);return(0,_.jsx)(d,{open:e,onOpenChange:t,children:(0,_.jsxs)(o,{className:`sm:max-w-[480px]`,"data-testid":`metadata-form-dialog`,children:[(0,_.jsxs)(f,{children:[(0,_.jsx)(r,{children:C?`Edit ${v}`:`New ${v}`}),(0,_.jsx)(i,{children:C?`Update the ${v.toLowerCase()} details below.`:`Fill in the details to create a new ${v.toLowerCase()}.`})]}),(0,_.jsx)(`div`,{className:`space-y-4 py-4`,children:S.map(e=>{let t=E||C&&e.disabledOnEdit===!0,n=w[e.key]??``,r=`metadata-field-${e.key}`;return(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsxs)(m,{htmlFor:r,children:[e.label,e.required&&(0,_.jsx)(`span`,{className:`text-destructive ml-1`,"aria-hidden":`true`,children:`*`})]}),e.type===`textarea`?(0,_.jsx)(u,{id:r,value:n,onChange:t=>O(e.key,t.target.value),placeholder:e.placeholder,disabled:t,"data-testid":`metadata-field-${e.key}`}):e.type===`select`&&e.options?(0,_.jsxs)(`select`,{id:r,value:n,onChange:t=>O(e.key,t.target.value),disabled:t,"aria-required":e.required?!0:void 0,className:`flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,"data-testid":`metadata-field-${e.key}`,children:[(0,_.jsx)(`option`,{value:``,children:`Select...`}),e.options.map(e=>(0,_.jsx)(`option`,{value:e.value,children:e.label},e.value))]}):e.type===`number`?(0,_.jsx)(p,{id:r,type:`number`,value:n,onChange:t=>O(e.key,t.target.value),placeholder:e.placeholder,disabled:t,"data-testid":`metadata-field-${e.key}`}):e.type===`boolean`?(0,_.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,_.jsx)(a,{id:r,checked:n===`true`,onCheckedChange:t=>O(e.key,String(t)),disabled:t,"data-testid":`metadata-field-${e.key}`}),(0,_.jsx)(m,{htmlFor:r,className:`text-sm text-muted-foreground cursor-pointer`,children:n===`true`?`Yes`:`No`})]}):(0,_.jsx)(p,{id:r,value:n,onChange:t=>O(e.key,t.target.value),placeholder:e.placeholder,disabled:t,"data-testid":`metadata-field-${e.key}`})]},e.key)})}),(0,_.jsxs)(c,{children:[(0,_.jsx)(l,{variant:`outline`,onClick:()=>t(!1),disabled:E,"data-testid":`metadata-form-cancel-btn`,children:`Cancel`}),(0,_.jsxs)(l,{onClick:k,disabled:E||!A,"data-testid":`metadata-form-submit-btn`,children:[E&&(0,_.jsx)(s,{className:`mr-2 h-4 w-4 animate-spin`}),C?`Save`:`Create`]})]})]})})}export{v as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{P as t,U as n,W as r}from"./framework-BW6KsEI0.js";import{Or as i}from"./plugins-core-Ccvbi6db.js";import{$ as a,Q as o,U as s,W as c,Z as l}from"./vendor-icons-CrSf7tAH.js";var u=e(r(),1),d=n();function f({open:e,onToggle:t,className:n}){return(0,d.jsxs)(i,{size:`sm`,variant:e?`secondary`:`outline`,onClick:t,className:`shadow-none gap-2 ${n||``}`,title:`Toggle Metadata Inspector`,children:[(0,d.jsx)(c,{className:`h-4 w-4`}),(0,d.jsx)(`span`,{className:`hidden lg:inline`,children:`Metadata`})]})}function p({sections:e,open:t}){if(!t)return null;let[n,r]=(0,u.useState)([`0`]),[i,c]=(0,u.useState)(null),f=async(e,t)=>{try{await navigator.clipboard.writeText(JSON.stringify(e,null,2)),c(t),setTimeout(()=>c(null),2e3)}catch(e){console.error(`Failed to copy:`,e)}},p=e=>{r(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:`Metadata Inspector`}),(0,d.jsx)(`span`,{className:`text-[10px] text-muted-foreground/60`,children:`JSON`})]}),(0,d.jsx)(`div`,{className:`flex-1 overflow-auto`,children:e.map((e,t)=>{let r=String(t),c=n.includes(r),u=i===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:()=>p(r),className:`flex-1 flex items-center justify-between text-left`,children:[(0,d.jsx)(`h4`,{className:`text-xs font-semibold text-foreground`,children:e.title}),c?(0,d.jsx)(o,{className:`h-3 w-3 text-muted-foreground ml-2`}):(0,d.jsx)(l,{className:`h-3 w-3 text-muted-foreground ml-2`})]}),(0,d.jsx)(`button`,{onClick:()=>f(e.data,t),className:`p-1 hover:bg-muted rounded transition-colors ml-2`,title:`Copy JSON`,children:u?(0,d.jsx)(a,{className:`h-3 w-3 text-green-600`}):(0,d.jsx)(s,{className:`h-3 w-3 text-muted-foreground`})})]}),c&&(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 m(){let[e,n]=(0,u.useState)((0,u.useMemo)(()=>{try{return typeof window<`u`?t(window.location.search).enabled:!1}catch{return!1}},[]));return{showDebug:e,toggleDebug:()=>n(e=>!e)}}export{f as n,m as r,p as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{U as t,W as n,m as r}from"./framework-BW6KsEI0.js";import{Hi as i,Ka as a,Or as o,Ur as s,cr as c,eo as l,gi as u,li as d,ln as f,lr as p,mr as m,xi as h}from"./plugins-core-Ccvbi6db.js";import{d as ee,p as te}from"./ui-layout-CYz0tyDf.js";import{c as ne}from"./infrastructure-94fpO8jL.js";import{r as re}from"./index-DATdOX6r.js";import{i as g,t as _}from"./getIcon-N5xWCMJy.js";import{t as ie}from"./MetadataFormDialog-Cy7k0Y55.js";var v=e(n(),1),y=t();function ae({items:e,columns:t,editable:n=!1,saving:r=!1,deletingName:i=null,typeLabel:a=`item`,rowActions:c=[],onItemClick:l,onEdit:u,onDelete:d}){return(0,y.jsx)(`div`,{className:`rounded-lg border bg-card`,"data-testid":`metadata-grid`,children:(0,y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,y.jsxs)(`table`,{className:`w-full text-sm`,"aria-label":`${a} list`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{className:`border-b bg-muted/50`,children:[t.map(e=>(0,y.jsx)(`th`,{className:`px-4 py-3 text-left font-medium text-muted-foreground`,style:e.width?{width:e.width}:void 0,children:e.label},e.key)),n&&(0,y.jsx)(`th`,{className:`px-4 py-3 text-right font-medium text-muted-foreground w-24`,children:`Actions`})]})}),(0,y.jsx)(`tbody`,{children:e.map(e=>{let f=String(e.name??``);return(0,y.jsxs)(`tr`,{className:`border-b last:border-0 hover:bg-accent/50 cursor-pointer transition-colors`,"data-testid":`metadata-item-${f}`,onClick:()=>l?.(f),children:[t.map(t=>{let n=String(e[t.key]??`—`);return(0,y.jsx)(`td`,{className:`px-4 py-3 truncate max-w-[200px]`,title:n,children:n},t.key)}),n&&(0,y.jsx)(`td`,{className:`px-4 py-3 text-right`,children:(0,y.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[c.map(t=>(0,y.jsx)(o,{variant:t.variant??`ghost`,size:`icon`,title:t.label,"aria-label":t.label,onClick:n=>{n.stopPropagation(),t.handler?.(e)},"data-testid":`row-action-${t.key}-${f}`,children:(0,y.jsx)(`span`,{className:`text-xs`,children:t.label.charAt(0)})},t.key)),(0,y.jsx)(o,{variant:`ghost`,size:`icon`,title:`Edit ${a}`,onClick:t=>{t.stopPropagation(),u?.(e)},disabled:r,"data-testid":`edit-${f}-btn`,children:(0,y.jsx)(h,{className:`h-4 w-4`})}),(0,y.jsx)(o,{variant:`ghost`,size:`icon`,title:i===f?`Click again to confirm`:`Delete ${a}`,onClick:e=>{e.stopPropagation(),d?.(f)},disabled:r,"data-testid":`delete-${f}-btn`,children:(0,y.jsx)(s,{className:`h-4 w-4 ${i===f?`text-destructive`:``}`})})]})})]},f)})})]})})})}function b(){let e=ee(),{appName:t,metadataType:n}=te(),b=t?`/apps/${t}`:``,x=re(),{refresh:S}=r(),{user:C}=ne(),w=C?.role===`admin`,T=n?g(n):void 0,[E,D]=(0,v.useState)([]),[O,k]=(0,v.useState)(!0),[A,j]=(0,v.useState)(``),[M,N]=(0,v.useState)(!1),[P,F]=(0,v.useState)(null),[oe,I]=(0,v.useState)(!1),[L,R]=(0,v.useState)(`create`),[z,B]=(0,v.useState)(null),V=(0,v.useCallback)(async()=>{if(!(!x||!n)){k(!0);try{D((await x.getItems(n)).filter(e=>!e._deleted))}catch{l.error(`Failed to load ${T?.pluralLabel??n}`)}finally{k(!1)}}},[x,n,T?.pluralLabel]);(0,v.useEffect)(()=>{V()},[V]);let H=(0,v.useMemo)(()=>{if(!A.trim())return E;let e=A.toLowerCase();return E.filter(t=>{let n=String(t.name??``).toLowerCase(),r=String(t.label??``).toLowerCase();return n.includes(e)||r.includes(e)})},[E,A]),U=(0,v.useCallback)(async e=>{if(!(!x||!n))if(P===e){N(!0);try{await x.deleteMetadataItem(n,e),D(t=>t.filter(t=>t.name!==e)),await S(),l.success(`${T?.label??`Item`} "${e}" deleted`)}catch{l.error(`Failed to delete "${e}"`)}finally{N(!1),F(null)}}else F(e)},[x,n,P,T?.label,S]),W=(0,v.useCallback)(()=>{B(null),R(`create`),I(!0)},[]),G=(0,v.useCallback)(e=>{B(e),R(`edit`),I(!0)},[]),K=(0,v.useCallback)(async e=>{if(!x||!n)return;let t=e.name??String(z?.name??``);if(t){N(!0);try{let r=L===`edit`?{...z,...e}:{...e};await x.saveMetadataItem(n,t,r),await S(),await V(),l.success(L===`edit`?`${T?.label??`Item`} "${t}" updated`:`${T?.label??`Item`} "${t}" created`)}catch{throw l.error(L===`edit`?`Failed to update "${t}"`:`Failed to create "${t}"`),Error(`Failed to save ${T?.label??`item`} "${t}"`)}finally{N(!1)}}},[x,n,z,L,T?.label,S,V]);if(!T)return(0,y.jsx)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,"data-testid":`metadata-manager-page`,children:(0,y.jsxs)(`div`,{className:`text-center text-muted-foreground py-12`,children:[(0,y.jsxs)(`p`,{className:`text-lg font-medium`,children:[`Unknown metadata type: `,n]}),(0,y.jsx)(o,{variant:`outline`,className:`mt-4`,onClick:()=>e(`${b}/system`),children:`Back to System Settings`})]})});let q=_(T.icon),J=T.editable!==!1&&w,Y=T.listComponent;if(Y)return(0,y.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,"data-testid":`metadata-manager-page`,children:[(0,y.jsx)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:(0,y.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,y.jsx)(o,{variant:`ghost`,size:`icon`,onClick:()=>e(`${b}/system`),"data-testid":`back-to-hub-btn`,children:(0,y.jsx)(a,{className:`h-4 w-4`})}),(0,y.jsx)(`div`,{className:`bg-primary/10 p-2 rounded-md shrink-0`,children:(0,y.jsx)(q,{className:`h-5 w-5 text-primary`})}),(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:T.pluralLabel}),(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:T.description})]})]})}),(0,y.jsx)(Y,{config:T,basePath:b,metadataType:n,isAdmin:w})]});let X=(T.actions??[]).filter(e=>e.scope===`page`),Z=(T.actions??[]).filter(e=>e.scope===`row`),Q=T.listMode??`card`,$=Q===`grid`||Q===`table`,se=T.columns??[{key:`name`,label:`Name`},{key:`label`,label:`Label`}];return(0,y.jsxs)(`div`,{className:`flex flex-col gap-4 p-4 sm:p-6`,"data-testid":`metadata-manager-page`,children:[(0,y.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center justify-between gap-3`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[(0,y.jsx)(o,{variant:`ghost`,size:`icon`,onClick:()=>e(`${b}/system`),"data-testid":`back-to-hub-btn`,children:(0,y.jsx)(a,{className:`h-4 w-4`})}),(0,y.jsx)(`div`,{className:`bg-primary/10 p-2 rounded-md shrink-0`,children:(0,y.jsx)(q,{className:`h-5 w-5 text-primary`})}),(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:T.pluralLabel}),(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:T.description})]})]}),J&&(0,y.jsxs)(o,{onClick:W,"data-testid":`create-metadata-btn`,children:[(0,y.jsx)(u,{className:`mr-2 h-4 w-4`}),`New `,T.label]}),X.length>0&&(0,y.jsx)(`div`,{className:`flex items-center gap-2`,children:X.map(e=>(0,y.jsx)(o,{variant:e.variant??`outline`,onClick:()=>e.handler?.(),"data-testid":`page-action-${e.key}`,children:e.label},e.key))})]}),(0,y.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start sm:items-center gap-2`,children:[(0,y.jsxs)(`div`,{className:`relative flex-1 max-w-sm`,children:[(0,y.jsxs)(`label`,{htmlFor:`metadata-search`,className:`sr-only`,children:[`Search `,T.pluralLabel.toLowerCase()]}),(0,y.jsx)(d,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`}),(0,y.jsx)(f,{id:`metadata-search`,placeholder:`Search ${T.pluralLabel.toLowerCase()}...`,value:A,onChange:e=>j(e.target.value),className:`pl-8`,"data-testid":`metadata-search-input`})]}),(0,y.jsxs)(m,{variant:`secondary`,"data-testid":`metadata-count-badge`,children:[H.length,` `,T.pluralLabel.toLowerCase()]})]}),O&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,"data-testid":`metadata-loading`,children:[(0,y.jsx)(i,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),`Loading `,T.pluralLabel.toLowerCase(),`...`]}),M&&(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,"data-testid":`metadata-saving`,children:[(0,y.jsx)(i,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),`Saving...`]}),!O&&H.length===0&&(0,y.jsx)(`div`,{className:`text-center text-muted-foreground py-12`,"data-testid":`metadata-empty`,children:(0,y.jsxs)(`p`,{children:[`No `,T.pluralLabel.toLowerCase(),` found.`]})}),!O&&H.length>0&&!$&&(0,y.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:H.map(t=>{let r=String(t.name??``),i=String(t.label??t.name??``),a=String(t.description??``);return(0,y.jsx)(c,{className:`transition-colors hover:bg-accent/50 cursor-pointer`,"data-testid":`metadata-item-${r}`,onClick:()=>e(`${b}/system/metadata/${n}/${r}`),children:(0,y.jsxs)(p,{className:`flex items-center justify-between p-4`,children:[(0,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`p`,{className:`font-medium truncate`,children:i}),(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:r}),a&&(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1 truncate`,children:a})]}),J&&(0,y.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0 ml-2`,children:[Z.map(e=>(0,y.jsx)(o,{variant:e.variant??`ghost`,size:`icon`,title:e.label,onClick:n=>{n.stopPropagation(),e.handler?.(t)},"data-testid":`row-action-${e.key}-${r}`,children:(0,y.jsx)(`span`,{className:`text-xs`,children:e.label.charAt(0)})},e.key)),(0,y.jsx)(o,{variant:`ghost`,size:`icon`,title:`Edit ${T.label.toLowerCase()}`,onClick:e=>{e.stopPropagation(),G(t)},disabled:M,"data-testid":`edit-${r}-btn`,children:(0,y.jsx)(h,{className:`h-4 w-4`})}),(0,y.jsx)(o,{variant:`ghost`,size:`icon`,title:P===r?`Click again to confirm`:`Delete ${T.label.toLowerCase()}`,onClick:e=>{e.stopPropagation(),U(r)},disabled:M,"data-testid":`delete-${r}-btn`,children:(0,y.jsx)(s,{className:`h-4 w-4 ${P===r?`text-destructive`:``}`})})]})]})},r)})}),!O&&H.length>0&&$&&(0,y.jsx)(ae,{items:H,columns:se,editable:J,saving:M,deletingName:P,typeLabel:T.label.toLowerCase(),rowActions:Z,onItemClick:t=>e(`${b}/system/metadata/${n}/${t}`),onEdit:G,onDelete:U}),J&&(0,y.jsx)(ie,{open:oe,onOpenChange:I,mode:L,typeLabel:T.label,formFields:T.formFields,initialValues:z??void 0,onSubmit:K})]})}export{b as MetadataManagerPage};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{U as t,W as n,f as r}from"./framework-BW6KsEI0.js";var i=e(n(),1),a=t(),o=300*1e3,s=[`app`],c={apps:`app`,objects:`object`,dashboards:`dashboard`,reports:`report`,pages:`page`},l=`objectui:metadata:`;function u(){try{let e=import.meta;if(e&&e.env&&typeof e.env.MODE==`string`)return e.env.MODE!==`production`}catch{}return!1}var d=u();function f(...e){d&&console.debug(`[MetadataProvider]`,...e)}function p(e){return e&&typeof e==`object`&&`items`in e&&Array.isArray(e.items)?e.items:[]}function m(e){return e==null?null:typeof e==`object`&&`item`in e?e.item??null:e}function h(e){return!!e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`}function g(){return{status:`idle`,items:[],byName:new Map,error:null,fetchedAt:0,promise:null}}function _(e){if(typeof sessionStorage>`u`)return null;try{let t=sessionStorage.getItem(l+e);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n:null}catch{return null}}function v(e,t){if(!(typeof sessionStorage>`u`))try{sessionStorage.setItem(l+e,JSON.stringify(t))}catch{}}function y({children:e,adapter:t,ttlMs:n=o}){let l=(0,i.useRef)(new Map),u=(0,i.useRef)(new Map),d=(0,i.useRef)(t);d.current=t;let[y,b]=(0,i.useState)(0),x=(0,i.useCallback)(()=>{typeof queueMicrotask==`function`?queueMicrotask(()=>b(e=>e+1)):Promise.resolve().then(()=>b(e=>e+1))},[]),S=(0,i.useCallback)(e=>{let t=l.current.get(e);return t||(t=g(),l.current.set(e,t)),t},[]),C=(0,i.useCallback)(e=>{let t=S(e);if(t.promise)return t.promise;if(t.status===`ready`&&Date.now()-t.fetchedAt<n)return f(`cache hit (fresh) type=${e} items=${t.items.length}`),Promise.resolve(t.items);let r=Date.now();t.status=`loading`,t.error=null;let i=d.current.getClient().meta.getItems(e).then(n=>{let i=p(n);t.items=i,t.status=`ready`,t.error=null,t.fetchedAt=Date.now(),t.promise=null,t.byName.clear();for(let e of i)h(e)&&t.byName.set(e.name,e);return e===`app`&&v(e,i),f(`fetched type=${e} items=${i.length} in ${Date.now()-r}ms`),x(),i}).catch(n=>{let r=n instanceof Error?n:Error(String(n));return t.status=`error`,t.error=r,t.promise=null,f(`fetch failed type=${e}`,r),x(),[]});return t.promise=i,i},[x,S,n]),w=(0,i.useCallback)((e,t)=>{let n=S(e);if(n.byName.has(t))return f(`item cache hit type=${e} name=${t}`),Promise.resolve(n.byName.get(t)??null);let r=u.current.get(e);r||(r=new Map,u.current.set(e,r));let i=r.get(t);if(i)return i;let a=Date.now(),o=d.current.getClient().meta.getItem(e,t).then(i=>{let o=m(i);return o&&n.byName.set(t,o),f(`fetched item type=${e} name=${t} in ${Date.now()-a}ms`),r.delete(t),o}).catch(n=>(r.delete(t),f(`fetch item failed type=${e} name=${t}`,n),null));return r.set(t,o),o},[S]),T=(0,i.useCallback)(async e=>{if(e){let t=S(e);t.fetchedAt=0,t.byName.clear(),await C(e);return}let t=Array.from(l.current.keys()).filter(e=>l.current.get(e).status!==`idle`);await Promise.all(t.map(e=>{let t=l.current.get(e);return t.fetchedAt=0,t.byName.clear(),C(e)}))},[C,S]),E=(0,i.useCallback)((e,t)=>{let n=l.current.get(e);n&&(t?(n.byName.delete(t),n.items=n.items.filter(e=>e?.name!==t),f(`invalidated type=${e} name=${t}`)):(n.status=`idle`,n.items=[],n.byName.clear(),n.error=null,n.fetchedAt=0,f(`invalidated type=${e}`)),x())},[x]),[D,O]=(0,i.useState)(!0),[k,A]=(0,i.useState)(null);(0,i.useEffect)(()=>{let e=!1,t=_(`app`);if(t){let e=S(`app`);e.items=t,e.status=`ready`,e.fetchedAt=0;for(let n of t)h(n)&&e.byName.set(n.name,n);x(),O(!1)}return(async()=>{for(let t of s)try{await C(t),e||A(null)}catch(t){e||A(t instanceof Error?t:Error(String(t)))}e||O(!1)})(),()=>{e=!0}},[t,C,S,x]);let j=(0,i.useMemo)(()=>{let e=e=>{let t=S(e);return t.status===`idle`&&C(e),t.items};return{apps:S(`app`).items,get objects(){return e(c.objects)},get dashboards(){return e(c.dashboards)},get reports(){return e(c.reports)},get pages(){return e(c.pages)},loading:D,error:k??S(`app`).error,refresh:T,invalidate:E,ensureType:C,getItem:w,getItemsByType:t=>e(t)}},[y,D,k,C,w,S,T,E]);return(0,a.jsx)(r.Provider,{value:j,children:e})}export{y as t};
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/src-BGoL_8qF.js","assets/rolldown-runtime-S-ySWqyJ.js","assets/plugins-core-Ccvbi6db.js","assets/data-adapter-v22lWuhc.js","assets/infrastructure-94fpO8jL.js","assets/framework-BW6KsEI0.js","assets/plugins-core-B5ROGaJH.css","assets/ui-layout-CYz0tyDf.js"])))=>i.map(i=>d[i]);
2
+ import{n as e,r as t}from"./rolldown-runtime-S-ySWqyJ.js";import{O as n,U as r,W as i,m as a,p as o}from"./framework-BW6KsEI0.js";import{Jt as s,Xt as c,Yt as l,Zt as u,eo as d,gt as f,ht as p,mt as m,qt as h}from"./plugins-core-Ccvbi6db.js";import{C as g}from"./data-adapter-v22lWuhc.js";import{m as _,p as v}from"./ui-layout-CYz0tyDf.js";import"./AdapterProvider-Cd4HYb7q.js";import"./MetadataProvider-Dvc9BxbC.js";import{B as y,w as b}from"./vendor-icons-CrSf7tAH.js";import{r as x,t as S}from"./MetadataInspector-DVtCDQtx.js";var C=t(i(),1),w=r();function T({open:e,onOpenChange:t,title:n,description:r,schema:i,onSchemaChange:a,collection:f,recordName:p,children:m}){let g=o(),_=(0,C.useRef)(i);_.current=i;let v=(0,C.useCallback)(async e=>{try{if(g)return await g.update(f,p,e),!0}catch(e){console.warn(`[DesignDrawer] Auto-save failed:`,e)}return!1},[g,f,p]),y=(0,C.useCallback)(async e=>{a(e),await v(e)},[a,v]);return(0,C.useEffect)(()=>{if(!e)return;let t=e=>{(e.ctrlKey||e.metaKey)&&e.key===`s`&&(e.preventDefault(),v(_.current).then(e=>{e&&d.success(`${n} saved`)}))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,v,n]),(0,w.jsx)(h,{open:e,onOpenChange:t,modal:!1,children:(0,w.jsxs)(s,{side:`right`,hideOverlay:!0,className:`w-full sm:w-[540px] sm:max-w-[540px] lg:w-[640px] lg:max-w-[640px] p-0 flex flex-col`,"data-testid":`design-drawer`,children:[(0,w.jsxs)(c,{className:`px-4 py-3 border-b shrink-0`,children:[(0,w.jsx)(u,{children:n}),(0,w.jsx)(l,{className:r?``:`sr-only`,children:r||`Visual editor — configure and preview ${n}`})]}),(0,w.jsx)(`div`,{className:`flex-1 overflow-auto p-4`,children:m(i,y)})]})})}var E=e({PageView:()=>O}),D=(0,C.lazy)(()=>g(()=>import(`./src-BGoL_8qF.js`).then(e=>e.t).then(e=>({default:e.PageCanvasEditor})),__vite__mapDeps([0,1,2,3,4,5,6,7])));function O(){let{pageName:e}=v(),[t]=_(),{showDebug:r}=x(),[i,o]=(0,C.useState)(!1),{pages:s}=a(),c=s?.find(t=>t.name===e),[l,u]=(0,C.useState)(null),d=(0,C.useCallback)(()=>{u(c),o(!0)},[c]),h=(0,C.useCallback)(e=>{o(e)},[]);if(!c)return(0,w.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,w.jsxs)(m,{children:[(0,w.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,w.jsx)(y,{className:`h-6 w-6 text-muted-foreground`})}),(0,w.jsx)(f,{children:`Page Not Found`}),(0,w.jsxs)(p,{children:[`The page "`,e,`" could not be found. It may have been removed or renamed.`]})]})});let g=Object.fromEntries(t.entries()),E=i&&l?l:c;return(0,w.jsxs)(`div`,{className:`flex flex-row h-full w-full overflow-hidden relative`,children:[(0,w.jsxs)(`div`,{className:`flex-1 overflow-auto h-full relative group`,children:[(0,w.jsx)(`div`,{className:`absolute top-1.5 sm:top-2 right-1.5 sm:right-2 z-50 flex items-center gap-1.5 transition-opacity ${r?`opacity-100`:`opacity-0 group-hover:opacity-100`}`,children:(0,w.jsxs)(`button`,{type:`button`,onClick:d,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":`page-edit-button`,children:[(0,w.jsx)(b,{className:`h-3.5 w-3.5`}),`Edit`]})}),(0,w.jsx)(n,{schema:{...E,type:E.type||`page`,context:{...E.context,params:g}}})]}),(0,w.jsx)(S,{open:r,sections:[{title:`Page Configuration`,data:E}]}),(0,w.jsx)(T,{open:i,onOpenChange:h,title:`Edit Page: ${c.label||c.title||e}`,schema:l||c,onSchemaChange:u,collection:`sys_page`,recordName:e,children:(e,t)=>(0,w.jsx)(C.Suspense,{fallback:(0,w.jsx)(`div`,{className:`p-4 text-muted-foreground`,children:`Loading editor…`}),children:(0,w.jsx)(D,{schema:e,onChange:t})})})]})}export{E as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{U as t,W as n}from"./framework-BW6KsEI0.js";import{Ea as r,Lr as i,Or as a,Ta as o,Vi as s,_r as c,cr as l,dr as u,fr as d,gr as f,hr as p,ln as m,lr as h,mr as g,un as _,ur as v,vr as y,yr as b}from"./plugins-core-Ccvbi6db.js";import{c as x,r as S}from"./infrastructure-94fpO8jL.js";var C=e(n(),1),w=t();function T(){let{user:e,updateUser:t,isLoading:n}=x(),[T,E]=(0,C.useState)(e?.name??``),[D,O]=(0,C.useState)(!1),[k,A]=(0,C.useState)(null);return e?(0,w.jsxs)(`div`,{className:`flex flex-col gap-4 sm:gap-6 p-4 sm:p-6 max-w-2xl`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`Profile`}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage your account settings`})]}),(0,w.jsx)(l,{children:(0,w.jsx)(h,{className:`pt-6`,children:(0,w.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,w.jsxs)(p,{className:`h-16 w-16`,children:[(0,w.jsx)(c,{src:e.image??void 0,alt:e.name??`User`}),(0,w.jsx)(f,{className:`text-lg bg-primary text-primary-foreground`,children:S(e)})]}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`p`,{className:`text-lg font-semibold truncate`,children:e.name??`User`}),(0,w.jsx)(`p`,{className:`text-sm text-muted-foreground truncate`,children:e.email}),(0,w.jsx)(g,{variant:`secondary`,className:`mt-1`,children:e.role??`member`})]})]})})}),(0,w.jsxs)(l,{children:[(0,w.jsxs)(u,{children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(i,{className:`h-4 w-4 text-muted-foreground`}),(0,w.jsx)(d,{className:`text-base sm:text-lg`,children:`Personal Information`})]}),(0,w.jsx)(v,{children:`Update your name and view account details`})]}),(0,w.jsx)(h,{children:(0,w.jsxs)(`form`,{onSubmit:async e=>{e.preventDefault(),A(null),O(!1);try{await t({name:T}),O(!0)}catch(e){A(e instanceof Error?e.message:String(e))}},className:`space-y-4`,children:[k&&(0,w.jsxs)(y,{variant:`destructive`,children:[(0,w.jsx)(r,{className:`h-4 w-4`}),(0,w.jsx)(b,{children:k})]}),D&&(0,w.jsxs)(y,{children:[(0,w.jsx)(o,{className:`h-4 w-4 text-green-600`}),(0,w.jsx)(b,{className:`text-green-800 dark:text-green-400`,children:`Profile updated successfully.`})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(_,{htmlFor:`profile-name`,children:`Name`}),(0,w.jsx)(m,{id:`profile-name`,type:`text`,value:T,onChange:e=>E(e.target.value),required:!0,"aria-required":`true`,disabled:n})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(_,{htmlFor:`profile-email`,children:`Email`}),(0,w.jsx)(m,{id:`profile-email`,type:`email`,value:e.email,disabled:!0,className:`bg-muted text-muted-foreground`}),(0,w.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Email cannot be changed.`})]}),(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(_,{children:`Role`}),(0,w.jsx)(m,{type:`text`,value:e.role??`member`,disabled:!0,className:`bg-muted text-muted-foreground`})]}),(0,w.jsx)(a,{type:`submit`,disabled:n,className:`w-full sm:w-auto`,children:n?`Saving...`:`Save Changes`})]})})]}),(0,w.jsx)(l,{children:(0,w.jsxs)(u,{children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(s,{className:`h-4 w-4 text-muted-foreground`}),(0,w.jsx)(d,{className:`text-base sm:text-lg`,children:`Change Password`})]}),(0,w.jsx)(v,{children:`To change your password, use the password reset flow from the login page.`})]})})]}):null}export{T as ProfilePage};
@@ -0,0 +1 @@
1
+ import{n as e,r as t}from"./rolldown-runtime-S-ySWqyJ.js";import{U as n,W as r,_ as i,a}from"./framework-BW6KsEI0.js";import{An as o,Cr as s,Dn as c,Dr as l,En as u,Er as d,On as f,Or as p,Sr as m,St as h,Tn as g,Tr as _,br as v,en as y,eo as b,gt as x,ht as S,in as C,kn as w,ln as T,mt as E,nn as D,rn as O,tn as k,un as A,wr as j,xr as M}from"./plugins-core-Ccvbi6db.js";import{d as ee,p as te}from"./ui-layout-CYz0tyDf.js";import{c as ne,u as re}from"./infrastructure-94fpO8jL.js";import{H as ie,a as ae}from"./vendor-icons-CrSf7tAH.js";import{o as oe,s as se}from"./plugins-views-CbLIJkBs.js";import{r as ce,t as N}from"./MetadataInspector-DVtCDQtx.js";import{t as P}from"./skeletons-CIQE_YYE.js";var F=t(r(),1),I=n(),L=(0,F.createContext)(void 0);function R({children:e}){let[t,n]=(0,F.useState)(`home`),[r,i]=(0,F.useState)(),[a,o]=(0,F.useState)(),s=(0,F.useMemo)(()=>({context:t,setContext:n,currentAppName:r,setCurrentAppName:i,recordTitle:a,setRecordTitle:o}),[t,r,a]);return(0,I.jsx)(L.Provider,{value:s,children:e})}function z(){return(0,F.useContext)(L)||{context:`app`,setContext:()=>{},currentAppName:void 0,setCurrentAppName:()=>{},recordTitle:void 0,setRecordTitle:()=>{}}}function le(e){let{setRecordTitle:t}=z();(0,F.useEffect)(()=>(t(e),()=>t(void 0)),[e,t])}function B(e){let{url:t,channel:n,autoReconnect:r=!0,reconnectInterval:i=1e3,maxReconnectAttempts:a=10,authToken:o}=e,[s,c]=(0,F.useState)(`disconnected`),[l,u]=(0,F.useState)(null),[d,f]=(0,F.useState)([]),[p,m]=(0,F.useState)(null),h=(0,F.useRef)(null),g=(0,F.useRef)(0),_=(0,F.useRef)(null),v=(0,F.useRef)(new Map),y=(0,F.useRef)([]),b=(0,F.useRef)(!0),x=(0,F.useRef)(!1),S=(0,F.useCallback)(()=>{_.current!==null&&(clearTimeout(_.current),_.current=null)},[]),C=(0,F.useCallback)(e=>{for(;y.current.length>0;){let t=y.current.shift(),r={type:t.type,channel:n,data:t.data,timestamp:new Date().toISOString()};e.send(JSON.stringify(r))}},[n]),w=(0,F.useCallback)(()=>{if(typeof WebSocket>`u`){m(Error(`WebSocket is not available in this environment`)),c(`error`);return}if(!t){m(Error(`WebSocket URL is required`)),c(`error`);return}try{let e=new URL(t);if(e.protocol!==`ws:`&&e.protocol!==`wss:`){m(Error(`WebSocket URL must use ws: or wss: protocol`)),c(`error`);return}}catch{m(Error(`Invalid WebSocket URL`)),c(`error`);return}h.current&&=(x.current=!0,h.current.close(),null),x.current=!1,c(`connecting`),m(null);let e=o?`${t}?token=${encodeURIComponent(o)}&channel=${encodeURIComponent(n)}`:`${t}?channel=${encodeURIComponent(n)}`,s;try{s=new WebSocket(e)}catch(e){if(!b.current)return;m(e instanceof Error?e:Error(`Failed to create WebSocket connection`)),c(`error`);return}h.current=s,s.onopen=()=>{b.current&&(c(`connected`),m(null),g.current=0,C(s))},s.onmessage=e=>{if(b.current)try{let t=JSON.parse(String(e.data));if(t.channel!==n)return;u(t),f(e=>[...e,t]);let r=v.current.get(t.type);r&&r.forEach(e=>e(t.data))}catch{}},s.onerror=()=>{b.current&&(m(Error(`WebSocket connection error`)),c(`error`))},s.onclose=()=>{if(b.current){if(h.current=null,x.current){c(`disconnected`);return}if(r&&g.current<a){c(`reconnecting`);let e=Math.min(i*2**g.current,3e4);g.current+=1,_.current=setTimeout(()=>{b.current&&w()},e)}else c(`disconnected`)}}},[t,n,o,r,i,a,C]),T=(0,F.useCallback)(()=>{S(),x.current=!0,g.current=0,h.current&&=(h.current.close(),null),c(`disconnected`)},[S]),E=(0,F.useCallback)(()=>{S(),g.current=0,w()},[w,S]),D=(0,F.useCallback)((e,t)=>{let r=h.current;if(r&&r.readyState===WebSocket.OPEN){let i={type:e,channel:n,data:t,timestamp:new Date().toISOString()};r.send(JSON.stringify(i))}else y.current.push({type:e,data:t})},[n]),O=(0,F.useCallback)((e,t)=>(v.current.has(e)||v.current.set(e,new Set),v.current.get(e).add(t),()=>{let n=v.current.get(e);n&&(n.delete(t),n.size===0&&v.current.delete(e))}),[]);return(0,F.useEffect)(()=>(b.current=!0,t&&w(),()=>{b.current=!1,S(),x.current=!0,h.current&&=(h.current.close(),null)}),[t,n,o]),{connectionState:s,isConnected:s===`connected`,lastMessage:l,messages:d,send:D,subscribe:O,disconnect:T,reconnect:E,error:p}}var V=0;function H(){return V+=1,`conflict-${Date.now()}-${V}`}var U=0;function W(){return U+=1,`ver-${Date.now()}-${U}`}function G(e,t,n){let[r,i]=(0,F.useState)([]),[a,o]=(0,F.useState)([]);return{versions:r,currentVersion:(0,F.useMemo)(()=>r.length===0?0:r[r.length-1].version,[r]),conflicts:a,hasConflicts:a.length>0,recordVersion:(0,F.useCallback)((n,r)=>{i(i=>{let a=i.length===0?1:i[i.length-1].version+1,o={id:W(),version:a,timestamp:new Date().toISOString(),userId:e,userName:t,changes:n,message:r};return[...i,o]})},[e,t]),resolveConflict:(0,F.useCallback)((n,r,a)=>{o(o=>{let s=o.find(e=>e.id===n);if(!s)return o;let c;switch(r){case`local`:c=s.localValue;break;case`remote`:c=s.remoteValue;break;case`merge`:c=a??s.localValue;break}return i(n=>{let i=n.length===0?1:n[n.length-1].version+1,a={id:W(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:{[s.field]:{before:s.baseValue,after:c}},message:`Resolved conflict on "${s.field}" using ${r} strategy`};return[...n,a]}),o.filter(e=>e.id!==n)})},[e,t]),resolveAllConflicts:(0,F.useCallback)(n=>{o(r=>{if(r.length===0)return r;let a={};for(let e of r)a[e.field]={before:e.baseValue,after:n===`local`?e.localValue:e.remoteValue};return i(r=>{let i=r.length===0?1:r[r.length-1].version+1,o={id:W(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:a,message:`Resolved all conflicts using ${n} strategy`};return[...r,o]}),[]})},[e,t]),revertToVersion:(0,F.useCallback)(n=>{let a=r.findIndex(e=>e.id===n);if(a===-1)return null;let o={};for(let e=0;e<=a;e++){let t=r[e];for(let[e,n]of Object.entries(t.changes))o[e]=n.after}let s={},c={};for(let e of r)for(let[t,n]of Object.entries(e.changes))c[t]=n.after;for(let[e,t]of Object.entries(o))c[e]!==t&&(s[e]={before:c[e],after:t});return Object.keys(s).length>0&&i(n=>{let i=n.length===0?1:n[n.length-1].version+1,o={id:W(),version:i,timestamp:new Date().toISOString(),userId:e,userName:t,changes:s,message:`Reverted to version ${r[a].version}`};return[...n,o]}),o},[r,e,t]),compareVersions:(0,F.useCallback)((e,t)=>{let n=r.findIndex(t=>t.id===e),i=r.findIndex(e=>e.id===t);if(n===-1||i===-1)return null;let[a,o]=n<i?[n,i]:[i,n],s=e=>{let t={};for(let n=0;n<=e;n++)for(let[e,i]of Object.entries(r[n].changes))t[e]=i.after;return t},c=s(a),l=s(o),u=new Set([...Object.keys(c),...Object.keys(l)]),d={};for(let e of u){let t=c[e],n=l[e];t!==n&&(d[e]={before:t,after:n})}return d},[r]),addConflict:(0,F.useCallback)(e=>{let t={...e,id:H()};o(e=>[...e,t])},[]),clearHistory:(0,F.useCallback)(()=>{i([]),o([])},[])}}var K={sm:24,md:32,lg:40},q={active:`#22c55e`,idle:`#f59e0b`,away:`#94a3b8`};function J(e){return e.split(` `).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}function Y({users:e,maxVisible:t=5,size:n=`md`,showStatus:r=!0,className:i}){let a=K[n],o=Math.round(a*.3),s=Math.round(a*.35),c=Math.max(8,Math.round(a*.28)),l=(0,F.useMemo)(()=>e.slice(0,t),[e,t]),u=Math.max(0,e.length-t),d={display:`inline-flex`,alignItems:`center`,flexDirection:`row-reverse`,fontFamily:`-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`},f={width:`${a}px`,height:`${a}px`,borderRadius:`50%`,border:`2px solid #fff`,display:`flex`,alignItems:`center`,justifyContent:`center`,fontSize:`${s}px`,fontWeight:600,color:`#fff`,position:`relative`,flexShrink:0,overflow:`hidden`,boxSizing:`border-box`},p={...f,backgroundColor:`#e2e8f0`,color:`#475569`,marginLeft:`-${o}px`},m={position:`absolute`,bottom:`-1px`,right:`-1px`,width:`${c}px`,height:`${c}px`,borderRadius:`50%`,border:`2px solid #fff`,boxSizing:`border-box`},h=(0,F.useMemo)(()=>[...l].reverse(),[l]);return F.createElement(`div`,{style:d,className:i,role:`group`,"aria-label":`${e.length} user${e.length===1?``:`s`} present`},u>0&&F.createElement(`div`,{key:`overflow`,style:p,title:`${u} more user${u===1?``:`s`}`},`+${u}`),h.map((e,t)=>F.createElement(`div`,{key:e.userId,style:{...f,backgroundColor:e.color,marginLeft:t>0||u>0?`-${o}px`:`0`},title:`${e.userName} (${e.status})`},e.avatar?F.createElement(`img`,{src:e.avatar,alt:e.userName,style:{width:`100%`,height:`100%`,objectFit:`cover`}}):J(e.userName),r&&F.createElement(`span`,{style:{...m,backgroundColor:q[e.status]}}))))}function X({state:e,onOpenChange:t}){let n=()=>{e.resolve?.(!0),t(!1)},r=()=>{e.resolve?.(!1),t(!1)};return(0,I.jsx)(v,{open:e.open,onOpenChange:e=>{e||r()},children:(0,I.jsxs)(s,{children:[(0,I.jsxs)(d,{children:[(0,I.jsx)(l,{children:e.options?.title||`Confirm Action`}),(0,I.jsx)(j,{children:e.message})]}),(0,I.jsxs)(_,{children:[(0,I.jsx)(m,{onClick:r,children:e.options?.cancelText||`Cancel`}),(0,I.jsx)(M,{onClick:n,children:e.options?.confirmText||`Continue`})]})]})})}function Z({state:e,onOpenChange:t}){let[n,r]=(0,F.useState)({}),[i,a]=(0,F.useState)({});(0,F.useEffect)(()=>{if(e.open){let t={};for(let n of e.params)n.defaultValue!==void 0&&(t[n.name]=n.defaultValue);r(t),a({})}},[e.open,e.params]);let s=e=>e==null?!0:typeof e==`string`?e.trim()===``:Array.isArray(e)?e.length===0:!1,l=()=>{let r={};for(let t of e.params)t.required&&s(n[t.name])&&(r[t.name]=!0);if(Object.keys(r).length>0){a(r);return}e.resolve?.(n),t(!1)},d=()=>{e.resolve?.(null),t(!1)},m=(e,t)=>{r(n=>({...n,[e]:t})),a(t=>({...t,[e]:!1}))};return(0,I.jsx)(g,{open:e.open,onOpenChange:e=>{e||d()},children:(0,I.jsxs)(u,{children:[(0,I.jsxs)(w,{children:[(0,I.jsx)(o,{children:`Action Parameters`}),(0,I.jsx)(c,{children:`Please provide the required information to continue.`})]}),(0,I.jsx)(`div`,{className:`grid gap-4 py-4`,children:e.params.map(e=>(0,I.jsxs)(`div`,{className:`grid gap-2`,children:[(0,I.jsxs)(A,{htmlFor:e.name,children:[e.label,e.required&&(0,I.jsx)(`span`,{className:`text-destructive ml-1`,children:`*`})]}),e.type===`select`&&e.options?(0,I.jsxs)(y,{value:n[e.name]??``,onValueChange:t=>m(e.name,t),children:[(0,I.jsx)(O,{id:e.name,className:i[e.name]?`border-destructive`:``,children:(0,I.jsx)(C,{placeholder:e.placeholder||`Select ${e.label}`})}),(0,I.jsx)(k,{children:e.options.map(e=>(0,I.jsx)(D,{value:e.value,children:e.label},e.value))})]}):e.type===`textarea`?(0,I.jsx)(h,{id:e.name,value:n[e.name]??``,onChange:t=>m(e.name,t.target.value),placeholder:e.placeholder,className:i[e.name]?`border-destructive`:``}):e.type===`number`?(0,I.jsx)(T,{id:e.name,type:`number`,value:n[e.name]??``,onChange:t=>m(e.name,t.target.value===``?void 0:t.target.valueAsNumber),placeholder:e.placeholder,className:i[e.name]?`border-destructive`:``}):(0,I.jsx)(T,{id:e.name,type:[`email`,`url`,`date`,`datetime-local`,`time`,`password`].includes(e.type)?e.type:`text`,value:n[e.name]??``,onChange:t=>m(e.name,t.target.value),placeholder:e.placeholder,className:i[e.name]?`border-destructive`:``}),i[e.name]&&(0,I.jsxs)(`p`,{className:`text-xs text-destructive`,children:[e.label,` is required`]}),e.helpText&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.helpText})]},e.name))}),(0,I.jsxs)(f,{children:[(0,I.jsx)(p,{variant:`outline`,onClick:d,children:`Cancel`}),(0,I.jsx)(p,{onClick:l,children:`Confirm`})]})]})})}var Q=e({RecordDetailView:()=>$}),ue={id:`current-user`,name:`Demo User`};function $({dataSource:e,objects:t,onEdit:n}){let{objectName:r,recordId:o}=te(),{showDebug:s}=ce(),{user:c}=ne(),l=ee(),{t:u}=a(),[d,f]=(0,F.useState)(!0),[p,m]=(0,F.useState)([]),[h,g]=(0,F.useState)([]),[_,v]=(0,F.useState)(0),[y,C]=(0,F.useState)({}),[w,T]=(0,F.useState)(),D=t.find(e=>e.name===r);le(w);let O=o,[k,A]=(0,F.useState)({open:!1,message:``}),[j,M]=(0,F.useState)({open:!1,params:[]}),L=(0,F.useCallback)((e,t)=>new Promise(n=>{A({open:!0,message:e,options:t,resolve:n})}),[]),R=(0,F.useCallback)(e=>new Promise(t=>{M({open:!0,params:e,resolve:t})}),[]),z=(0,F.useCallback)((e,t)=>{t?.type===`error`?b.error(e):b.success(e)},[]),B=(0,F.useCallback)((e,t)=>{t?.external||t?.newTab?window.open(e,`_blank`,`noopener,noreferrer`):l(e)},[l]),V=(0,F.useCallback)(async t=>{try{let n=t.target||t.name,i=t.params||{};switch(n){case`opportunity_change_stage`:await e.update(r,O,{stage:i.new_stage});break;case`opportunity_mark_won`:await e.update(r,O,{stage:`closed_won`});break;case`opportunity_mark_lost`:await e.update(r,O,{stage:`closed_lost`,loss_reason:i.loss_reason});break;default:Object.keys(i).length>0&&await e.update(r,O,i);break}let a=t.refreshAfter===!0;return a&&v(e=>e+1),{success:!0,reload:a}}catch(e){return{success:!1,error:e.message}}},[e,r,O]),H=(0,F.useMemo)(()=>re(),[]),U=(0,F.useCallback)(async e=>{let t=e.target||e.name;if(!t)return{success:!1,error:`No flow target provided for flow action`};try{let n=await H(`https://demo.objectstack.ai/api/v1/automation/${encodeURIComponent(t)}/trigger`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:O,objectName:r,params:e.params??{}})}),i=await n.json().catch(()=>null);if(!n.ok||i&&i.success===!1)return{success:!1,error:i?.error||`Flow "${t}" failed (HTTP ${n.status})`};let a=e.refreshAfter!==!1;return a&&v(e=>e+1),{success:!0,data:i?.data,reload:a}}catch(e){return{success:!1,error:e.message}}},[H,O,r]),W=(0,F.useCallback)(async e=>{let t=e.target||e.name;if(!t)return{success:!1,error:`No action target provided`};let n=e.params&&!Array.isArray(e.params)?e.params:{};try{let i=e.objectName||r||`global`,a=await H(`https://demo.objectstack.ai/api/v1/actions/${encodeURIComponent(i)}/${encodeURIComponent(t)}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({recordId:O,params:n})}),o=await a.json().catch(()=>null);if(!a.ok||o&&o.success===!1)return{success:!1,error:o?.error||`Action "${t}" failed (HTTP ${a.status})`};let s=e.refreshAfter!==!1;return s&&v(e=>e+1),{success:!0,data:o?.data,reload:s}}catch(e){return{success:!1,error:e.message}}},[H,O,r]),G=(0,F.useMemo)(()=>{if(!D||!t)return[];let e=[];for(let n of t)if(n.name!==D.name)for(let[t,r]of Object.entries(n.fields||{}))r&&(r.type===`lookup`||r.type===`master_detail`)&&(r.reference_to||r.reference)===D.name&&e.push({childObject:n.name,childLabel:n.label||n.name,referenceField:t});return e},[D,t]);(0,F.useEffect)(()=>{if(!e||!O||G.length===0)return;let t=!1;return Promise.all(G.map(({childObject:t,referenceField:n})=>e.find(t,{$filter:{[n]:O}}).then(e=>({childObject:t,items:Array.isArray(e)?e:e?.data||[]})).catch(e=>(console.warn(`[RecordDetailView] Failed to fetch related ${t}:`,e),{childObject:t,items:[]})))).then(e=>{if(t)return;let n={};for(let{childObject:t,items:r}of e)n[t]=r;C(n)}),()=>{t=!0}},[e,O,G]);let K=c?{id:c.id,name:c.name,avatar:c.image}:ue;(0,F.useEffect)(()=>{if(!e||!r||!O)return;let t=`${r}:${O}`;e.find(`sys_presence`,{$filter:{recordId:O}}).then(e=>{e.data?.length&&g(e.data)}).catch(()=>{}),e.find(`sys_comment`,{$filter:{threadId:t},$orderby:{createdAt:`asc`}}).then(e=>{e.data?.length&&m(e.data.map(e=>({id:e.id,type:`comment`,actor:e.author?.name??`Unknown`,actorAvatarUrl:e.author?.avatar,body:e.content,createdAt:e.createdAt,updatedAt:e.updatedAt,parentId:e.parentId,reactions:e.reactions?Object.entries(e.reactions).map(([e,t])=>({emoji:e,count:t.length,reacted:t.includes(K.id)})):void 0})))}).catch(()=>{})},[e,r,O,K]);let q=(0,F.useCallback)(async t=>{let n={id:crypto.randomUUID(),type:`comment`,actor:K.name,actorAvatarUrl:`avatar`in K?K.avatar:void 0,body:t,createdAt:new Date().toISOString()};if(m(e=>[...e,n]),e){let i=`${r}:${O}`;e.create(`sys_comment`,{id:n.id,threadId:i,author:K,content:t,mentions:[],createdAt:n.createdAt}).catch(()=>{})}},[K,e,r,O]),J=(0,F.useCallback)(async(t,n)=>{let i={id:crypto.randomUUID(),type:`comment`,actor:K.name,actorAvatarUrl:`avatar`in K?K.avatar:void 0,body:n,createdAt:new Date().toISOString(),parentId:t};if(m(e=>[...e,i].map(e=>e.id===t?{...e,replyCount:(e.replyCount??0)+1}:e)),e){let a=`${r}:${O}`;e.create(`sys_comment`,{id:i.id,threadId:a,author:K,content:n,mentions:[],createdAt:i.createdAt,parentId:t}).catch(()=>{})}},[K,e,r,O]),Q=(0,F.useCallback)((t,n)=>{m(r=>r.map(r=>{if(r.id!==t)return r;let i=[...r.reactions??[]],a=i.findIndex(e=>e.emoji===n);if(a>=0){let e=i[a];e.reacted?e.count<=1?i.splice(a,1):i[a]={...e,count:e.count-1,reacted:!1}:i[a]={...e,count:e.count+1,reacted:!0}}else i.push({emoji:n,count:1,reacted:!0});let o={...r,reactions:i};return e&&e.update(`sys_comment`,String(t),{$toggleReaction:{emoji:n,userId:K.id}}).catch(()=>{}),o}))},[K.id,e]);(0,F.useEffect)(()=>{f(!0),queueMicrotask(()=>f(!1))},[r,o]);let $=(0,F.useMemo)(()=>{if(!D)return{type:`detail-view`};let e=D.primaryField||Object.keys(D.fields||{}).find(e=>e===`name`||e===`title`),n=D.views?.form?.sections,r=n&&n.length>0?n.map(e=>({title:e.title,collapsible:e.collapsible,defaultCollapsed:e.defaultCollapsed,fields:(e.fields||[]).map(e=>{let t=typeof e==`string`?e:e.name,n=D.fields[t];if(!n)return console.warn(`[RecordDetailView] Field "${t}" not found in ${D.name} definition`),{name:t,label:t};let r=n.reference_to||n.reference;return{name:t,label:n.label||t,type:n.type||`text`,...n.options&&{options:n.options},...r&&{reference_to:r},...n.reference_field&&{reference_field:n.reference_field},...n.currency&&{currency:n.currency}}})})):[{showBorder:!1,fields:Object.keys(D.fields||{}).map(e=>{let t=D.fields[e],n=t.reference_to||t.reference;return{name:e,label:t.label||e,type:t.type||`text`,...t.options&&{options:t.options},...n&&{reference_to:n},...t.reference_field&&{reference_field:t.reference_field},...t.currency&&{currency:t.currency}}})}],i=(()=>{let e=new Set;return(D.actions||[]).filter(t=>t.locations?.includes(`record_header`)?t.name?e.has(t.name)?!1:(e.add(t.name),!0):!0:!1)})(),a=D.views?.detail?.highlightFields??[],o=D.views?.detail?.sectionGroups??D.views?.form?.sectionGroups,s=G.map(({childObject:e,childLabel:n,referenceField:r})=>{let i=t.find(t=>t.name===e);return{title:n,type:`table`,api:e,data:y[e]||[],referenceField:r,icon:i?.icon}});return{type:`detail-view`,objectName:D.name,resourceId:O,showBack:!0,onBack:`history`,showEdit:!0,title:D.label,primaryField:e,sections:r,autoTabs:!0,autoDiscoverRelated:!0,...s.length>0&&{related:s},...a.length>0&&{highlightFields:a},...o&&o.length>0&&{sectionGroups:o},...i.length>0&&{actions:[{type:`action:bar`,location:`record_header`,actions:i}]}}},[D?.name,O,y,_]);return d?(0,I.jsx)(P,{}):D?(0,I.jsxs)(`div`,{className:`h-full bg-background overflow-hidden flex flex-col relative`,children:[(0,I.jsx)(`div`,{className:`absolute top-2 sm:top-4 right-2 sm:right-4 z-50 flex items-center gap-2`,children:h.length>0&&(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:`Users viewing this record`,children:[(0,I.jsx)(ae,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,I.jsx)(Y,{users:h,size:`sm`,maxVisible:4,showStatus:!0})]})}),(0,I.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-row`,children:[(0,I.jsx)(`div`,{className:`flex-1 overflow-auto p-3 sm:p-4 lg:p-6 scroll-pb-48`,children:(0,I.jsx)(i,{context:{record:{},objectName:r,user:K},onConfirm:L,onToast:z,onNavigate:B,onParamCollection:R,handlers:{api:V,flow:U,script:W,modal:W},children:(0,I.jsx)(se,{schema:$,dataSource:e,objectLabel:D.label,onDataLoaded:e=>{if(!e||typeof e!=`object`)return;let t=$.primaryField,n=[t&&e[t],e.name,e.title,e.label,e.subject].find(e=>typeof e==`string`&&e.trim().length>0);n&&n!==w&&T(n)},onEdit:()=>{n({id:O})},discussionSlot:(0,I.jsx)(oe,{config:{position:`bottom`,collapsible:!1,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:p,onAddComment:q,onAddReply:J,onToggleReaction:Q})},_)})}),(0,I.jsx)(N,{open:s,sections:[{title:`View Schema`,data:$}]})]}),(0,I.jsx)(X,{state:k,onOpenChange:e=>{e||A(e=>({...e,open:!1}))}}),(0,I.jsx)(Z,{state:j,onOpenChange:e=>{e||M(e=>({...e,open:!1}))}})]}):(0,I.jsx)(`div`,{className:`flex h-full items-center justify-center p-4`,children:(0,I.jsxs)(E,{children:[(0,I.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,I.jsx)(ie,{className:`h-6 w-6 text-muted-foreground`})}),(0,I.jsx)(x,{children:`Object Not Found`}),(0,I.jsxs)(S,{children:[`Object "`,r,`" definition missing. Check your configuration or navigate back to select a valid object.`]})]})})}export{G as a,z as c,Y as i,Z as n,B as o,X as r,R as s,Q as t};
@@ -0,0 +1 @@
1
+ import{n as e,r as t}from"./rolldown-runtime-S-ySWqyJ.js";import{U as n,W as r,m as i,p as a}from"./framework-BW6KsEI0.js";import{gt as o,ht as s,mt as c}from"./plugins-core-Ccvbi6db.js";import{p as l}from"./ui-layout-CYz0tyDf.js";import"./AdapterProvider-Cd4HYb7q.js";import"./MetadataProvider-Dvc9BxbC.js";import{M as u,rt as d,w as f}from"./vendor-icons-CrSf7tAH.js";import{n as p,t as m}from"./plugins-views-CbLIJkBs.js";import{r as h,t as g}from"./MetadataInspector-DVtCDQtx.js";var _=e({ReportView:()=>x}),v=t(r(),1),y=n(),b=[{value:`month`,label:`Month`,type:`text`},{value:`revenue`,label:`Revenue`,type:`number`},{value:`count`,label:`Count`,type:`number`},{value:`region`,label:`Region`,type:`text`},{value:`product`,label:`Product`,type:`text`},{value:`source`,label:`Lead Source`,type:`text`},{value:`stage`,label:`Stage`,type:`text`},{value:`amount`,label:`Amount`,type:`number`}];function x({dataSource:e}){let{reportName:t}=l(),{showDebug:n}=h(),r=a(),[_,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(0),{reports:w,objects:T,loading:E,refresh:D}=i(),O=w?.find(e=>e.name===t),[k,A]=(0,v.useState)(O),[j,M]=(0,v.useState)(null),[N,P]=(0,v.useState)([]),[F,I]=(0,v.useState)(!1),L=(0,v.useMemo)(()=>{let e=j||k,t=e?.objectName||e?.dataSource?.object||e?.dataSource?.resource;if(t&&T?.length){let e=T.find(e=>e.name===t);if(e?.fields){let t=e.fields;return Array.isArray(t)?t.map(e=>typeof e==`string`?{value:e,label:e,type:`text`}:{value:e.name,label:e.label||e.name,type:e.type||`text`}):Object.entries(t).map(([e,t])=>({value:e,label:t.label||e,type:t.type||`text`}))}}return b},[j,k,T]),R=(0,v.useCallback)(async e=>{try{r&&(await r.update(`sys_report`,t,e),D().catch(()=>{}))}catch(e){console.warn(`[ReportView] Auto-save failed:`,e)}},[r,t,D]),z=(0,v.useCallback)(()=>{M(k),x(!0),C(e=>e+1)},[k]),B=(0,v.useCallback)(()=>{x(!1)},[]),V=(0,v.useMemo)(()=>j||k,[S]),H=(0,v.useCallback)(e=>{M(e),R(e),C(e=>e+1)},[R]),U=(0,v.useCallback)((e,t)=>{M(n=>({...n,[e]:t}))},[]);(0,v.useEffect)(()=>{A(O)},[O]),(0,v.useEffect)(()=>{_||M(null)},[O]);let W=j||k,G=(0,v.useMemo)(()=>JSON.stringify(W?.filters),[W?.filters]),K=(0,v.useMemo)(()=>JSON.stringify(W?.dataSource),[W?.dataSource]),q=(0,v.useMemo)(()=>JSON.stringify(W?.data),[W?.data]);if((0,v.useEffect)(()=>{if(!W||!e){P([]);return}if(W.data&&Array.isArray(W.data)){P(W.data);return}if(W.dataSource){(async()=>{I(!0);try{let t=W.dataSource.object||W.dataSource.resource;if(!t){console.warn(`ReportView: dataSource missing object/resource property`),P([]);return}P((await e.find(t,{$filter:W.dataSource.filter,$orderby:W.dataSource.sort,$top:W.dataSource.limit})).data||[])}catch(e){console.error(`ReportView: Failed to load data from dataSource`,e),P([])}finally{I(!1)}})();return}if(W.objectName){(async()=>{I(!0);try{P((await e.find(W.objectName,{$filter:W.filters,$orderby:W.sort,$top:W.limit||100})).data||[])}catch(e){console.error(`ReportView: Failed to load data from objectName`,e),P([])}finally{I(!1)}})();return}P([])},[W?.objectName,W?.limit,G,K,q,e]),E)return(0,y.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,y.jsx)(u,{className:`h-8 w-8 animate-spin text-muted-foreground`})});if(!O||!k)return!E&&!O?(0,y.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,y.jsxs)(c,{children:[(0,y.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,y.jsx)(d,{className:`h-6 w-6 text-muted-foreground`})}),(0,y.jsx)(o,{children:`Report Not Found`}),(0,y.jsxs)(s,{children:[`The report "`,t,`" could not be found. It may have been removed or renamed.`]})]})}):(0,y.jsx)(`div`,{className:`h-full flex items-center justify-center p-8`,children:(0,y.jsx)(u,{className:`h-8 w-8 animate-spin text-muted-foreground`})});let J=e=>{let t={...e};if(!t.title&&t.label&&(t.title=t.label),!t.fields&&Array.isArray(t.columns)&&(t.fields=t.columns.map(e=>({name:e.field||e.name,label:e.label,type:e.type,format:e.format,renderAs:e.renderAs,colorMap:e.colorMap,...e.aggregate?{aggregation:e.aggregate,showInSummary:!0}:{}}))),t.fields&&Array.isArray(t.fields)&&t.fields.length>0){let n=t.fields.some(e=>e.showInSummary||e.aggregation),r=t.reportType||`tabular`,i=[];if((r===`summary`||n)&&i.push({type:`summary`,title:`Key Metrics`}),i.push({type:`table`,title:`Details`,columns:t.fields.map(e=>({name:e.name,label:e.label,type:e.type,format:e.format,renderAs:e.renderAs,colorMap:e.colorMap}))}),t.chartConfig?.chartType&&i.push({type:`chart`,title:`Chart`,chart:{type:`chart`,chartType:t.chartConfig.chartType,xAxisField:t.chartConfig.xAxisField,yAxisFields:t.chartConfig.yAxisFields}}),Array.isArray(e.sections)){let n=e.sections.filter(e=>e.type===`chart`&&!t.chartConfig?.chartType);i.push(...n)}t.sections=i}else t.sections||=[];return t},Y=j||k,X={type:`report-viewer`,report:J(Y),data:N,showToolbar:!0,allowExport:!0,loading:F};return(0,y.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden bg-background`,children:[(0,y.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,y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,y.jsx)(`h1`,{className:`text-lg sm:text-xl md:text-2xl font-bold tracking-tight truncate`,children:Y.title||Y.label||`Report Viewer`}),Y.description&&(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 line-clamp-2`,children:Y.description})]}),(0,y.jsx)(`div`,{className:`shrink-0 flex items-center gap-1.5`,children:(0,y.jsxs)(`button`,{type:`button`,onClick:z,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":`report-edit-button`,children:[(0,y.jsx)(f,{className:`h-3.5 w-3.5`}),`Edit`]})})]}),(0,y.jsxs)(`div`,{className:`flex-1 overflow-hidden flex flex-col sm:flex-row relative`,children:[(0,y.jsx)(`div`,{className:`flex-1 min-w-0 overflow-auto p-4 sm:p-6 lg:p-8 bg-muted/5`,children:(0,y.jsx)(`div`,{className:`max-w-5xl mx-auto shadow-sm border rounded-lg sm:rounded-xl bg-background overflow-hidden min-h-150`,children:(0,y.jsx)(p,{schema:X})})}),(0,y.jsx)(m,{open:_,onClose:B,config:V,onSave:H,onFieldChange:U,availableFields:L}),(0,y.jsx)(g,{open:n,sections:[{title:`Report Configuration`,data:Y}]})]})]})}export{_ as t};
@@ -0,0 +1 @@
1
+ import{n as e,r as t}from"./rolldown-runtime-S-ySWqyJ.js";import{U as n,W as r,m as i}from"./framework-BW6KsEI0.js";import{cr as a,ln as o,lr as s,mr as c}from"./plugins-core-Ccvbi6db.js";import{i as l,m as u,p as d}from"./ui-layout-CYz0tyDf.js";import"./MetadataProvider-Dvc9BxbC.js";import{B as f,H as p,N as m,b as h,ct as g,rt as _}from"./vendor-icons-CrSf7tAH.js";var v=e({SearchResultsPage:()=>w}),y=t(r(),1),b=n();function x(e){let t=[];for(let n of e)n.type===`group`&&n.children?t.push(...x(n.children)):t.push(n);return t}var S={object:p,dashboard:m,page:f,report:_},C={object:`bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200`,dashboard:`bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200`,page:`bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200`,report:`bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200`};function w(){let{appName:e}=d(),[t,n]=u(),[r,f]=(0,y.useState)(t.get(`q`)||``),{apps:m}=i(),_=m||[],v=_.find(t=>t.name===e)||_[0],w=`/apps/${e}`,T=(0,y.useMemo)(()=>v?x(v.navigation||[]).map(e=>{let t=`#`;return e.type===`object`?(t=`${w}/${e.objectName}`,e.viewName&&(t+=`/view/${e.viewName}`)):e.type===`dashboard`?t=`${w}/dashboard/${e.dashboardName}`:e.type===`page`?t=`${w}/page/${e.pageName}`:e.type===`report`&&(t=`${w}/report/${e.reportName}`),{id:e.id,label:e.label||e.objectName||e.dashboardName||e.pageName||e.reportName||``,href:t,type:e.type,description:e.description}}).filter(e=>e.href!==`#`):[],[v,w]),E=(0,y.useMemo)(()=>{if(!r.trim())return T;let e=r.toLowerCase();return T.filter(t=>t.label.toLowerCase().includes(e)||t.type.toLowerCase().includes(e)||t.description&&t.description.toLowerCase().includes(e))},[T,r]),D=e=>{f(e),n(e?{q:e}:{})},O=(0,y.useMemo)(()=>{let e={};for(let t of E)(e[t.type]||=[]).push(t);return e},[E]);return(0,b.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6 max-w-4xl mx-auto`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsxs)(l,{to:w,className:`flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,b.jsx)(g,{className:`h-4 w-4`}),`Back`]}),(0,b.jsx)(`h1`,{className:`text-xl font-semibold`,children:`Search`})]}),(0,b.jsxs)(`div`,{className:`relative`,children:[(0,b.jsx)(`label`,{htmlFor:`search-results-input`,className:`sr-only`,children:`Search objects, dashboards, pages, reports`}),(0,b.jsx)(h,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`,"aria-hidden":`true`}),(0,b.jsx)(o,{id:`search-results-input`,value:r,onChange:e=>D(e.target.value),placeholder:`Search objects, dashboards, pages, reports...`,className:`pl-10 h-11 text-base`,autoFocus:!0})]}),(0,b.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:r.trim()?`${E.length} result${E.length===1?``:`s`} for "${r}"`:`${T.length} items available`}),E.length===0?(0,b.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 text-center`,children:[(0,b.jsx)(h,{className:`h-12 w-12 text-muted-foreground/30 mb-4`}),(0,b.jsx)(`p`,{className:`text-lg font-medium text-muted-foreground`,children:`No results found`}),(0,b.jsx)(`p`,{className:`text-sm text-muted-foreground/80 mt-1`,children:`Try adjusting your search terms`})]}):(0,b.jsx)(`div`,{className:`space-y-6`,children:Object.entries(O).map(([e,t])=>(0,b.jsxs)(`div`,{children:[(0,b.jsxs)(`h2`,{className:`text-sm font-medium text-muted-foreground mb-2 flex items-center gap-1.5`,children:[(0,b.jsx)(S[e]||p,{className:`h-4 w-4`}),e.charAt(0).toUpperCase()+e.slice(1),`s`,(0,b.jsx)(c,{variant:`secondary`,className:`ml-1 text-xs`,children:t.length})]}),(0,b.jsx)(`div`,{className:`grid gap-2`,children:t.map(e=>{let t=S[e.type]||p;return(0,b.jsx)(l,{to:e.href,className:`rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,children:(0,b.jsx)(a,{className:`hover:bg-accent/50 transition-colors cursor-pointer`,children:(0,b.jsxs)(s,{className:`flex items-center gap-3 p-3`,children:[(0,b.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded ${C[e.type]||``}`,children:(0,b.jsx)(t,{className:`h-4 w-4`})}),(0,b.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,b.jsx)(`p`,{className:`text-sm font-medium truncate`,children:e.label}),e.description&&(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:e.description})]}),(0,b.jsx)(c,{variant:`outline`,className:`text-xs shrink-0`,children:e.type})]})})},e.id)})})]},e))})]})}export{v as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-S-ySWqyJ.js";import{U as t,W as n,m as r,p as i}from"./framework-BW6KsEI0.js";import{Hi as a,Ir as o,Lr as s,Ra as c,Zi as l,cr as u,dr as d,fr as f,ii as p,lr as m,mr as h,ui as g,ur as _}from"./plugins-core-Ccvbi6db.js";import{d as v,p as y}from"./ui-layout-CYz0tyDf.js";import"./index-DATdOX6r.js";import{r as b,t as x}from"./getIcon-N5xWCMJy.js";var S=e(n(),1),C=t();function w(){let e=v(),{appName:t}=y(),n=t?`/apps/${t}`:``,w=i(),{apps:T,objects:E,dashboards:D,reports:O,pages:k}=r(),[A,j]=(0,S.useState)({apps:null,objects:null,users:null,orgs:null,roles:null,permissions:null,auditLogs:null,dashboard:null,page:null,report:null}),[M,N]=(0,S.useState)(!0),P=(0,S.useCallback)(async()=>{if(w){N(!0);try{let[e,t,n,r,i]=await Promise.all([w.find(`sys_user`).catch(()=>({data:[]})),w.find(`sys_org`).catch(()=>({data:[]})),w.find(`sys_role`).catch(()=>({data:[]})),w.find(`sys_permission`).catch(()=>({data:[]})),w.find(`sys_audit_log`).catch(()=>({data:[]}))]);j({apps:T?.length??0,objects:E?.length??0,users:e.data?.length??0,orgs:t.data?.length??0,roles:n.data?.length??0,permissions:r.data?.length??0,auditLogs:i.data?.length??0,dashboard:D?.length??0,page:k?.length??0,report:O?.length??0})}catch{}finally{N(!1)}}},[w,T,E,D,O,k]);(0,S.useEffect)(()=>{P()},[P]);let F=b().map(e=>{let t=e.customRoute?`${n}${e.customRoute}`:`${n}/system/metadata/${e.type}`,r=x(e.icon),i=null;return i=e.type===`app`?A.apps:e.type===`object`?A.objects:A[e.type]??null,{title:e.pluralLabel,description:e.description,icon:r,href:t,countLabel:e.pluralLabel.toLowerCase(),count:i}}),I=[{title:`Users`,description:`Manage system users and accounts`,icon:o,href:`${n}/system/users`,countLabel:`users`,count:A.users},{title:`Organizations`,description:`Manage organizations and teams`,icon:c,href:`${n}/system/organizations`,countLabel:`organizations`,count:A.orgs},{title:`Roles`,description:`Configure roles and access levels`,icon:p,href:`${n}/system/roles`,countLabel:`roles`,count:A.roles},{title:`Permissions`,description:`Manage permission rules and assignments`,icon:l,href:`${n}/system/permissions`,countLabel:`permissions`,count:A.permissions},{title:`Audit Log`,description:`View system activity and changes`,icon:g,href:`${n}/system/audit-log`,countLabel:`entries`,count:A.auditLogs},{title:`Profile`,description:`View and edit your account settings`,icon:s,href:`${n}/system/profile`,countLabel:``,count:null}],L=[...F,...I];return(0,C.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 sm:p-6`,children:[(0,C.jsxs)(`div`,{className:`min-w-0`,children:[(0,C.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold tracking-tight`,children:`System Settings`}),(0,C.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:`Manage applications, users, roles, permissions, and system configuration`})]}),M&&(0,C.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,role:`status`,"aria-live":`polite`,children:[(0,C.jsx)(a,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),`Loading statistics...`]}),(0,C.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:L.map(t=>{let n=t.icon;return(0,C.jsxs)(u,{className:`cursor-pointer transition-colors hover:bg-accent/50`,onClick:()=>e(t.href),"data-testid":`hub-card-${t.title.toLowerCase().replace(/\s+/g,`-`)}`,role:`link`,tabIndex:0,"aria-label":`${t.title}: ${t.description}`,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),e(t.href))},children:[(0,C.jsxs)(d,{className:`flex flex-row items-center gap-3 pb-2`,children:[(0,C.jsx)(`div`,{className:`flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary`,children:(0,C.jsx)(n,{className:`h-5 w-5`})}),(0,C.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,C.jsx)(f,{className:`text-base`,children:t.title}),(0,C.jsx)(_,{className:`text-xs`,children:t.description})]})]}),(0,C.jsx)(m,{className:`pt-0`,children:t.count!==null&&(0,C.jsxs)(h,{variant:`secondary`,children:[t.count,` `,t.countLabel]})})]},t.title)})})]})}export{w as SystemHubPage};