@objectstack/console 17.0.0-rc.4 → 17.0.0-rc.5
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.
- package/CHANGELOG.md +20 -0
- package/dist/.objectui-sha +1 -1
- package/dist/assets/AdapterProvider-D5_dIBsl.js +2 -0
- package/dist/assets/{AiPendingActionsPage-UIynjb20.js → AiPendingActionsPage-CVC7LIfi.js} +1 -1
- package/dist/assets/{ApiConsolePage-B7CzUZnr.js → ApiConsolePage-CpDU7ooT.js} +1 -1
- package/dist/assets/{AppDocsIndex-DUsMqAwN.js → AppDocsIndex-DFMKKZm6.js} +1 -1
- package/dist/assets/{AppManagementPage-DJ6118-F.js → AppManagementPage-Cot1HC5W.js} +1 -1
- package/dist/assets/{ApprovalsInboxPage-CTVm3l-x.js → ApprovalsInboxPage-ruj1cfw8.js} +1 -1
- package/dist/assets/{AuditLogPage-Riqi0U7P.js → AuditLogPage-QwYEUDC7.js} +1 -1
- package/dist/assets/{ComponentNavView-B2otfGZ7.js → ComponentNavView-BzOXbmFy.js} +1 -1
- package/dist/assets/{CreateViewDialog-z6h6V9xj.js → CreateViewDialog-DZQW3zK4.js} +1 -1
- package/dist/assets/{DashboardView-6_sxqUcT.js → DashboardView-CWd5f0LK.js} +1 -1
- package/dist/assets/{DeveloperHubPage-NbNGfp6j.js → DeveloperHubPage-CdgOf6lM.js} +1 -1
- package/dist/assets/{DocShell-DvmmtwpW.js → DocShell-BAMZcj4T.js} +1 -1
- package/dist/assets/{ExpressionProvider-_qLpGaJS.js → ExpressionProvider-BKktrnvG.js} +1 -1
- package/dist/assets/{FlowRunsPage-ZTpe0n1O.js → FlowRunsPage-Cr-PKPag.js} +1 -1
- package/dist/assets/{IntegrationsPage-DMuzWjMr.js → IntegrationsPage-CmkmHyHB.js} +2 -2
- package/dist/assets/{InterfaceListPage-BHcPP_6g.js → InterfaceListPage-Bf9_sd45.js} +1 -1
- package/dist/assets/{ManagedByBadge-DNLmY8V4.js → ManagedByBadge-BPiPq6-K.js} +1 -1
- package/dist/assets/{MarketplaceAccessDenied-Drlrrrd9.js → MarketplaceAccessDenied-DQYD2Yla.js} +1 -1
- package/dist/assets/{MarketplaceInstalledPage-CYP2CaJz.js → MarketplaceInstalledPage-BvHt07_e.js} +1 -1
- package/dist/assets/{MarketplacePackagePage-DZwFKOQv.js → MarketplacePackagePage-Duz9UzE3.js} +2 -2
- package/dist/assets/{MarketplacePage-XU0PQLAW.js → MarketplacePage-BfYSidiA.js} +1 -1
- package/dist/assets/{MetadataInspector-CoxLxxKN.js → MetadataInspector-DZP7_4Ng.js} +1 -1
- package/dist/assets/{MetadataProvider-DJXxy8nz.js → MetadataProvider-C5EAtW6M.js} +1 -1
- package/dist/assets/{ObjectDataPage-CHRZduUP.js → ObjectDataPage-EBvhhSu8.js} +1 -1
- package/dist/assets/{PageView-D27Yy4W9.js → PageView-DHw-8JWT.js} +1 -1
- package/dist/assets/{ProfilePage-09XXYshY.js → ProfilePage-BFO0o43s.js} +1 -1
- package/dist/assets/{PublicFormsPage-O8fm4eBn.js → PublicFormsPage-3RTLTTOX.js} +1 -1
- package/dist/assets/RecordDetailView-D6YP24Fu.js +9 -0
- package/dist/assets/RecordFormPage-CEuXajud.js +1 -0
- package/dist/assets/ReportDefaultInspector-CoVDiePd.js +3 -0
- package/dist/assets/{ReportView-CwCw4i27.js → ReportView-DU1WEs9f.js} +1 -1
- package/dist/assets/{SearchResultsPage-I8ngrVdn.js → SearchResultsPage-BaK92Vl2.js} +1 -1
- package/dist/assets/{SettingsHub-BY_utblN.js → SettingsHub-BkazZzY4.js} +1 -1
- package/dist/assets/{SettingsView-DNKEl-i-.js → SettingsView-BxS4_zm8.js} +1 -1
- package/dist/assets/{SystemHubPage-WWns1vXN.js → SystemHubPage-CwaVpP2G.js} +1 -1
- package/dist/assets/{createDerive-CsNhKPNT.js → createDerive-CeHn9TlT.js} +1 -1
- package/dist/assets/data-adapter-BbwX3ocs.js +32 -0
- package/dist/assets/framework-Dk4iu8ZK.js +8 -0
- package/dist/assets/{getIcon-CQlbi2Hn.js → getIcon-0xu011em.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-0kvj_GdK.js → highlighted-body-OFNGDK62-DaX2t0Np.js} +1 -1
- package/dist/assets/{i18n-BFepWCa9.js → i18n-BqOg8Sj-.js} +1 -1
- package/dist/assets/index-QGTHTleH.js +2 -0
- package/dist/assets/{infrastructure-BKCMsWnH.js → infrastructure-V4ehxh8R.js} +1 -1
- package/dist/assets/mermaid-GHXKKRXX-DhkyRE-b.js +1 -0
- package/dist/assets/metadata-admin-CngSCs9l.js +25 -0
- package/dist/assets/plugin-calendar-BhbFZ1Dz.js +1 -0
- package/dist/assets/plugin-charts-DCnTkboW.js +7 -0
- package/dist/assets/plugin-chatbot-Cxk2I5E2.js +120 -0
- package/dist/assets/plugin-dashboard-Cc5zXaJZ.js +6 -0
- package/dist/assets/plugin-form-BPgojUr9.js +1 -0
- package/dist/assets/plugin-gantt-D5_Cski-.js +63 -0
- package/dist/assets/plugin-grid-DOeo-xLc.js +8 -0
- package/dist/assets/plugin-kanban-DO8gBhwP.js +1 -0
- package/dist/assets/{plugin-map-zu5SGrw4.js → plugin-map-Ob_kDGyN.js} +1 -1
- package/dist/assets/{plugin-markdown-BqKwZink.js → plugin-markdown-mn_FYkeV.js} +1 -1
- package/dist/assets/plugin-report-DVVwWMiU.js +59 -0
- package/dist/assets/{plugin-timeline-sB_LQnGB.js → plugin-timeline-rzVARN_g.js} +1 -1
- package/dist/assets/{plugin-tree-CHZ2Wjl4.js → plugin-tree-BjFac627.js} +1 -1
- package/dist/assets/plugin-view-DA6WPNHK.js +1 -0
- package/dist/assets/plugins-views-wOHCrjrA.js +4 -0
- package/dist/assets/{runtime-metadata-persistence-TwDeIZza.js → runtime-metadata-persistence-DrONSJyN.js} +1 -1
- package/dist/assets/{skeletons-BZIrujxl.js → skeletons-D41oCKnf.js} +1 -1
- package/dist/assets/src-DGFWwOg3.js +1 -0
- package/dist/assets/{src-Boqr2A0h.js → src-aYMNjfWn.js} +1 -1
- package/dist/assets/src-rZhRmjZV.js +19 -0
- package/dist/assets/ui-components-BioReIdK.js +72 -0
- package/dist/assets/ui-layout-CSKVB0dn.js +1 -0
- package/dist/assets/{use-book-data-BIflvfeG.js → use-book-data-DoM93RB0.js} +1 -1
- package/dist/assets/{useSettingsLabel-CeykvoQ_.js → useSettingsLabel-JZ_zJ7Ow.js} +1 -1
- package/dist/index.html +3 -3
- package/package.json +1 -1
- package/dist/assets/AdapterProvider-BJ47DW1h.js +0 -2
- package/dist/assets/RecordDetailView-aOOCQH95.js +0 -9
- package/dist/assets/RecordFormPage-oqNb9asS.js +0 -1
- package/dist/assets/ReportDefaultInspector-Bo94YiWL.js +0 -3
- package/dist/assets/data-adapter-Bh8GerYu.js +0 -32
- package/dist/assets/framework-s0wcPYfi.js +0 -8
- package/dist/assets/index-CB0grcA9.js +0 -2
- package/dist/assets/mermaid-GHXKKRXX-CI_uxHoC.js +0 -1
- package/dist/assets/metadata-admin-CApOhXis.js +0 -25
- package/dist/assets/plugin-calendar-BOjBc2zc.js +0 -1
- package/dist/assets/plugin-charts-Bk48oCaW.js +0 -7
- package/dist/assets/plugin-chatbot-CEj8h-9I.js +0 -120
- package/dist/assets/plugin-dashboard-B0k1x0iX.js +0 -6
- package/dist/assets/plugin-form-B_6Tki5r.js +0 -1
- package/dist/assets/plugin-gantt-va3r2kNG.js +0 -63
- package/dist/assets/plugin-grid-C0rE_dCh.js +0 -8
- package/dist/assets/plugin-kanban-BhzMbWNL.js +0 -1
- package/dist/assets/plugin-report-DOylY2iS.js +0 -59
- package/dist/assets/plugin-view-DoxfBkwY.js +0 -1
- package/dist/assets/plugins-views-DoZ6BQOM.js +0 -4
- package/dist/assets/src--uGAhLxY.js +0 -19
- package/dist/assets/src-t-RiW1Dw.js +0 -1
- package/dist/assets/ui-components-BFOT5Gog.js +0 -72
- package/dist/assets/ui-layout-D4KJD2jH.js +0 -1
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import{o as e,r as t}from"./rolldown-runtime-C0FnF6B9.js";import{r as n,y as r}from"./vendor-react-DpRf6e0g.js";import{Ct as i,Gn as a,It as o,St as s,Tt as c,bt as l,et as u,mn as d,pn as f,ut as p,wt as m,xt as h}from"./framework-s0wcPYfi.js";import{Cr as g,Er as _,Hr as v,Sr as y,Ti as b,br as x,cn as S,d as C,di as w,g as T,ga as E,il as D,nl as O,ua as ee,uo as k,wr as A,xr as j,xs as M}from"./ui-components-BFOT5Gog.js";var N=e(r(),1),P=n(),te=({schema:e})=>{let{title:t,description:n,data:r,columns:i}=e;e.chart?.type;let o=!!e.chart;return(0,P.jsxs)(x,{className:`h-full flex flex-col ${e.className||``}`,children:[(0,P.jsxs)(g,{children:[t&&(0,P.jsx)(A,{children:t}),n&&(0,P.jsx)(y,{children:n})]}),(0,P.jsxs)(j,{className:`flex-1 overflow-auto space-y-4`,children:[o&&(()=>{let t=e.chart?.type,n=t?a.get(t):null;return n||=a.get(`chart`),n?(0,P.jsx)(`div`,{className:`min-h-[300px] border rounded-lg p-4 bg-background/50`,children:(0,P.jsx)(n,{schema:{...e.chart,data:e.chart.data||r}})}):(0,P.jsxs)(`div`,{className:`min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center`,children:[`Unknown component type: `,t||`chart`]})})(),r&&r.length>0&&(0,P.jsx)(`div`,{className:`border rounded-lg`,children:(()=>{let e=a.get(`grid`)||a.get(`table`);return e?(0,P.jsx)(e,{schema:{type:`grid`,rowData:r,columnDefs:i,domLayout:`autoHeight`}}):(0,P.jsx)(`div`,{className:`overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm text-left`,children:[(0,P.jsx)(`thead`,{className:`text-xs uppercase bg-muted`,children:(0,P.jsx)(`tr`,{children:i?.map(e=>(0,P.jsx)(`th`,{className:`px-6 py-3`,children:e.headerName||e.label||e.field},e.field))})}),(0,P.jsx)(`tbody`,{children:r.map((e,t)=>(0,P.jsx)(`tr`,{className:`bg-background border-b`,children:i?.map(t=>(0,P.jsx)(`td`,{className:`px-6 py-4`,children:e[t.field]},t.field))},t))})]})})})()})]})]})};function F(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=ne(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
2
|
-
`))?`"${n.replace(/"/g,`""`)}"`:n??``}));H([...n?.includeHeaders===!1?[]:[i.join(`,`)],...a.map(e=>e.join(`,`))].join(`
|
|
3
|
-
`),n?.filename||`${e.title||`report`}.csv`,`text/csv`)}function I(e,t,n){let r={title:e.title,description:e.description,generatedAt:new Date().toISOString(),data:t};H(JSON.stringify(r,null,2),n?.filename||`${e.title||`report`}.json`,`application/json`)}function L(e,t,n){let r=e.fields||[],i=ie(n?.orientation),a=re(n?.pageSize);H(`<!DOCTYPE html>
|
|
4
|
-
<html>
|
|
5
|
-
<head>
|
|
6
|
-
<meta charset="utf-8">
|
|
7
|
-
<title>${V(e.title||`Report`)}</title>
|
|
8
|
-
<style>
|
|
9
|
-
@page { size: ${a} ${i}; margin: 20mm; }
|
|
10
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
11
|
-
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
12
|
-
.description { color: #666; margin-bottom: 24px; }
|
|
13
|
-
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
14
|
-
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
15
|
-
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
16
|
-
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
17
|
-
tr:nth-child(even) { background: #fafafa; }
|
|
18
|
-
</style>
|
|
19
|
-
</head>
|
|
20
|
-
<body>
|
|
21
|
-
<h1>${V(e.title||`Report`)}</h1>
|
|
22
|
-
${e.description?`<p class="description">${V(e.description)}</p>`:``}
|
|
23
|
-
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
24
|
-
<table>
|
|
25
|
-
<thead><tr>${r.map(e=>`<th>${V(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
26
|
-
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${V(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
27
|
-
</table>
|
|
28
|
-
</body>
|
|
29
|
-
</html>`,n?.filename||`${e.title||`report`}.html`,`text/html`)}function R(e,t,n){let r=e.fields||[],i=ie(n?.orientation),a=re(n?.pageSize),o=window.open(``,`_blank`);if(!o){L(e,t,{...n,format:`html`,filename:n?.filename?.replace(/\.pdf$/,`.html`)||`${e.title||`report`}.html`});return}o.document.write(`<!DOCTYPE html>
|
|
30
|
-
<html>
|
|
31
|
-
<head>
|
|
32
|
-
<meta charset="utf-8">
|
|
33
|
-
<title>${V(e.title||`Report`)}</title>
|
|
34
|
-
<style>
|
|
35
|
-
@page { size: ${a} ${i}; margin: 20mm; }
|
|
36
|
-
@media print { .no-print { display: none; } }
|
|
37
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
38
|
-
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
39
|
-
.description { color: #666; margin-bottom: 24px; }
|
|
40
|
-
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
41
|
-
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
42
|
-
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
43
|
-
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
44
|
-
tr:nth-child(even) { background: #fafafa; }
|
|
45
|
-
</style>
|
|
46
|
-
</head>
|
|
47
|
-
<body>
|
|
48
|
-
<h1>${V(e.title||`Report`)}</h1>
|
|
49
|
-
${e.description?`<p class="description">${V(e.description)}</p>`:``}
|
|
50
|
-
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
51
|
-
<table>
|
|
52
|
-
<thead><tr>${r.map(e=>`<th>${V(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
53
|
-
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${V(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
54
|
-
</table>
|
|
55
|
-
</body>
|
|
56
|
-
</html>`),o.document.close(),o.onload=()=>{o.print()}}function z(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=ne(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
57
|
-
`)||n.includes(` `))?`"${n.replace(/"/g,`""`)}"`:n??``}));H(``+[...n?.includeHeaders===!1?[]:[i.join(` `)],...a.map(e=>e.join(` `))].join(`
|
|
58
|
-
`),n?.filename||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function B(e,t,n,r){switch(e){case`csv`:F(t,n,r);break;case`json`:I(t,n,r);break;case`html`:L(t,n,r);break;case`pdf`:R(t,n,r);break;case`excel`:z(t,n,r);break;default:console.warn(`Unsupported export format: ${e}`)}}function V(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function ne(e){if(typeof e==`string`&&e.length>0){let t=e.charAt(0);if(t===`=`||t===`+`||t===`-`||t===`@`||t===`|`)return`\t${e}`}return e}function re(e){return[`A4`,`A3`,`Letter`,`Legal`].includes(e||``)?e:`A4`}function ie(e){return e===`landscape`?`landscape`:`portrait`}function H(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function U(e,t){if(e==null||e===``)return``;let n=t?.type,r=t?.format;if(n===`date`||r===`date`||ae(e))return oe(e);if(n===`number`||typeof e==`number`){let t=typeof e==`number`?e:Number(e);return isNaN(t)?String(e):r===`currency`||r===`currency_cny`?`¥${t.toLocaleString(`en-US`,{minimumFractionDigits:0,maximumFractionDigits:0})}`:r===`currency_usd`?`$${t.toLocaleString(`en-US`,{minimumFractionDigits:0,maximumFractionDigits:0})}`:r===`percent`?`${t.toLocaleString(`en-US`,{minimumFractionDigits:1,maximumFractionDigits:1})}%`:t.toLocaleString(`en-US`)}return String(e)}function ae(e){return typeof e==`string`&&/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(e)}function oe(e){try{let t=new Date(e);return isNaN(t.getTime())?String(e):`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}catch{return String(e)}}function se(e,t){if(!t||t.length===0||!e||e.length===0)return null;let n=t[0],r=n.field,i=new Map;for(let t of e){let e=String(t[r]??`(empty)`);i.has(e)||i.set(e,[]),i.get(e).push(t)}let a=[];for(let[e,t]of i)a.push({key:e,label:`${n.label||r}: ${e}`,rows:t});let o=n.sort===`desc`?-1:1;return a.sort((e,t)=>e.key.localeCompare(t.key)*o),a}function ce(e,t,n){if(!e)return 0;let r=e.map(e=>Number(e[t])||0);switch(n){case`count`:return e.length;case`sum`:return r.reduce((e,t)=>e+t,0);case`avg`:return r.length>0?(r.reduce((e,t)=>e+t,0)/r.length).toFixed(2):0;case`min`:return r.length>0?Math.min(...r):0;case`max`:return r.length>0?Math.max(...r):0;case`distinct`:return new Set(e.map(e=>e[t])).size;default:return``}}var W=({schema:e,onRefresh:t})=>{let{report:n,data:r,showToolbar:i=!0,allowExport:a=!0,allowPrint:o=!0,loading:s=!1}=e,c=e=>{if(!n){console.warn(`ReportViewer: Cannot export, no report defined`);return}B(e,n,r||[],n.exportConfigs?.[e])},l=()=>{window.print()},d=()=>{t?.()},f=(e,t)=>ce(r,e,t),p=(e,t)=>{let r=n?.conditionalFormatting;if(!(!r||!Array.isArray(r)))for(let n of r){if(n.field!==e)continue;let r=String(t??``),i=String(n.value??``),a=!1;switch(n.operator){case`equals`:a=r===i;break;case`not_equals`:a=r!==i;break;case`contains`:a=r.includes(i);break;case`greater_than`:a=Number(t)>Number(n.value);break;case`less_than`:a=Number(t)<Number(n.value)}if(a){let e={};return n.backgroundColor&&(e.backgroundColor=n.backgroundColor),n.textColor&&(e.color=n.textColor),e}}},m=(e,t)=>{if(e==null||e===``)return``;if(t.renderAs===`badge`&&(!t.type||t.type===`string`||t.type===`text`)){let n=t.colorMap?.[String(e)]||``;return(0,P.jsx)(_,{className:n,children:String(e)})}if(t.aggregation)return U(e,t);if(t.type){let n={...t};t.colorMap&&!n.options&&(n.options=Object.entries(t.colorMap).map(([e,t])=>({value:e,label:e,color:t})));let r=C(T(n));return(0,P.jsx)(r,{value:e,field:n})}return U(e,t)};return n?(0,P.jsxs)(`div`,{className:`space-y-4`,children:[i&&(0,P.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-4 bg-card rounded-lg border`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-lg font-semibold`,children:n.title}),n.description&&(0,P.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description})]}),(0,P.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.refreshInterval&&(0,P.jsxs)(v,{variant:`outline`,size:`sm`,onClick:d,children:[(0,P.jsx)(ee,{className:`h-4 w-4 mr-2`}),`Refresh`]}),o&&(0,P.jsxs)(v,{variant:`outline`,size:`sm`,onClick:l,children:[(0,P.jsx)(E,{className:`h-4 w-4 mr-2`}),`Print`]}),a&&n.showExportButtons&&(0,P.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,P.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>c(`pdf`),children:[(0,P.jsx)(M,{className:`h-4 w-4 mr-2`}),`PDF`]}),(0,P.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>c(`excel`),children:[(0,P.jsx)(M,{className:`h-4 w-4 mr-2`}),`Excel`]}),(0,P.jsxs)(v,{variant:`outline`,size:`sm`,onClick:()=>c(`csv`),children:[(0,P.jsx)(M,{className:`h-4 w-4 mr-2`}),`CSV`]})]})]})]}),(0,P.jsxs)(x,{children:[(0,P.jsxs)(g,{children:[!i&&n.title&&(0,P.jsx)(A,{children:n.title}),!i&&n.description&&(0,P.jsx)(y,{children:n.description})]}),(0,P.jsxs)(j,{className:`space-y-6`,children:[s&&(0,P.jsxs)(`div`,{className:`space-y-6`,children:[(0,P.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[1,2,3].map(e=>(0,P.jsx)(x,{children:(0,P.jsxs)(j,{className:`p-4 space-y-2`,children:[(0,P.jsx)(S,{className:`h-4 w-20`}),(0,P.jsx)(S,{className:`h-8 w-28`})]})},e))}),(0,P.jsxs)(`div`,{className:`space-y-2`,children:[(0,P.jsx)(S,{className:`h-10 w-full`}),[1,2,3,4,5].map(e=>(0,P.jsx)(S,{className:`h-8 w-full`},e))]})]}),!s&&n.sections?.map((e,t)=>e.visible===!1?null:(0,P.jsxs)(`div`,{className:`space-y-2`,children:[e.title&&e.type!==`header`&&(0,P.jsx)(`h3`,{className:`text-lg font-semibold border-b pb-2`,children:e.title}),e.type===`header`&&e.title&&(0,P.jsx)(`div`,{className:`text-2xl font-bold py-4`,children:e.title}),e.type===`summary`&&(0,P.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:n.fields?.filter(e=>e.showInSummary).map((e,t)=>(0,P.jsx)(x,{children:(0,P.jsxs)(j,{className:`p-4`,children:[(0,P.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e.label||e.name}),(0,P.jsx)(`div`,{className:`text-2xl font-bold`,children:U(f(e.name,e.aggregation),e)})]})},t))}),e.type===`table`&&(0,P.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,P.jsx)(`thead`,{className:`bg-muted`,children:(0,P.jsx)(`tr`,{children:e.columns?.map((e,t)=>(0,P.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,P.jsx)(`tbody`,{children:(()=>{let t=se(r||[],n.groupBy||[]);return t?t.map(t=>(0,P.jsxs)(N.Fragment,{children:[(0,P.jsx)(`tr`,{className:`bg-muted/60`,children:(0,P.jsxs)(`td`,{colSpan:e.columns?.length||1,className:`px-4 py-2 font-semibold text-sm`,children:[t.label,` (`,t.rows.length,`)`]})}),t.rows.map((t,n)=>(0,P.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,P.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:p(e.name,t[e.name]),children:m(t[e.name],e)},n))},n))]},t.key)):r?.map((t,n)=>(0,P.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,P.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:p(e.name,t[e.name]),children:m(t[e.name],e)},n))},n))})()})]})}),e.type===`text`&&e.text&&(0,P.jsx)(`div`,{className:`prose max-w-none`,children:(0,P.jsx)(`p`,{children:e.text})}),e.type===`page-break`&&(0,P.jsx)(`div`,{className:`border-t-2 border-dashed my-8 print:page-break-after-always`}),e.content&&(0,P.jsx)(u,{schema:e.content})]},t)),!n.sections&&r&&r.length>0&&(0,P.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,P.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,P.jsx)(`thead`,{className:`bg-muted`,children:(0,P.jsx)(`tr`,{children:n.fields?.map((e,t)=>(0,P.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,P.jsx)(`tbody`,{children:r.map((e,t)=>(0,P.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:n.fields?.map((t,n)=>(0,P.jsx)(`td`,{className:`px-4 py-2 ${t.type===`number`?`text-right tabular-nums`:``}`,style:p(t.name,e[t.name]),children:m(e[t.name],t)},n))},t))})]})})]})]})]}):(0,P.jsx)(x,{children:(0,P.jsx)(j,{className:`p-8 text-center text-muted-foreground`,children:`No report to display`})})};function G(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.dataset==`string`&&t.dataset.length>0||t.type===`joined`&&Array.isArray(t.blocks)&&t.blocks.some(e=>typeof e?.dataset==`string`)}function K(e,t){return e?typeof e==`string`?e:typeof e==`object`&&typeof e.default==`string`?e.default:t:t}function q(e){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&!!e):[]}function J(e){if(!Array.isArray(e))return;let t={};for(let n of e){let e=n&&typeof n==`object`?n.by:void 0;typeof e!=`string`||!e||(t[e]=n.direction===`desc`?`desc`:`asc`)}return Object.keys(t).length>0?t:void 0}function le(e,t,n){if(!e)return;let r=new Set([...t,...n]),i={};for(let[t,n]of Object.entries(e))r.has(t)&&(i[t]=n);return Object.keys(i).length>0?i:void 0}function Y(e,t,n,r,i,a,o){let[s,c]=N.useState({status:`idle`,rows:[]}),l=le(o,t,n),u=JSON.stringify(r??null),d=JSON.stringify(a??null),f=JSON.stringify(l??null),p=`${e}|${t.join(`,`)}|${n.join(`,`)}|${u}|${d}|${f}`;return N.useEffect(()=>{let o=i;if(!o||typeof o.queryDataset!=`function`){c({status:`error`,rows:[],error:`This data source does not support dataset queries.`});return}if(!e||n.length===0){c({status:`idle`,rows:[]});return}let s=!1;return c({status:`loading`,rows:[]}),o.queryDataset(e,{dimensions:t,measures:n,...r&&Object.keys(r).length>0?{runtimeFilter:r}:{},...a?{totals:{groupings:a}}:{},...l?{order:l}:{}}).then(e=>{s||c({status:`ok`,rows:Array.isArray(e?.rows)?e.rows:[],fields:Array.isArray(e?.fields)?e.fields:[],object:e?.object,dimensionFields:e?.dimensionFields,drillRawRows:Array.isArray(e?.drillRawRows)?e.drillRawRows:void 0,drillRanges:Array.isArray(e?.drillRanges)?e.drillRanges:void 0,totals:Array.isArray(e?.totals)?e.totals:void 0})}).catch(e=>{s||c({status:`error`,rows:[],error:String(e?.message??e)})}),()=>{s=!0}},[p]),s}function ue({dataset:e}){return(0,P.jsxs)(`div`,{className:`flex items-center justify-center rounded-md border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground`,children:[`This report binds the “`,e,`” dataset — choose at least one measure (values) to render.`]})}function X({status:e,error:t}){return e===`error`?(0,P.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-md border border-destructive/40 bg-destructive/5 px-3 py-2 text-xs text-destructive`,children:[(0,P.jsx)(w,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,P.jsx)(`span`,{className:`break-words`,children:t})]}):(0,P.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-xs text-muted-foreground`,children:[(0,P.jsx)(k,{className:`h-4 w-4 animate-spin`}),` Running report…`]})}function de(){return(0,P.jsxs)(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-md border border-dashed bg-muted/20 p-6 text-xs text-muted-foreground`,children:[(0,P.jsx)(b,{className:`h-6 w-6`}),` The dataset returned no rows for this report’s scope.`]})}var fe=`cursor-pointer hover:bg-accent/40`;function pe({dataset:e,rows:t,values:n,runtimeFilter:r,dataSource:a,onDrill:o,order:l,withTotals:u}){let d=Y(e,t,n,r,a,u&&t.length>0?[[]]:void 0,l),{fieldLabel:f}=O(),p=D();if(n.length===0)return(0,P.jsx)(ue,{dataset:e});if(d.status===`loading`||d.status===`idle`)return(0,P.jsx)(X,{status:d.status});if(d.status===`error`)return(0,P.jsx)(X,{status:`error`,error:d.error});if(d.rows.length===0)return(0,P.jsx)(de,{});let h=!!o&&t.length>0,g=d.dimensionFields?t.filter(e=>e in d.dimensionFields):[],_=(n,i)=>{let a={};for(let e of t)a[e]=n[e];let c=d.drillRanges?.[i],l=!!c&&Object.keys(c).length>0,u=d.object&&(g.length>0||l)?s(d.drillRawRows?.[i],g,d.dimensionFields??{},r,c):void 0;o({dataset:e,groupKey:a,runtimeFilter:r,object:d.object,objectFilter:u})},{measureField:v,headerLabel:y}=i(d.fields,d.object,f),b=[...t,...n],x=u?d.totals?.find(e=>Array.isArray(e.dimensions)&&e.dimensions.length===0)?.rows?.[0]:void 0,S=p(`report.total`,`Total`);return(0,P.jsx)(`div`,{className:`overflow-auto max-h-[70vh] rounded-md border`,children:(0,P.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,P.jsx)(`thead`,{className:`bg-muted/40`,children:(0,P.jsx)(`tr`,{children:b.map(e=>(0,P.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:y(e)},e))})}),(0,P.jsxs)(`tbody`,{children:[d.rows.map((e,t)=>(0,P.jsx)(`tr`,{className:`border-t${h?` ${fe}`:``}`,"data-testid":h?`dataset-drill-row`:void 0,onClick:h?()=>_(e,t):void 0,children:b.map(t=>(0,P.jsx)(`td`,{className:`px-2 py-1 tabular-nums whitespace-nowrap`,children:n.includes(t)?c(e[t],v(t)?.format,v(t)?.currency,v(t)?.percentScale):m(e[t])},t))},t)),x&&(0,P.jsxs)(`tr`,{className:`border-t bg-muted/30 font-medium`,"data-testid":`dataset-report-total-row`,children:[t.length>0&&(0,P.jsx)(`td`,{colSpan:t.length,className:`px-2 py-1 whitespace-nowrap`,children:S}),n.map(e=>(0,P.jsx)(`td`,{className:`px-2 py-1 tabular-nums whitespace-nowrap`,children:c(x[e],v(e)?.format,v(e)?.currency,v(e)?.percentScale)},e))]})]})]})})}function me(e){switch(e){case`summary`:return`summary`;case`matrix`:return`matrix`;case`joined`:return`joined`;default:return`tabular`}}function he(e){switch(e){case`bar`:case`column`:case`horizontal-bar`:case`line`:case`area`:case`pie`:case`donut`:case`funnel`:case`scatter`:case`treemap`:case`sankey`:case`radar`:case`combo`:return{kind:`series`,chartType:e};case`gauge`:case`solid-gauge`:case`metric`:case`kpi`:case`bullet`:return{kind:`single_value`};case`table`:case`pivot`:return{kind:`tabular`};default:return{kind:`unsupported`,type:String(e)}}}function ge(e){let[,t]=N.useReducer(e=>e+1,0);return N.useEffect(()=>{if(a.get(e))return;let n=typeof a.subscribe==`function`?a.subscribe(()=>{a.get(e)&&t()}):void 0,r=a.loadLazy?.(e);return r&&typeof r.then==`function`&&r.then(()=>t()).catch(()=>{}),n},[e]),a.get(e)}function _e({dataset:e,chart:t,runtimeFilter:n,dataSource:r,order:a}){let o=typeof t.xAxis==`string`?t.xAxis:``,s=typeof t.yAxis==`string`?t.yAxis:``,l=he(t.type),u=l.kind===`series`||l.kind===`single_value`,d=Y(e,l.kind===`series`&&o?[o]:[],u&&s?[s]:[],n,r,void 0,a),f=ge(`chart`),{fieldLabel:p}=O(),m=typeof t.title==`string`?t.title:void 0;if(l.kind===`tabular`)return null;if(l.kind===`unsupported`)return(0,P.jsxs)(`div`,{className:`rounded-md border border-dashed bg-muted/20 px-3 py-2 text-xs text-muted-foreground`,"data-testid":`dataset-report-chart-unsupported`,children:[`Chart type “`,l.type,`” is not a spec chart type — the grouped table below carries this report’s numbers.`]});if(l.kind===`series`&&!o||!s)return null;if(d.status===`loading`||d.status===`idle`)return(0,P.jsxs)(`div`,{className:`flex items-center gap-2 p-4 text-xs text-muted-foreground`,children:[(0,P.jsx)(k,{className:`h-4 w-4 animate-spin`}),` Loading chart…`]});if(d.status===`error`||d.rows.length===0)return null;if(l.kind===`single_value`){let{measureField:e,headerLabel:t}=i(d.fields,d.object,p),n=e(s);return(0,P.jsxs)(`div`,{className:`rounded-md border bg-card p-3`,"data-testid":`dataset-report-metric`,children:[m?(0,P.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:m}):null,(0,P.jsxs)(`div`,{className:`flex flex-col gap-0.5 py-2`,children:[(0,P.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums`,children:c(d.rows[0]?.[s],n?.format,n?.currency,n?.percentScale)}),(0,P.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(s)})]})]})}return f?(0,P.jsxs)(`div`,{className:`rounded-md border bg-card p-3`,"data-testid":`dataset-report-chart`,children:[m?(0,P.jsx)(`h3`,{className:`mb-2 text-sm font-semibold`,children:m}):null,(0,P.jsx)(f,{schema:{chartType:l.chartType,data:d.rows,xAxisKey:o,series:[{dataKey:s}],height:typeof t.height==`number`?t.height:280,isAnimationActive:!1}})]}):null}function Z(e,t){return l(e.map(e=>String(t[e]??`∅`)))}function Q(e,t){return e.map(e=>m(t[e])).join(` / `)}function ve({dataset:e,rows:t,columnsAcross:n,values:r,runtimeFilter:a,dataSource:o,onDrill:l,order:u}){let d=Y(e,[...t,...n],r,a,o,[t,n,[]],u),f=D(),{fieldLabel:p}=O(),g=N.useMemo(()=>{if(d.status!==`ok`)return null;let e=[],r=[],i=new Set,a=new Set,o=new Map;return d.rows.forEach((s,c)=>{let l=Z(t,s),u=Z(n,s);if(!i.has(l)){i.add(l);let n={};for(let e of t)n[e]=s[e];e.push({id:l,label:Q(t,s),key:n})}if(!a.has(u)){a.add(u);let e={};for(let t of n)e[t]=s[t];r.push({id:u,label:Q(n,s),key:e})}o.set(h(l,u),{row:s,index:c})}),{rowHeaders:e,colHeaders:r,cells:o}},[d,t,n]);if(r.length===0)return(0,P.jsx)(ue,{dataset:e});if(d.status===`loading`||d.status===`idle`)return(0,P.jsx)(X,{status:d.status});if(d.status===`error`)return(0,P.jsx)(X,{status:`error`,error:d.error});if(!g||g.rowHeaders.length===0)return(0,P.jsx)(de,{});let{measureField:_,headerLabel:v}=i(d.fields,d.object,p),y=f(`report.total`,`Total`),b=!!l,x=d.dimensionFields?[...t,...n].filter(e=>e in d.dimensionFields):[],S=(t,n,r)=>{let i=d.drillRanges?.[r],o=!!i&&Object.keys(i).length>0,c=d.object&&(x.length>0||o)?s(d.drillRawRows?.[r],x,d.dimensionFields??{},a,i):void 0;l({dataset:e,groupKey:{...t,...n},runtimeFilter:a,object:d.object,objectFilter:c})},C=g.colHeaders.flatMap(e=>r.map(t=>({col:e,measure:t,header:r.length===1?e.label:`${e.label} · ${v(t)}`}))),w=e=>d.totals?.find(t=>Array.isArray(t.dimensions)&&t.dimensions.join(`,`)===e.join(`,`))?.rows,T=new Map;for(let e of w(t)??[])T.set(Z(t,e),e);let E=new Map;for(let e of w(n)??[])E.set(Z(n,e),e);let ee=w([])?.[0],k=T.size>0,A=E.size>0;return(0,P.jsx)(`div`,{className:`overflow-auto max-h-[70vh] rounded-md border`,"data-testid":`dataset-matrix`,children:(0,P.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,P.jsx)(`thead`,{className:`bg-muted/40`,children:(0,P.jsxs)(`tr`,{children:[t.map(e=>(0,P.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:v(e)},e)),C.map(e=>(0,P.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,children:e.header},`${e.col.id}-${e.measure}`)),k&&r.map(e=>(0,P.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,"data-testid":`matrix-total-col-header`,children:r.length===1?y:`${y} · ${v(e)}`},`total-${e}`))]})}),(0,P.jsxs)(`tbody`,{children:[g.rowHeaders.map(e=>(0,P.jsxs)(`tr`,{className:`border-t`,children:[t.map(t=>(0,P.jsx)(`td`,{className:`px-2 py-1 whitespace-nowrap font-medium`,children:m(e.key[t])},t)),C.map(t=>{let n=g.cells.get(h(e.id,t.col.id)),r=n?.row[t.measure],i=b&&n!=null;return(0,P.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap${i?` ${fe}`:``}`,"data-testid":i?`dataset-drill-cell`:void 0,onClick:i?()=>S(e.key,t.col.key,n.index):void 0,children:c(r,_(t.measure)?.format,_(t.measure)?.currency,_(t.measure)?.percentScale)},`${t.col.id}-${t.measure}`)}),k&&r.map(t=>(0,P.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium`,"data-testid":`matrix-row-total`,children:c(T.get(e.id)?.[t],_(t)?.format,_(t)?.currency,_(t)?.percentScale)},`total-${t}`))]},e.id)),A&&(0,P.jsxs)(`tr`,{className:`border-t bg-muted/30 font-medium`,"data-testid":`matrix-total-row`,children:[t.length>0&&(0,P.jsx)(`td`,{colSpan:t.length,className:`px-2 py-1 whitespace-nowrap`,children:y}),C.map(e=>(0,P.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,children:c(E.get(e.col.id)?.[e.measure],_(e.measure)?.format,_(e.measure)?.currency,_(e.measure)?.percentScale)},`${e.col.id}-${e.measure}`)),k&&r.map(e=>(0,P.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,"data-testid":`matrix-grand-total`,children:c(ee?.[e],_(e)?.format,_(e)?.currency,_(e)?.percentScale)},`grand-${e}`))]})]})]})})}var ye=({report:e,dataSource:t,runtimeFilter:n,onDrill:r,className:i})=>{let a=o(e.runtimeFilter??e.filter,n),s=e.drilldown===!1?void 0:r,c=me(e.type);if(c===`joined`&&Array.isArray(e.blocks))return(0,P.jsx)(`div`,{className:i,"data-testid":`dataset-joined-report`,"data-report-name":e.name,style:{display:`flex`,flexDirection:`column`,gap:24},children:e.blocks.map((e,n)=>{let r=o(a,e.runtimeFilter??e.filter),i=q(e.columns),c=J(e.order),l=me(e.type),u=l===`matrix`&&i.length>0?(0,P.jsx)(ve,{dataset:String(e.dataset??``),rows:q(e.rows),columnsAcross:i,values:q(e.values),runtimeFilter:r,dataSource:t,onDrill:s,order:c}):(0,P.jsx)(pe,{dataset:String(e.dataset??``),rows:q(e.rows),values:q(e.values),runtimeFilter:r,dataSource:t,onDrill:s,order:c,withTotals:l===`summary`||l===`matrix`});return(0,P.jsxs)(`section`,{"data-testid":`dataset-report-block`,"data-block-id":e.name??`block-${n}`,className:`flex flex-col gap-2 rounded-lg border bg-card p-4`,children:[(0,P.jsxs)(`header`,{className:`flex flex-col gap-0.5`,children:[(0,P.jsx)(`h3`,{className:`text-sm font-semibold`,children:K(e.label,e.name??`Block ${n+1}`)}),e.description?(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:K(e.description,``)}):null]}),u]},e.name??`block-${n}`)})});let l=q(e.columns),u=J(e.order);if(c===`matrix`&&l.length>0)return(0,P.jsx)(`div`,{className:i,"data-testid":`dataset-report`,"data-report-name":e.name,children:(0,P.jsx)(ve,{dataset:String(e.dataset??``),rows:q(e.rows),columnsAcross:l,values:q(e.values),runtimeFilter:a,dataSource:t,onDrill:s,order:u})});let d=e.chart&&typeof e.chart==`object`&&e.chart.type?e.chart:null;return(0,P.jsxs)(`div`,{className:`${i??``} flex flex-col gap-3`,"data-testid":`dataset-report`,"data-report-name":e.name,"data-report-presentation":c,children:[d?(0,P.jsx)(_e,{dataset:String(e.dataset??``),chart:d,runtimeFilter:a,dataSource:t,order:u}):null,(0,P.jsx)(pe,{dataset:String(e.dataset??``),rows:q(e.rows),values:q(e.values),runtimeFilter:a,dataSource:t,onDrill:s,order:u,withTotals:c===`summary`||c===`matrix`})]})},$=e=>{let{dataSource:t,rows:n,runtimeFilter:r,onDrill:i,className:a}=e,o=N.useContext(p),s=t??o?.dataSource,c=e.schema;if(c&&typeof c==`object`&&c.type===`spec-report`&&c.report&&typeof c.report==`object`&&(c=c.report),G(c))return(0,P.jsx)(ye,{report:c,dataSource:s,runtimeFilter:r,onDrill:i,className:a});if(f(c)){let e={type:`report-viewer`,report:d(c),data:n??[],showToolbar:!1};return(0,P.jsx)(`div`,{className:a,"data-testid":`report-presentation-bridge`,children:(0,P.jsx)(W,{schema:e})})}return(0,P.jsx)(te,{schema:c})};async function be(e,t){let{dataSource:n,resource:r,queryParams:i,format:a,exportConfig:o}=t,s=a||e.defaultExportFormat||`pdf`;try{let t=(await n.find(r,i)).data||[];return B(s,e,t,{format:s,...e.exportConfigs?.[s],...o}),{success:!0,recordCount:t.length,format:s}}catch(e){return{success:!1,recordCount:0,format:s,error:e.message}}}function xe(e,t,n={}){let{columns:r,filename:i,includeAggregationRow:a=!1}=n,o=r||(e.fields||[]).map(Ce),s=o.map(e=>e.header),c=t.map((e,t)=>o.map(n=>{if(n.formula)return n.formula.replace(/\{ROW\}/g,String(t+2));let r=e[n.name];return we(r,n.numberFormat)}));if(a&&t.length>0){let n=o.map((n,r)=>{let i=(e.fields||[]).find(e=>e.name===n.name);if(i?.aggregation){let e=Ee(r),n=t.length+1;switch(i.aggregation){case`sum`:return`=SUM(${e}2:${e}${n})`;case`avg`:return`=AVERAGE(${e}2:${e}${n})`;case`count`:return`=COUNTA(${e}2:${e}${n})`;case`min`:return`=MIN(${e}2:${e}${n})`;case`max`:return`=MAX(${e}2:${e}${n})`;default:return``}}return``});c.push(n)}Oe(``+[s.join(` `),...c.map(e=>e.join(` `))].join(`
|
|
59
|
-
`),i||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function Se(e,t,n,r){return async()=>{let i=e.schedule;if(!i?.enabled)return[];let a=i.formats||[e.defaultExportFormat||`pdf`],o=[];for(let r of a){let i=await be(e,{dataSource:t,resource:n,format:r});o.push(i)}return r(e,i),o}}function Ce(e){return{name:e.name,header:e.label||e.name}}function we(e,t){return e==null?``:typeof e==`number`&&t?e.toLocaleString(`en-US`,Te(t)):De(String(e))}function Te(e){if(e.includes(`%`))return{style:`percent`,minimumFractionDigits:0};let t=(e.match(/0/g)||[]).length;return{minimumFractionDigits:Math.max(0,t-1),maximumFractionDigits:Math.max(0,t-1)}}function Ee(e){let t=``,n=e;for(;n>=0;)t=String.fromCharCode(n%26+65)+t,n=Math.floor(n/26)-1;return t}function De(e){if(e.length>0){let t=e.charAt(0);if(t===`=`||t===`+`||t===`-`||t===`@`||t===`|`)return`'${e}`}return e}function Oe(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}var ke=t({DatasetReportRenderer:()=>ye,LegacyReportRenderer:()=>te,ReportRenderer:()=>$,ReportViewer:()=>W,createScheduleTrigger:()=>Se,exportAsCSV:()=>F,exportAsExcel:()=>z,exportAsHTML:()=>L,exportAsJSON:()=>I,exportAsPDF:()=>R,exportExcelWithFormulas:()=>xe,exportReport:()=>B,exportWithLiveData:()=>be,formatValue:()=>U,isDatasetReport:()=>G,mergeFilters:()=>o});a.register(`report`,$,{namespace:`report`,label:`Report`,category:`Report`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`chart`,type:`code`,label:`Chart Configuration`}]}),a.register(`spec-report`,$,{namespace:`report`,label:`Spec Report`,category:`Report`,inputs:[{name:`dataset`,type:`string`,label:`Dataset`},{name:`type`,type:`string`,label:`Report Type`}]}),a.register(`report-viewer`,W,{namespace:`report`,label:`Report Viewer`,category:`Report`,inputs:[{name:`report`,type:`code`,label:`Report Definition`},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`}]});export{ke as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{r as t,y as n}from"./vendor-react-DpRf6e0g.js";import{F as r,P as i,b as a,w as o}from"./vendor-objectstack-Dm5CaPeY.js";import{Fn as s,Gn as c,Un as l,et as u,ht as d,ut as f}from"./framework-s0wcPYfi.js";import{$n as p,Ai as m,Bc as h,Bi as g,Bn as _,Bo as v,Ca as y,Dn as b,Ea as x,En as S,Er as C,Ft as w,Gn as T,Hn as ee,Ho as E,Hr as D,In as O,Jc as k,Ji as A,Jn as te,Kn as j,Li as ne,Mn as re,Mt as ie,Nn as ae,On as M,Os as N,Pn as oe,Pt as se,Qi as P,Qn as ce,Rc as F,Rn as I,Sa as le,Tn as ue,Un as de,Vn as L,Vo as R,Wn as z,Wr as B,Xi as fe,Xn as V,Yc as H,Yi as U,Yn as pe,Yr as W,Zn as me,_c as G,_n as K,_t as he,an as ge,bn as q,bo as _e,cc as ve,do as ye,dr as be,ea as xe,er as Se,fo as J,fr as Y,gn as X,hr as Ce,in as we,io as Te,is as Ee,jo as De,lc as Oe,ln as ke,lo as Z,mi as Ae,mr as je,ol as Me,on as Ne,po as Pe,pr as Fe,qn as Ie,qo as Le,rl as Re,sn as ze,st as Be,tr as Ve,ur as He,vn as Ue,vs as We,wi as Ge,ya as Ke,yc as qe,yn as Je,yr as Ye,zn as Xe}from"./ui-components-BFOT5Gog.js";import{i as Ze}from"./vendor-ui-utils-CnzHPXVC.js";import{t as Qe}from"./plugin-form-B_6Tki5r.js";import{_ as $e,a as et,c as tt,d as nt,n as rt,o as it,p as at,r as ot,s as st,t as ct,u as lt,v as ut,y as dt}from"./vendor-dndkit-SuQV8biA.js";import{i as ft}from"./plugin-grid-C0rE_dCh.js";var Q=e(n(),1),$=t(),pt={list:`List`,detail:`Detail`,grid:`Grid`,kanban:`Kanban`,calendar:`Calendar`,timeline:`Timeline`,map:`Map`,gallery:`Gallery`,gantt:`Gantt`,chart:`Chart`,tree:`Tree`},mt={list:ye,detail:Ee,grid:R,kanban:_e,calendar:qe,timeline:k,map:Te,gallery:De,gantt:ne,chart:G,tree:J},ht=Ze(`flex gap-4`,{variants:{position:{top:`flex-col`,bottom:`flex-col-reverse`,left:`flex-row`,right:`flex-row-reverse`}},defaultVariants:{position:`top`}}),gt=Ze(`w-full`,{variants:{orientation:{horizontal:`w-full`,vertical:`w-48`}},defaultVariants:{orientation:`horizontal`}}),_t=Ze(`flex gap-2`,{variants:{orientation:{horizontal:`flex-row flex-wrap`,vertical:`flex-col`}},defaultVariants:{orientation:`horizontal`}}),vt=Ze(``,{variants:{orientation:{horizontal:``,vertical:`flex h-auto flex-col items-stretch`}},defaultVariants:{orientation:`horizontal`}});function yt(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}var bt={Home:`House`};function xt(e){if(!e)return null;let t=yt(e),n=bt[t]||t;return B[n]||null}function St(e){return e.label?e.label:pt[e.type]||e.type}function Ct(e){return e.icon?xt(e.icon):mt[e.type]||null}function wt(e){return e.activeView?e.activeView:e.defaultView?e.defaultView:e.views?.[0]?.type}var Tt={share:A,settings:U,duplicate:N,delete:Ae},Et={share:`Share`,settings:`Settings`,duplicate:`Duplicate`,delete:`Delete`},Dt=({schema:e,className:t,onViewChange:n,onCreateView:r,onViewAction:i,createViewLabel:a=`Create view`,...o})=>{let s=Q.useMemo(()=>e.storageKey?e.storageKey:`view-switcher${e.id?`-${e.id}`:``}`,[e.id,e.storageKey]),[c,l]=Q.useState(()=>wt(e));Q.useEffect(()=>{if(e.activeView){l(e.activeView);return}if(e.persistPreference)try{let t=localStorage.getItem(s);if(t){let n=e.views.find(e=>e.type===t)?.type;n&&l(n)}}catch{}},[e.activeView,e.persistPreference,e.views,s]),Q.useEffect(()=>{if(!(!e.persistPreference||!c||e.activeView))try{localStorage.setItem(s,c)}catch{}},[c,e.activeView,e.persistPreference,s]);let d=Q.useCallback(t=>{n?.(t),e.onViewChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onViewChange,{detail:{view:t}}))},[n,e.onViewChange]),f=Q.useCallback(e=>{l(e),d(e)},[d]),p=c||e.views?.[0]?.type,m=p||``,h=e.views.find(e=>e.type===p)||e.views?.[0],g=e.variant||`tabs`,_=e.position||`top`,v=_===`left`||_===`right`,y=v?`vertical`:`horizontal`,b=e.viewActions&&e.viewActions.length>0?(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:e.viewActions.map((e,t)=>{let n=e.icon&&xt(e.icon)||Tt[e.type];return(0,$.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>i?.(e.type,p),title:Et[e.type]||e.type,children:n?(0,$.jsx)(n,{className:`h-3.5 w-3.5`}):null},`action-${e.type}-${t}`)})}):null,x=e.allowCreateView?(0,$.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>r?.(),title:a,children:(0,$.jsx)(Ke,{className:`h-3.5 w-3.5`})}):null,S=(0,$.jsxs)(`div`,{className:H(gt({orientation:y}),`flex items-center gap-1`),children:[g===`dropdown`&&(0,$.jsxs)(X,{value:m,onValueChange:e=>f(e),children:[(0,$.jsx)(Je,{className:H(`w-full`,v?`h-10`:`h-9`),children:(0,$.jsx)(q,{placeholder:`Select view`})}),(0,$.jsx)(K,{children:e.views.map((e,t)=>(0,$.jsx)(Ue,{value:e.type,children:St(e)},`${e.type}-${t}`))})]}),g===`buttons`&&(0,$.jsx)(`div`,{className:H(_t({orientation:y})),children:e.views.map((e,t)=>{let n=e.type===p,r=Ct(e);return(0,$.jsxs)(D,{type:`button`,size:`sm`,variant:n?`secondary`:`ghost`,className:H(`justify-start gap-2`,v?`w-full`:``),onClick:()=>f(e.type),children:[r?(0,$.jsx)(r,{className:`h-4 w-4`}):null,(0,$.jsx)(`span`,{children:St(e)})]},`${e.type}-${t}`)})}),g===`tabs`&&(0,$.jsx)(ie,{value:m,onValueChange:e=>f(e),children:(0,$.jsx)(se,{className:H(vt({orientation:y})),children:e.views.map((e,t)=>{let n=Ct(e);return(0,$.jsxs)(w,{value:e.type,className:H(`gap-2`,v?`justify-start`:``),children:[n?(0,$.jsx)(n,{className:`h-4 w-4`}):null,(0,$.jsx)(`span`,{children:St(e)})]},`${e.type}-${t}`)})})}),b,x]}),C=h?.schema?Array.isArray(h.schema)?(0,$.jsx)(`div`,{className:`space-y-4`,children:h.schema.map((e,t)=>(0,$.jsx)(u,{schema:e,...o},`${h.type}-${t}`))}):(0,$.jsx)(u,{schema:h.schema,...o}):null;return(0,$.jsxs)(`div`,{className:H(ht({position:_}),t),children:[(0,$.jsx)(`div`,{className:H(`shrink-0`,v?`flex flex-col`:`flex`),children:S}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,children:C})]})},Ot={sm:480,md:720,lg:960,xl:1200,full:1600};function kt(e){let t=a(e);return t<=3?`sm`:t<=8?`md`:t<=15?`lg`:`xl`}function At(e,t){return`min(92vw, ${Ot[!e||e===`auto`?kt(t):e]}px)`}var jt=u;function Mt(){let{t:e}=Me(),t=e(`console.objectView.new`);return t===`console.objectView.new`?`New`:t}var Nt=Re({"detail.recordDetailWithLabel":`{{label}} Detail`,"form.createTitle":`Create {{object}}`,"form.editTitle":`Edit {{object}}`,"form.viewTitle":`View {{object}}`},`detail.recordDetailWithLabel`),Pt=({schema:e,dataSource:t,className:n,views:r,activeViewId:i,onViewChange:a,onRowClick:c,onEdit:u,renderListView:f,hideNamedViewTabs:p,toolbarAddon:m,onCreateView:h,onViewAction:g})=>{let _=Mt(),{t:v}=Nt(),[y,b]=(0,Q.useState)(null),x=(0,Q.useRef)(null);x.current=y;let[S,C]=(0,Q.useState)(!1),[ee,E]=(0,Q.useState)(`create`),[O,k]=(0,Q.useState)(null),[A,te]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(!(!t?.onMutation||!e.objectName)&&!f)return t.onMutation(t=>{t.resource===e.objectName&&te(e=>e+1)})},[t,e.objectName,f]);let[ne,re]=(0,Q.useState)([]),[ae,M]=(0,Q.useState)(!1),N=e.listViews,oe=N!=null&&Object.keys(N).length>0,[P,ce]=(0,Q.useState)(()=>e.defaultListView&&N?.[e.defaultListView]?e.defaultListView:N&&Object.keys(N)[0]||``),F=(0,Q.useMemo)(()=>!oe||!P?null:N[P]||null,[oe,P,N]),I=(0,Q.useMemo)(()=>r&&r.length>0?r:null,[r]),le=I!=null&&I.length>0,ue=i||I?.[0]?.id,L=I?.find(e=>e.id===ue)||I?.[0],R=(0,Q.useMemo)(()=>F?.type?F.type:L?.type?L.type:e.defaultViewType||`grid`,[F,L,e.defaultViewType]),B=e.navigation;(0,Q.useEffect)(()=>{let n=!0;return e.objectName&&t&&(async()=>{try{let r=await t.getObjectSchema(e.objectName);n&&b(r)}catch(e){console.error(`Failed to fetch object schema:`,e)}})(),()=>{n=!1}},[e.objectName,t]),(0,Q.useEffect)(()=>{let n=!0;return(async()=>{if(!f&&R!==`grid`&&!(!t||!e.objectName)){M(!0);try{let r=l(F?.filter||L?.filter||e.table?.defaultFilters),i=F?.sort||L?.sort||e.table?.defaultSort||void 0,a=s(x.current?.fields),o=await t.find(e.objectName,{$filter:r,$orderby:i,$top:100,...a.length>0?{$expand:a}:{}}),c=[];Array.isArray(o)?c=o:o&&typeof o==`object`&&(Array.isArray(o.data)?c=o.data:Array.isArray(o.records)?c=o.records:Array.isArray(o.value)&&(c=o.value)),n&&re(c)}catch(e){console.error(`ObjectView data fetch error:`,e)}finally{n&&M(!1)}}})(),()=>{n=!1}},[e.objectName,t,R,A,F,L,f]);let fe=ke(),V=e.layout||o(y,{viewport:fe?`mobile`:`desktop`}),U=e.operations||e.table?.operations||{create:!0,read:!0,update:!0,delete:!0},pe=(0,Q.useCallback)(()=>{V===`page`&&e.onNavigate?e.onNavigate(`new`,`edit`):(E(`create`),k(null),C(!0))},[V,e]),W=(0,Q.useCallback)(t=>{if(u){u(t);return}if(V===`page`&&e.onNavigate){let n=t.id||t._id;e.onNavigate(n,`edit`)}else E(`edit`),k(t),C(!0)},[V,e,u]),me=(0,Q.useCallback)(t=>{if(V===`page`&&e.onNavigate){let n=t.id||t._id;e.onNavigate(n,`view`)}else E(`view`),k(t),C(!0)},[V,e]),G=(0,Q.useCallback)(t=>{if(c){c(t);return}if(B){if(B.mode===`none`||B.preventNavigation)return;if(B.mode===`new_window`||B.openNewTab){let n=t.id||t._id,r=`/${e.objectName}/${encodeURIComponent(String(n))}`;window.open(r,`_blank`);return}if(B.mode===`drawer`){E(`view`),k(t),C(!0);return}if(B.mode===`modal`){E(`view`),k(t),C(!0);return}if(B.mode===`page`){let n=t.id||t._id;e.onNavigate&&e.onNavigate(n,`view`);return}if(B.mode===`split`||B.mode===`popover`){E(`view`),k(t),C(!0);return}}U.read!==!1&&me(t)},[c,B,U.read,me,e]),K=(0,Q.useCallback)(e=>{te(e=>e+1)},[]),he=(0,Q.useCallback)(e=>{te(e=>e+1)},[]),ge=(0,Q.useCallback)(()=>{C(!1),k(null),te(e=>e+1)},[]),q=(0,Q.useCallback)(()=>{C(!1),k(null)},[]);(0,Q.useCallback)(()=>{te(e=>e+1)},[]);let _e=(0,Q.useMemo)(()=>!le||!I||I.length<=1?null:{type:`view-switcher`,variant:`tabs`,position:`top`,persistPreference:!0,storageKey:`view-pref-${e.objectName}`,defaultView:L?.type||`grid`,activeView:L?.type||`grid`,views:I.map(e=>({type:e.type,label:e.label,icon:{kanban:`kanban`,calendar:`calendar`,map:`map`,gallery:`layout-grid`,timeline:`activity`,gantt:`gantt-chart`,grid:`table`,list:`list`,detail:`file-text`,chart:`bar-chart-3`}[e.type]||`table`})),allowCreateView:e.allowCreateView,viewActions:e.viewActions},[le,I,L,e.objectName,e.allowCreateView,e.viewActions]),ve=(0,Q.useCallback)(e=>{if(!I)return;let t=I.find(t=>t.type===e);t&&a&&a(t.id)},[I,a]),ye=(0,Q.useCallback)(e=>{ce(e)},[]),xe=(0,Q.useCallback)(t=>{let n={objectName:e.objectName,fields:F?.columns||L?.columns||e.table?.fields,className:`h-full w-full`,showSearch:L?.showSearch??e.showSearch??!1,showSort:L?.showSort??e.showSort??!1,showFilters:L?.showFilters??e.showFilters??!1,striped:L?.striped??!1,bordered:L?.bordered??!1,color:L?.color},r=F?.options||L||{};switch(t){case`kanban`:{let t=r.kanban||{},i=t.groupByField||t.groupField||`status`,a=(Array.isArray(t.columns)&&t.columns.length>0?t.columns:n.fields)||[],{columns:o,groupByField:s,groupField:c,titleField:l,conditionalFormatting:u,...d}=t,f=t.conditionalFormatting??L?.conditionalFormatting??e.conditionalFormatting;return{type:`object-kanban`,...n,groupBy:i,groupField:i,titleField:t.titleField||`name`,cardFields:a,...d,...f?{conditionalFormatting:f}:{}}}case`calendar`:return{type:`object-calendar`,...n,startDateField:r.calendar?.startDateField||`start_date`,endDateField:r.calendar?.endDateField||`end_date`,titleField:r.calendar?.titleField||`name`,...r.calendar||{}};case`gallery`:return{type:`object-gallery`,...n,imageField:r.gallery?.coverField||r.gallery?.imageField,titleField:r.gallery?.titleField||`name`,...r.gallery||{}};case`timeline`:return{type:`object-timeline`,...n,startDateField:r.timeline?.startDateField||r.timeline?.dateField||`created_at`,titleField:r.timeline?.titleField||`name`,...r.timeline||{}};case`gantt`:return{type:`object-gantt`,...n,startDateField:r.gantt?.startDateField||`start_date`,endDateField:r.gantt?.endDateField||`end_date`,progressField:r.gantt?.progressField||`progress`,dependenciesField:r.gantt?.dependenciesField||`dependencies`,...r.gantt||{}};case`map`:return{type:`object-map`,...n,locationField:r.map?.locationField||`location`,...r.map||{}};case`tree`:return{type:`object-tree`,...n,parentField:r.tree?.parentField,labelField:r.tree?.labelField||r.tree?.titleField||`name`,fields:r.tree?.fields||n.fields,defaultExpandedDepth:r.tree?.defaultExpandedDepth,...r.tree||{}};case`chart`:{let t=r.chart||{};if(t.dataset){let e=Array.isArray(t.dimensions)?t.dimensions:[],n=Array.isArray(t.values)?t.values:[];return{type:`object-chart`,dataset:t.dataset,dimensions:e,values:n,chartType:t.chartType||`bar`,xAxisKey:e[0],series:n.map(e=>({dataKey:e,label:e})),className:`h-[400px] w-full`}}let n=Array.isArray(t.yAxisFields)&&t.yAxisFields[0]||t.valueField||`value`,i=t.xAxisField||t.categoryField||`name`;return{type:`object-chart`,objectName:e.objectName,chartType:t.chartType||`bar`,aggregate:{field:n,function:t.aggregation||`count`,groupBy:i},xAxisKey:i,series:[{dataKey:n,label:n}],className:`h-[400px] w-full`}}default:return null}},[e.objectName,e.table?.fields,F,L]),Se=(0,Q.useMemo)(()=>({type:`object-grid`,objectName:e.objectName,title:e.table?.title,description:e.table?.description,fields:F?.columns||L?.columns||e.table?.fields,columns:F?.columns||L?.columns||e.table?.columns,operations:{...U,create:!1},defaultFilters:F?.filter||L?.filter||e.table?.defaultFilters,defaultSort:F?.sort||L?.sort||e.table?.defaultSort,pageSize:e.table?.pageSize,selectable:e.table?.selectable,striped:L?.striped??e.table?.striped,bordered:L?.bordered??e.table?.bordered,className:e.table?.className}),[e,U,F,L]),J=()=>{let t=O?O.id||O._id:void 0;return{type:`object-form`,objectName:e.objectName,mode:ee,recordId:t,title:e.form?.title,description:e.form?.description,fields:e.form?.fields,customFields:e.form?.customFields,sections:e.form?.sections,groups:e.form?.groups,layout:e.form?.layout,columns:e.form?.columns,showSubmit:e.form?.showSubmit,submitText:e.form?.submitText,showCancel:e.form?.showCancel,cancelText:e.form?.cancelText,showReset:e.form?.showReset,initialValues:e.form?.initialValues,buttons:e.form?.buttons,defaults:e.form?.defaults,readOnly:e.form?.readOnly||ee===`view`,className:e.form?.className,subforms:e.form?.subforms,onSuccess:ge,onCancel:q}},X=()=>{if(e.form?.title)return e.form.title;let t=y?.label||e.objectName;switch(ee){case`create`:return v(`form.createTitle`,{object:t});case`edit`:return v(`form.editTitle`,{object:t});case`view`:return v(`form.viewTitle`,{object:t});default:return t}},we=(0,Q.useMemo)(()=>{let e=B?.width;return e?typeof e==`number`?`max-w-[${e}px]`:`max-w-[${e}]`:``},[B]),Te=()=>(0,$.jsx)(de,{open:S,onOpenChange:C,direction:`right`,children:(0,$.jsxs)(z,{className:H(`w-full sm:max-w-2xl`,we),children:[(0,$.jsxs)(j,{children:[(0,$.jsx)(Ie,{children:X()}),e.form?.description&&(0,$.jsx)(T,{children:e.form.description})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto px-4 pb-4`,children:(0,$.jsx)(Qe,{schema:J(),dataSource:t})})]})}),Ee=()=>(0,$.jsx)(He,{open:S,onOpenChange:C,children:(0,$.jsxs)(be,{className:H(`max-w-2xl max-h-[90vh] overflow-y-auto`,we),children:[(0,$.jsxs)(je,{children:[(0,$.jsx)(Ce,{children:X()}),e.form?.description&&(0,$.jsx)(Y,{children:e.form.description})]}),(0,$.jsx)(Qe,{schema:J(),dataSource:t})]})}),De=F?.filter||L?.filter||e.table?.defaultFilters,Oe=F?.sort||L?.sort||e.table?.defaultSort,Z=()=>{let n=`${e.objectName}-${P||L?.id||`default`}-${R}-${A}`;if(f)return f({schema:{type:`list-view`,objectName:e.objectName,viewType:R,label:F?.label??L?.label,columns:F?.columns||L?.columns||e.table?.fields,filter:De,sort:Oe,rowHeight:L?.rowHeight,densityMode:L?.densityMode,groupBy:L?.groupBy,groupBy2:L?.groupBy2,grouping:L?.grouping,options:F?.options||L,userActions:{...d(e??{}).userActions,...d(L??{}).userActions},compactToolbar:L?.compactToolbar??e.compactToolbar,allowExport:L?.allowExport??e.allowExport,striped:L?.striped??e.striped,bordered:L?.bordered??e.bordered,color:L?.color??e.color,inlineEdit:L?.inlineEdit??e.inlineEdit,wrapHeaders:L?.wrapHeaders??e.wrapHeaders,clickIntoRecordDetails:L?.clickIntoRecordDetails??e.clickIntoRecordDetails,addRecordViaForm:L?.addRecordViaForm??e.addRecordViaForm,addDeleteRecordsInline:L?.addDeleteRecordsInline??e.addDeleteRecordsInline,collapseAllByDefault:L?.collapseAllByDefault??e.collapseAllByDefault,fieldTextColor:L?.fieldTextColor??e.fieldTextColor,prefixField:L?.prefixField??e.prefixField,showDescription:L?.showDescription??e.showDescription,data:F?.data??L?.data??e.data,navigation:L?.navigation??e.navigation,selection:L?.selection??e.selection,pagination:L?.pagination??e.pagination,searchableFields:L?.searchableFields??e.searchableFields,filterableFields:L?.filterableFields??e.filterableFields,resizable:L?.resizable??e.resizable,hiddenFields:L?.hiddenFields??e.hiddenFields,rowActions:L?.rowActions??e.rowActions,rowActionDefs:L?.rowActionDefs??e.rowActionDefs,bulkActions:L?.bulkActions??e.bulkActions,sharing:L?.sharing??e.sharing,addRecord:L?.addRecord??e.addRecord,conditionalFormatting:L?.conditionalFormatting??e.conditionalFormatting,userFilters:L?.userFilters??e.userFilters,showRecordCount:L?.showRecordCount??e.showRecordCount,allowPrinting:L?.allowPrinting??e.allowPrinting,virtualScroll:L?.virtualScroll??e.virtualScroll,emptyState:L?.emptyState??e.emptyState,aria:L?.aria??e.aria,refreshTrigger:A},dataSource:t,onEdit:W,onRowClick:G,className:`h-full`,refreshKey:A,onAddRecord:pe});if(R!==`grid`){let e=xe(R);if(e&&jt)return(0,$.jsx)(jt,{schema:e,dataSource:t,data:ne,loading:ae},n);if(!jt)return(0,$.jsx)(`div`,{className:`flex items-center justify-center h-40 text-muted-foreground`,children:(0,$.jsxs)(`p`,{children:[`SchemaRenderer not available. Install @object-ui/react to render `,R,` views.`]})})}return(0,$.jsx)(ft,{schema:Se,dataSource:t,onRowClick:G,onEdit:U.update===!1?void 0:W,onDelete:U.delete===!1?void 0:K,onBulkDelete:U.delete===!1?void 0:he},n)},Ae=()=>{if(p||!oe)return null;let e=Object.entries(N);return e.length<=1?null:(0,$.jsx)(ie,{value:P,onValueChange:ye,className:`w-full`,children:(0,$.jsx)(se,{className:`w-auto`,children:e.map(([e,t])=>(0,$.jsx)(w,{value:e,className:`text-sm`,children:t.label||e},e))})})},Me=()=>{let t=e.showCreate!==!1&&U.create!==!1,n=e.showViewSwitcher===!0,r=Ae();return!r&&!n&&!t&&!m?null:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r,(n||t||m)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:n&&_e&&(0,$.jsx)(Dt,{schema:_e,onViewChange:ve,onCreateView:h,onViewAction:g,className:`overflow-x-auto`})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[m,t&&(0,$.jsxs)(D,{size:`sm`,onClick:pe,children:[(0,$.jsx)(Ke,{className:`h-4 w-4`}),_]})]})]})]})},Ne=B?.mode===`modal`?`modal`:B?.mode===`drawer`?`drawer`:B?.mode===`split`?`split`:B?.mode===`popover`?`popover`:V,Pe=e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:(0,$.jsx)(Qe,{schema:J(),dataSource:t})}),Fe=(0,Q.useCallback)(e=>{e||q()},[q]),Le=Me();if(Ne===`split`){let t=y?.label||e.objectName;return(0,$.jsxs)(`div`,{className:H(`flex flex-col h-full min-w-0 overflow-hidden`,n),children:[(e.title||e.description)&&(0,$.jsxs)(`div`,{className:`mb-4 shrink-0`,children:[e.title&&(0,$.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:e.title}),e.description&&(0,$.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.description})]}),Le&&(0,$.jsx)(`div`,{className:`mb-4 shrink-0`,children:Le}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:S&&O?(0,$.jsx)(Be,{isOpen:S,selectedRecord:O,mode:`split`,close:q,setIsOpen:Fe,width:B?.width,isOverlay:!0,title:v(`detail.recordDetailWithLabel`,{label:t}),mainContent:(0,$.jsx)(`div`,{className:`h-full overflow-auto`,children:Z()}),children:Pe}):Z()})]})}return(0,$.jsxs)(`div`,{className:H(`flex flex-col h-full min-w-0 overflow-hidden`,n),children:[(e.title||e.description)&&(0,$.jsxs)(`div`,{className:`mb-4 shrink-0`,children:[e.title&&(0,$.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:e.title}),e.description&&(0,$.jsx)(`p`,{className:`text-muted-foreground mt-1`,children:e.description})]}),Le&&(0,$.jsx)(`div`,{className:`mb-4 shrink-0`,children:Le}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 min-w-0 overflow-hidden`,children:Z()}),Ne===`drawer`&&Te(),Ne===`modal`&&Ee(),Ne===`popover`&&S&&O&&(0,$.jsx)(Be,{isOpen:S,selectedRecord:O,mode:`popover`,close:q,setIsOpen:Fe,width:B?.width,isOverlay:!0,title:X(),children:Pe})]})},Ft=Ze(`flex`,{variants:{layout:{inline:`flex-col space-y-4`,popover:`items-center`,drawer:`items-center`}},defaultVariants:{layout:`inline`}}),It=e=>e==null||e===``?!0:Array.isArray(e)?e.length===0:typeof e==`object`&&Object.values(e).every(e=>e==null||e===``),Lt=e=>Array.isArray(e)?{start:e[0]||``,end:e[1]||``}:e&&typeof e==`object`?{start:e.start||``,end:e.end||``}:{start:``,end:``},Rt=({schema:e,className:t,onChange:n})=>{let[r,i]=Q.useState(e.values||{}),[a,o]=Q.useState(!1);Q.useEffect(()=>{e.values&&i(e.values)},[e.values]);let s=Q.useCallback(t=>{n?.(t),e.onChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{values:t}}))},[n,e.onChange]),c=Q.useCallback((t,n)=>{let a={...r,[t]:n};i(a),e.showApply||s(a)},[s,e.showApply,r]),l=Q.useCallback(()=>{let t={};if(i(t),e.showApply){s(t);return}s(t)},[s,e.showApply]),u=Q.useCallback(()=>{s(r),o(!1)},[s,r]),d=Q.useMemo(()=>Object.values(r).filter(e=>!It(e)).length,[r]),f=e=>{let t=e.label||e.field,n=e.placeholder||`Filter by ${t}`;switch(e.type){case`number`:return(0,$.jsx)(M,{type:`number`,value:r[e.field]??``,placeholder:n,onChange:t=>{let n=t.target.value,r=n===``?``:Number(n);c(e.field,r)}});case`select`:return(0,$.jsxs)(X,{value:r[e.field]===void 0?``:String(r[e.field]),onValueChange:t=>{let n=e.options?.find(e=>String(e.value)===t);c(e.field,n?n.value:t)},children:[(0,$.jsx)(Je,{children:(0,$.jsx)(q,{placeholder:n})}),(0,$.jsx)(K,{children:e.options?.map(e=>(0,$.jsx)(Ue,{value:String(e.value),children:e.label},String(e.value)))})]});case`multi-select`:{let t=r[e.field],n=Array.isArray(t)?t:t?[t]:[];return(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto space-y-0.5 border rounded-md p-2`,children:e.options?.map(t=>{let r=n.map(String).includes(String(t.value));return(0,$.jsxs)(`label`,{className:H(`flex items-center gap-2 text-sm py-1 px-1.5 rounded cursor-pointer`,r?`bg-primary/5 text-primary`:`hover:bg-muted`),children:[(0,$.jsx)(Ye,{checked:r,onCheckedChange:r=>{let i=r?[...n,t.value]:n.filter(e=>String(e)!==String(t.value));c(e.field,i)}}),(0,$.jsx)(`span`,{className:`truncate`,children:t.label})]},String(t.value))})})}case`date`:return(0,$.jsx)(M,{type:`date`,value:r[e.field]??``,onChange:t=>c(e.field,t.target.value)});case`date-range`:{let t=Lt(r[e.field]);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(M,{type:`date`,value:t.start??``,onChange:n=>{c(e.field,{...t,start:n.target.value})}}),(0,$.jsx)(M,{type:`date`,value:t.end??``,onChange:n=>{c(e.field,{...t,end:n.target.value})}})]})}case`boolean`:return(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ye,{checked:!!r[e.field],onCheckedChange:t=>c(e.field,!!t)}),(0,$.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`Enabled`})]});default:return(0,$.jsx)(M,{value:r[e.field]??``,placeholder:n,onChange:t=>c(e.field,t.target.value)})}},p=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:e.filters.map(e=>(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(re,{className:`text-xs text-muted-foreground`,children:e.label||e.field}),f(e)]},e.field))}),(e.showApply||e.showClear)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t pt-3`,children:[e.showClear&&(0,$.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,onClick:l,children:`Clear`}),e.showApply&&(0,$.jsx)(D,{type:`button`,size:`sm`,onClick:u,children:`Apply`})]})]}),m=e.layout||`inline`;return m===`popover`?(0,$.jsx)(`div`,{className:H(Ft({layout:m}),t),children:(0,$.jsxs)(ue,{open:a,onOpenChange:o,children:[(0,$.jsx)(b,{asChild:!0,children:(0,$.jsxs)(D,{type:`button`,variant:d>0?`secondary`:`outline`,size:`sm`,className:`gap-2`,children:[(0,$.jsx)(g,{className:`h-4 w-4`}),`Filters`,d>0&&(0,$.jsx)(`span`,{className:`inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary`,children:d})]})}),(0,$.jsx)(S,{align:`start`,className:`w-[520px] p-4`,children:p})]})}):m===`drawer`?(0,$.jsxs)(`div`,{className:H(Ft({layout:m}),t),children:[(0,$.jsxs)(D,{type:`button`,variant:d>0?`secondary`:`outline`,size:`sm`,className:`gap-2`,onClick:()=>o(!0),children:[(0,$.jsx)(g,{className:`h-4 w-4`}),`Filters`,d>0&&(0,$.jsx)(`span`,{className:`inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary`,children:d})]}),(0,$.jsx)(de,{open:a,onOpenChange:o,children:(0,$.jsxs)(z,{children:[(0,$.jsxs)(j,{children:[(0,$.jsx)(Ie,{children:`Filters`}),(0,$.jsx)(T,{children:`Refine the data with advanced filters.`})]}),(0,$.jsx)(`div`,{className:`px-4 pb-6`,children:p})]})})]}):(0,$.jsxs)(`div`,{className:H(Ft({layout:m}),t),children:[p,!e.showApply&&e.showClear&&(0,$.jsxs)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`gap-2`,onClick:l,children:[(0,$.jsx)(W,{className:`h-3.5 w-3.5`}),`Clear filters`]})]})},zt=Ze(``,{variants:{variant:{buttons:`flex flex-wrap gap-2`,dropdown:`flex flex-wrap items-center gap-3`,builder:`space-y-3`}},defaultVariants:{variant:`dropdown`}}),Bt=e=>e?e.map(e=>({field:e.field,direction:e.direction})):[],Vt=e=>e.map(e=>({id:`${e.field}-${e.direction}`,field:e.field,order:e.direction})),Ht=e=>e.filter(e=>e.field).map(e=>({field:e.field,direction:e.order})),Ut=({schema:e,className:t,onChange:n})=>{let[r,i]=Q.useState(()=>Bt(e.sort)),[a,o]=Q.useState(()=>Vt(Bt(e.sort)));Q.useEffect(()=>{let t=Bt(e.sort);i(t),o(Vt(t))},[e.sort]);let s=Q.useCallback(t=>{i(t),n?.(t),e.onChange&&typeof window<`u`&&window.dispatchEvent(new CustomEvent(e.onChange,{detail:{sort:t}}))},[n,e.onChange]),c=Q.useCallback(t=>{let n=r.find(e=>e.field===t),i=!!e.multiple;if(!n){let e=i?[...r,{field:t,direction:`asc`}]:[{field:t,direction:`asc`}];s(e);return}if(n.direction===`asc`){let e=r.map(e=>e.field===t?{...e,direction:`desc`}:e);s(e);return}let a=r.filter(e=>e.field!==t);s(a)},[s,e.multiple,r]);if((e.variant||`dropdown`)===`buttons`)return(0,$.jsx)(`div`,{className:H(zt({variant:`buttons`}),t),children:e.fields.map(e=>{let t=r.find(t=>t.field===e.field);return(0,$.jsxs)(D,{type:`button`,variant:t?`secondary`:`outline`,size:`sm`,onClick:()=>c(e.field),className:`gap-2`,children:[(0,$.jsx)(`span`,{children:e.label||e.field}),t&&(0,$.jsx)(F,{className:H(`h-3.5 w-3.5 motion-safe:transition-transform motion-safe:duration-200`,t.direction===`desc`&&`rotate-180`),"aria-label":t.direction===`asc`?`ascending`:`descending`})]},e.field)})});if(e.multiple)return(0,$.jsx)(`div`,{className:H(zt({variant:`builder`}),t),children:(0,$.jsx)(he,{fields:e.fields.map(e=>({value:e.field,label:e.label||e.field})),value:a,onChange:e=>{o(e),s(Ht(e))}})});let l=r[0];return(0,$.jsxs)(`div`,{className:H(zt({variant:`dropdown`}),t),children:[(0,$.jsxs)(X,{value:l?.field||``,onValueChange:e=>{if(!e){s([]);return}s([{field:e,direction:l?.direction||`asc`}])},children:[(0,$.jsx)(Je,{className:`w-56`,children:(0,$.jsx)(q,{placeholder:`Select field`})}),(0,$.jsx)(K,{children:e.fields.map(e=>(0,$.jsx)(Ue,{value:e.field,children:e.label||e.field},e.field))})]}),(0,$.jsxs)(X,{value:l?.direction||`asc`,onValueChange:e=>{l?.field&&s([{field:l.field,direction:e}])},children:[(0,$.jsx)(Je,{className:`w-36`,children:(0,$.jsx)(q,{})}),(0,$.jsxs)(K,{children:[(0,$.jsx)(Ue,{value:`asc`,children:`Ascending`}),(0,$.jsx)(Ue,{value:`desc`,children:`Descending`})]})]})]})};function Wt(){if(typeof crypto<`u`&&typeof crypto.randomUUID==`function`)return crypto.randomUUID();if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``)}return Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)}function Gt(e,t,n,r){return`${e}/share/${t}/${n}?mode=readonly&token=${r}`}var Kt=({objectName:e,viewId:t=`default`,baseUrl:n,onShare:r,className:i})=>{let[a,o]=Q.useState(null),[s,c]=Q.useState(!1),[l,u]=Q.useState(!1),[d,f]=Q.useState(``),[p,m]=Q.useState(``),h=n??(typeof window<`u`?window.location.origin:``),g=Q.useCallback(()=>{let n=Wt(),i=Gt(h,e,t,n);o(i),c(!1);let a=p?new Date(Date.now()+parseInt(p,10)*864e5).toISOString():void 0;r?.(i,{password:d||void 0,expiresAt:a})},[h,e,t,r,d,p]),_=Q.useCallback(async()=>{if(a)try{await navigator.clipboard.writeText(a),c(!0),setTimeout(()=>c(!1),2e3)}catch{let e=document.createElement(`textarea`);e.value=a,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e),c(!0),setTimeout(()=>c(!1),2e3)}},[a]);return(0,$.jsxs)(ue,{open:l,onOpenChange:u,children:[(0,$.jsx)(b,{asChild:!0,children:(0,$.jsxs)(D,{variant:`outline`,size:`sm`,className:H(`gap-2`,i),children:[(0,$.jsx)(A,{className:`h-4 w-4`}),`Share`]})}),(0,$.jsxs)(S,{className:`w-96 space-y-4`,align:`end`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h4`,{className:`text-sm font-medium`,children:`Share View`}),(0,$.jsx)(C,{variant:`secondary`,className:`text-xs`,children:`Read-only`})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Generate a public link to share this view. Recipients can view data without logging in.`})]}),a?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(M,{value:a,readOnly:!0,className:`h-8 text-xs`,onClick:e=>e.target.select()}),(0,$.jsx)(D,{variant:`outline`,size:`sm`,onClick:_,className:`shrink-0 gap-1`,children:s?(0,$.jsx)(Oe,{className:`h-4 w-4 text-green-500`}):(0,$.jsx)(N,{className:`h-4 w-4`})})]}),(d||p)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[d&&(0,$.jsxs)(C,{variant:`outline`,className:`text-xs gap-1`,children:[(0,$.jsx)(Z,{className:`h-3 w-3`}),`Password protected`]}),p&&(0,$.jsxs)(C,{variant:`outline`,className:`text-xs gap-1`,children:[(0,$.jsx)(qe,{className:`h-3 w-3`}),`Expires in `,p,` day`,p===`1`?``:`s`]})]})]}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,$.jsx)(Z,{className:`h-3.5 w-3.5`}),`Password protection (optional)`]}),(0,$.jsx)(M,{type:`password`,value:d,onChange:e=>f(e.target.value),placeholder:`Enter password...`,className:`h-8 text-xs`})]}),(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,$.jsx)(qe,{className:`h-3.5 w-3.5`}),`Expires after (optional)`]}),(0,$.jsxs)(`select`,{value:p,onChange:e=>m(e.target.value),className:`w-full h-8 text-xs rounded-md border border-input bg-background px-3`,children:[(0,$.jsx)(`option`,{value:``,children:`Never`}),(0,$.jsx)(`option`,{value:`1`,children:`1 day`}),(0,$.jsx)(`option`,{value:`7`,children:`7 days`}),(0,$.jsx)(`option`,{value:`30`,children:`30 days`}),(0,$.jsx)(`option`,{value:`90`,children:`90 days`})]})]}),(0,$.jsxs)(D,{onClick:g,className:`w-full gap-2`,size:`sm`,children:[(0,$.jsx)(A,{className:`h-4 w-4`}),`Generate Link`]})]})]})]})};function qt(){let{t:e}=Me();return(t,n,r)=>{let i=e(t,r);return!i||i===t?n:String(i)}}var Jt={private:0,team:1,organization:2,public:3},Yt=8,Xt=({id:e,disabled:t,children:n})=>{let{attributes:r,listeners:i,setNodeRef:a,transform:o,transition:s,isDragging:c}=it({id:e,disabled:t,attributes:{role:`tab`,roleDescription:`view tab`,tabIndex:0}}),l={transform:dt.Transform.toString(o),transition:s,zIndex:c?10:void 0,opacity:c?.5:void 0};return(0,$.jsx)($.Fragment,{children:n({setNodeRef:a,style:l,listeners:i,attributes:r,isDragging:c})})},Zt=({views:e,activeViewId:t,onViewChange:n,viewTypeIcons:r={},config:i={},onAddView:a,onRenameView:o,onDuplicateView:s,onDeleteView:c,onSetDefaultView:l,onShareView:u,onSaveAsView:d,onPinView:f,onReorderViews:g,onChangeViewType:b,onConfigView:S,onManageViews:C,availableViewTypes:w,hasUnsavedChanges:T=!1,onResetChanges:k,className:j})=>{let{showAddButton:ne=!0,inlineRename:re=!0,contextMenu:ie=!0,reorderable:se=!1,maxVisibleTabs:P=4,showIndicators:F=!0,showSaveAsView:ue=!0,showPinnedSection:de=!0,showVisibilityGroups:R=!1}=i,z=qt(),[B,U]=(0,Q.useState)(null),[W,G]=(0,Q.useState)(``),K=(0,Q.useRef)(null);(0,Q.useEffect)(()=>{B&&K.current&&(K.current.focus(),K.current.select())},[B]);let he=(0,Q.useCallback)(t=>{if(!re||!o)return;let n=e.find(e=>e.id===t);n&&(n.readonly||(U(t),G(n.label)))},[re,o,e]),q=(0,Q.useCallback)(()=>{B&&W.trim()&&o&&o(B,W.trim()),U(null),G(``)},[B,W,o]),ye=(0,Q.useCallback)(()=>{U(null),G(``)},[]),be=(0,Q.useMemo)(()=>e.length>0&&e.every(e=>!!e.readonly),[e]),J=(0,Q.useMemo)(()=>{let t=[...e];return t.sort((e,t)=>{if(de){let n=+!!e.isPinned,r=+!!t.isPinned;if(n!==r)return r-n}if(R){let n=Jt[e.visibility||`public`]??Jt.public,r=Jt[t.visibility||`public`]??Jt.public;if(n!==r)return n-r}return 0}),t},[e,de,R]),{visibleViews:Y,overflowViews:X}=(0,Q.useMemo)(()=>{let e=J.slice(0,P),n=J.slice(P),r=n.findIndex(e=>e.id===t);if(r===-1)return{visibleViews:e,overflowViews:n};let i=n[r],a=e.length>0?[...e.slice(0,-1),i]:[i],o=e.length>0?e[e.length-1]:null,s=n.filter((e,t)=>t!==r);return o&&s.unshift(o),{visibleViews:a,overflowViews:s}},[J,P,t]),Ce=ut($e(nt,{activationConstraint:{distance:Yt}}),$e(lt)),Te=(0,Q.useCallback)(e=>{let{active:t,over:n}=e;if(!n||t.id===n.id||!g)return;let r=J.findIndex(e=>e.id===t.id),i=J.findIndex(e=>e.id===n.id);r!==-1&&i!==-1&&g(rt(J,r,i).map(e=>e.id))},[J,g]),Ee=Ge,De=(0,Q.useCallback)(e=>{if(!R||e===0)return!1;let t=Y[e-1],n=Y[e],r=e=>e.visibility===`private`;return r(t)&&!r(n)},[R,Y]),Oe=(e,i)=>{let a=e.id===t,d=r[e.type]||Ee,T=B===e.id,D=F&&(e.hasActiveFilters||e.hasActiveSort),k=De(i),j=!!e.readonly,ne=(e=>R?e.visibility===`private`?(0,$.jsx)(Z,{"data-testid":`view-tab-visibility-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}):e.visibility?(0,$.jsx)(E,{"data-testid":`view-tab-visibility-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}):null:null)(e),re=t=>(0,$.jsxs)(`div`,{"data-testid":`view-tab-${e.id}`,role:`tab`,tabIndex:0,"aria-selected":a,onClick:()=>!T&&n(e.id),onDoubleClick:()=>he(e.id),onKeyDown:t=>{!T&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.id))},...t?.listeners??{},...t?.attributes??{},className:H(`group/tab inline-flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap relative outline-none focus-visible:ring-2 focus-visible:ring-ring`,t?.isDragging?`cursor-grabbing`:`cursor-pointer`,a?`border-primary text-primary`:`border-transparent text-muted-foreground hover:text-foreground hover:border-border`),children:[se&&g&&(0,$.jsx)(`span`,{"data-testid":`view-tab-drag-handle-${e.id}`,"aria-hidden":`true`,className:H(`text-muted-foreground transition-opacity pointer-events-none`,`opacity-0 group-hover/tab:opacity-100`,t?.isDragging&&`opacity-100`),children:(0,$.jsx)(v,{className:`h-3 w-3`})}),de&&e.isPinned&&(0,$.jsx)(y,{"data-testid":`view-tab-pin-indicator-${e.id}`,className:`h-3 w-3 text-primary shrink-0`}),ne,(0,$.jsx)(d,{className:`h-3.5 w-3.5`}),T?(0,$.jsx)(M,{ref:K,"data-testid":`view-tab-rename-input-${e.id}`,value:W,onChange:e=>G(e.target.value),onBlur:q,onKeyDown:e=>{e.key===`Enter`&&q(),e.key===`Escape`&&ye()},className:`h-5 w-24 px-1 py-0 text-sm border-none focus-visible:ring-1`,onClick:e=>e.stopPropagation()}):(0,$.jsx)(`span`,{children:e.label}),j&&!be&&(0,$.jsxs)(we,{children:[(0,$.jsx)(ze,{asChild:!0,children:(0,$.jsx)(Z,{"data-testid":`view-tab-readonly-${e.id}`,"aria-label":z(`view.readonlyAriaLabel`,`Read-only view`),className:`h-3 w-3 text-muted-foreground shrink-0`})}),(0,$.jsx)(ge,{side:`bottom`,className:`text-xs`,children:e.readonlyReason||z(`view.readonlyTooltip`,`System view — defined in code, read-only.`)})]}),D&&(0,$.jsxs)(we,{children:[(0,$.jsx)(ze,{asChild:!0,children:(0,$.jsxs)(`span`,{"data-testid":`view-tab-indicator-${e.id}`,className:`ml-1 inline-flex items-center gap-0.5 h-4 px-1 rounded-full bg-primary/10 text-primary shrink-0`,children:[e.hasActiveFilters&&(0,$.jsx)(Le,{className:`h-2.5 w-2.5`}),e.hasActiveSort&&(0,$.jsx)(h,{className:`h-2.5 w-2.5`})]})}),(0,$.jsx)(ge,{side:`bottom`,className:`text-xs`,children:[e.hasActiveFilters&&`Active filters`,e.hasActiveSort&&`Active sort`].filter(Boolean).join(`, `)})]}),e.isDefault&&(0,$.jsx)(m,{className:`h-3 w-3 text-amber-500 fill-amber-500 shrink-0`}),a&&(S||o||s||c)&&(0,$.jsxs)(ae,{children:[(0,$.jsx)(ee,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"data-testid":`view-tab-actions-${e.id}`,className:`ml-0.5 h-4 w-4 flex items-center justify-center rounded hover:bg-accent shrink-0 opacity-70 hover:opacity-100 transition-opacity`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),"aria-label":z(`view.tabActionsFor`,`View actions for ${e.label}`,{name:e.label}),children:(0,$.jsx)(ve,{className:`h-3 w-3`})})}),(0,$.jsxs)(oe,{align:`start`,className:`min-w-[180px]`,onClick:e=>e.stopPropagation(),children:[S&&!j&&(0,$.jsxs)(O,{"data-testid":`view-tab-menu-config-${e.id}`,onClick:()=>S(e.id),children:[(0,$.jsx)(fe,{className:`h-4 w-4 mr-2`}),` `,z(`view.editViewConfig`,`Edit view config`)]}),o&&!j&&(0,$.jsxs)(O,{"data-testid":`view-tab-menu-rename-${e.id}`,onClick:()=>he(e.id),children:[(0,$.jsx)(x,{className:`h-4 w-4 mr-2`}),` `,z(`view.rename`,`Rename`)]}),s&&(0,$.jsxs)(O,{"data-testid":`view-tab-menu-duplicate-${e.id}`,onClick:()=>s(e.id),children:[(0,$.jsx)(N,{className:`h-4 w-4 mr-2`}),` `,z(`view.duplicateView`,`Duplicate view`)]}),u&&(0,$.jsxs)(O,{"data-testid":`view-tab-menu-share-${e.id}`,onClick:()=>u(e.id),children:[(0,$.jsx)(A,{className:`h-4 w-4 mr-2`}),` `,z(`view.shareView`,`Share view`)]}),l&&!j&&(0,$.jsxs)(O,{"data-testid":`view-tab-menu-default-${e.id}`,onClick:()=>l(e.id),children:[(0,$.jsx)(m,{className:`h-4 w-4 mr-2`}),` `,z(`view.setAsDefault`,`Set as default`)]}),f&&!j&&(0,$.jsx)(O,{"data-testid":`view-tab-menu-pin-${e.id}`,onClick:()=>f(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(le,{className:`h-4 w-4 mr-2`}),` `,z(`view.unpinView`,`Unpin view`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{className:`h-4 w-4 mr-2`}),` `,z(`view.pinView`,`Pin view`)]})}),b&&!j&&w&&w.length>0&&(0,$.jsxs)(Xe,{children:[(0,$.jsxs)(L,{"data-testid":`view-tab-menu-change-type-${e.id}`,children:[(0,$.jsx)(_e,{className:`h-4 w-4 mr-2`}),` `,z(`view.changeViewType`,`Change view type`)]}),(0,$.jsx)(_,{children:w.map(t=>{let n=r[t.type]||Ee;return(0,$.jsxs)(O,{"data-testid":`view-tab-menu-type-${e.id}-${t.type}`,disabled:t.type===e.type,onClick:()=>b(e.id,t.type),children:[(0,$.jsx)(n,{className:`h-4 w-4 mr-2`}),(0,$.jsx)(`span`,{children:t.label})]},t.type)})})]}),c&&!j&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{}),(0,$.jsxs)(O,{"data-testid":`view-tab-menu-delete-${e.id}`,onClick:()=>c(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Ae,{className:`h-4 w-4 mr-2`}),` `,z(`view.deleteView`,`Delete view`)]})]}),C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{}),(0,$.jsxs)(O,{"data-testid":`view-tab-menu-manage-${e.id}`,onClick:C,children:[(0,$.jsx)(Pe,{className:`h-4 w-4 mr-2`}),` `,z(`view.manageAllViews`,`Manage all views…`)]})]})]})]})]}),P=t=>!ie||T?t:(0,$.jsxs)(te,{children:[(0,$.jsx)(Ve,{asChild:!0,children:t}),(0,$.jsxs)(pe,{children:[o&&!j&&(0,$.jsxs)(V,{"data-testid":`context-menu-rename-${e.id}`,onClick:()=>he(e.id),children:[(0,$.jsx)(x,{className:`h-4 w-4 mr-2`}),` `,z(`view.rename`,`Rename`)]}),s&&(0,$.jsxs)(V,{"data-testid":`context-menu-duplicate-${e.id}`,onClick:()=>s(e.id),children:[(0,$.jsx)(N,{className:`h-4 w-4 mr-2`}),` `,z(`view.duplicateView`,`Duplicate view`)]}),u&&(0,$.jsxs)(V,{"data-testid":`context-menu-share-${e.id}`,onClick:()=>u(e.id),children:[(0,$.jsx)(A,{className:`h-4 w-4 mr-2`}),` `,z(`view.shareView`,`Share view`)]}),l&&!j&&(0,$.jsxs)(V,{"data-testid":`context-menu-default-${e.id}`,onClick:()=>l(e.id),children:[(0,$.jsx)(m,{className:`h-4 w-4 mr-2`}),` `,z(`view.setAsDefault`,`Set as default`)]}),f&&!j&&(0,$.jsx)(V,{"data-testid":`context-menu-pin-${e.id}`,onClick:()=>f(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(le,{className:`h-4 w-4 mr-2`}),` `,z(`view.unpinView`,`Unpin view`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{className:`h-4 w-4 mr-2`}),` `,z(`view.pinView`,`Pin view`)]})}),b&&!j&&w&&w.length>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(me,{}),(0,$.jsxs)(ce,{children:[(0,$.jsxs)(Se,{"data-testid":`context-menu-change-type-${e.id}`,children:[(0,$.jsx)(_e,{className:`h-4 w-4 mr-2`}),` `,z(`view.changeViewType`,`Change view type`)]}),(0,$.jsx)(p,{"data-testid":`context-menu-type-submenu-${e.id}`,children:w.map(t=>{let n=r[t.type]||Ee;return(0,$.jsxs)(V,{"data-testid":`context-menu-type-${e.id}-${t.type}`,disabled:t.type===e.type,onClick:()=>b(e.id,t.type),children:[(0,$.jsx)(n,{className:`h-4 w-4 mr-2`}),(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{children:t.label}),t.description&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.description})]})]},t.type)})})]})]}),c&&!j&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(me,{}),(0,$.jsxs)(V,{"data-testid":`context-menu-delete-${e.id}`,onClick:()=>c(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Ae,{className:`h-4 w-4 mr-2`}),` `,z(`view.deleteView`,`Delete view`)]})]}),C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(me,{}),(0,$.jsxs)(V,{"data-testid":`context-menu-manage-${e.id}`,onClick:C,children:[(0,$.jsx)(Pe,{className:`h-4 w-4 mr-2`}),` `,z(`view.manageAllViews`,`Manage all views…`)]})]})]})]});return se&&g?(0,$.jsxs)(Q.Fragment,{children:[k&&(0,$.jsx)(`div`,{"data-testid":`view-tab-visibility-separator`,className:`w-px h-5 bg-border mx-1 self-center shrink-0`}),(0,$.jsx)(Xt,{id:e.id,children:({setNodeRef:e,style:t,listeners:n,attributes:r,isDragging:i})=>(0,$.jsx)(`div`,{ref:e,style:t,className:H(`flex`,i&&`z-10`),children:P(re({listeners:n,attributes:r,isDragging:i}))})})]},e.id):(0,$.jsxs)(Q.Fragment,{children:[k&&(0,$.jsx)(`div`,{"data-testid":`view-tab-visibility-separator`,className:`w-px h-5 bg-border mx-1 self-center shrink-0`}),P(re())]},e.id)},ke=(0,$.jsx)($.Fragment,{children:Y.map((e,t)=>Oe(e,t))});return(0,$.jsx)(Ne,{children:(0,$.jsxs)(`div`,{"data-testid":`view-tab-bar`,className:H(`flex items-center gap-0.5 -mb-px`,j),children:[se&&g?(0,$.jsx)(tt,{sensors:Ce,collisionDetection:at,onDragEnd:Te,children:(0,$.jsx)(ct,{items:Y.map(e=>e.id),strategy:ot,children:(0,$.jsx)(`div`,{"data-testid":`view-tab-sortable-container`,className:`flex items-center gap-0.5`,children:ke})})}):ke,X.length>0&&(0,$.jsxs)(ae,{children:[(0,$.jsx)(ee,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`view-tab-overflow`,className:`inline-flex items-center gap-1 px-2 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors`,children:[(0,$.jsx)(We,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`text-xs`,children:z(`view.moreViews`,`${X.length} more`,{count:X.length})})]})}),(0,$.jsxs)(oe,{align:`end`,children:[C&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(O,{"data-testid":`view-tab-overflow-manage`,onClick:C,className:`font-medium`,children:[(0,$.jsx)(Pe,{className:`h-4 w-4 mr-2`}),` `,z(`view.manageAllViews`,`Manage all views…`)]}),(0,$.jsx)(I,{})]}),X.map(e=>{let t=r[e.type]||Ee;return(0,$.jsxs)(O,{"data-testid":`view-tab-overflow-${e.id}`,onClick:()=>n(e.id),children:[e.isPinned&&(0,$.jsx)(y,{className:`h-3 w-3 mr-1 text-primary shrink-0`}),(0,$.jsx)(t,{className:`h-4 w-4 mr-2`}),e.label,F&&(e.hasActiveFilters||e.hasActiveSort)&&(0,$.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-0.5 h-4 px-1 rounded-full bg-primary/10 text-primary`,children:[e.hasActiveFilters&&(0,$.jsx)(Le,{className:`h-2.5 w-2.5`}),e.hasActiveSort&&(0,$.jsx)(h,{className:`h-2.5 w-2.5`})]})]},e.id)})]})]}),ne&&a&&(0,$.jsxs)(we,{children:[(0,$.jsx)(ze,{asChild:!0,children:(0,$.jsx)(`button`,{"data-testid":`view-tab-add`,onClick:a,className:`inline-flex items-center px-2 py-2 text-muted-foreground hover:text-foreground transition-colors`,children:(0,$.jsx)(Ke,{className:`h-4 w-4`})})}),(0,$.jsx)(ge,{children:`Add View`})]}),ue&&T&&(0,$.jsxs)(`div`,{"data-testid":`view-tab-save-as`,className:`flex items-center gap-1 ml-2 text-xs text-amber-600 dark:text-amber-400`,children:[(0,$.jsx)(xe,{className:`h-3.5 w-3.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:`Unsaved changes`}),d&&(0,$.jsx)(D,{variant:`ghost`,size:`sm`,"data-testid":`view-tab-save-as-btn`,className:`h-6 px-2 text-xs`,onClick:d,children:`Save as View`}),k&&(0,$.jsx)(D,{variant:`ghost`,size:`sm`,"data-testid":`view-tab-reset-btn`,className:`h-6 px-2 text-xs`,onClick:k,children:`Reset`})]})]})})};function Qt(){let{t:e}=Me();return(t,n,r)=>{let i=e(t,r);return!i||i===t?n:String(i)}}var $t=Ge,en=({view:e,isActive:t,Icon:n,isRenaming:r,onStartRename:i,onCommitRename:a,onCancelRename:o,onRowClick:s,onDelete:c,onDuplicate:l,onSetDefault:u,onSetPinned:d,onConfigView:f})=>{let p=Qt(),{attributes:h,listeners:g,setNodeRef:_,transform:b,transition:S,isDragging:C}=it({id:e.id}),w={transform:dt.Transform.toString(b),transition:S,opacity:C?.5:1},T=(0,Q.useRef)(null),[E,D]=(0,Q.useState)(e.label),k=!!e.readonly;(0,Q.useEffect)(()=>{r&&(D(e.label),requestAnimationFrame(()=>{T.current?.focus(),T.current?.select()}))},[r,e.label]);let A=(0,Q.useCallback)(()=>{let t=E.trim();t&&t!==e.label?a(e.id,t):o()},[E,e.id,e.label,a,o]);return(0,$.jsxs)(`li`,{ref:_,style:w,"data-testid":`manage-views-row-${e.id}`,className:H(`group/row flex items-center gap-2 px-2 py-2 rounded-md border border-transparent`,`hover:bg-accent/50 transition-colors`,t&&`bg-accent/40 border-border`,C&&`shadow-md bg-background border-border z-10`),children:[(0,$.jsx)(`button`,{type:`button`,...h,...g,"aria-label":p(`view.dragToReorder`,`Drag to reorder`),"data-testid":`manage-views-drag-${e.id}`,className:`shrink-0 h-6 w-5 flex items-center justify-center text-muted-foreground/40 hover:text-muted-foreground cursor-grab active:cursor-grabbing rounded hover:bg-accent`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(v,{className:`h-4 w-4`})}),(0,$.jsx)(n,{className:`shrink-0 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(`div`,{className:`flex-1 min-w-0`,onClick:()=>{r||s?.(e.id)},children:r?(0,$.jsx)(M,{ref:T,value:E,onChange:e=>D(e.target.value),onBlur:A,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),A()):e.key===`Escape`&&(e.preventDefault(),o())},onClick:e=>e.stopPropagation(),className:`h-7 text-sm`,"data-testid":`manage-views-rename-input-${e.id}`}):(0,$.jsxs)(`button`,{type:`button`,className:`w-full text-left text-sm font-medium truncate cursor-pointer flex items-center gap-1.5`,onDoubleClick:t=>{t.stopPropagation(),k||i(e.id)},title:e.label,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e.label}),k&&(0,$.jsx)(Z,{"aria-label":p(`view.readonlyAriaLabel`,`Read-only view`),"data-testid":`manage-views-readonly-${e.id}`,className:`h-3 w-3 text-muted-foreground shrink-0`}),e.isDefault&&(0,$.jsxs)(`span`,{className:`ml-1 inline-flex items-center text-[10px] uppercase tracking-wide text-muted-foreground`,title:p(`view.defaultView`,`Default view`),children:[(0,$.jsx)(m,{className:`h-3 w-3 mr-0.5 fill-current`}),` `,p(`view.defaultBadge`,`default`)]})]})}),d&&!r&&!k&&(0,$.jsx)(Ne,{delayDuration:300,children:(0,$.jsxs)(we,{children:[(0,$.jsx)(ze,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":e.isPinned?p(`view.unpinView`,`Unpin View`):p(`view.pinView`,`Pin View`),"data-testid":`manage-views-pin-${e.id}`,onClick:t=>{t.stopPropagation(),d(e.id,!e.isPinned)},className:H(`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent transition-colors`,e.isPinned?`text-amber-500`:`text-muted-foreground/40 opacity-0 group-hover/row:opacity-100`),children:e.isPinned?(0,$.jsx)(y,{className:`h-4 w-4 fill-current`}):(0,$.jsx)(y,{className:`h-4 w-4`})})}),(0,$.jsx)(ge,{side:`top`,children:e.isPinned?p(`view.unpinView`,`Unpin View`):p(`view.pinView`,`Pin View`)})]})}),u&&!r&&!e.isDefault&&!k&&(0,$.jsx)(Ne,{delayDuration:300,children:(0,$.jsxs)(we,{children:[(0,$.jsx)(ze,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":p(`view.setAsDefault`,`Set as Default`),"data-testid":`manage-views-default-${e.id}`,onClick:t=>{t.stopPropagation(),u(e.id)},className:`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground/40 hover:text-foreground opacity-0 group-hover/row:opacity-100 transition-colors`,children:(0,$.jsx)(m,{className:`h-4 w-4`})})}),(0,$.jsx)(ge,{side:`top`,children:p(`view.setAsDefault`,`Set as Default`)})]})}),!r&&(c||l||f||u)&&(0,$.jsxs)(ae,{children:[(0,$.jsx)(ee,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":p(`view.tabActionsFor`,`View actions for ${e.label}`,{name:e.label}),"data-testid":`manage-views-actions-${e.id}`,onClick:e=>e.stopPropagation(),className:`shrink-0 h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground opacity-60 group-hover/row:opacity-100 transition-opacity`,children:(0,$.jsx)(We,{className:`h-4 w-4`})})}),(0,$.jsxs)(oe,{align:`end`,className:`min-w-[180px]`,children:[!k&&(0,$.jsxs)(O,{"data-testid":`manage-views-action-rename-${e.id}`,onClick:()=>i(e.id),children:[(0,$.jsx)(x,{className:`h-4 w-4 mr-2`}),` `,p(`view.rename`,`Rename`)]}),l&&(0,$.jsxs)(O,{"data-testid":`manage-views-action-duplicate-${e.id}`,onClick:()=>l(e.id),children:[(0,$.jsx)(N,{className:`h-4 w-4 mr-2`}),` `,p(`view.duplicateView`,`Duplicate View`)]}),f&&!k&&(0,$.jsxs)(O,{"data-testid":`manage-views-action-config-${e.id}`,onClick:()=>f(e.id),children:[(0,$.jsx)(x,{className:`h-4 w-4 mr-2`}),` `,p(`view.editViewConfig`,`Edit view config`)]}),u&&!e.isDefault&&!k&&(0,$.jsxs)(O,{"data-testid":`manage-views-action-default-${e.id}`,onClick:()=>u(e.id),children:[(0,$.jsx)(m,{className:`h-4 w-4 mr-2`}),` `,p(`view.setAsDefault`,`Set as Default`)]}),d&&!k&&(0,$.jsx)(O,{"data-testid":`manage-views-action-pin-${e.id}`,onClick:()=>d(e.id,!e.isPinned),children:e.isPinned?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(le,{className:`h-4 w-4 mr-2`}),` `,p(`view.unpinView`,`Unpin View`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(y,{className:`h-4 w-4 mr-2`}),` `,p(`view.pinView`,`Pin View`)]})}),c&&!k&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(I,{}),(0,$.jsxs)(O,{"data-testid":`manage-views-action-delete-${e.id}`,onClick:()=>c(e.id),className:`text-destructive focus:text-destructive`,children:[(0,$.jsx)(Ae,{className:`h-4 w-4 mr-2`}),` `,p(`view.deleteView`,`Delete View`)]})]})]})]}),r&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[(0,$.jsx)(`button`,{type:`button`,"aria-label":p(`common.save`,`Save`),onMouseDown:e=>e.preventDefault(),onClick:A,className:`h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-emerald-600`,children:(0,$.jsx)(Oe,{className:`h-4 w-4`})}),(0,$.jsx)(`button`,{type:`button`,"aria-label":p(`common.cancel`,`Cancel`),onMouseDown:e=>e.preventDefault(),onClick:o,className:`h-7 w-7 inline-flex items-center justify-center rounded hover:bg-accent text-muted-foreground`,children:(0,$.jsx)(W,{className:`h-4 w-4`})})]})]})},tn=({open:e,onOpenChange:t,views:n,activeViewId:r,viewTypeIcons:i={},onRename:a,onDelete:o,onDuplicate:s,onSetDefault:c,onSetPinned:l,onReorder:u,onAddView:d,onConfigView:f})=>{let p=Qt(),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(()=>n.map(e=>e.id));(0,Q.useEffect)(()=>{y(n.map(e=>e.id))},[n]),(0,Q.useEffect)(()=>{e||(_(null),h(``))},[e]);let b=(0,Q.useMemo)(()=>{let e=new Map(n.map(e=>[e.id,e]));return v.map(t=>e.get(t)).filter(Boolean)},[v,n]),x=(0,Q.useMemo)(()=>{if(!m.trim())return b;let e=m.toLowerCase();return b.filter(t=>t.label.toLowerCase().includes(e))},[b,m]),S=ut($e(nt,{activationConstraint:{distance:5}}),$e(lt,{coordinateGetter:et})),C=e=>{let{active:t,over:n}=e;if(!n||t.id===n.id)return;let r=v.indexOf(String(t.id)),i=v.indexOf(String(n.id));if(r<0||i<0)return;let a=rt(v,r,i);y(a),u?.(a)},w=e=>{t(!1),requestAnimationFrame(()=>f?.(e))};return(0,$.jsx)(He,{open:e,onOpenChange:t,children:(0,$.jsxs)(be,{className:`sm:max-w-[560px] p-0 gap-0 overflow-hidden`,"data-testid":`manage-views-dialog`,children:[(0,$.jsxs)(je,{className:`px-5 pt-5 pb-3`,children:[(0,$.jsx)(Ce,{className:`text-base`,children:p(`view.manageViews`,`Manage views`)}),(0,$.jsx)(Y,{className:`text-xs`,children:p(`view.manageViewsDescription`,`Reorder, rename, pin, or delete every view in this object.`)})]}),(0,$.jsx)(`div`,{className:`px-5 pb-3`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(P,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none`}),(0,$.jsx)(M,{value:m,onChange:e=>h(e.target.value),placeholder:p(`view.searchViews`,`Search views`),className:`pl-8 h-9`,"data-testid":`manage-views-search`})]})}),(0,$.jsx)(`div`,{className:`px-3 pb-3 max-h-[55vh] overflow-y-auto`,"data-testid":`manage-views-list`,children:x.length===0?(0,$.jsx)(`div`,{className:`text-center text-sm text-muted-foreground py-10`,children:p(`view.noViewsFound`,`No views match your search.`)}):(0,$.jsx)(tt,{sensors:S,collisionDetection:at,onDragEnd:C,children:(0,$.jsx)(ct,{items:x.map(e=>e.id),strategy:st,children:(0,$.jsx)(`ul`,{className:`space-y-0.5`,children:x.map(e=>{let t=i[e.type]||$t;return(0,$.jsx)(en,{view:e,Icon:t,isActive:e.id===r,isRenaming:g===e.id,onStartRename:e=>_(e),onCancelRename:()=>_(null),onCommitRename:(e,t)=>{_(null),a?.(e,t)},onDelete:o,onDuplicate:s,onSetDefault:c,onSetPinned:l,onConfigView:f?w:void 0},e.id)})})})})}),(0,$.jsxs)(Fe,{className:`border-t bg-muted/30 px-5 py-3 flex sm:justify-between gap-2`,children:[d?(0,$.jsxs)(D,{variant:`ghost`,size:`sm`,onClick:()=>{t(!1),requestAnimationFrame(()=>d())},"data-testid":`manage-views-add`,className:`text-sm`,children:[(0,$.jsx)(Ke,{className:`h-4 w-4 mr-1.5`}),` `,p(`view.addNewView`,`Add new view`)]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(D,{size:`sm`,onClick:()=>t(!1),"data-testid":`manage-views-done`,children:p(`view.done`,`Done`)})]})]})})},nn=e=>e.toLowerCase().replace(/[\s_-]+/g,``);new Map([...i.map(e=>[nn(e),e]),...Object.entries(r).map(([e,t])=>[nn(e),t])]);function rn(e){let t=(e||``).toLowerCase();return[`integer`,`int`,`float`,`double`,`number`,`currency`,`money`,`percent`,`rating`].includes(t)?`number`:[`date`,`datetime`,`datetime_tz`,`timestamp`,`time`].includes(t)?`date`:[`boolean`,`bool`,`checkbox`,`switch`].includes(t)?`boolean`:[`select`,`picklist`,`single_select`,`multi_select`,`enum`,`status`,`lookup`,`master_detail`,`user`,`owner`].includes(t)?`select`:`text`}function an(e){return e.fields?Object.entries(e.fields).filter(([e,t])=>!(e.startsWith(`_`)||t?.hidden)).map(([e,t])=>({value:e,label:t.label||e,type:rn(t.type),options:t.options,rawType:t.type,rawName:e})):[]}var on=new Set([`image`,`image_url`,`photo`,`picture`,`avatar`,`file`,`attachment`,`attachments`,`media`,`url`,`link`]),sn=[`image`,`photo`,`picture`,`avatar`,`thumbnail`,`thumb`,`logo`,`cover`,`banner`,`icon`,`attachment`];function cn(e){if(!e)return!1;let t=(e.rawType||e.type||``).toLowerCase();if(on.has(t))return!0;let n=(e.rawName||e.name||e.key||e.value||``).toLowerCase();return n?sn.some(e=>n.includes(e)):!1}var ln=new Set([`geolocation`,`geo`,`geo_point`,`geopoint`,`location`,`latlng`,`lnglat`]);function un(e,t){if(!e)return!1;let n=(e.rawType||e.type||``).toLowerCase();if(ln.has(n))return!0;let r=(e.rawName||e.name||e.key||e.value||``).toLowerCase();return r?t===`latitude`?/(^|[_-])lat([^a-z]|itude)?($|[_-])/.test(r)||r===`lat`:/(^|[_-])(lng|lon|long)([^a-z]|gitude)?($|[_-])/.test(r)||r===`lng`||r===`lon`:!1}function dn(e,t){if(e.length!==0){for(let n of t){let t=e.find(e=>e.value.toLowerCase().includes(n));if(t)return t.value}return e[0]?.value}}var fn=[`status`,`stage`,`state`,`priority`,`category`,`type`],pn=[`start_date`,`startdate`,`due_date`,`duedate`,`event_date`,`date`,`created_at`,`createdat`,`created`],mn=[`end_date`,`enddate`,`finish_date`,`completion_date`,`closed_at`],hn=f,gn=({schema:e})=>{let t=(0,Q.useContext)(hn)?.dataSource??null;return(0,$.jsx)(Pt,{schema:e,dataSource:t})};c.register(`object-view`,gn,{namespace:`plugin-view`,label:`Object View`,category:`view`,icon:`LayoutDashboard`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`layout`,type:`enum`,label:`Form Layout`,enum:[`drawer`,`modal`,`page`]},{name:`defaultViewType`,type:`enum`,label:`Default View Type`,enum:[`grid`,`kanban`,`gallery`,`calendar`,`timeline`,`gantt`,`map`]},{name:`defaultListView`,type:`string`,label:`Default Named View`},{name:`showSearch`,type:`boolean`,label:`Show Search`},{name:`showFilters`,type:`boolean`,label:`Show Filters`},{name:`showCreate`,type:`boolean`,label:`Show Create Button`},{name:`showRefresh`,type:`boolean`,label:`Show Refresh Button`},{name:`showViewSwitcher`,type:`boolean`,label:`Show View Switcher`},{name:`listViews`,type:`object`,label:`Named List Views`},{name:`navigation`,type:`object`,label:`Navigation Config`},{name:`searchableFields`,type:`array`,label:`Searchable Fields`},{name:`filterableFields`,type:`array`,label:`Filterable Fields`}],defaultProps:{layout:`drawer`,defaultViewType:`grid`,showSearch:!0,showFilters:!0,showCreate:!0,showRefresh:!0,showViewSwitcher:!0}}),c.register(`view`,gn,{namespace:`plugin-view`,label:`View`,category:`view`}),c.register(`view-switcher`,Dt,{namespace:`view`,label:`View Switcher`,category:`view`,icon:`LayoutGrid`,inputs:[{name:`views`,type:`array`,label:`Views`,required:!0},{name:`defaultView`,type:`string`,label:`Default View`},{name:`activeView`,type:`string`,label:`Active View`},{name:`variant`,type:`enum`,label:`Variant`,enum:[`tabs`,`buttons`,`dropdown`]},{name:`position`,type:`enum`,label:`Position`,enum:[`top`,`bottom`,`left`,`right`]},{name:`persistPreference`,type:`boolean`,label:`Persist Preference`},{name:`storageKey`,type:`string`,label:`Storage Key`},{name:`onViewChange`,type:`string`,label:`On View Change Event`}],defaultProps:{variant:`tabs`,position:`top`,defaultView:`grid`,views:[{type:`grid`,label:`Grid`,schema:{type:`text`,content:`Grid view`}},{type:`list`,label:`List`,schema:{type:`text`,content:`List view`}}]}}),c.register(`filter-ui`,Rt,{namespace:`view`,label:`Filter UI`,category:`view`,icon:`SlidersHorizontal`,inputs:[{name:`filters`,type:`array`,label:`Filters`,required:!0},{name:`values`,type:`object`,label:`Values`},{name:`onChange`,type:`string`,label:`On Change Event`},{name:`showClear`,type:`boolean`,label:`Show Clear Button`},{name:`showApply`,type:`boolean`,label:`Show Apply Button`},{name:`layout`,type:`enum`,label:`Layout`,enum:[`inline`,`popover`,`drawer`]}],defaultProps:{layout:`inline`,showApply:!1,showClear:!0,filters:[{field:`name`,label:`Name`,type:`text`,placeholder:`Search name`},{field:`status`,label:`Status`,type:`select`,options:[{label:`Open`,value:`open`},{label:`Closed`,value:`closed`}]},{field:`created_at`,label:`Created`,type:`date`}]}}),c.register(`sort-ui`,Ut,{namespace:`view`,label:`Sort UI`,category:`view`,icon:`ArrowUpDown`,inputs:[{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`sort`,type:`array`,label:`Sort`},{name:`onChange`,type:`string`,label:`On Change Event`},{name:`multiple`,type:`boolean`,label:`Allow Multiple`},{name:`variant`,type:`enum`,label:`Variant`,enum:[`dropdown`,`buttons`]}],defaultProps:{variant:`dropdown`,multiple:!0,fields:[{field:`name`,label:`Name`},{field:`created_at`,label:`Created At`}],sort:[{field:`name`,direction:`asc`}]}}),c.register(`shared-view-link`,Kt,{namespace:`view`,label:`Shared View Link`,category:`view`,icon:`Share2`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewId`,type:`string`,label:`View ID`},{name:`baseUrl`,type:`string`,label:`Base URL`}],defaultProps:{objectName:`objects`,viewId:`default`}}),c.register(`view:simple`,({schema:e,className:t,children:n,dataSource:r,...i})=>{let a=e.props?.columns?{display:`grid`,gridTemplateColumns:`repeat(${e.props.columns}, 1fr)`,gap:`1rem`}:void 0;return(0,$.jsx)(`div`,{className:t,style:a,...i,children:n})},{namespace:`plugin-view`,label:`Simple View`,category:`view`});export{un as a,tn as c,At as d,an as i,Zt as l,fn as n,cn as o,pn as r,dn as s,mn as t,Pt as u};
|