@objectstack/console 11.3.0 → 11.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/assets/{AdapterProvider-BiTdGDAR.js → AdapterProvider-DPeLrdd0.js} +1 -1
  2. package/dist/assets/{AiPendingActionsPage-pA6WQiJs.js → AiPendingActionsPage-CK0MN4fG.js} +1 -1
  3. package/dist/assets/{ApiConsolePage-C2RUq2a1.js → ApiConsolePage-BmQiYn3w.js} +1 -1
  4. package/dist/assets/{AppDocsIndex-4jDRVpod.js → AppDocsIndex-BZTtsBDk.js} +1 -1
  5. package/dist/assets/{AppManagementPage-D4Qdfc-k.js → AppManagementPage-JurgDSH0.js} +1 -1
  6. package/dist/assets/{ApprovalsInboxPage-97ofFRyB.js → ApprovalsInboxPage-C9iYBMLT.js} +1 -1
  7. package/dist/assets/{AuditLogPage-CE9VainX.js → AuditLogPage-DL7PJi-M.js} +1 -1
  8. package/dist/assets/{ComponentNavView-HWYwp2J3.js → ComponentNavView-DKxGXsn4.js} +1 -1
  9. package/dist/assets/{ConsoleFloatingChatbot-CYQ0DGQS.js → ConsoleFloatingChatbot-C2nsKCCe.js} +1 -1
  10. package/dist/assets/{DashboardView-_v1xyHY7.js → DashboardView-B7b14P2Q.js} +1 -1
  11. package/dist/assets/{DashboardWidgetInspector-CagpzDS6.js → DashboardWidgetInspector-C34BJd1Y.js} +1 -1
  12. package/dist/assets/{DeveloperHubPage-BSqHoM6g.js → DeveloperHubPage-L2d7wuq1.js} +1 -1
  13. package/dist/assets/{ExpressionProvider-BeRnSjp4.js → ExpressionProvider-1HR1mriH.js} +1 -1
  14. package/dist/assets/{FlowRunsPage-dzQVp59a.js → FlowRunsPage-BjOtW_pQ.js} +1 -1
  15. package/dist/assets/{IntegrationsPage-COUMVn63.js → IntegrationsPage-DAdLb-sn.js} +1 -1
  16. package/dist/assets/{InterfaceListPage-DyRkCp_l.js → InterfaceListPage-DqCSKUiZ.js} +1 -1
  17. package/dist/assets/{ManagedByBadge-CorAI3gR.js → ManagedByBadge-DbBdqwy6.js} +1 -1
  18. package/dist/assets/{MarketplaceAccessDenied-BQ6-NcgV.js → MarketplaceAccessDenied-D5Q4tCaN.js} +1 -1
  19. package/dist/assets/{MarketplaceInstalledPage-CUPRsl4f.js → MarketplaceInstalledPage-DVJsLTJz.js} +1 -1
  20. package/dist/assets/{MarketplacePackagePage-CiSZE5lH.js → MarketplacePackagePage-BAmq5XCe.js} +1 -1
  21. package/dist/assets/{MarketplacePage-CzTXmemx.js → MarketplacePage-DEHHowk4.js} +1 -1
  22. package/dist/assets/MetadataInspector-B-6wYdsG.js +1 -0
  23. package/dist/assets/{MetadataProvider-CkIT9awy.js → MetadataProvider-BWz_wO6c.js} +1 -1
  24. package/dist/assets/{PageView-B82BdAMg.js → PageView-Cpr2xKrz.js} +1 -1
  25. package/dist/assets/{ProfilePage-BbTxTg63.js → ProfilePage-DqnQIsPE.js} +1 -1
  26. package/dist/assets/{PublicFormsPage-CHmoVuOC.js → PublicFormsPage-31yNJEQI.js} +1 -1
  27. package/dist/assets/{RecordDetailView-Bo53OY-a.js → RecordDetailView-BQ_3CT6r.js} +2 -2
  28. package/dist/assets/{RecordFormPage-BXLWOLOE.js → RecordFormPage-BlwecW-b.js} +1 -1
  29. package/dist/assets/{ReportDefaultInspector-BxP74HM2.js → ReportDefaultInspector-CN7-euct.js} +2 -2
  30. package/dist/assets/{ReportView-BWv6u_ys.js → ReportView-sIfQGnUd.js} +1 -1
  31. package/dist/assets/{SearchResultsPage-DvvT6E4h.js → SearchResultsPage-tqhQY_2e.js} +1 -1
  32. package/dist/assets/{SettingsHub-CDaz4A8F.js → SettingsHub-DxYP6XPZ.js} +1 -1
  33. package/dist/assets/{SettingsView-CkL3YJNr.js → SettingsView-BozW36Q1.js} +1 -1
  34. package/dist/assets/{SystemHubPage-DRMrwvla.js → SystemHubPage-BWj_QRhg.js} +1 -1
  35. package/dist/assets/{data-adapter-B9YoyoUW.js → data-adapter-ByjA1NUo.js} +1 -1
  36. package/dist/assets/{framework-BGQ7DoWM.js → framework-DxDZ_zWg.js} +7 -7
  37. package/dist/assets/{highlighted-body-OFNGDK62-D9Y-fWz-.js → highlighted-body-OFNGDK62-Dd_tKU0d.js} +1 -1
  38. package/dist/assets/{index-BzqR5LGR.js → index-BOAOy2Kf.js} +1 -1
  39. package/dist/assets/index-D77Ldu25.css +2 -0
  40. package/dist/assets/mermaid-GHXKKRXX-C3IUIOL6.js +1 -0
  41. package/dist/assets/{metadata-admin-CWGl9yQd.js → metadata-admin-D-7GOz4f.js} +5 -5
  42. package/dist/assets/{plugin-calendar-Bvz5MlbF.js → plugin-calendar-BcvpxKiE.js} +1 -1
  43. package/dist/assets/plugin-charts-CDte3Ehs.js +7 -0
  44. package/dist/assets/{plugin-chatbot-C7dKmmA6.js → plugin-chatbot-DniX3Bvt.js} +5 -5
  45. package/dist/assets/{plugin-dashboard-CWaZph1r.js → plugin-dashboard-o2MA7Ifu.js} +3 -3
  46. package/dist/assets/{plugin-form-B73E4Mbd.js → plugin-form-DZ4onNeM.js} +1 -1
  47. package/dist/assets/{plugin-gantt-Bf38rZLK.js → plugin-gantt-AilsJyD3.js} +2 -2
  48. package/dist/assets/{plugin-grid-a4T-OeTY.js → plugin-grid-3YqjO8MI.js} +4 -4
  49. package/dist/assets/{plugin-kanban-Co4jnw0I.js → plugin-kanban-CLMCf7aa.js} +1 -1
  50. package/dist/assets/{plugin-map-Cr2T-pjl.js → plugin-map-CWL5OAIS.js} +1 -1
  51. package/dist/assets/{plugin-markdown-PeIRJlRw.js → plugin-markdown-Bb6EtX1b.js} +1 -1
  52. package/dist/assets/{plugin-report-DacHRf4i.js → plugin-report-B8k3qnd6.js} +3 -3
  53. package/dist/assets/{plugin-timeline-ueCjCHSY.js → plugin-timeline-CHfJ8XYZ.js} +1 -1
  54. package/dist/assets/{plugin-tree-KBPNkKuR.js → plugin-tree-DabKEfvM.js} +1 -1
  55. package/dist/assets/{plugin-view-CbNN954o.js → plugin-view-c3Puf0-v.js} +1 -1
  56. package/dist/assets/plugins-views-BFmfVAkr.js +4 -0
  57. package/dist/assets/{skeletons-CZdepTdC.js → skeletons-Cct3--c-.js} +1 -1
  58. package/dist/assets/src-BM-XgFqH.js +2 -0
  59. package/dist/assets/src-BvIm_4jD.js +135 -0
  60. package/dist/assets/{src-DzNV76wU.js → src-f2cvKHyo.js} +1 -1
  61. package/dist/assets/{types-CoZkCf64.js → types-eEPSTWZr.js} +1 -1
  62. package/dist/assets/ui-components-BDy7soRa.js +42 -0
  63. package/dist/assets/{ui-layout-DQDnaREz.js → ui-layout-tBg9Ny6m.js} +1 -1
  64. package/dist/assets/{useActionModal-DI7oaRiK.js → useActionModal-Cd50Dc4Y.js} +1 -1
  65. package/dist/assets/{useOpenRecordList-pMYhKC_q.js → useOpenRecordList-CKVQ3oer.js} +1 -1
  66. package/dist/assets/{useReconcileOnError-p9SZCLMb.js → useReconcileOnError-D8Uet4j6.js} +1 -1
  67. package/dist/index.html +4 -4
  68. package/package.json +1 -1
  69. package/dist/assets/MetadataInspector-Ci4IEXl6.js +0 -1
  70. package/dist/assets/index-0xh0t0SY.css +0 -2
  71. package/dist/assets/mermaid-GHXKKRXX-DfINr0ix.js +0 -1
  72. package/dist/assets/plugin-charts-BQs_--tP.js +0 -7
  73. package/dist/assets/plugins-views-C-R-Gk81.js +0 -4
  74. package/dist/assets/src-DRWgP_lu.js +0 -2
  75. package/dist/assets/ui-components-J75dr3Ae.js +0 -42
@@ -1,6 +1,6 @@
1
- import{o as e,r as t,t as n}from"./rolldown-runtime-DAXXjFlN.js";import{_ as r,g as i,t as a}from"./vendor-react-slxo-5GC.js";import{N as o,P as s,V as c,Y as l,Z as u,b as d,ct as f,dt as p,ft as m,gt as h,ht as g,i as _,it as v,jt as y,kt as b,lt as x,m as S,mt as C,n as w,nt as T,ot as E,pt as ee,rt as D,st as O,t as k,tt as A,ut as j}from"./framework-BGQ7DoWM.js";import{$ as M,B as te,Dc as N,Fi as P,Gi as F,H as I,Ic as ne,Jn as re,Jr as ie,Kt as L,Ls as ae,Mc as R,Mr as z,N as B,Pc as V,Qn as oe,Rc as se,Sc as ce,Tr as H,Ua as U,Ut as le,V as ue,Vt as W,Wt as G,Zn as K,_ as q,a as de,ec as J,f as fe,hi as pe,ir as Y,it as X,ka as me,ki as he,o as ge,or as _e,ot as ve,qn as ye,qt as be,rr as xe,rt as Se,sr as Ce,ts as we,u as Te,xc as Ee,yo as De,z as Oe,zc as ke}from"./ui-components-J75dr3Ae.js";import{o as Ae,t as je}from"./vendor-ui-utils-C1OpMExs.js";import{_ as Me,c as Ne,d as Pe,g as Fe,h as Ie,i as Le,n as Re,o as ze,p as Be,s as Ve,t as He}from"./vendor-dndkit-DoPtQigN.js";var Z=e(r(),1),Ue=e(i(),1),Q=a();function We(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&e.provider===`object`}function Ge(e,t){if(t==null||e==null||typeof e!=`number`||!Number.isFinite(e)||typeof t!=`number`||!Number.isFinite(t))return null;if(t===0)return e===0?{value:0,direction:`neutral`}:{value:100,direction:e>0?`up`:`down`};let n=e-t;if(n===0)return{value:0,direction:`neutral`};let r=Math.round(n/Math.abs(t)*100);return{value:Math.abs(r),direction:r>0?`up`:`down`}}var Ke=new Set([`id`,`organization_id`,`tenant_id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`deleted_at`,`deleted_by`,`version`,`_id`,`__typename`]);function qe(e,t){return t&&(t.isSystem===!0||t.system===!0)?!0:Ke.has(e)}var Je=new Set([`select`,`picklist`,`dropdown`,`status`]),Ye=new Set([`currency`,`money`,`number`,`integer`,`decimal`,`float`,`percent`,`percentage`]);function Xe(e){let t={},n=e?.fields;if(!n)return t;if(Array.isArray(n))for(let e of n)e?.name&&(t[e.name]=e);else for(let[e,r]of Object.entries(n))t[e]={name:e,...r};return t}function Ze(e){let{accessorKey:t,label:n,def:r,objectName:i,fieldOptionLabel:a,overrides:o={}}=e,s=o.referenceTo??r?.referenceTo??(typeof r?.reference==`string`?r.reference:r?.reference?.to)??r?.target,c=o.options??r?.options;return i&&c&&a&&Je.has(r?.type)&&(c=c.map(e=>{if(e==null)return e;let n=typeof e==`object`?e.value:e,r=typeof e==`object`&&e.label||String(n);return{value:n,label:a(i,t,String(n),r),color:typeof e==`object`?e.color:void 0}})),{name:t,label:n,type:o.type??r?.type,options:c,referenceTo:s,format:o.format??r?.format,currency:o.currency??r?.currency??r?.defaultCurrency,decimals:o.decimals??r?.decimals??r?.precision??r?.scale}}function Qe(e){return Ye.has(e.type)||typeof e.format==`string`&&/^[\$¥€£]|%$|0/.test(e.format)}function $e(e,t,n){if(e==null||e===``)return``;let r=t.format;if(typeof r==`string`&&/^\$|¥|€|£/.test(r)&&typeof e==`number`){let i={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`}[r[0]];return de(e,t.currency||i||n)}if(typeof r==`string`&&/%/.test(r)&&typeof e==`number`){let t=(r.match(/0\.(0+)%/)||[,``])[1].length;return Te((e>1?e/100:e)*100,t)}return typeof r==`string`&&/[YMDHms]/.test(r)?ge(e,r):(0,Q.jsx)(fe(q(t)),{value:e,field:t})}var et=[`name`,`title`,`label`,`subject`,`display_name`,`full_name`];function tt(e,t){if(t&&t.trim())return t;for(let t of et){let n=e[t];if(typeof n==`string`&&n.trim())return n}let n=e.id??e._id;return n==null?`Record`:String(n)}var nt=({record:e,objectName:t,objectSchema:n,fields:r,title:i,target:a=`drawer`,onClose:o})=>{let{fieldLabel:s,fieldOptionLabel:c}=ke(),{currency:l}=ne(),u=(0,Z.useMemo)(()=>{if(!e)return[];let i=Xe(n),a;return a=r&&r.length>0?r:Object.keys(i).length>0?Object.keys(i).filter(e=>!qe(e,i[e])):Object.keys(e).filter(e=>!e.startsWith(`_`)&&!qe(e)),a.map(n=>{let r=i[n],a=n.charAt(0).toUpperCase()+n.slice(1).replace(/([A-Z])/g,` $1`).replace(/_/g,` `),o=t?s(t,n,a):a,u=Ze({accessorKey:n,label:o,def:r,objectName:t,fieldOptionLabel:c});return{key:n,label:o,node:$e(e[n],u,l),numeric:Qe(u)}})},[e,n,t,r,s,c,l]);if(!e)return null;let d=tt(e,i),f=(0,Q.jsx)(`dl`,{className:`divide-y divide-border/60`,"data-testid":`record-detail-body`,children:u.map(e=>(0,Q.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 py-2.5`,children:[(0,Q.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground self-center`,children:e.label}),(0,Q.jsx)(`dd`,{className:`col-span-2 text-sm break-words ${e.numeric?`tabular-nums`:``}`,children:e.node===``||e.node==null?(0,Q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`—`}):e.node})]},e.key))});return a===`dialog`?(0,Q.jsx)(ye,{open:!0,onOpenChange:e=>!e&&o(),children:(0,Q.jsxs)(re,{className:`max-w-2xl`,children:[(0,Q.jsx)(K,{children:(0,Q.jsx)(oe,{children:d})}),(0,Q.jsx)(`div`,{className:`max-h-[70vh] overflow-auto`,children:f})]})}):(0,Q.jsx)(le,{open:!0,onOpenChange:e=>!e&&o(),children:(0,Q.jsxs)(G,{side:`right`,className:`w-full sm:max-w-md md:max-w-lg flex flex-col`,children:[(0,Q.jsx)(L,{children:(0,Q.jsx)(be,{children:d})}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto mt-2 pr-1`,children:f})]})})};function rt(e){return e.map(e=>typeof e==`string`?{header:e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().replace(/\b\w/g,e=>e.toUpperCase()),accessorKey:e}:e)}function it(e,t){if(!t?.fields)return[];let n={};if(Array.isArray(t.fields))for(let e of t.fields)e?.name&&(n[e.name]=e);else for(let[e,r]of Object.entries(t.fields))n[e]={name:e,...r};let r=e=>e===`lookup`||e===`reference`||e===`master_detail`||e===`user`||e===`owner`,i=Array.isArray(e.columns)?e.columns:[],a=new Set;if(i.length>0){let e=i.map(e=>typeof e==`string`?e:e.accessorKey||e.name).filter(Boolean);for(let t of e){let e=n[t];e&&r(e.type)&&a.add(t)}}else for(let[e,t]of Object.entries(n))r(t?.type)&&a.add(e);return Array.from(a)}var at=({schema:e,dataSource:t,className:n})=>{let{currency:r}=ne(),i=(0,Z.useContext)(l),a=t||i?.dataSource,o=u(e.bind),{fieldLabel:s,fieldOptionLabel:d}=ke(),f=`No data available`,p=`No data source available for`;try{let{t:e}=_(),t=e(`dashboard.noDataAvailable`);t&&t!==`dashboard.noDataAvailable`&&(f=t);let n=e(`dashboard.noDataSourceFor`);n&&n!==`dashboard.noDataSourceFor`&&(p=n)}catch{}let[m,h]=(0,Z.useState)([]),[v,y]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(()=>!(Array.isArray(e.data)&&e.data.length>0)&&!!e.objectName),[C,w]=(0,Z.useState)(null),T=e.drillDown,E=g(T)&&(T?.mode??`record`)===`record`,[D,O]=(0,Z.useState)(null),k=(0,Z.useCallback)(e=>{O(e??null)},[]);(0,Z.useEffect)(()=>{let t=!0;return e.objectName&&!o&&(!e.data||e.data.length===0)?(async()=>{if(!a||!e.objectName){t&&S(!1);return}t&&(S(!0),w(null));try{let n;if(typeof a.find==`function`){let t=it(e,v),r={$filter:ee(e.filter)};t.length&&(r.$expand=t),n=b(await a.find(e.objectName,r))}else return;t&&h(n)}catch(e){console.error(`[ObjectDataTable] Fetch error:`,e),t&&w(e instanceof Error?e.message:`Failed to load data`)}finally{t&&S(!1)}})():t&&S(!1),()=>{t=!1}},[e.objectName,a,o,e.data,e.filter,v]),(0,Z.useEffect)(()=>{let t=!0;if(!(!a||!e.objectName||typeof a.getObjectSchema!=`function`))return a.getObjectSchema(e.objectName).then(e=>{t&&y(e)}).catch(()=>{}),()=>{t=!1}},[e.objectName,a]);let A=o||e.data||m,j=Array.isArray(A)?A:[],M=(0,Z.useMemo)(()=>{let t=e.objectName,n={};if(v?.fields){let e=v.fields;if(Array.isArray(e))for(let t of e)t?.name&&(n[t.name]=t);else for(let[t,r]of Object.entries(e))n[t]={name:t,...r}}let i=e=>{let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/([A-Z])/g,` $1`);return t?s(t,e,n):n},a=e=>{let i=Ze({accessorKey:e.accessorKey,label:e.header,def:n[e.accessorKey],objectName:t,fieldOptionLabel:d,overrides:{type:e.type,format:e.format,options:e.options,referenceTo:e.referenceTo,currency:e.currency,decimals:e.decimals}}),a=e.align??(Qe(i)?`right`:void 0);if(typeof e.cell==`function`)return{...e,...i,align:a};let o=e=>$e(e,i,r);return{...e,...i,align:a,cell:o}};if(e.columns&&e.columns.length>0){let n=rt(e.columns);return(t?n.map(e=>({...e,header:s(t,e.accessorKey,e.header)})):n).map(a)}return j.length===0?[]:(Object.keys(n).length>0?Object.keys(n).filter(e=>!qe(e,n[e])):Object.keys(j[0]).filter(e=>!e.startsWith(`_`)&&!qe(e))).map(e=>a({header:i(e),accessorKey:e}))},[e.columns,e.objectName,j,v,s,d,r]);if(x&&j.length===0)return(0,Q.jsx)(`div`,{className:R(`overflow-auto`,n),"data-testid":`table-loading`,children:(0,Q.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(W,{className:`h-6 w-1/4`}),(0,Q.jsx)(W,{className:`h-6 w-1/4`}),(0,Q.jsx)(W,{className:`h-6 w-1/4`}),(0,Q.jsx)(W,{className:`h-6 w-1/4`})]}),[1,2,3,4].map(e=>(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(W,{className:`h-5 w-1/4`}),(0,Q.jsx)(W,{className:`h-5 w-1/4`}),(0,Q.jsx)(W,{className:`h-5 w-1/4`}),(0,Q.jsx)(W,{className:`h-5 w-1/4`})]},e))]})});if(C)return(0,Q.jsx)(`div`,{className:R(`overflow-auto`,n),"data-testid":`table-error`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`table-error-message`,children:[(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,Q.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,Q.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,Q.jsx)(`p`,{className:`text-xs`,children:C})]})});if(!a&&e.objectName&&j.length===0)return(0,Q.jsx)(`div`,{className:R(`overflow-auto`,n),children:(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,Q.jsxs)(`p`,{className:`text-xs`,children:[p,` “`,e.objectName,`”`]})})});if(j.length===0)return(0,Q.jsx)(`div`,{className:R(`overflow-auto`,n),"data-testid":`table-empty-state`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Q.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,Q.jsx)(`line`,{x1:`3`,y1:`9`,x2:`21`,y2:`9`}),(0,Q.jsx)(`line`,{x1:`9`,y1:`21`,x2:`9`,y2:`9`})]}),(0,Q.jsx)(`p`,{className:`text-xs`,children:f})]})});let N={...e,type:`data-table`,data:j,columns:M,onRowClick:e.onRowClick??(E?k:void 0)},P=T?.title&&!T.title.includes("${")?T.title:void 0;return(0,Q.jsxs)(`div`,{className:R(`relative`,n),children:[(0,Q.jsx)(te,{active:x&&j.length>0}),(0,Q.jsx)(c,{schema:N,className:n}),E&&(0,Q.jsx)(nt,{record:D,objectName:e.objectName,objectSchema:v,fields:T?.columns,title:P,target:T?.target===`dialog`?`dialog`:`drawer`,onClose:()=>O(null)})]})},ot=({objectName:e,filter:t,onNavigate:n,className:r})=>{let{openRecordList:i}=d(),a=w();return!i||!e?null:(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,className:r,"data-testid":`drill-open-in-list`,onClick:()=>{i(e,t),n?.()},children:[a(`dashboard.openInList`,`Open in list`),(0,Q.jsx)(ce,{className:`ml-1 h-3.5 w-3.5`})]})},st=({open:e,onClose:t,title:n,target:r=`drawer`,objectName:i,filter:a,dataSource:o,columns:s,maxRows:l,className:u,report:f})=>{let{openRecordList:p}=d(),m=f&&typeof f==`object`&&(Array.isArray(f.columns)||`objectName`in f),h=r===`navigate`&&!!p&&!m&&!!i;if(Z.useEffect(()=>{e&&h&&(p(i,a),t())},[e,h]),h)return null;let g=m?null:(0,Q.jsx)(ot,{objectName:i,filter:a,onNavigate:t}),_=(0,Q.jsx)(`div`,{className:R(`overflow-auto`,u),"data-testid":`drill-down-body`,children:m?(()=>{let e=f.filter,t=e?a?{$and:[e,a]}:e:a;return(0,Q.jsx)(c,{schema:{...f,type:`spec-report`,report:{...f,filter:t},filter:t}})})():(0,Q.jsx)(at,{schema:{type:`object-data-table`,objectName:i,filter:a,columns:s?.map(e=>({accessorKey:e,header:e})),pagination:!0,searchable:!1,pageSize:l,drillDown:{enabled:!0,mode:`record`,target:`dialog`}},dataSource:o})});return r===`dialog`?(0,Q.jsx)(ye,{open:e,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(re,{className:`max-w-5xl`,children:[(0,Q.jsxs)(K,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,Q.jsx)(oe,{children:n}),g]}),_]})}):(0,Q.jsx)(le,{open:e,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(G,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,Q.jsxs)(L,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,Q.jsx)(be,{children:n}),g]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:_})]})})},ct=A;function lt(e,t,n){let r=[],i=[],a=new Set,o=new Set,s=new Map;return e.forEach((e,c)=>{let l=t.map(t=>String(e[t]??`∅`)).join(``),u=String(e[n]??`∅`);a.has(l)||(a.add(l),r.push({id:l,labels:t.map(t=>D(e[t]))})),o.has(u)||(o.add(u),i.push({id:u,label:D(e[n])})),s.set(`${l} ${u}`,c)}),{rowHeaders:r,colHeaders:i,cellIndex:s}}function ut(e){if(e==null)return``;let t=String(e);return/[",\n\r]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t}function dt(e){return e.map(e=>e.map(ut).join(`,`)).join(`\r
2
- `)}function ft(e,t){if(typeof document>`u`)return;let n=e&&e.trim()?e.trim():`export`,r=new Blob([`${dt(t)}`],{type:`text/csv;charset=utf-8;`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n.endsWith(`.csv`)?n:`${n}.csv`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}var pt=new Set([`metric`,`kpi`,`gauge`,`solid-gauge`,`bullet`]),mt={bar:`bar`,column:`column`,"horizontal-bar":`horizontal-bar`,"grouped-bar":`bar`,"stacked-bar":`bar`,"bi-polar-bar":`bar`,line:`line`,spline:`line`,"step-line":`line`,area:`area`,"stacked-area":`area`,pie:`pie`,donut:`donut`,funnel:`funnel`,pyramid:`funnel`,scatter:`scatter`,bubble:`scatter`,radar:`radar`,treemap:`treemap`,sankey:`sankey`};function ht({widget:e,dataSource:t}){let n=String(e?.dataset??``),r=(0,Z.useMemo)(()=>Array.isArray(e?.dimensions)?e.dimensions.filter(Boolean):[],[e]),i=(0,Z.useMemo)(()=>Array.isArray(e?.values)?e.values.filter(Boolean):[],[e]),a=e?.compareTo&&typeof e.compareTo==`object`?e.compareTo:void 0,o=String(e?.type??``),s=pt.has(o)||r.length===0,l=o===`table`||o===`pivot`,u=o===`pivot`&&r.length>=2,d=u?r.slice(0,-1):[],p=u?r[r.length-1]:``,m=u?[d,[p],[]]:void 0,h=w(),{fieldLabel:g}=ke(),_=e?.filter,y=(0,Z.useMemo)(()=>_&&typeof _==`object`&&Object.keys(_).length>0?ee(_):void 0,[_]),[b,S]=(0,Z.useState)({status:`idle`,rows:[]}),[C,k]=(0,Z.useState)(null),[A,M]=(0,Z.useState)(null),[te,N]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>{let e=t;if(!e||typeof e.queryDataset!=`function`){S({status:`error`,rows:[],error:h(`dashboard.datasetUnsupported`,`This data source does not support dataset queries.`)});return}if(i.length===0){S({status:`idle`,rows:[]});return}let o=!1;return S({status:`loading`,rows:[]}),e.queryDataset(n,{dimensions:r,measures:i,...y?{runtimeFilter:y}:{},...a?{compareTo:a}:{},...m?{totals:{groupings:m}}:{}}).then(e=>{o||S({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,totals:Array.isArray(e?.totals)?e.totals:void 0})}).catch(e=>{o||S({status:`error`,rows:[],error:String(e?.message??e)})}),()=>{o=!0}},[`${o}|${n}|${r.join(`,`)}|${i.join(`,`)}|${JSON.stringify(_??null)}|${JSON.stringify(a??null)}`]),(0,Z.useEffect)(()=>{if(s||l){M(null),N(null);return}let e=b.object;if(!e||r.length===0){M(null),N(null);return}let t=e=>b.dimensionFields&&b.dimensionFields[e]||e,n=!1;return(async()=>{try{let i=await(await fetch(`/api/v1/meta/object/${encodeURIComponent(e)}`,{headers:{accept:`application/json`},credentials:`include`})).json().catch(()=>null),a=i?.item??i?.data??i,o=f(a?.fields?.[t(r[0])]?.options),s={};for(let e of r){let n=O(a?.fields?.[t(e)]?.options);n&&(s[e]=n)}n||(M(o),N(Object.keys(s).length>0?s:null))}catch{n||(M(null),N(null))}})(),()=>{n=!0}},[b.object,b.dimensionFields,r,s,l]),i.length===0)return(0,Q.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground`,children:h(`dashboard.pickMeasures`,`Pick measures (values) for this dataset widget.`)});if(b.status===`loading`||b.status===`idle`)return(0,Q.jsxs)(`div`,{className:`h-full w-full p-2`,"data-testid":`dataset-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:h(`dashboard.loading`,`Loading…`)}),s?(0,Q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-start justify-center gap-2 p-2`,children:[(0,Q.jsx)(W,{className:`h-8 w-32 rounded`}),(0,Q.jsx)(W,{className:`h-3 w-20 rounded`})]}):l?(0,Q.jsx)(I,{className:`h-full`,rows:5,columns:Math.max(2,r.length+i.length)}):(0,Q.jsx)(ue,{className:`h-full`})]});if(b.status===`error`)return(0,Q.jsxs)(`div`,{role:`alert`,className:`flex h-full w-full items-start gap-2 rounded border border-destructive/40 bg-destructive/5 p-3 text-xs text-destructive`,children:[(0,Q.jsx)(ie,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`break-words`,children:b.error})]});if(b.rows.length===0&&!s)return(0,Q.jsxs)(`div`,{className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground`,children:[(0,Q.jsx)(J,{className:`mr-2 h-4 w-4`}),h(`dashboard.noRows`,`No rows`)]});let{measureField:P,headerLabel:F}=T(b.fields,b.object,g),{object:ne,dimensionFields:re,drillRawRows:L}=b,ae=re?r.filter(e=>e in re):[],z=!!ne&&ae.length>0,B=(t,n)=>{!ne||!re||k({filter:ct(L?.[t],ae,re,y),title:n||String(e?.title??``)})},V=C&&ne?(0,Q.jsx)(st,{open:!0,onClose:()=>k(null),title:C.title||String(e?.title??h(`dashboard.details`,`Details`)),objectName:ne,filter:C.filter,dataSource:t}):null;if(s){let e=P(i[0]);return(0,Q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-start justify-center gap-1 p-2`,children:[(0,Q.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums`,children:v(b.rows[0]?.[i[0]]??0,e?.format,e?.currency)}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:F(i[0])})]})}if(l){let t=[...r,...i],a=(0,Q.jsx)(`button`,{type:`button`,onClick:()=>ft(String(e?.title??n??`export`),[t.map(e=>F(e)),...b.rows.map(e=>t.map(t=>{let n=e[t];return n==null?``:typeof n==`number`?n:String(n)}))]),"data-testid":`dataset-export`,title:h(`dashboard.exportCsv`,`Export CSV`),"aria-label":h(`dashboard.exportCsv`,`Export CSV`),className:`absolute right-1 top-1 z-10 rounded p-1 text-muted-foreground opacity-70 hover:bg-accent/50 hover:text-foreground hover:opacity-100`,children:(0,Q.jsx)(we,{className:`h-3.5 w-3.5`})});if(u){let e=lt(b.rows,d,p),t=e.colHeaders.flatMap(e=>i.map(t=>({col:e,measure:t,header:i.length===1?e.label:`${e.label} · ${F(t)}`}))),n=(e,t)=>v(e,P(t)?.format,P(t)?.currency),r=e=>b.totals?.find(t=>Array.isArray(t.dimensions)&&t.dimensions.join(`,`)===e.join(`,`))?.rows,o=new Map;for(let e of r(d)??[])o.set(d.map(t=>String(e[t]??`∅`)).join(``),e);let s=new Map;for(let e of r([p])??[])s.set(String(e[p]??`∅`),e);let c=r([])?.[0],l=o.size>0,u=s.size>0,f=h(`dashboard.total`,`Total`);return(0,Q.jsxs)(`div`,{className:`relative h-full w-full overflow-auto p-1`,"data-testid":`dataset-matrix`,children:[a,(0,Q.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Q.jsx)(`thead`,{className:`bg-muted/40`,children:(0,Q.jsxs)(`tr`,{children:[d.map(e=>(0,Q.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:F(e)},e)),t.map(e=>(0,Q.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,children:e.header},`${e.col.id}-${e.measure}`)),l&&i.map(e=>(0,Q.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,"data-testid":`matrix-total-col-header`,children:i.length===1?f:`${f} · ${F(e)}`},`total-${e}`))]})}),(0,Q.jsxs)(`tbody`,{children:[e.rowHeaders.map(r=>(0,Q.jsxs)(`tr`,{className:`border-t`,children:[r.labels.map((e,t)=>(0,Q.jsx)(`td`,{className:`px-2 py-1 whitespace-nowrap font-medium`,children:e},t)),t.map(t=>{let i=e.cellIndex.get(`${r.id} ${t.col.id}`),a=i==null?void 0:b.rows[i],o=z&&i!=null,s=[...r.labels,t.col.label].filter(Boolean).join(` / `);return(0,Q.jsx)(`td`,{className:R(`px-2 py-1 text-right tabular-nums whitespace-nowrap`,o&&`cursor-pointer hover:bg-accent/40`),"data-testid":o?`dataset-drill-cell`:void 0,onClick:o?()=>B(i,s):void 0,children:a?n(a[t.measure],t.measure):`—`},`${t.col.id}-${t.measure}`)}),l&&i.map(e=>(0,Q.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium`,"data-testid":`matrix-row-total`,children:n(o.get(r.id)?.[e],e)},`total-${e}`))]},r.id)),u&&(0,Q.jsxs)(`tr`,{className:`border-t bg-muted/30 font-medium`,"data-testid":`matrix-total-row`,children:[d.length>0&&(0,Q.jsx)(`td`,{colSpan:d.length,className:`px-2 py-1 whitespace-nowrap`,children:f}),t.map(e=>(0,Q.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,children:n(s.get(e.col.id)?.[e.measure],e.measure)},`${e.col.id}-${e.measure}`)),l&&i.map(e=>(0,Q.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,"data-testid":`matrix-grand-total`,children:n(c?.[e],e)},`grand-${e}`))]})]})]}),V]})}let o=[...r,...i];return(0,Q.jsxs)(`div`,{className:`relative h-full w-full overflow-auto p-1`,children:[a,(0,Q.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Q.jsx)(`thead`,{className:`bg-muted/40`,children:(0,Q.jsx)(`tr`,{children:o.map(e=>(0,Q.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:F(e)},e))})}),(0,Q.jsx)(`tbody`,{children:b.rows.map((e,t)=>(0,Q.jsx)(`tr`,{className:R(`border-t`,z&&`cursor-pointer hover:bg-accent/40`),"data-testid":z?`dataset-drill-row`:void 0,onClick:z?()=>B(t,ae.map(t=>D(e[t])).filter(Boolean).join(` / `)):void 0,children:o.map(t=>(0,Q.jsx)(`td`,{className:`px-2 py-1 whitespace-nowrap tabular-nums`,children:i.includes(t)?v(e[t],P(t)?.format,P(t)?.currency):D(e[t])},t))},t))})]}),V]})}let oe=mt[o]??`bar`,se=j(b.rows,te),{data:ce,xAxisKey:H,series:U}=E(se,r,i,b.fields),le=z?e=>{let t=x(se,r,i,e?.category,e?.series);if(t<0)return;let n=r.length>=2&&i.length===1;B(t,[e?.category,n?e?.series:void 0].filter(Boolean).map(String).join(` / `))}:void 0;return(0,Q.jsxs)(`div`,{className:R(`relative h-full w-full min-h-[220px]`),children:[(0,Q.jsx)(c,{schema:{type:`chart`,chartType:oe,data:ce,xAxisKey:H,series:U,...A?{categoryColors:A}:{}},onChartClick:le,onSegmentClick:le}),V]})}function gt({id:e,disabled:t,gridSpan:n,className:r,children:i}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u,isOver:d}=ze({id:e,disabled:t});return(0,Q.jsx)(`div`,{ref:s,style:{transform:Me.Transform.toString(c),transition:l,opacity:u?.4:1,...n?{gridColumn:`span ${n.w}`,gridRow:`span ${n.h}`}:{}},className:R(`h-full w-full`,r,!t&&`cursor-grab active:cursor-grabbing`,d&&!u&&`ring-2 ring-primary ring-offset-2 rounded-lg`),"data-sortable-widget-id":e,...a,...o,children:i})}function _t(e){return e?ve(e):null}function vt(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var yt=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],bt={column:`bar`,"stacked-bar":`bar`,"grouped-bar":`bar`,"bi-polar-bar":`bar`,spline:`line`,"step-line":`line`,"stacked-area":`area`,pyramid:`funnel`,bubble:`scatter`},xt=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`scatter`,`funnel`,`radar`,`treemap`,`sankey`]),St=new Set([`gauge`,`solid-gauge`,`kpi`,`bullet`]),Ct=new Set([`sunburst`,`word-cloud`,`choropleth`,`bubble-map`,`gl-map`,`heatmap`,`waterfall`,`box-plot`,`violin`,`candlestick`,`stock`]),wt=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`scatter`,`treemap`,`sankey`]);function Tt(e){return wt.has(e)?{enabled:!0}:void 0}var Et=(0,Z.forwardRef)(({schema:e,className:t,dataSource:n,onRefresh:r,recordCount:i,userActions:a,designMode:o,selectedWidgetId:s,onWidgetClick:l,onWidgetsReorder:u,modalHandler:d,scriptHandlers:f,hideHeaderText:p,...m},h)=>{let g=(()=>{if(e.columns!=null)return e.columns;let t=e.widgets??[],n=0;for(let e of t){let t=(e.layout?.x??0)+(e.layout?.w??0);t>n&&(n=t),(e.layout?.w??0)>n&&(n=e.layout.w)}return n>4?12:4})(),v=g,y=e.gap||4,b=e.columns!=null||g!==4,[x,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!1),E=(0,Z.useRef)(null),{executeAction:ee,engine:D}=S({actions:(0,Z.useMemo)(()=>(e.header?.actions??[]).map(e=>({name:e.actionUrl||e.label,type:e.actionType||`url`,target:e.actionUrl,label:e.label})),[e.header?.actions])}),{dashboardLabel:O,dashboardDescription:k,dashboardActionLabel:A,widgetTitle:j,widgetDescription:M,fieldLabel:te}=se(),{t:N}=_(),P=(0,Z.useCallback)((e,t,n)=>n&&(!t||t===`value`||t===`count`||n===`count`)?N(`report.aggregate.${n}`,{defaultValue:n}):e?te(e,t,t):t,[N,te]),I=e.name,ne=(0,Z.useCallback)(e=>I?A(I,e.actionUrl||e.label,e.label):e.label,[I,A]),re=(0,Z.useCallback)(e=>{let t=vt(e.title);return!I||!e.id||t===void 0?t:j(I,e.id,t)},[I,j]),ie=(0,Z.useCallback)(e=>{let t=vt(e.description);return!I||!e.id?t:M(I,e.id,t)},[I,M]);(0,Z.useEffect)(()=>{let e=D.getRunner();if(d&&e.setModalHandler(d),f)for(let[t,n]of Object.entries(f))e.registerScript(t,n)},[D,d,f]),(0,Z.useEffect)(()=>{let e=()=>T(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let L=(0,Z.useCallback)(()=>{r&&(C(!0),r(),setTimeout(()=>C(!1),600))},[r]);(0,Z.useEffect)(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!r))return E.current=setInterval(L,e.refreshInterval*1e3),()=>{E.current&&clearInterval(E.current)}},[e.refreshInterval,r,L]);let ae=(0,Z.useCallback)((e,t)=>{!o||!l||!t||(e.stopPropagation(),l(t))},[o,l]),z=(0,Z.useCallback)((t,n,r)=>{if(!o||!l)return;let i=e.widgets||[];if(t.key===`Enter`||t.key===` `)t.preventDefault(),l(n??null);else if(t.key===`ArrowRight`||t.key===`ArrowDown`){t.preventDefault();let e=r+1<i.length?i[r+1]:null;e?.id&&l(e.id)}else if(t.key===`ArrowLeft`||t.key===`ArrowUp`){t.preventDefault();let e=r-1>=0?i[r-1]:null;e?.id&&l(e.id)}else t.key===`Escape`&&(t.preventDefault(),l(null))},[o,l,e.widgets]),B=(0,Z.useCallback)(e=>{!o||!l||e.target===e.currentTarget&&l(null)},[o,l]),V=!!(o&&u),oe=Fe(Ie(Pe,{activationConstraint:{distance:5}})),ce=(0,Z.useCallback)(t=>{if(!V)return;let{active:n,over:r}=t;if(!r||n.id===r.id)return;let i=e.widgets??[],a=i.findIndex(e=>e.id===n.id),o=i.findIndex(e=>e.id===r.id);a<0||o<0||u?.(Re(i,a,o))},[V,e.widgets,u]),U=(e,t,r)=>{let i=e.type===`metric`||St.has(e.type||``),a=b?{w:Math.min(i?3:6,v),h:i?2:4}:void 0,l=e.layout??a,u=l?{...l,w:Math.min(l.w,v)}:void 0,d=!!e.dataset,f=(()=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`metric`&&e.object){let t=n.data,r=We(t)&&t.aggregate?{field:e.valueField||t.aggregate.field,function:e.aggregate||t.aggregate.function,groupBy:e.categoryField??t.aggregate.groupBy??`_all`}:e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object||(We(t)?t.object:void 0),aggregate:r,filter:(We(t)?t.filter:void 0)||e.filter,label:n.label||re(e)||``,fallbackValue:n.value,trend:n.trend,icon:n.icon,description:n.description,colorVariant:e.colorVariant,format:n.format,currency:n.currency,prefix:n.prefix,suffix:n.suffix,drillDown:n.drillDown??{enabled:!0},title:n.label||re(e)||``,compareTo:e.compareTo}}if(St.has(t||``)&&e.object){let t=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object,aggregate:t,filter:e.filter,label:n.label||re(e)||``,fallbackValue:n.fallbackValue??n.value,icon:n.icon,description:n.description,colorVariant:e.colorVariant,format:n.format,currency:n.currency,prefix:n.prefix,suffix:n.suffix,invert:n.invert,compareTo:e.compareTo}}let r=t&&bt[t]||t;if(r&&xt.has(r)){let t=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(We(t)){let o=t.aggregate,s=(()=>{let t=e.categoryField||o?.groupBy;if(t)return e.categoryGranularity&&typeof t==`string`?{field:t,dateGranularity:e.categoryGranularity}:t})(),c=o?{field:e.valueField||o.field,function:e.aggregate||o.function,groupBy:s}:void 0,l=c?.field||a,u=e.object||t.object;return{type:`object-chart`,chartType:r,objectName:u,aggregate:c,filter:t.filter||e.filter,xAxisKey:i,series:[{dataKey:l,label:P(u,l,c?.function)}],colors:yt,drillDown:n.drillDown??Tt(r),compareTo:e.compareTo,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(!t&&e.object){let t=e.categoryField||`name`,a=e.categoryGranularity?{field:t,dateGranularity:e.categoryGranularity}:t,o=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:a}:void 0,s=e.valueField||`value`;return{type:`object-chart`,chartType:r,objectName:e.object,aggregate:o,filter:e.filter,xAxisKey:i,series:[{dataKey:s,label:P(e.object,s,e.aggregate)}],colors:yt,drillDown:n.drillDown??Tt(r),compareTo:e.compareTo,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}return{type:`chart`,chartType:r,data:Array.isArray(t)?t:t?.items||[],xAxisKey:i,series:[{dataKey:a,label:P(e.object,a,e.aggregate)}],colors:yt,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(t===`table`){let t=e.data||n.data,r=We(t)||!t&&e.object?n.drillDown??{enabled:!0,mode:`record`}:void 0;if(We(t)){let{data:i,...a}=n;return{type:`object-data-table`,...a,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,drillDown:r,className:`border-0`}}return!t&&e.object?{type:`object-data-table`,...n,objectName:e.object,filter:e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,drillDown:r,className:`border-0`}:{type:`data-table`,...n,data:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}if(t===`pivot`){let t=e.data||n.data,r=e,i={rowField:r.rowField??n.rowField,columnField:r.columnField??n.columnField,valueField:r.valueField??n.valueField,aggregation:r.aggregation??n.aggregation??`sum`,showRowTotals:r.showRowTotals??n.showRowTotals,showColumnTotals:r.showColumnTotals??n.showColumnTotals,format:r.format??n.format},a=(We(t)||!t&&e.object)&&n.drillDown===void 0?{...n,drillDown:{enabled:!0}}:n;if(We(t)){let{data:n,...r}=a;return{type:`object-pivot`,...r,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter}}return!t&&e.object?{type:`object-pivot`,...a,...i,objectName:e.object,filter:e.filter}:{type:`pivot`,...n,...i,data:Array.isArray(t)?t:t?.items||[]}}if(t===`list`){let t=e.data||n.data,r=We(t)||!t&&e.object?n.drillDown??{enabled:!0,mode:`record`}:void 0;if(We(t)){let{data:i,...a}=n;return{type:`object-data-table`,...a,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:!1,pagination:!1,drillDown:r,className:`border-0`}}return!t&&e.object?{type:`object-data-table`,...n,objectName:e.object,filter:e.filter,searchable:!1,pagination:!1,drillDown:r,className:`border-0`}:{type:`data-table`,...n,data:Array.isArray(t)?t:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}return t===`custom`?{type:`text`,value:"Custom widget — set `component` to a UIComponent schema.",variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground`}:t&&Ct.has(t)?{type:`text`,value:`「${t}」chart type is not supported yet`,variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground`}:{...e,...n}})(),p=e.type===`metric`&&!d,m=re(e),h=ie(e),g=e.id||m||`widget-${t}`,_=o&&s===e.id,y=o?{"data-testid":`dashboard-preview-widget-${e.id}`,"data-widget-id":e.id,role:`button`,tabIndex:0,"aria-selected":_,"aria-label":`Widget: ${m||`Widget ${t+1}`}`,onClick:t=>ae(t,e.id),onKeyDown:n=>z(n,e.id,t)}:{},x=o?R(`cursor-pointer rounded-lg transition-all outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,_?`ring-2 ring-primary shadow-md bg-primary/5 dark:bg-primary/10`:`hover:ring-2 hover:ring-primary/40 hover:shadow-sm`):void 0,S=!w&&u&&!V?{gridColumn:`span ${u.w}`,gridRow:`span ${u.h}`}:void 0,C=p?(0,Q.jsxs)(`div`,{className:R(`h-full w-full`,o&&`relative`,x),style:S,...y,children:[d?(0,Q.jsx)(`div`,{className:R(`h-full w-full`,o&&`pointer-events-none`),children:(0,Q.jsx)(ht,{widget:e,dataSource:n})}):(0,Q.jsx)(c,{schema:f,className:R(`h-full w-full`,o&&`pointer-events-none`),dataSource:n}),o&&(0,Q.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]}):(0,Q.jsxs)(xe,{className:R(`overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md`,`bg-card/50 backdrop-blur-sm`,r&&`w-full`,o&&`relative`,x),style:S,...y,children:[m&&(0,Q.jsxs)(_e,{className:`pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6`,children:[(0,Q.jsx)(Ce,{className:`text-sm sm:text-base font-medium tracking-tight truncate`,title:m,children:m}),h&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 line-clamp-2`,children:h})]}),(0,Q.jsx)(Y,{className:`p-0`,children:(0,Q.jsx)(`div`,{className:R(`h-full w-full`,`p-3 sm:p-4 md:p-6`,o&&`pointer-events-none`),children:d?(0,Q.jsx)(ht,{widget:e,dataSource:n}):(0,Q.jsx)(c,{schema:f,dataSource:n})})}),o&&(0,Q.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]});return V&&e.id?(0,Q.jsx)(gt,{id:e.id,gridSpan:!w&&u?{w:u.w,h:u.h}:void 0,children:C},g):(0,Q.jsx)(Z.Fragment,{children:C},g)},le=e.header&&(0,Q.jsxs)(`div`,{className:`col-span-full mb-4`,children:[!p&&e.header.showTitle!==!1&&e.title&&(0,Q.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:I?O({name:I,label:vt(e.title)}):vt(e.title)}),!p&&e.header.showDescription!==!1&&e.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:I?k({name:I,description:vt(e.description)}):vt(e.description)}),e.header.actions&&e.header.actions.length>0&&(0,Q.jsx)(`div`,{className:`flex gap-2 mt-3`,children:e.header.actions.map((e,t)=>{let n=_t(e.icon);return(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:async()=>{let{actionType:t,actionUrl:n,label:r}=e;if(!t||!n){console.warn(`[DashboardRenderer] Header action missing actionType/actionUrl:`,e);return}if(t===`url`){/^https?:\/\//.test(n)||n.startsWith(`//`)?window.location.assign(n):(window.history.pushState({},``,n),window.dispatchEvent(new PopStateEvent(`popstate`)));return}if(t===`modal`||t===`script`){let e=await ee(n||r);e?.success||console.warn(`[DashboardRenderer] action failed`,e?.error);return}console.warn(`[DashboardRenderer] Unknown header actionType="${t}" for "${r}"`)},children:[n&&(0,Q.jsx)(n,{className:`w-4 h-4 mr-1.5`}),ne(e)]},t)})})]}),ue=i!==void 0&&(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.toLocaleString(),` records`]}),W=a?JSON.stringify(a):void 0,G=r&&(0,Q.jsxs)(`div`,{className:R(`flex items-center justify-end gap-3 mb-2`,!w&&`col-span-full`),children:[ue,(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:L,disabled:x,"aria-label":`Refresh dashboard`,children:[(0,Q.jsx)(F,{className:R(`h-4 w-4 mr-2`,x&&`animate-spin`)}),x?`Refreshing…`:`Refresh All`]})]}),K=(0,Z.useMemo)(()=>(e.widgets??[]).map(e=>e.id).filter(e=>!!e),[e.widgets]),q=(0,Z.useMemo)(()=>(e.widgets??[]).filter(e=>e.type===`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]),de=(0,Z.useMemo)(()=>(e.widgets??[]).filter(e=>e.type!==`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]);if(w){let n=e.widgets?.filter(e=>e.type===`metric`)||[],r=e.widgets?.filter(e=>e.type!==`metric`)||[],i=(0,Q.jsxs)(`div`,{ref:h,className:R(`flex flex-col gap-4 px-4`,t),"data-user-actions":W,onClick:B,...m,children:[le,G,n.length>0&&(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,onClick:B,children:(0,Q.jsx)(He,{items:q,strategy:Le,disabled:!V,children:n.map((e,t)=>U(e,t))})}),r.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-col gap-4`,onClick:B,children:(0,Q.jsx)(He,{items:de,strategy:Ve,disabled:!V,children:r.map((e,t)=>U(e,t,!0))})})]});return V?(0,Q.jsx)(Ne,{sensors:oe,collisionDetection:Be,onDragEnd:ce,children:i}):i}let J=(0,Q.jsxs)(`div`,{ref:h,className:R(`grid`,!b&&`auto-rows-min grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,t),style:{...b&&{gridTemplateColumns:`repeat(${v}, minmax(0, 1fr))`,gridAutoRows:`minmax(5rem, auto)`},gap:`${y*.25}rem`},"data-user-actions":W,onClick:B,...m,children:[le,G,(0,Q.jsx)(He,{items:K,strategy:Le,disabled:!V,children:e.widgets?.map((e,t)=>U(e,t))})]});return V?(0,Q.jsx)(Ne,{sensors:oe,collisionDetection:Be,onDragEnd:ce,children:J}):J});function Dt(e){let{margin:t,containerPadding:n,containerWidth:r,cols:i}=e;return(r-t[0]*(i-1)-n[0]*2)/i}function Ot(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function kt(e,t,n,r,i,a,o){let{margin:s,containerPadding:c,rowHeight:l}=e,u=Dt(e),d,f,p,m;if(o?(d=Math.round(o.width),f=Math.round(o.height)):(d=Ot(r,u,s[0]),f=Ot(i,l,s[1])),a?(p=Math.round(a.top),m=Math.round(a.left)):o?(p=Math.round(o.top),m=Math.round(o.left)):(p=Math.round((l+s[1])*n+c[1]),m=Math.round((u+s[0])*t+c[0])),!a&&!o){if(Number.isFinite(r)){let e=Math.round((u+s[0])*(t+r)+c[0])-m-d;e!==s[0]&&(d+=e-s[0])}if(Number.isFinite(i)){let e=Math.round((l+s[1])*(n+i)+c[1])-p-f;e!==s[1]&&(f+=e-s[1])}}return{top:p,left:m,width:d,height:f}}function At(e,t,n,r,i){let{margin:a,containerPadding:o,cols:s,rowHeight:c,maxRows:l}=e,u=Dt(e),d=Math.round((n-o[0])/(u+a[0])),f=Math.round((t-o[1])/(c+a[1]));return d=Nt(d,0,s-r),f=Nt(f,0,l-i),{x:d,y:f}}function jt(e,t,n){let{margin:r,containerPadding:i,rowHeight:a}=e,o=Dt(e);return{x:Math.round((n-i[0])/(o+r[0])),y:Math.round((t-i[1])/(a+r[1]))}}function Mt(e,t,n){let{margin:r,rowHeight:i}=e,a=Dt(e);return{w:Math.max(1,Math.round((t+r[0])/(a+r[0]))),h:Math.max(1,Math.round((n+r[1])/(i+r[1])))}}function Nt(e,t,n){return Math.max(Math.min(e,n),t)}function Pt(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function Ft(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&Pt(r,t))return r}}function It(e,t){return e.filter(e=>Pt(e,t))}function Lt(e,t){return t===`horizontal`?zt(e):t===`vertical`||t===`wrap`?Rt(e):[...e]}function Rt(e){return[...e].sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)}function zt(e){return[...e].sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x)}function Bt(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0){let e=r.y+r.h;e>t&&(t=e)}}return t}function Vt(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&r.i===t)return r}}function Ht(e){return e.filter(e=>e.static===!0)}function Ut(e){return{i:e.i,x:e.x,y:e.y,w:e.w,h:e.h,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,constraints:e.constraints,isBounded:e.isBounded}}function Wt(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t[n]=Ut(r))}return t}function Gt(e,t){let n=Array(e.length);for(let r=0;r<e.length;r++){let i=e[r];i!==void 0&&(t.i===i.i?n[r]=t:n[r]=i)}return n}function Kt(e,t,n){let r=Vt(e,t);return r?(r=n(Ut(r)),[Gt(e,r),r]):[[...e],null]}function qt(e,t){let n=Ht(e);for(let r=0;r<e.length;r++){let i=e[r];if(i!==void 0)if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;Ft(n,i);)i.y++}return e}function Jt(e,t,n,r,i,a,o,s,c){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return[...e];let l=t.x,u=t.y;typeof n==`number`&&(t.x=n),typeof r==`number`&&(t.y=r),t.moved=!0;let d=Lt(e,o);(o===`vertical`&&typeof r==`number`?u>=r:o===`horizontal`&&typeof n==`number`&&l>=n)&&(d=d.reverse());let f=It(d,t),p=f.length>0;if(p&&c)return Wt(e);if(p&&a)return t.x=l,t.y=u,t.moved=!1,e;let m=[...e];for(let e=0;e<f.length;e++){let n=f[e];n!==void 0&&(n.moved||(m=n.static?Yt(m,n,t,i,o):Yt(m,t,n,i,o)))}return m}function Yt(e,t,n,r,i,a){let o=i===`horizontal`,s=i===`vertical`,c=t.static;if(r){r=!1;let a={x:o?Math.max(t.x-n.w,0):n.x,y:s?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:`-1`},l=Ft(e,a),u=l!==void 0&&l.y+l.h>t.y,d=l!==void 0&&t.x+t.w>l.x;if(!l)return Jt(e,n,o?a.x:void 0,s?a.y:void 0,r,c,i);if(u&&s)return Jt(e,n,void 0,n.y+1,r,c,i);if(u&&i===null)return t.y=n.y,n.y+=n.h,[...e];if(d&&o)return Jt(e,t,n.x,void 0,r,c,i)}let l=o?n.x+1:void 0,u=s?n.y+1:void 0;return l===void 0&&u===void 0?[...e]:Jt(e,n,l,u,r,c,i)}function Xt(e,t,n){return Math.max(t,Math.min(n,e))}var Zt=[{name:`gridBounds`,constrainPosition(e,t,n,{cols:r,maxRows:i}){return{x:Xt(t,0,Math.max(0,r-e.w)),y:Xt(n,0,Math.max(0,i-e.h))}},constrainSize(e,t,n,r,{cols:i,maxRows:a}){let o=r===`w`||r===`nw`||r===`sw`?e.x+e.w:i-e.x,s=r===`n`||r===`nw`||r===`ne`?e.y+e.h:a-e.y;return{w:Xt(t,1,Math.max(1,o)),h:Xt(n,1,Math.max(1,s))}}},{name:`minMaxSize`,constrainSize(e,t,n){return{w:Xt(t,e.minW??1,e.maxW??1/0),h:Xt(n,e.minH??1,e.maxH??1/0)}}}];function Qt(e,t,n,r,i){let a={x:n,y:r};for(let n of e)n.constrainPosition&&(a=n.constrainPosition(t,a.x,a.y,i));if(t.constraints)for(let e of t.constraints)e.constrainPosition&&(a=e.constrainPosition(t,a.x,a.y,i));return a}function $t(e,t,n,r,i,a){let o={w:n,h:r};for(let n of e)n.constrainSize&&(o=n.constrainSize(t,o.w,o.h,i,a));if(t.constraints)for(let e of t.constraints)e.constrainSize&&(o=e.constrainSize(t,o.w,o.h,i,a));return o}function en({top:e,left:t,width:n,height:r}){let i=`translate(${t}px,${e}px)`;return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:`${n}px`,height:`${r}px`,position:`absolute`}}function tn({top:e,left:t,width:n,height:r}){return{top:`${e}px`,left:`${t}px`,width:`${n}px`,height:`${r}px`,position:`absolute`}}function nn(e){return e*100+`%`}function rn(e,t,n,r){return e+n>r?t:n}function an(e,t,n){return e<0?t:n}function on(e){return Math.max(0,e)}function sn(e){return Math.max(0,e)}var cn=(e,t,n)=>{let{left:r,height:i,width:a}=t,o=e.top-(i-e.height);return{left:r,width:a,height:an(o,e.height,i),top:sn(o)}},ln=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{top:r,height:a,width:rn(e.left,e.width,o,n),left:on(i)}},un=(e,t,n)=>{let{top:r,height:i,width:a}=t,o=e.left+e.width-a;return o<0?{height:i,width:e.left+e.width,top:sn(r),left:0}:{height:i,width:a,top:sn(r),left:o}},dn=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{width:o,left:i,height:an(r,e.height,a),top:sn(r)}},fn={n:cn,ne:(e,t,n)=>cn(e,ln(e,t,n)),e:ln,se:(e,t,n)=>dn(e,ln(e,t,n)),s:dn,sw:(e,t,n)=>dn(e,un(e,t)),w:un,nw:(e,t,n)=>cn(e,un(e,t))};function pn(e,t,n,r){let i=fn[e];return i?i(t,{...t,...n},r):n}var mn={type:`transform`,scale:1,calcStyle(e){return en(e)}},hn={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},gn={enabled:!0,bounded:!1,threshold:3},_n={enabled:!0,handles:[`se`]},vn={enabled:!1,defaultItem:{w:1,h:1}};function yn(e,t,n,r,i){let a=r===`x`?`w`:`h`;t[r]+=1;let o=e.findIndex(e=>e.i===t.i),s=i??Ht(e).length>0;for(let i=o+1;i<e.length;i++){let o=e[i];if(o!==void 0&&!o.static){if(!s&&o.y>t.y+t.h)break;Pt(t,o)&&yn(e,o,n+t[a],r,s)}}t[r]=n}function bn(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0),t.y=Math.min(r,t.y);t.y>0&&!Ft(e,t);)t.y--;let i;for(;(i=Ft(e,t))!==void 0;)yn(n,t,i.y+i.h,`y`);return t.y=Math.max(t.y,0),t}function xn(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0);t.x>0&&!Ft(e,t);)t.x--;let i;for(;(i=Ft(e,t))!==void 0;)if(yn(r,t,i.x+i.w,`x`),t.x+t.w>n)for(t.x=n-t.w,t.y++;t.x>0&&!Ft(e,t);)t.x--;return t.x=Math.max(t.x,0),t}var Sn={type:`vertical`,allowOverlap:!1,compact(e,t){let n=Ht(e),r=Bt(n),i=Rt(e),a=Array(e.length);for(let t=0;t<i.length;t++){let o=i[t];if(o===void 0)continue;let s=Ut(o);s.static||(s=bn(n,s,i,r),r=Math.max(r,s.y+s.h),n.push(s));let c=e.indexOf(o);a[c]=s,s.moved=!1}return a}},Cn={type:`horizontal`,allowOverlap:!1,compact(e,t){let n=Ht(e),r=zt(e),i=Array(e.length);for(let a=0;a<r.length;a++){let o=r[a];if(o===void 0)continue;let s=Ut(o);s.static||(s=xn(n,s,t,r),n.push(s));let c=e.indexOf(o);i[c]=s,s.moved=!1}return i}},wn={type:null,allowOverlap:!1,compact(e,t){return Wt(e)}},Tn={...Sn,allowOverlap:!0,compact(e,t){return Wt(e)}},En={...Cn,allowOverlap:!0,compact(e,t){return Wt(e)}},Dn={...wn,allowOverlap:!0};function On(e,t=!1,n=!1){let r;return r=t?e===`vertical`?Tn:e===`horizontal`?En:Dn:e===`vertical`?Sn:e===`horizontal`?Cn:wn,n?{...r,preventCollision:n}:r}function kn(e){return Object.keys(e).sort((t,n)=>e[t]-e[n])}function An(e,t){let n=kn(e),r=n[0];if(r===void 0)throw Error(`No breakpoints defined`);for(let i=1;i<n.length;i++){let a=n[i];a!==void 0&&t>e[a]&&(r=a)}return r}function jn(e,t){let n=t[e];if(n===void 0)throw Error(`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(e)} is missing!`);return n}function Mn(e,t,n,r,i,a){let o=e[n];if(o)return Wt(o);let s=e[r],c=kn(t),l=c.slice(c.indexOf(n));for(let t=0;t<l.length;t++){let n=l[t];if(n===void 0)continue;let r=e[n];if(r){s=r;break}}let u=qt(Wt(s||[]),{cols:i});return(typeof a==`object`&&a?a:On(a)).compact(u,i)}function Nn(e,t){if(Array.isArray(e))return e;let n=e,r=n[t];if(r!==void 0)return r;let i=Object.keys(n);for(let e of i){let t=n[e];if(t!==void 0)return t}return[10,10]}var Pn=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n[`fast-equals`]={}))})(e,(function(e){function t(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function n(e){return function(t,n,r,i){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r,i);var a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);var s=e(t,n,r,i);return i.delete(t),i.delete(n),s}}function r(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function i(e){return e.constructor===Object||e.constructor==null}function a(e){return typeof e.then==`function`}function o(e,t){return e===t||e!==e&&t!==t}var s=Object.prototype.toString;function c(e){var t=e.areArraysEqual,n=e.areDatesEqual,r=e.areMapsEqual,c=e.areObjectsEqual,l=e.areRegExpsEqual,u=e.areSetsEqual,d=e.createIsNestedEqual,f=d(p);function p(e,d,p){if(e===d)return!0;if(!e||!d||typeof e!=`object`||typeof d!=`object`)return e!==e&&d!==d;if(i(e)&&i(d))return c(e,d,f,p);var m=Array.isArray(e),h=Array.isArray(d);if(m||h)return m===h&&t(e,d,f,p);var g=s.call(e);return g===s.call(d)?g===`[object Date]`?n(e,d,f,p):g===`[object RegExp]`?l(e,d,f,p):g===`[object Map]`?r(e,d,f,p):g===`[object Set]`?u(e,d,f,p):g===`[object Object]`||g===`[object Arguments]`?a(e)||a(d)?!1:c(e,d,f,p):g===`[object Boolean]`||g===`[object Number]`||g===`[object String]`?o(e.valueOf(),d.valueOf()):!1:!1}return p}function l(e,t,n,r){var i=e.length;if(t.length!==i)return!1;for(;i-->0;)if(!n(e[i],t[i],i,i,e,t,r))return!1;return!0}var u=n(l);function d(e,t){return o(e.valueOf(),t.valueOf())}function f(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={},o=0;return e.forEach(function(s,c){if(i){var l=!1,u=0;t.forEach(function(i,d){!l&&!a[u]&&(l=n(c,d,o,u,e,t,r)&&n(s,i,c,d,e,t,r))&&(a[u]=!0),u++}),o++,i=l}}),i}var p=n(f),m=`_owner`,h=Object.prototype.hasOwnProperty;function g(e,t,n,r){var i=Object.keys(e),a=i.length;if(Object.keys(t).length!==a)return!1;for(var o;a-->0;){if(o=i[a],o===m){var s=!!e.$$typeof,c=!!t.$$typeof;if((s||c)&&s!==c)return!1}if(!h.call(t,o)||!n(e[o],t[o],o,o,e,t,r))return!1}return!0}var _=n(g);function v(e,t){return e.source===t.source&&e.flags===t.flags}function y(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={};return e.forEach(function(o,s){if(i){var c=!1,l=0;t.forEach(function(i,u){!c&&!a[l]&&(c=n(o,i,s,u,e,t,r))&&(a[l]=!0),l++}),i=c}}),i}var b=n(y),x=Object.freeze({areArraysEqual:l,areDatesEqual:d,areMapsEqual:f,areObjectsEqual:g,areRegExpsEqual:v,areSetsEqual:y,createIsNestedEqual:t}),S=Object.freeze({areArraysEqual:u,areDatesEqual:d,areMapsEqual:p,areObjectsEqual:_,areRegExpsEqual:v,areSetsEqual:b,createIsNestedEqual:t}),C=c(x);function w(e,t){return C(e,t,void 0)}var T=c(r(x,{createIsNestedEqual:function(){return o}}));function E(e,t){return T(e,t,void 0)}var ee=c(S);function D(e,t){return ee(e,t,new WeakMap)}var O=c(r(S,{createIsNestedEqual:function(){return o}}));function k(e,t){return O(e,t,new WeakMap)}function A(e){return c(r(x,e(x)))}function j(e){var t=c(r(S,e(S)));return(function(e,n,r){return r===void 0&&(r=new WeakMap),t(e,n,r)})}e.circularDeepEqual=D,e.circularShallowEqual=k,e.createCustomCircularEqual=j,e.createCustomEqual=A,e.deepEqual=w,e.sameValueZeroEqual=o,e.shallowEqual=E,Object.defineProperty(e,"__esModule",{value:!0})}))}));function Fn(e={}){let{measureBeforeMount:t=!1,initialWidth:n=1280}=e,[r,i]=(0,Z.useState)(n),[a,o]=(0,Z.useState)(!t),s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),l=(0,Z.useCallback)(()=>{let e=s.current;if(e){let t=e.offsetWidth;i(t),a||o(!0)}},[a]);return(0,Z.useEffect)(()=>{let e=s.current;if(e){if(l(),typeof ResizeObserver<`u`){let t=null;return c.current=new ResizeObserver(e=>{let n=e[0];if(n){let e=n.contentRect.width;t!==null&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{i(e),t=null})}}),c.current.observe(e),()=>{t!==null&&cancelAnimationFrame(t),c.current&&=(c.current.disconnect(),null)}}return()=>{c.current&&=(c.current.disconnect(),null)}}},[l]),{width:r,mounted:a,containerRef:s,measureWidth:l}}var In=n(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Ln=n(((e,t)=>{var n=In();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Rn=n(((e,t)=>{t.exports=Ln()()})),$=e(Rn(),1);function zn(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function Bn(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function Vn(e){return typeof e==`number`&&!isNaN(e)}function Hn(e){return parseInt(e,10)}function Un(e,t,n){if(e[t])return Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}var Wn=[`Moz`,`Webkit`,`O`,`ms`];function Gn(e=`transform`){if(typeof window>`u`)return``;let t=window.document?.documentElement?.style;if(!t||e in t)return``;for(let n=0;n<Wn.length;n++)if(Kn(e,Wn[n])in t)return Wn[n];return``}function Kn(e,t){return t?`${t}${qn(e)}`:e}function qn(e){let t=``,n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]===`-`?n=!0:t+=e[r];return t}var Jn=Gn(),Yn=``;function Xn(e,t){Yn||=zn([`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`],function(t){return Bn(e[t])})??``;let n=e[Yn];return Bn(n)?!!n.call(e,t):!1}function Zn(e,t,n){let r=e;do{if(Xn(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function Qn(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.addEventListener?e.addEventListener(t,a,i):e.attachEvent?e.attachEvent(`on`+t,a):e[`on`+t]=a}function $n(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.removeEventListener?e.removeEventListener(t,a,i):e.detachEvent?e.detachEvent(`on`+t,a):e[`on`+t]=null}function er(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=Hn(n.borderTopWidth),t+=Hn(n.borderBottomWidth),t}function tr(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=Hn(n.borderLeftWidth),t+=Hn(n.borderRightWidth),t}function nr(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=Hn(n.paddingTop),t-=Hn(n.paddingBottom),t}function rr(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=Hn(n.paddingLeft),t-=Hn(n.paddingRight),t}function ir(e,t,n){let r=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-r.left)/n,y:(e.clientY+t.scrollTop-r.top)/n}}function ar(e,t){let n=sr(e,t,`px`);return{[Kn(`transform`,Jn)]:n}}function or(e,t){return sr(e,t,``)}function sr({x:e,y:t},n,r){let i=`translate(${e}${r},${t}${r})`;return n&&(i=`translate(${`${typeof n.x==`string`?n.x:n.x+r}`}, ${`${typeof n.y==`string`?n.y:n.y+r}`})`+i),i}function cr(e,t){return e.targetTouches&&zn(e.targetTouches,e=>t===e.identifier)||e.changedTouches&&zn(e.changedTouches,e=>t===e.identifier)}function lr(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function ur(){return typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0}function dr(e,t){if(!e)return;let n=e.getElementById(`react-draggable-style-el`);if(!n){n=e.createElement(`style`),n.type=`text/css`,n.id=`react-draggable-style-el`;let r=t??ur();r&&n.setAttribute(`nonce`,r),n.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
1
+ import{o as e,r as t,t as n}from"./rolldown-runtime-DAXXjFlN.js";import{_ as r,g as i,t as a}from"./vendor-react-slxo-5GC.js";import{N as o,Nt as s,P as c,V as l,Y as u,Z as d,b as f,ct as p,dt as m,ft as h,gt as g,ht as _,i as v,it as y,jt as b,lt as x,m as S,mt as C,n as w,nt as T,ot as E,pt as ee,rt as D,st as O,t as k,tt as A,ut as j}from"./framework-DxDZ_zWg.js";import{$ as M,B as te,Dc as N,Fi as P,Gi as F,H as I,Ic as ne,Jn as re,Jr as ie,Kt as L,Ls as ae,Mc as R,Mr as z,N as B,Pc as V,Qn as oe,Rc as se,Sc as ce,Tr as H,Ua as U,Ut as le,V as ue,Vt as W,Wt as G,Zn as K,_ as q,a as de,ec as J,f as fe,hi as pe,ir as Y,it as X,ka as me,ki as he,o as ge,or as _e,ot as ve,qn as ye,qt as be,rr as xe,rt as Se,sr as Ce,ts as we,u as Te,xc as Ee,yo as De,z as Oe,zc as ke}from"./ui-components-BDy7soRa.js";import{o as Ae,t as je}from"./vendor-ui-utils-C1OpMExs.js";import{_ as Me,c as Ne,d as Pe,g as Fe,h as Ie,i as Le,n as Re,o as ze,p as Be,s as Ve,t as He}from"./vendor-dndkit-DoPtQigN.js";var Z=e(r(),1),Ue=e(i(),1),Q=a();function We(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&e.provider===`object`}function Ge(e,t){if(t==null||e==null||typeof e!=`number`||!Number.isFinite(e)||typeof t!=`number`||!Number.isFinite(t))return null;if(t===0)return e===0?{value:0,direction:`neutral`}:{value:100,direction:e>0?`up`:`down`};let n=e-t;if(n===0)return{value:0,direction:`neutral`};let r=Math.round(n/Math.abs(t)*100);return{value:Math.abs(r),direction:r>0?`up`:`down`}}var Ke=new Set([`id`,`organization_id`,`tenant_id`,`created_at`,`updated_at`,`created_by`,`updated_by`,`deleted_at`,`deleted_by`,`version`,`_id`,`__typename`]);function qe(e,t){return t&&(t.isSystem===!0||t.system===!0)?!0:Ke.has(e)}var Je=new Set([`select`,`picklist`,`dropdown`,`status`]),Ye=new Set([`currency`,`money`,`number`,`integer`,`decimal`,`float`,`percent`,`percentage`]);function Xe(e){let t={},n=e?.fields;if(!n)return t;if(Array.isArray(n))for(let e of n)e?.name&&(t[e.name]=e);else for(let[e,r]of Object.entries(n))t[e]={name:e,...r};return t}function Ze(e){let{accessorKey:t,label:n,def:r,objectName:i,fieldOptionLabel:a,overrides:o={}}=e,s=o.referenceTo??r?.referenceTo??(typeof r?.reference==`string`?r.reference:r?.reference?.to)??r?.target,c=o.options??r?.options;return i&&c&&a&&Je.has(r?.type)&&(c=c.map(e=>{if(e==null)return e;let n=typeof e==`object`?e.value:e,r=typeof e==`object`&&e.label||String(n);return{value:n,label:a(i,t,String(n),r),color:typeof e==`object`?e.color:void 0}})),{name:t,label:n,type:o.type??r?.type,options:c,referenceTo:s,format:o.format??r?.format,currency:o.currency??r?.currency??r?.defaultCurrency,decimals:o.decimals??r?.decimals??r?.precision??r?.scale}}function Qe(e){return Ye.has(e.type)||typeof e.format==`string`&&/^[\$¥€£]|%$|0/.test(e.format)}function $e(e,t,n){if(e==null||e===``)return``;let r=t.format;if(typeof r==`string`&&/^\$|¥|€|£/.test(r)&&typeof e==`number`){let i={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`}[r[0]];return de(e,t.currency||i||n)}if(typeof r==`string`&&/%/.test(r)&&typeof e==`number`){let t=(r.match(/0\.(0+)%/)||[,``])[1].length;return Te((e>1?e/100:e)*100,t)}return typeof r==`string`&&/[YMDHms]/.test(r)?ge(e,r):(0,Q.jsx)(fe(q(t)),{value:e,field:t})}var et=[`name`,`title`,`label`,`subject`,`display_name`,`full_name`];function tt(e,t){if(t&&t.trim())return t;for(let t of et){let n=e[t];if(typeof n==`string`&&n.trim())return n}let n=e.id??e._id;return n==null?`Record`:String(n)}var nt=({record:e,objectName:t,objectSchema:n,fields:r,title:i,target:a=`drawer`,onClose:o})=>{let{fieldLabel:s,fieldOptionLabel:c}=ke(),{currency:l}=ne(),u=(0,Z.useMemo)(()=>{if(!e)return[];let i=Xe(n),a;return a=r&&r.length>0?r:Object.keys(i).length>0?Object.keys(i).filter(e=>!qe(e,i[e])):Object.keys(e).filter(e=>!e.startsWith(`_`)&&!qe(e)),a.map(n=>{let r=i[n],a=n.charAt(0).toUpperCase()+n.slice(1).replace(/([A-Z])/g,` $1`).replace(/_/g,` `),o=t?s(t,n,a):a,u=Ze({accessorKey:n,label:o,def:r,objectName:t,fieldOptionLabel:c});return{key:n,label:o,node:$e(e[n],u,l),numeric:Qe(u)}})},[e,n,t,r,s,c,l]);if(!e)return null;let d=tt(e,i),f=(0,Q.jsx)(`dl`,{className:`divide-y divide-border/60`,"data-testid":`record-detail-body`,children:u.map(e=>(0,Q.jsxs)(`div`,{className:`grid grid-cols-3 gap-3 py-2.5`,children:[(0,Q.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground self-center`,children:e.label}),(0,Q.jsx)(`dd`,{className:`col-span-2 text-sm break-words ${e.numeric?`tabular-nums`:``}`,children:e.node===``||e.node==null?(0,Q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`—`}):e.node})]},e.key))});return a===`dialog`?(0,Q.jsx)(ye,{open:!0,onOpenChange:e=>!e&&o(),children:(0,Q.jsxs)(re,{className:`max-w-2xl`,children:[(0,Q.jsx)(K,{children:(0,Q.jsx)(oe,{children:d})}),(0,Q.jsx)(`div`,{className:`max-h-[70vh] overflow-auto`,children:f})]})}):(0,Q.jsx)(le,{open:!0,onOpenChange:e=>!e&&o(),children:(0,Q.jsxs)(G,{side:`right`,className:`w-full sm:max-w-md md:max-w-lg flex flex-col`,children:[(0,Q.jsx)(L,{children:(0,Q.jsx)(be,{children:d})}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-auto mt-2 pr-1`,children:f})]})})};function rt(e){return e.map(e=>typeof e==`string`?{header:e.replace(/_/g,` `).replace(/([A-Z])/g,` $1`).trim().replace(/\b\w/g,e=>e.toUpperCase()),accessorKey:e}:e)}function it(e,t){if(!t?.fields)return[];let n={};if(Array.isArray(t.fields))for(let e of t.fields)e?.name&&(n[e.name]=e);else for(let[e,r]of Object.entries(t.fields))n[e]={name:e,...r};let r=e=>e===`lookup`||e===`reference`||e===`master_detail`||e===`user`||e===`owner`,i=Array.isArray(e.columns)?e.columns:[],a=new Set;if(i.length>0){let e=i.map(e=>typeof e==`string`?e:e.accessorKey||e.name).filter(Boolean);for(let t of e){let e=n[t];e&&r(e.type)&&a.add(t)}}else for(let[e,t]of Object.entries(n))r(t?.type)&&a.add(e);return Array.from(a)}var at=({schema:e,dataSource:t,className:n})=>{let{currency:r}=ne(),i=(0,Z.useContext)(u),a=t||i?.dataSource,o=d(e.bind),{fieldLabel:s,fieldOptionLabel:c}=ke(),f=`No data available`,p=`No data source available for`;try{let{t:e}=v(),t=e(`dashboard.noDataAvailable`);t&&t!==`dashboard.noDataAvailable`&&(f=t);let n=e(`dashboard.noDataSourceFor`);n&&n!==`dashboard.noDataSourceFor`&&(p=n)}catch{}let[m,h]=(0,Z.useState)([]),[g,y]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(()=>!(Array.isArray(e.data)&&e.data.length>0)&&!!e.objectName),[C,w]=(0,Z.useState)(null),T=e.drillDown,E=_(T)&&(T?.mode??`record`)===`record`,[D,O]=(0,Z.useState)(null),k=(0,Z.useCallback)(e=>{O(e??null)},[]);(0,Z.useEffect)(()=>{let t=!0;return e.objectName&&!o&&(!e.data||e.data.length===0)?(async()=>{if(!a||!e.objectName){t&&S(!1);return}t&&(S(!0),w(null));try{let n;if(typeof a.find==`function`){let t=it(e,g),r={$filter:ee(e.filter)};t.length&&(r.$expand=t),n=b(await a.find(e.objectName,r))}else return;t&&h(n)}catch(e){console.error(`[ObjectDataTable] Fetch error:`,e),t&&w(e instanceof Error?e.message:`Failed to load data`)}finally{t&&S(!1)}})():t&&S(!1),()=>{t=!1}},[e.objectName,a,o,e.data,e.filter,g]),(0,Z.useEffect)(()=>{let t=!0;if(!(!a||!e.objectName||typeof a.getObjectSchema!=`function`))return a.getObjectSchema(e.objectName).then(e=>{t&&y(e)}).catch(()=>{}),()=>{t=!1}},[e.objectName,a]);let A=o||e.data||m,j=Array.isArray(A)?A:[],M=(0,Z.useMemo)(()=>{let t=e.objectName,n={};if(g?.fields){let e=g.fields;if(Array.isArray(e))for(let t of e)t?.name&&(n[t.name]=t);else for(let[t,r]of Object.entries(e))n[t]={name:t,...r}}let i=e=>{let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/([A-Z])/g,` $1`);return t?s(t,e,n):n},a=e=>{let i=Ze({accessorKey:e.accessorKey,label:e.header,def:n[e.accessorKey],objectName:t,fieldOptionLabel:c,overrides:{type:e.type,format:e.format,options:e.options,referenceTo:e.referenceTo,currency:e.currency,decimals:e.decimals}}),a=e.align??(Qe(i)?`right`:void 0);if(typeof e.cell==`function`)return{...e,...i,align:a};let o=e=>$e(e,i,r);return{...e,...i,align:a,cell:o}};if(e.columns&&e.columns.length>0){let n=rt(e.columns);return(t?n.map(e=>({...e,header:s(t,e.accessorKey,e.header)})):n).map(a)}return j.length===0?[]:(Object.keys(n).length>0?Object.keys(n).filter(e=>!qe(e,n[e])):Object.keys(j[0]).filter(e=>!e.startsWith(`_`)&&!qe(e))).map(e=>a({header:i(e),accessorKey:e}))},[e.columns,e.objectName,j,g,s,c,r]);if(x&&j.length===0)return(0,Q.jsx)(`div`,{className:R(`overflow-auto`,n),"data-testid":`table-loading`,children:(0,Q.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(W,{className:`h-6 w-1/4`}),(0,Q.jsx)(W,{className:`h-6 w-1/4`}),(0,Q.jsx)(W,{className:`h-6 w-1/4`}),(0,Q.jsx)(W,{className:`h-6 w-1/4`})]}),[1,2,3,4].map(e=>(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(W,{className:`h-5 w-1/4`}),(0,Q.jsx)(W,{className:`h-5 w-1/4`}),(0,Q.jsx)(W,{className:`h-5 w-1/4`}),(0,Q.jsx)(W,{className:`h-5 w-1/4`})]},e))]})});if(C)return(0,Q.jsx)(`div`,{className:R(`overflow-auto`,n),"data-testid":`table-error`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`table-error-message`,children:[(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,Q.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,Q.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,Q.jsx)(`p`,{className:`text-xs`,children:C})]})});if(!a&&e.objectName&&j.length===0)return(0,Q.jsx)(`div`,{className:R(`overflow-auto`,n),children:(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,Q.jsxs)(`p`,{className:`text-xs`,children:[p,` “`,e.objectName,`”`]})})});if(j.length===0)return(0,Q.jsx)(`div`,{className:R(`overflow-auto`,n),"data-testid":`table-empty-state`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Q.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,Q.jsx)(`line`,{x1:`3`,y1:`9`,x2:`21`,y2:`9`}),(0,Q.jsx)(`line`,{x1:`9`,y1:`21`,x2:`9`,y2:`9`})]}),(0,Q.jsx)(`p`,{className:`text-xs`,children:f})]})});let N={...e,type:`data-table`,data:j,columns:M,onRowClick:e.onRowClick??(E?k:void 0)},P=T?.title&&!T.title.includes("${")?T.title:void 0;return(0,Q.jsxs)(`div`,{className:R(`relative`,n),children:[(0,Q.jsx)(te,{active:x&&j.length>0}),(0,Q.jsx)(l,{schema:N,className:n}),E&&(0,Q.jsx)(nt,{record:D,objectName:e.objectName,objectSchema:g,fields:T?.columns,title:P,target:T?.target===`dialog`?`dialog`:`drawer`,onClose:()=>O(null)})]})},ot=({objectName:e,filter:t,onNavigate:n,className:r})=>{let{openRecordList:i}=f(),a=w();return!i||!e?null:(0,Q.jsxs)(H,{type:`button`,variant:`ghost`,size:`sm`,className:r,"data-testid":`drill-open-in-list`,onClick:()=>{i(e,t),n?.()},children:[a(`dashboard.openInList`,`Open in list`),(0,Q.jsx)(ce,{className:`ml-1 h-3.5 w-3.5`})]})},st=({open:e,onClose:t,title:n,target:r=`drawer`,objectName:i,filter:a,dataSource:o,columns:s,maxRows:c,className:u,report:d})=>{let{openRecordList:p}=f(),m=d&&typeof d==`object`&&(Array.isArray(d.columns)||`objectName`in d),h=r===`navigate`&&!!p&&!m&&!!i;if(Z.useEffect(()=>{e&&h&&(p(i,a),t())},[e,h]),h)return null;let g=m?null:(0,Q.jsx)(ot,{objectName:i,filter:a,onNavigate:t}),_=(0,Q.jsx)(`div`,{className:R(`overflow-auto`,u),"data-testid":`drill-down-body`,children:m?(()=>{let e=d.filter,t=e?a?{$and:[e,a]}:e:a;return(0,Q.jsx)(l,{schema:{...d,type:`spec-report`,report:{...d,filter:t},filter:t}})})():(0,Q.jsx)(at,{schema:{type:`object-data-table`,objectName:i,filter:a,columns:s?.map(e=>({accessorKey:e,header:e})),pagination:!0,searchable:!1,pageSize:c,drillDown:{enabled:!0,mode:`record`,target:`dialog`}},dataSource:o})});return r===`dialog`?(0,Q.jsx)(ye,{open:e,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(re,{className:`max-w-5xl`,children:[(0,Q.jsxs)(K,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,Q.jsx)(oe,{children:n}),g]}),_]})}):(0,Q.jsx)(le,{open:e,onOpenChange:e=>!e&&t(),children:(0,Q.jsxs)(G,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-4xl flex flex-col`,children:[(0,Q.jsxs)(L,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,Q.jsx)(be,{children:n}),g]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:_})]})})},ct=A;function lt(e,t,n){let r=[],i=[],a=new Set,o=new Set,s=new Map;return e.forEach((e,c)=>{let l=t.map(t=>String(e[t]??`∅`)).join(``),u=String(e[n]??`∅`);a.has(l)||(a.add(l),r.push({id:l,labels:t.map(t=>D(e[t]))})),o.has(u)||(o.add(u),i.push({id:u,label:D(e[n])})),s.set(`${l} ${u}`,c)}),{rowHeaders:r,colHeaders:i,cellIndex:s}}function ut(e){if(e==null)return``;let t=String(e);return/[",\n\r]/.test(t)?`"${t.replace(/"/g,`""`)}"`:t}function dt(e){return e.map(e=>e.map(ut).join(`,`)).join(`\r
2
+ `)}function ft(e,t){if(typeof document>`u`)return;let n=e&&e.trim()?e.trim():`export`,r=new Blob([`${dt(t)}`],{type:`text/csv;charset=utf-8;`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=n.endsWith(`.csv`)?n:`${n}.csv`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(i)}var pt=new Set([`metric`,`kpi`,`gauge`,`solid-gauge`,`bullet`]),mt={bar:`bar`,column:`column`,"horizontal-bar":`horizontal-bar`,"grouped-bar":`bar`,"stacked-bar":`bar`,"bi-polar-bar":`bar`,line:`line`,spline:`line`,"step-line":`line`,area:`area`,"stacked-area":`area`,pie:`pie`,donut:`donut`,funnel:`funnel`,pyramid:`funnel`,scatter:`scatter`,bubble:`scatter`,radar:`radar`,treemap:`treemap`,sankey:`sankey`};function ht({widget:e,dataSource:t}){let n=String(e?.dataset??``),r=(0,Z.useMemo)(()=>Array.isArray(e?.dimensions)?e.dimensions.filter(Boolean):[],[e]),i=(0,Z.useMemo)(()=>Array.isArray(e?.values)?e.values.filter(Boolean):[],[e]),a=e?.compareTo&&typeof e.compareTo==`object`?e.compareTo:void 0,o=String(e?.type??``),s=pt.has(o)||r.length===0,c=o===`table`||o===`pivot`,u=o===`pivot`&&r.length>=2,d=u?r.slice(0,-1):[],f=u?r[r.length-1]:``,m=u?[d,[f],[]]:void 0,h=w(),{fieldLabel:g}=ke(),_=e?.filter,v=(0,Z.useMemo)(()=>_&&typeof _==`object`&&Object.keys(_).length>0?ee(_):void 0,[_]),[b,S]=(0,Z.useState)({status:`idle`,rows:[]}),[C,k]=(0,Z.useState)(null),[A,M]=(0,Z.useState)(null),[te,N]=(0,Z.useState)(null);if((0,Z.useEffect)(()=>{let e=t;if(!e||typeof e.queryDataset!=`function`){S({status:`error`,rows:[],error:h(`dashboard.datasetUnsupported`,`This data source does not support dataset queries.`)});return}if(i.length===0){S({status:`idle`,rows:[]});return}let o=!1;return S({status:`loading`,rows:[]}),e.queryDataset(n,{dimensions:r,measures:i,...v?{runtimeFilter:v}:{},...a?{compareTo:a}:{},...m?{totals:{groupings:m}}:{}}).then(e=>{o||S({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,totals:Array.isArray(e?.totals)?e.totals:void 0})}).catch(e=>{o||S({status:`error`,rows:[],error:String(e?.message??e)})}),()=>{o=!0}},[`${o}|${n}|${r.join(`,`)}|${i.join(`,`)}|${JSON.stringify(_??null)}|${JSON.stringify(a??null)}`]),(0,Z.useEffect)(()=>{if(s||c){M(null),N(null);return}let e=b.object;if(!e||r.length===0){M(null),N(null);return}let t=e=>b.dimensionFields&&b.dimensionFields[e]||e,n=!1;return(async()=>{try{let i=await(await fetch(`/api/v1/meta/object/${encodeURIComponent(e)}`,{headers:{accept:`application/json`},credentials:`include`})).json().catch(()=>null),a=i?.item??i?.data??i,o=p(a?.fields?.[t(r[0])]?.options),s={};for(let e of r){let n=O(a?.fields?.[t(e)]?.options);n&&(s[e]=n)}n||(M(o),N(Object.keys(s).length>0?s:null))}catch{n||(M(null),N(null))}})(),()=>{n=!0}},[b.object,b.dimensionFields,r,s,c]),i.length===0)return(0,Q.jsx)(`div`,{className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground`,children:h(`dashboard.pickMeasures`,`Pick measures (values) for this dataset widget.`)});if(b.status===`loading`||b.status===`idle`)return(0,Q.jsxs)(`div`,{className:`h-full w-full p-2`,"data-testid":`dataset-loading`,role:`status`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,Q.jsx)(`span`,{className:`sr-only`,children:h(`dashboard.loading`,`Loading…`)}),s?(0,Q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-start justify-center gap-2 p-2`,children:[(0,Q.jsx)(W,{className:`h-8 w-32 rounded`}),(0,Q.jsx)(W,{className:`h-3 w-20 rounded`})]}):c?(0,Q.jsx)(I,{className:`h-full`,rows:5,columns:Math.max(2,r.length+i.length)}):(0,Q.jsx)(ue,{className:`h-full`})]});if(b.status===`error`)return(0,Q.jsxs)(`div`,{role:`alert`,className:`flex h-full w-full items-start gap-2 rounded border border-destructive/40 bg-destructive/5 p-3 text-xs text-destructive`,children:[(0,Q.jsx)(ie,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`break-words`,children:b.error})]});if(b.rows.length===0&&!s)return(0,Q.jsxs)(`div`,{className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-xs text-muted-foreground`,children:[(0,Q.jsx)(J,{className:`mr-2 h-4 w-4`}),h(`dashboard.noRows`,`No rows`)]});let{measureField:P,headerLabel:F}=T(b.fields,b.object,g),{object:ne,dimensionFields:re,drillRawRows:L}=b,ae=re?r.filter(e=>e in re):[],z=!!ne&&ae.length>0,B=(t,n)=>{!ne||!re||k({filter:ct(L?.[t],ae,re,v),title:n||String(e?.title??``)})},V=C&&ne?(0,Q.jsx)(st,{open:!0,onClose:()=>k(null),title:C.title||String(e?.title??h(`dashboard.details`,`Details`)),objectName:ne,filter:C.filter,dataSource:t}):null;if(s){let e=P(i[0]);return(0,Q.jsxs)(`div`,{className:`flex h-full w-full flex-col items-start justify-center gap-1 p-2`,children:[(0,Q.jsx)(`span`,{className:`text-2xl font-semibold tabular-nums`,children:y(b.rows[0]?.[i[0]]??0,e?.format,e?.currency)}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:F(i[0])})]})}if(c){let t=[...r,...i],a=(0,Q.jsx)(`button`,{type:`button`,onClick:()=>ft(String(e?.title??n??`export`),[t.map(e=>F(e)),...b.rows.map(e=>t.map(t=>{let n=e[t];return n==null?``:typeof n==`number`?n:String(n)}))]),"data-testid":`dataset-export`,title:h(`dashboard.exportCsv`,`Export CSV`),"aria-label":h(`dashboard.exportCsv`,`Export CSV`),className:`absolute right-1 top-1 z-10 rounded p-1 text-muted-foreground opacity-70 hover:bg-accent/50 hover:text-foreground hover:opacity-100`,children:(0,Q.jsx)(we,{className:`h-3.5 w-3.5`})});if(u){let e=lt(b.rows,d,f),t=e.colHeaders.flatMap(e=>i.map(t=>({col:e,measure:t,header:i.length===1?e.label:`${e.label} · ${F(t)}`}))),n=(e,t)=>y(e,P(t)?.format,P(t)?.currency),r=e=>b.totals?.find(t=>Array.isArray(t.dimensions)&&t.dimensions.join(`,`)===e.join(`,`))?.rows,o=new Map;for(let e of r(d)??[])o.set(d.map(t=>String(e[t]??`∅`)).join(``),e);let s=new Map;for(let e of r([f])??[])s.set(String(e[f]??`∅`),e);let c=r([])?.[0],l=o.size>0,u=s.size>0,p=h(`dashboard.total`,`Total`);return(0,Q.jsxs)(`div`,{className:`relative h-full w-full overflow-auto p-1`,"data-testid":`dataset-matrix`,children:[a,(0,Q.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Q.jsx)(`thead`,{className:`bg-muted/40`,children:(0,Q.jsxs)(`tr`,{children:[d.map(e=>(0,Q.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:F(e)},e)),t.map(e=>(0,Q.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,children:e.header},`${e.col.id}-${e.measure}`)),l&&i.map(e=>(0,Q.jsx)(`th`,{className:`px-2 py-1.5 text-right font-medium whitespace-nowrap`,"data-testid":`matrix-total-col-header`,children:i.length===1?p:`${p} · ${F(e)}`},`total-${e}`))]})}),(0,Q.jsxs)(`tbody`,{children:[e.rowHeaders.map(r=>(0,Q.jsxs)(`tr`,{className:`border-t`,children:[r.labels.map((e,t)=>(0,Q.jsx)(`td`,{className:`px-2 py-1 whitespace-nowrap font-medium`,children:e},t)),t.map(t=>{let i=e.cellIndex.get(`${r.id} ${t.col.id}`),a=i==null?void 0:b.rows[i],o=z&&i!=null,s=[...r.labels,t.col.label].filter(Boolean).join(` / `);return(0,Q.jsx)(`td`,{className:R(`px-2 py-1 text-right tabular-nums whitespace-nowrap`,o&&`cursor-pointer hover:bg-accent/40`),"data-testid":o?`dataset-drill-cell`:void 0,onClick:o?()=>B(i,s):void 0,children:a?n(a[t.measure],t.measure):`—`},`${t.col.id}-${t.measure}`)}),l&&i.map(e=>(0,Q.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap font-medium`,"data-testid":`matrix-row-total`,children:n(o.get(r.id)?.[e],e)},`total-${e}`))]},r.id)),u&&(0,Q.jsxs)(`tr`,{className:`border-t bg-muted/30 font-medium`,"data-testid":`matrix-total-row`,children:[d.length>0&&(0,Q.jsx)(`td`,{colSpan:d.length,className:`px-2 py-1 whitespace-nowrap`,children:p}),t.map(e=>(0,Q.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,children:n(s.get(e.col.id)?.[e.measure],e.measure)},`${e.col.id}-${e.measure}`)),l&&i.map(e=>(0,Q.jsx)(`td`,{className:`px-2 py-1 text-right tabular-nums whitespace-nowrap`,"data-testid":`matrix-grand-total`,children:n(c?.[e],e)},`grand-${e}`))]})]})]}),V]})}let o=[...r,...i];return(0,Q.jsxs)(`div`,{className:`relative h-full w-full overflow-auto p-1`,children:[a,(0,Q.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,Q.jsx)(`thead`,{className:`bg-muted/40`,children:(0,Q.jsx)(`tr`,{children:o.map(e=>(0,Q.jsx)(`th`,{className:`px-2 py-1.5 text-left font-medium whitespace-nowrap`,children:F(e)},e))})}),(0,Q.jsx)(`tbody`,{children:b.rows.map((e,t)=>(0,Q.jsx)(`tr`,{className:R(`border-t`,z&&`cursor-pointer hover:bg-accent/40`),"data-testid":z?`dataset-drill-row`:void 0,onClick:z?()=>B(t,ae.map(t=>D(e[t])).filter(Boolean).join(` / `)):void 0,children:o.map(t=>(0,Q.jsx)(`td`,{className:`px-2 py-1 whitespace-nowrap tabular-nums`,children:i.includes(t)?y(e[t],P(t)?.format,P(t)?.currency):D(e[t])},t))},t))})]}),V]})}let oe=mt[o]??`bar`,se=j(b.rows,te),{data:ce,xAxisKey:H,series:U}=E(se,r,i,b.fields),le=z?e=>{let t=x(se,r,i,e?.category,e?.series);if(t<0)return;let n=r.length>=2&&i.length===1;B(t,[e?.category,n?e?.series:void 0].filter(Boolean).map(String).join(` / `))}:void 0;return(0,Q.jsxs)(`div`,{className:R(`relative h-full w-full min-h-[220px]`),children:[(0,Q.jsx)(l,{schema:{type:`chart`,chartType:oe,data:ce,xAxisKey:H,series:U,...A?{categoryColors:A}:{}},onChartClick:le,onSegmentClick:le}),V]})}function gt({id:e,disabled:t,gridSpan:n,className:r,children:i}){let{attributes:a,listeners:o,setNodeRef:s,transform:c,transition:l,isDragging:u,isOver:d}=ze({id:e,disabled:t});return(0,Q.jsx)(`div`,{ref:s,style:{transform:Me.Transform.toString(c),transition:l,opacity:u?.4:1,...n?{gridColumn:`span ${n.w}`,gridRow:`span ${n.h}`}:{}},className:R(`h-full w-full`,r,!t&&`cursor-grab active:cursor-grabbing`,d&&!u&&`ring-2 ring-primary ring-offset-2 rounded-lg`),"data-sortable-widget-id":e,...a,...o,children:i})}function _t(e){return e?ve(e):null}function vt(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var yt=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],bt={column:`bar`,"stacked-bar":`bar`,"grouped-bar":`bar`,"bi-polar-bar":`bar`,spline:`line`,"step-line":`line`,"stacked-area":`area`,pyramid:`funnel`,bubble:`scatter`},xt=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`scatter`,`funnel`,`radar`,`treemap`,`sankey`]),St=new Set([`gauge`,`solid-gauge`,`kpi`,`bullet`]),Ct=new Set([`sunburst`,`word-cloud`,`choropleth`,`bubble-map`,`gl-map`,`heatmap`,`waterfall`,`box-plot`,`violin`,`candlestick`,`stock`]),wt=new Set([`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`scatter`,`treemap`,`sankey`]);function Tt(e){return wt.has(e)?{enabled:!0}:void 0}var Et=(0,Z.forwardRef)(({schema:e,className:t,dataSource:n,onRefresh:r,recordCount:i,userActions:a,designMode:o,selectedWidgetId:s,onWidgetClick:c,onWidgetsReorder:u,modalHandler:d,scriptHandlers:f,hideHeaderText:p,...m},h)=>{let g=(()=>{if(e.columns!=null)return e.columns;let t=e.widgets??[],n=0;for(let e of t){let t=(e.layout?.x??0)+(e.layout?.w??0);t>n&&(n=t),(e.layout?.w??0)>n&&(n=e.layout.w)}return n>4?12:4})(),_=g,y=e.gap||4,b=e.columns!=null||g!==4,[x,C]=(0,Z.useState)(!1),[w,T]=(0,Z.useState)(!1),E=(0,Z.useRef)(null),{executeAction:ee,engine:D}=S({actions:(0,Z.useMemo)(()=>(e.header?.actions??[]).map(e=>({name:e.actionUrl||e.label,type:e.actionType||`url`,target:e.actionUrl,label:e.label})),[e.header?.actions])}),{dashboardLabel:O,dashboardDescription:k,dashboardActionLabel:A,widgetTitle:j,widgetDescription:M,fieldLabel:te}=se(),{t:N}=v(),P=(0,Z.useCallback)((e,t,n)=>n&&(!t||t===`value`||t===`count`||n===`count`)?N(`report.aggregate.${n}`,{defaultValue:n}):e?te(e,t,t):t,[N,te]),I=e.name,ne=(0,Z.useCallback)(e=>I?A(I,e.actionUrl||e.label,e.label):e.label,[I,A]),re=(0,Z.useCallback)(e=>{let t=vt(e.title);return!I||!e.id||t===void 0?t:j(I,e.id,t)},[I,j]),ie=(0,Z.useCallback)(e=>{let t=vt(e.description);return!I||!e.id?t:M(I,e.id,t)},[I,M]);(0,Z.useEffect)(()=>{let e=D.getRunner();if(d&&e.setModalHandler(d),f)for(let[t,n]of Object.entries(f))e.registerScript(t,n)},[D,d,f]),(0,Z.useEffect)(()=>{let e=()=>T(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let L=(0,Z.useCallback)(()=>{r&&(C(!0),r(),setTimeout(()=>C(!1),600))},[r]);(0,Z.useEffect)(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!r))return E.current=setInterval(L,e.refreshInterval*1e3),()=>{E.current&&clearInterval(E.current)}},[e.refreshInterval,r,L]);let ae=(0,Z.useCallback)((e,t)=>{!o||!c||!t||(e.stopPropagation(),c(t))},[o,c]),z=(0,Z.useCallback)((t,n,r)=>{if(!o||!c)return;let i=e.widgets||[];if(t.key===`Enter`||t.key===` `)t.preventDefault(),c(n??null);else if(t.key===`ArrowRight`||t.key===`ArrowDown`){t.preventDefault();let e=r+1<i.length?i[r+1]:null;e?.id&&c(e.id)}else if(t.key===`ArrowLeft`||t.key===`ArrowUp`){t.preventDefault();let e=r-1>=0?i[r-1]:null;e?.id&&c(e.id)}else t.key===`Escape`&&(t.preventDefault(),c(null))},[o,c,e.widgets]),B=(0,Z.useCallback)(e=>{!o||!c||e.target===e.currentTarget&&c(null)},[o,c]),V=!!(o&&u),oe=Fe(Ie(Pe,{activationConstraint:{distance:5}})),ce=(0,Z.useCallback)(t=>{if(!V)return;let{active:n,over:r}=t;if(!r||n.id===r.id)return;let i=e.widgets??[],a=i.findIndex(e=>e.id===n.id),o=i.findIndex(e=>e.id===r.id);a<0||o<0||u?.(Re(i,a,o))},[V,e.widgets,u]),U=(e,t,r)=>{let i=e.type===`metric`||St.has(e.type||``),a=b?{w:Math.min(i?3:6,_),h:i?2:4}:void 0,c=e.layout??a,u=c?{...c,w:Math.min(c.w,_)}:void 0,d=!!e.dataset,f=(()=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`metric`&&e.object){let t=n.data,r=We(t)&&t.aggregate?{field:e.valueField||t.aggregate.field,function:e.aggregate||t.aggregate.function,groupBy:e.categoryField??t.aggregate.groupBy??`_all`}:e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object||(We(t)?t.object:void 0),aggregate:r,filter:(We(t)?t.filter:void 0)||e.filter,label:n.label||re(e)||``,fallbackValue:n.value,trend:n.trend,icon:n.icon,description:n.description,colorVariant:e.colorVariant,format:n.format,currency:n.currency,prefix:n.prefix,suffix:n.suffix,drillDown:n.drillDown??{enabled:!0},title:n.label||re(e)||``,compareTo:e.compareTo}}if(St.has(t||``)&&e.object){let t=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`_all`}:void 0;return{type:`object-metric`,objectName:e.object,aggregate:t,filter:e.filter,label:n.label||re(e)||``,fallbackValue:n.fallbackValue??n.value,icon:n.icon,description:n.description,colorVariant:e.colorVariant,format:n.format,currency:n.currency,prefix:n.prefix,suffix:n.suffix,invert:n.invert,compareTo:e.compareTo}}let r=t&&bt[t]||t;if(r&&xt.has(r)){let t=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(We(t)){let o=t.aggregate,s=(()=>{let t=e.categoryField||o?.groupBy;if(t)return e.categoryGranularity&&typeof t==`string`?{field:t,dateGranularity:e.categoryGranularity}:t})(),c=o?{field:e.valueField||o.field,function:e.aggregate||o.function,groupBy:s}:void 0,l=c?.field||a,u=e.object||t.object;return{type:`object-chart`,chartType:r,objectName:u,aggregate:c,filter:t.filter||e.filter,xAxisKey:i,series:[{dataKey:l,label:P(u,l,c?.function)}],colors:yt,drillDown:n.drillDown??Tt(r),compareTo:e.compareTo,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(!t&&e.object){let t=e.categoryField||`name`,a=e.categoryGranularity?{field:t,dateGranularity:e.categoryGranularity}:t,o=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:a}:void 0,s=e.valueField||`value`;return{type:`object-chart`,chartType:r,objectName:e.object,aggregate:o,filter:e.filter,xAxisKey:i,series:[{dataKey:s,label:P(e.object,s,e.aggregate)}],colors:yt,drillDown:n.drillDown??Tt(r),compareTo:e.compareTo,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}return{type:`chart`,chartType:r,data:Array.isArray(t)?t:t?.items||[],xAxisKey:i,series:[{dataKey:a,label:P(e.object,a,e.aggregate)}],colors:yt,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(t===`table`){let t=e.data||n.data,r=We(t)||!t&&e.object?n.drillDown??{enabled:!0,mode:`record`}:void 0;if(We(t)){let{data:i,...a}=n;return{type:`object-data-table`,...a,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,drillDown:r,className:`border-0`}}return!t&&e.object?{type:`object-data-table`,...n,objectName:e.object,filter:e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,drillDown:r,className:`border-0`}:{type:`data-table`,...n,data:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}if(t===`pivot`){let t=e.data||n.data,r=e,i={rowField:r.rowField??n.rowField,columnField:r.columnField??n.columnField,valueField:r.valueField??n.valueField,aggregation:r.aggregation??n.aggregation??`sum`,showRowTotals:r.showRowTotals??n.showRowTotals,showColumnTotals:r.showColumnTotals??n.showColumnTotals,format:r.format??n.format},a=(We(t)||!t&&e.object)&&n.drillDown===void 0?{...n,drillDown:{enabled:!0}}:n;if(We(t)){let{data:n,...r}=a;return{type:`object-pivot`,...r,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter}}return!t&&e.object?{type:`object-pivot`,...a,...i,objectName:e.object,filter:e.filter}:{type:`pivot`,...n,...i,data:Array.isArray(t)?t:t?.items||[]}}if(t===`list`){let t=e.data||n.data,r=We(t)||!t&&e.object?n.drillDown??{enabled:!0,mode:`record`}:void 0;if(We(t)){let{data:i,...a}=n;return{type:`object-data-table`,...a,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:!1,pagination:!1,drillDown:r,className:`border-0`}}return!t&&e.object?{type:`object-data-table`,...n,objectName:e.object,filter:e.filter,searchable:!1,pagination:!1,drillDown:r,className:`border-0`}:{type:`data-table`,...n,data:Array.isArray(t)?t:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}return t===`custom`?{type:`text`,value:"Custom widget — set `component` to a UIComponent schema.",variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground`}:t&&Ct.has(t)?{type:`text`,value:`「${t}」chart type is not supported yet`,variant:`caption`,align:`center`,className:`flex h-full w-full items-center justify-center rounded border border-dashed bg-muted/20 p-4 text-muted-foreground`}:{...e,...n}})(),p=e.type===`metric`&&!d,m=re(e),h=ie(e),g=e.id||m||`widget-${t}`,v=o&&s===e.id,y=o?{"data-testid":`dashboard-preview-widget-${e.id}`,"data-widget-id":e.id,role:`button`,tabIndex:0,"aria-selected":v,"aria-label":`Widget: ${m||`Widget ${t+1}`}`,onClick:t=>ae(t,e.id),onKeyDown:n=>z(n,e.id,t)}:{},x=o?R(`cursor-pointer rounded-lg transition-all outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,v?`ring-2 ring-primary shadow-md bg-primary/5 dark:bg-primary/10`:`hover:ring-2 hover:ring-primary/40 hover:shadow-sm`):void 0,S=!w&&u&&!V?{gridColumn:`span ${u.w}`,gridRow:`span ${u.h}`}:void 0,C=p?(0,Q.jsxs)(`div`,{className:R(`h-full w-full`,o&&`relative`,x),style:S,...y,children:[d?(0,Q.jsx)(`div`,{className:R(`h-full w-full`,o&&`pointer-events-none`),children:(0,Q.jsx)(ht,{widget:e,dataSource:n})}):(0,Q.jsx)(l,{schema:f,className:R(`h-full w-full`,o&&`pointer-events-none`),dataSource:n}),o&&(0,Q.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]}):(0,Q.jsxs)(xe,{className:R(`overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md`,`bg-card/50 backdrop-blur-sm`,r&&`w-full`,o&&`relative`,x),style:S,...y,children:[m&&(0,Q.jsxs)(_e,{className:`pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6`,children:[(0,Q.jsx)(Ce,{className:`text-sm sm:text-base font-medium tracking-tight truncate`,title:m,children:m}),h&&(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 line-clamp-2`,children:h})]}),(0,Q.jsx)(Y,{className:`p-0`,children:(0,Q.jsx)(`div`,{className:R(`h-full w-full`,`p-3 sm:p-4 md:p-6`,o&&`pointer-events-none`),children:d?(0,Q.jsx)(ht,{widget:e,dataSource:n}):(0,Q.jsx)(l,{schema:f,dataSource:n})})}),o&&(0,Q.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]});return V&&e.id?(0,Q.jsx)(gt,{id:e.id,gridSpan:!w&&u?{w:u.w,h:u.h}:void 0,children:C},g):(0,Q.jsx)(Z.Fragment,{children:C},g)},le=e.header&&(0,Q.jsxs)(`div`,{className:`col-span-full mb-4`,children:[!p&&e.header.showTitle!==!1&&e.title&&(0,Q.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:I?O({name:I,label:vt(e.title)}):vt(e.title)}),!p&&e.header.showDescription!==!1&&e.description&&(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:I?k({name:I,description:vt(e.description)}):vt(e.description)}),e.header.actions&&e.header.actions.length>0&&(0,Q.jsx)(`div`,{className:`flex gap-2 mt-3`,children:e.header.actions.map((e,t)=>{let n=_t(e.icon);return(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:async()=>{let{actionType:t,actionUrl:n,label:r}=e;if(!t||!n){console.warn(`[DashboardRenderer] Header action missing actionType/actionUrl:`,e);return}if(t===`url`){/^https?:\/\//.test(n)||n.startsWith(`//`)?window.location.assign(n):(window.history.pushState({},``,n),window.dispatchEvent(new PopStateEvent(`popstate`)));return}if(t===`modal`||t===`script`){let e=await ee(n||r);e?.success||console.warn(`[DashboardRenderer] action failed`,e?.error);return}console.warn(`[DashboardRenderer] Unknown header actionType="${t}" for "${r}"`)},children:[n&&(0,Q.jsx)(n,{className:`w-4 h-4 mr-1.5`}),ne(e)]},t)})})]}),ue=i!==void 0&&(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.toLocaleString(),` records`]}),W=a?JSON.stringify(a):void 0,G=r&&(0,Q.jsxs)(`div`,{className:R(`flex items-center justify-end gap-3 mb-2`,!w&&`col-span-full`),children:[ue,(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:L,disabled:x,"aria-label":`Refresh dashboard`,children:[(0,Q.jsx)(F,{className:R(`h-4 w-4 mr-2`,x&&`animate-spin`)}),x?`Refreshing…`:`Refresh All`]})]}),K=(0,Z.useMemo)(()=>(e.widgets??[]).map(e=>e.id).filter(e=>!!e),[e.widgets]),q=(0,Z.useMemo)(()=>(e.widgets??[]).filter(e=>e.type===`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]),de=(0,Z.useMemo)(()=>(e.widgets??[]).filter(e=>e.type!==`metric`).map(e=>e.id).filter(e=>!!e),[e.widgets]);if(w){let n=e.widgets?.filter(e=>e.type===`metric`)||[],r=e.widgets?.filter(e=>e.type!==`metric`)||[],i=(0,Q.jsxs)(`div`,{ref:h,className:R(`flex flex-col gap-4 px-4`,t),"data-user-actions":W,onClick:B,...m,children:[le,G,n.length>0&&(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,onClick:B,children:(0,Q.jsx)(He,{items:q,strategy:Le,disabled:!V,children:n.map((e,t)=>U(e,t))})}),r.length>0&&(0,Q.jsx)(`div`,{className:`flex flex-col gap-4`,onClick:B,children:(0,Q.jsx)(He,{items:de,strategy:Ve,disabled:!V,children:r.map((e,t)=>U(e,t,!0))})})]});return V?(0,Q.jsx)(Ne,{sensors:oe,collisionDetection:Be,onDragEnd:ce,children:i}):i}let J=(0,Q.jsxs)(`div`,{ref:h,className:R(`grid`,!b&&`auto-rows-min grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,t),style:{...b&&{gridTemplateColumns:`repeat(${_}, minmax(0, 1fr))`,gridAutoRows:`minmax(5rem, auto)`},gap:`${y*.25}rem`},"data-user-actions":W,onClick:B,...m,children:[le,G,(0,Q.jsx)(He,{items:K,strategy:Le,disabled:!V,children:e.widgets?.map((e,t)=>U(e,t))})]});return V?(0,Q.jsx)(Ne,{sensors:oe,collisionDetection:Be,onDragEnd:ce,children:J}):J});function Dt(e){let{margin:t,containerPadding:n,containerWidth:r,cols:i}=e;return(r-t[0]*(i-1)-n[0]*2)/i}function Ot(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function kt(e,t,n,r,i,a,o){let{margin:s,containerPadding:c,rowHeight:l}=e,u=Dt(e),d,f,p,m;if(o?(d=Math.round(o.width),f=Math.round(o.height)):(d=Ot(r,u,s[0]),f=Ot(i,l,s[1])),a?(p=Math.round(a.top),m=Math.round(a.left)):o?(p=Math.round(o.top),m=Math.round(o.left)):(p=Math.round((l+s[1])*n+c[1]),m=Math.round((u+s[0])*t+c[0])),!a&&!o){if(Number.isFinite(r)){let e=Math.round((u+s[0])*(t+r)+c[0])-m-d;e!==s[0]&&(d+=e-s[0])}if(Number.isFinite(i)){let e=Math.round((l+s[1])*(n+i)+c[1])-p-f;e!==s[1]&&(f+=e-s[1])}}return{top:p,left:m,width:d,height:f}}function At(e,t,n,r,i){let{margin:a,containerPadding:o,cols:s,rowHeight:c,maxRows:l}=e,u=Dt(e),d=Math.round((n-o[0])/(u+a[0])),f=Math.round((t-o[1])/(c+a[1]));return d=Nt(d,0,s-r),f=Nt(f,0,l-i),{x:d,y:f}}function jt(e,t,n){let{margin:r,containerPadding:i,rowHeight:a}=e,o=Dt(e);return{x:Math.round((n-i[0])/(o+r[0])),y:Math.round((t-i[1])/(a+r[1]))}}function Mt(e,t,n){let{margin:r,rowHeight:i}=e,a=Dt(e);return{w:Math.max(1,Math.round((t+r[0])/(a+r[0]))),h:Math.max(1,Math.round((n+r[1])/(i+r[1])))}}function Nt(e,t,n){return Math.max(Math.min(e,n),t)}function Pt(e,t){return!(e.i===t.i||e.x+e.w<=t.x||e.x>=t.x+t.w||e.y+e.h<=t.y||e.y>=t.y+t.h)}function Ft(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&Pt(r,t))return r}}function It(e,t){return e.filter(e=>Pt(e,t))}function Lt(e,t){return t===`horizontal`?zt(e):t===`vertical`||t===`wrap`?Rt(e):[...e]}function Rt(e){return[...e].sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)}function zt(e){return[...e].sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x)}function Bt(e){let t=0;for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0){let e=r.y+r.h;e>t&&(t=e)}}return t}function Vt(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&r.i===t)return r}}function Ht(e){return e.filter(e=>e.static===!0)}function Ut(e){return{i:e.i,x:e.x,y:e.y,w:e.w,h:e.h,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,moved:!!e.moved,static:!!e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,constraints:e.constraints,isBounded:e.isBounded}}function Wt(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t[n]=Ut(r))}return t}function Gt(e,t){let n=Array(e.length);for(let r=0;r<e.length;r++){let i=e[r];i!==void 0&&(t.i===i.i?n[r]=t:n[r]=i)}return n}function Kt(e,t,n){let r=Vt(e,t);return r?(r=n(Ut(r)),[Gt(e,r),r]):[[...e],null]}function qt(e,t){let n=Ht(e);for(let r=0;r<e.length;r++){let i=e[r];if(i!==void 0)if(i.x+i.w>t.cols&&(i.x=t.cols-i.w),i.x<0&&(i.x=0,i.w=t.cols),!i.static)n.push(i);else for(;Ft(n,i);)i.y++}return e}function Jt(e,t,n,r,i,a,o,s,c){if(t.static&&t.isDraggable!==!0||t.y===r&&t.x===n)return[...e];let l=t.x,u=t.y;typeof n==`number`&&(t.x=n),typeof r==`number`&&(t.y=r),t.moved=!0;let d=Lt(e,o);(o===`vertical`&&typeof r==`number`?u>=r:o===`horizontal`&&typeof n==`number`&&l>=n)&&(d=d.reverse());let f=It(d,t),p=f.length>0;if(p&&c)return Wt(e);if(p&&a)return t.x=l,t.y=u,t.moved=!1,e;let m=[...e];for(let e=0;e<f.length;e++){let n=f[e];n!==void 0&&(n.moved||(m=n.static?Yt(m,n,t,i,o):Yt(m,t,n,i,o)))}return m}function Yt(e,t,n,r,i,a){let o=i===`horizontal`,s=i===`vertical`,c=t.static;if(r){r=!1;let a={x:o?Math.max(t.x-n.w,0):n.x,y:s?Math.max(t.y-n.h,0):n.y,w:n.w,h:n.h,i:`-1`},l=Ft(e,a),u=l!==void 0&&l.y+l.h>t.y,d=l!==void 0&&t.x+t.w>l.x;if(!l)return Jt(e,n,o?a.x:void 0,s?a.y:void 0,r,c,i);if(u&&s)return Jt(e,n,void 0,n.y+1,r,c,i);if(u&&i===null)return t.y=n.y,n.y+=n.h,[...e];if(d&&o)return Jt(e,t,n.x,void 0,r,c,i)}let l=o?n.x+1:void 0,u=s?n.y+1:void 0;return l===void 0&&u===void 0?[...e]:Jt(e,n,l,u,r,c,i)}function Xt(e,t,n){return Math.max(t,Math.min(n,e))}var Zt=[{name:`gridBounds`,constrainPosition(e,t,n,{cols:r,maxRows:i}){return{x:Xt(t,0,Math.max(0,r-e.w)),y:Xt(n,0,Math.max(0,i-e.h))}},constrainSize(e,t,n,r,{cols:i,maxRows:a}){let o=r===`w`||r===`nw`||r===`sw`?e.x+e.w:i-e.x,s=r===`n`||r===`nw`||r===`ne`?e.y+e.h:a-e.y;return{w:Xt(t,1,Math.max(1,o)),h:Xt(n,1,Math.max(1,s))}}},{name:`minMaxSize`,constrainSize(e,t,n){return{w:Xt(t,e.minW??1,e.maxW??1/0),h:Xt(n,e.minH??1,e.maxH??1/0)}}}];function Qt(e,t,n,r,i){let a={x:n,y:r};for(let n of e)n.constrainPosition&&(a=n.constrainPosition(t,a.x,a.y,i));if(t.constraints)for(let e of t.constraints)e.constrainPosition&&(a=e.constrainPosition(t,a.x,a.y,i));return a}function $t(e,t,n,r,i,a){let o={w:n,h:r};for(let n of e)n.constrainSize&&(o=n.constrainSize(t,o.w,o.h,i,a));if(t.constraints)for(let e of t.constraints)e.constrainSize&&(o=e.constrainSize(t,o.w,o.h,i,a));return o}function en({top:e,left:t,width:n,height:r}){let i=`translate(${t}px,${e}px)`;return{transform:i,WebkitTransform:i,MozTransform:i,msTransform:i,OTransform:i,width:`${n}px`,height:`${r}px`,position:`absolute`}}function tn({top:e,left:t,width:n,height:r}){return{top:`${e}px`,left:`${t}px`,width:`${n}px`,height:`${r}px`,position:`absolute`}}function nn(e){return e*100+`%`}function rn(e,t,n,r){return e+n>r?t:n}function an(e,t,n){return e<0?t:n}function on(e){return Math.max(0,e)}function sn(e){return Math.max(0,e)}var cn=(e,t,n)=>{let{left:r,height:i,width:a}=t,o=e.top-(i-e.height);return{left:r,width:a,height:an(o,e.height,i),top:sn(o)}},ln=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{top:r,height:a,width:rn(e.left,e.width,o,n),left:on(i)}},un=(e,t,n)=>{let{top:r,height:i,width:a}=t,o=e.left+e.width-a;return o<0?{height:i,width:e.left+e.width,top:sn(r),left:0}:{height:i,width:a,top:sn(r),left:o}},dn=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{width:o,left:i,height:an(r,e.height,a),top:sn(r)}},fn={n:cn,ne:(e,t,n)=>cn(e,ln(e,t,n)),e:ln,se:(e,t,n)=>dn(e,ln(e,t,n)),s:dn,sw:(e,t,n)=>dn(e,un(e,t)),w:un,nw:(e,t,n)=>cn(e,un(e,t))};function pn(e,t,n,r){let i=fn[e];return i?i(t,{...t,...n},r):n}var mn={type:`transform`,scale:1,calcStyle(e){return en(e)}},hn={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},gn={enabled:!0,bounded:!1,threshold:3},_n={enabled:!0,handles:[`se`]},vn={enabled:!1,defaultItem:{w:1,h:1}};function yn(e,t,n,r,i){let a=r===`x`?`w`:`h`;t[r]+=1;let o=e.findIndex(e=>e.i===t.i),s=i??Ht(e).length>0;for(let i=o+1;i<e.length;i++){let o=e[i];if(o!==void 0&&!o.static){if(!s&&o.y>t.y+t.h)break;Pt(t,o)&&yn(e,o,n+t[a],r,s)}}t[r]=n}function bn(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0),t.y=Math.min(r,t.y);t.y>0&&!Ft(e,t);)t.y--;let i;for(;(i=Ft(e,t))!==void 0;)yn(n,t,i.y+i.h,`y`);return t.y=Math.max(t.y,0),t}function xn(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0);t.x>0&&!Ft(e,t);)t.x--;let i;for(;(i=Ft(e,t))!==void 0;)if(yn(r,t,i.x+i.w,`x`),t.x+t.w>n)for(t.x=n-t.w,t.y++;t.x>0&&!Ft(e,t);)t.x--;return t.x=Math.max(t.x,0),t}var Sn={type:`vertical`,allowOverlap:!1,compact(e,t){let n=Ht(e),r=Bt(n),i=Rt(e),a=Array(e.length);for(let t=0;t<i.length;t++){let o=i[t];if(o===void 0)continue;let s=Ut(o);s.static||(s=bn(n,s,i,r),r=Math.max(r,s.y+s.h),n.push(s));let c=e.indexOf(o);a[c]=s,s.moved=!1}return a}},Cn={type:`horizontal`,allowOverlap:!1,compact(e,t){let n=Ht(e),r=zt(e),i=Array(e.length);for(let a=0;a<r.length;a++){let o=r[a];if(o===void 0)continue;let s=Ut(o);s.static||(s=xn(n,s,t,r),n.push(s));let c=e.indexOf(o);i[c]=s,s.moved=!1}return i}},wn={type:null,allowOverlap:!1,compact(e,t){return Wt(e)}},Tn={...Sn,allowOverlap:!0,compact(e,t){return Wt(e)}},En={...Cn,allowOverlap:!0,compact(e,t){return Wt(e)}},Dn={...wn,allowOverlap:!0};function On(e,t=!1,n=!1){let r;return r=t?e===`vertical`?Tn:e===`horizontal`?En:Dn:e===`vertical`?Sn:e===`horizontal`?Cn:wn,n?{...r,preventCollision:n}:r}function kn(e){return Object.keys(e).sort((t,n)=>e[t]-e[n])}function An(e,t){let n=kn(e),r=n[0];if(r===void 0)throw Error(`No breakpoints defined`);for(let i=1;i<n.length;i++){let a=n[i];a!==void 0&&t>e[a]&&(r=a)}return r}function jn(e,t){let n=t[e];if(n===void 0)throw Error(`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(e)} is missing!`);return n}function Mn(e,t,n,r,i,a){let o=e[n];if(o)return Wt(o);let s=e[r],c=kn(t),l=c.slice(c.indexOf(n));for(let t=0;t<l.length;t++){let n=l[t];if(n===void 0)continue;let r=e[n];if(r){s=r;break}}let u=qt(Wt(s||[]),{cols:i});return(typeof a==`object`&&a?a:On(a)).compact(u,i)}function Nn(e,t){if(Array.isArray(e))return e;let n=e,r=n[t];if(r!==void 0)return r;let i=Object.keys(n);for(let e of i){let t=n[e];if(t!==void 0)return t}return[10,10]}var Pn=n(((e,t)=>{(function(n,r){typeof e==`object`&&t!==void 0?r(e):typeof define==`function`&&define.amd?define([`exports`],r):(n=typeof globalThis<`u`?globalThis:n||self,r(n[`fast-equals`]={}))})(e,(function(e){function t(e){return function(t,n,r,i,a,o,s){return e(t,n,s)}}function n(e){return function(t,n,r,i){if(!t||!n||typeof t!=`object`||typeof n!=`object`)return e(t,n,r,i);var a=i.get(t),o=i.get(n);if(a&&o)return a===n&&o===t;i.set(t,n),i.set(n,t);var s=e(t,n,r,i);return i.delete(t),i.delete(n),s}}function r(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n}function i(e){return e.constructor===Object||e.constructor==null}function a(e){return typeof e.then==`function`}function o(e,t){return e===t||e!==e&&t!==t}var s=Object.prototype.toString;function c(e){var t=e.areArraysEqual,n=e.areDatesEqual,r=e.areMapsEqual,c=e.areObjectsEqual,l=e.areRegExpsEqual,u=e.areSetsEqual,d=e.createIsNestedEqual,f=d(p);function p(e,d,p){if(e===d)return!0;if(!e||!d||typeof e!=`object`||typeof d!=`object`)return e!==e&&d!==d;if(i(e)&&i(d))return c(e,d,f,p);var m=Array.isArray(e),h=Array.isArray(d);if(m||h)return m===h&&t(e,d,f,p);var g=s.call(e);return g===s.call(d)?g===`[object Date]`?n(e,d,f,p):g===`[object RegExp]`?l(e,d,f,p):g===`[object Map]`?r(e,d,f,p):g===`[object Set]`?u(e,d,f,p):g===`[object Object]`||g===`[object Arguments]`?a(e)||a(d)?!1:c(e,d,f,p):g===`[object Boolean]`||g===`[object Number]`||g===`[object String]`?o(e.valueOf(),d.valueOf()):!1:!1}return p}function l(e,t,n,r){var i=e.length;if(t.length!==i)return!1;for(;i-->0;)if(!n(e[i],t[i],i,i,e,t,r))return!1;return!0}var u=n(l);function d(e,t){return o(e.valueOf(),t.valueOf())}function f(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={},o=0;return e.forEach(function(s,c){if(i){var l=!1,u=0;t.forEach(function(i,d){!l&&!a[u]&&(l=n(c,d,o,u,e,t,r)&&n(s,i,c,d,e,t,r))&&(a[u]=!0),u++}),o++,i=l}}),i}var p=n(f),m=`_owner`,h=Object.prototype.hasOwnProperty;function g(e,t,n,r){var i=Object.keys(e),a=i.length;if(Object.keys(t).length!==a)return!1;for(var o;a-->0;){if(o=i[a],o===m){var s=!!e.$$typeof,c=!!t.$$typeof;if((s||c)&&s!==c)return!1}if(!h.call(t,o)||!n(e[o],t[o],o,o,e,t,r))return!1}return!0}var _=n(g);function v(e,t){return e.source===t.source&&e.flags===t.flags}function y(e,t,n,r){var i=e.size===t.size;if(!i)return!1;if(!e.size)return!0;var a={};return e.forEach(function(o,s){if(i){var c=!1,l=0;t.forEach(function(i,u){!c&&!a[l]&&(c=n(o,i,s,u,e,t,r))&&(a[l]=!0),l++}),i=c}}),i}var b=n(y),x=Object.freeze({areArraysEqual:l,areDatesEqual:d,areMapsEqual:f,areObjectsEqual:g,areRegExpsEqual:v,areSetsEqual:y,createIsNestedEqual:t}),S=Object.freeze({areArraysEqual:u,areDatesEqual:d,areMapsEqual:p,areObjectsEqual:_,areRegExpsEqual:v,areSetsEqual:b,createIsNestedEqual:t}),C=c(x);function w(e,t){return C(e,t,void 0)}var T=c(r(x,{createIsNestedEqual:function(){return o}}));function E(e,t){return T(e,t,void 0)}var ee=c(S);function D(e,t){return ee(e,t,new WeakMap)}var O=c(r(S,{createIsNestedEqual:function(){return o}}));function k(e,t){return O(e,t,new WeakMap)}function A(e){return c(r(x,e(x)))}function j(e){var t=c(r(S,e(S)));return(function(e,n,r){return r===void 0&&(r=new WeakMap),t(e,n,r)})}e.circularDeepEqual=D,e.circularShallowEqual=k,e.createCustomCircularEqual=j,e.createCustomEqual=A,e.deepEqual=w,e.sameValueZeroEqual=o,e.shallowEqual=E,Object.defineProperty(e,"__esModule",{value:!0})}))}));function Fn(e={}){let{measureBeforeMount:t=!1,initialWidth:n=1280}=e,[r,i]=(0,Z.useState)(n),[a,o]=(0,Z.useState)(!t),s=(0,Z.useRef)(null),c=(0,Z.useRef)(null),l=(0,Z.useCallback)(()=>{let e=s.current;if(e){let t=e.offsetWidth;i(t),a||o(!0)}},[a]);return(0,Z.useEffect)(()=>{let e=s.current;if(e){if(l(),typeof ResizeObserver<`u`){let t=null;return c.current=new ResizeObserver(e=>{let n=e[0];if(n){let e=n.contentRect.width;t!==null&&cancelAnimationFrame(t),t=requestAnimationFrame(()=>{i(e),t=null})}}),c.current.observe(e),()=>{t!==null&&cancelAnimationFrame(t),c.current&&=(c.current.disconnect(),null)}}return()=>{c.current&&=(c.current.disconnect(),null)}}},[l]),{width:r,mounted:a,containerRef:s,measureWidth:l}}var In=n(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Ln=n(((e,t)=>{var n=In();function r(){}function i(){}i.resetWarningCache=r,t.exports=function(){function e(e,t,r,i,a,o){if(o!==n){var s=Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw s.name=`Invariant Violation`,s}}e.isRequired=e;function t(){return e}var a={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:i,resetWarningCache:r};return a.PropTypes=a,a}})),Rn=n(((e,t)=>{t.exports=Ln()()})),$=e(Rn(),1);function zn(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function Bn(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function Vn(e){return typeof e==`number`&&!isNaN(e)}function Hn(e){return parseInt(e,10)}function Un(e,t,n){if(e[t])return Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}var Wn=[`Moz`,`Webkit`,`O`,`ms`];function Gn(e=`transform`){if(typeof window>`u`)return``;let t=window.document?.documentElement?.style;if(!t||e in t)return``;for(let n=0;n<Wn.length;n++)if(Kn(e,Wn[n])in t)return Wn[n];return``}function Kn(e,t){return t?`${t}${qn(e)}`:e}function qn(e){let t=``,n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]===`-`?n=!0:t+=e[r];return t}var Jn=Gn(),Yn=``;function Xn(e,t){Yn||=zn([`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`],function(t){return Bn(e[t])})??``;let n=e[Yn];return Bn(n)?!!n.call(e,t):!1}function Zn(e,t,n){let r=e;do{if(Xn(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function Qn(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.addEventListener?e.addEventListener(t,a,i):e.attachEvent?e.attachEvent(`on`+t,a):e[`on`+t]=a}function $n(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.removeEventListener?e.removeEventListener(t,a,i):e.detachEvent?e.detachEvent(`on`+t,a):e[`on`+t]=null}function er(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=Hn(n.borderTopWidth),t+=Hn(n.borderBottomWidth),t}function tr(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=Hn(n.borderLeftWidth),t+=Hn(n.borderRightWidth),t}function nr(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=Hn(n.paddingTop),t-=Hn(n.paddingBottom),t}function rr(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=Hn(n.paddingLeft),t-=Hn(n.paddingRight),t}function ir(e,t,n){let r=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-r.left)/n,y:(e.clientY+t.scrollTop-r.top)/n}}function ar(e,t){let n=sr(e,t,`px`);return{[Kn(`transform`,Jn)]:n}}function or(e,t){return sr(e,t,``)}function sr({x:e,y:t},n,r){let i=`translate(${e}${r},${t}${r})`;return n&&(i=`translate(${`${typeof n.x==`string`?n.x:n.x+r}`}, ${`${typeof n.y==`string`?n.y:n.y+r}`})`+i),i}function cr(e,t){return e.targetTouches&&zn(e.targetTouches,e=>t===e.identifier)||e.changedTouches&&zn(e.changedTouches,e=>t===e.identifier)}function lr(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function ur(){return typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0}function dr(e,t){if(!e)return;let n=e.getElementById(`react-draggable-style-el`);if(!n){n=e.createElement(`style`),n.type=`text/css`,n.id=`react-draggable-style-el`;let r=t??ur();r&&n.setAttribute(`nonce`,r),n.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
3
3
  `,n.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
4
4
  `,e.getElementsByTagName(`head`)[0].appendChild(n)}e.body&&mr(e.body,`react-draggable-transparent-selection`)}function fr(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{pr(e)}):pr(e)}function pr(e){if(e)try{e.body&&hr(e.body,`react-draggable-transparent-selection`);let t=e.selection;if(t)t.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function mr(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function hr(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}function gr(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r==`string`?r:Cr(r);let i=wr(e);if(typeof r==`string`){let{ownerDocument:e}=i,t=e.defaultView;if(!t)throw Error(`Cannot resolve the owner window of the draggable node.`);let n;if(n=r===`parent`?i.parentNode:i.getRootNode().querySelector(r),!(n instanceof t.HTMLElement))throw Error(`Bounds selector "`+r+`" could not find an element.`);let a=n,o=t.getComputedStyle(i),s=t.getComputedStyle(a);r={left:-i.offsetLeft+Hn(s.paddingLeft)+Hn(o.marginLeft),top:-i.offsetTop+Hn(s.paddingTop)+Hn(o.marginTop),right:rr(a)-tr(i)-i.offsetLeft+Hn(s.paddingRight)-Hn(o.marginRight),bottom:nr(a)-er(i)-i.offsetTop+Hn(s.paddingBottom)-Hn(o.marginBottom)}}return Vn(r.right)&&(t=Math.min(t,r.right)),Vn(r.bottom)&&(n=Math.min(n,r.bottom)),Vn(r.left)&&(t=Math.max(t,r.left)),Vn(r.top)&&(n=Math.max(n,r.top)),[t,n]}function _r(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function vr(e){return e.props.axis===`both`||e.props.axis===`x`}function yr(e){return e.props.axis===`both`||e.props.axis===`y`}function br(e,t,n){let r=typeof t==`number`?cr(e,t):null;if(typeof t==`number`&&!r)return null;let i=wr(n),a=n.props.offsetParent||i.offsetParent||i.ownerDocument.body;return ir(r||e,a,n.props.scale)}function xr(e,t,n){let r=!Vn(e.lastX),i=wr(e);return r?{node:i,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:i,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function Sr(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function Cr(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function wr(e){let t=e.findDOMNode();if(!t)throw Error(`<DraggableCore>: Unmounted during event!`);return t}function Tr(...e){({}).DRAGGABLE_DEBUG&&console.log(...e)}var Er={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},Dr=Er.mouse,Or=class extends Z.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button==`number`&&e.button!==0||e.ctrlKey))return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(`<DraggableCore> not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!Zn(e.target,this.props.handle,t)||this.props.cancel&&Zn(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=lr(e);this.touchIdentifier=r;let i=br(e,r,this);if(i==null)return;let{x:a,y:o}=i,s=xr(this,a,o);Tr(`DraggableCore: handleDragStart: %j`,s),Tr(`calling`,this.props.onStart),!(this.props.onStart(e,s)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&dr(n,this.props.nonce),this.dragging=!0,this.lastX=a,this.lastY=o,Qn(n,Dr.move,this.handleDrag),Qn(n,Dr.stop,this.handleDragStop))},this.handleDrag=e=>{let t=br(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=_r(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=xr(this,n,r);if(Tr(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}return}this.lastX=n,this.lastY=r},this.handleDragStop=e=>{if(!this.dragging)return;let t=br(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=_r(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=xr(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&fr(a.ownerDocument),Tr(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&(Tr(`DraggableCore: Removing handlers`),$n(a.ownerDocument,Dr.move,this.handleDrag),$n(a.ownerDocument,Dr.stop,this.handleDragStop))},this.onMouseDown=e=>(Dr=Er.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(Dr=Er.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(Dr=Er.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(Dr=Er.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&Qn(e,Er.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;$n(t,Er.mouse.move,this.handleDrag),$n(t,Er.touch.move,this.handleDrag),$n(t,Er.mouse.stop,this.handleDragStop),$n(t,Er.touch.stop,this.handleDragStop),$n(e,Er.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&fr(t)}}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=Ue.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):(Tr(`react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef`),null)}render(){return Z.cloneElement(Z.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};Or.displayName=`DraggableCore`,Or.propTypes={allowAnyClick:$.default.bool,allowMobileScroll:$.default.bool,children:$.default.node.isRequired,disabled:$.default.bool,enableUserSelectHack:$.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:$.default.arrayOf($.default.number),handle:$.default.string,cancel:$.default.string,nodeRef:$.default.object,nonce:$.default.string,onStart:$.default.func,onDrag:$.default.func,onStop:$.default.func,onMouseDown:$.default.func,scale:$.default.number,className:Un,style:Un,transform:Un},Or.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var kr=class extends Z.Component{constructor(e){super(e),this.onDragStart=(e,t)=>{if(Tr(`Draggable: onDragStart: %j`,t),this.props.onStart(e,Sr(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(e,t)=>{if(!this.state.dragging)return!1;Tr(`Draggable: onDrag: %j`,t);let n=Sr(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=gr(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)},this.onDragStop=(e,t)=>{if(!this.state.dragging||this.props.onStop(e,Sr(this,t))===!1)return!1;Tr(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:t}){return e&&(!t||e.x!==t.x||e.y!==t.y)?(Tr(`Draggable: getDerivedStateFromProps %j`,{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=Ue.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):null}render(){let{axis:e,bounds:t,children:n,defaultPosition:r,defaultClassName:i,defaultClassNameDragging:a,defaultClassNameDragged:o,position:s,positionOffset:c,scale:l,...u}=this.props,d={},f=null,p=!s||this.state.dragging,m=s||r,h={x:vr(this)&&p?this.state.x:m.x,y:yr(this)&&p?this.state.y:m.y};this.state.isElementSVG?f=or(h,c):d=ar(h,c);let g=Z.Children.only(n),_=Ae(g.props.className||``,i,{[a]:this.state.dragging,[o]:this.state.dragged});return Z.createElement(Or,{...u,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},Z.cloneElement(g,{className:_,style:{...g.props.style,...d},transform:f}))}};kr.displayName=`Draggable`,kr.propTypes={...Or.propTypes,axis:$.default.oneOf([`both`,`x`,`y`,`none`]),bounds:$.default.oneOfType([$.default.shape({left:$.default.number,right:$.default.number,top:$.default.number,bottom:$.default.number}),$.default.string,$.default.oneOf([!1])]),defaultClassName:$.default.string,defaultClassNameDragging:$.default.string,defaultClassNameDragged:$.default.string,defaultPosition:$.default.shape({x:$.default.number,y:$.default.number}),positionOffset:$.default.shape({x:$.default.oneOfType([$.default.number,$.default.string]),y:$.default.oneOfType([$.default.number,$.default.string])}),position:$.default.shape({x:$.default.number,y:$.default.number}),className:Un,style:Un,transform:Un},kr.defaultProps={...Or.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1};var Ar=n(((e,t)=>{var n=Object.create,a=Object.defineProperty,o=Object.getOwnPropertyDescriptor,s=Object.getOwnPropertyNames,c=Object.getPrototypeOf,l=Object.prototype.hasOwnProperty,u=(e,t)=>{for(var n in t)a(e,n,{get:t[n],enumerable:!0})},d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let i of s(t))!l.call(e,i)&&i!==n&&a(e,i,{get:()=>t[i],enumerable:!(r=o(t,i))||r.enumerable});return e},f=(e,t,r)=>(r=e==null?{}:n(c(e)),d(t||!e||!e.__esModule?a(r,`default`,{value:e,enumerable:!0}):r,e)),p=e=>d(a({},`__esModule`,{value:!0}),e),m={};u(m,{DraggableCore:()=>me,default:()=>he}),t.exports=p(m);var h=f(r()),g=f(Rn()),_=f(i()),v=je();function y(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function b(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function x(e){return typeof e==`number`&&!isNaN(e)}function S(e){return parseInt(e,10)}function C(e,t,n){if(e[t])return Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}var w=[`Moz`,`Webkit`,`O`,`ms`];function T(e=`transform`){if(typeof window>`u`)return``;let t=window.document?.documentElement?.style;if(!t||e in t)return``;for(let n=0;n<w.length;n++)if(E(e,w[n])in t)return w[n];return``}function E(e,t){return t?`${t}${ee(e)}`:e}function ee(e){let t=``,n=!0;for(let r=0;r<e.length;r++)n?(t+=e[r].toUpperCase(),n=!1):e[r]===`-`?n=!0:t+=e[r];return t}var D=T(),O=``;function k(e,t){O||=y([`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`],function(t){return b(e[t])})??``;let n=e[O];return b(n)?!!n.call(e,t):!1}function A(e,t,n){let r=e;do{if(k(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function j(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.addEventListener?e.addEventListener(t,a,i):e.attachEvent?e.attachEvent(`on`+t,a):e[`on`+t]=a}function M(e,t,n,r){if(!e)return;let i={capture:!0,...r},a=n;e.removeEventListener?e.removeEventListener(t,a,i):e.detachEvent?e.detachEvent(`on`+t,a):e[`on`+t]=null}function te(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=S(n.borderTopWidth),t+=S(n.borderBottomWidth),t}function N(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t+=S(n.borderLeftWidth),t+=S(n.borderRightWidth),t}function P(e){let t=e.clientHeight,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=S(n.paddingTop),t-=S(n.paddingBottom),t}function F(e){let t=e.clientWidth,n=e.ownerDocument.defaultView.getComputedStyle(e);return t-=S(n.paddingLeft),t-=S(n.paddingRight),t}function I(e,t,n){let r=t===t.ownerDocument.body?{left:0,top:0}:t.getBoundingClientRect();return{x:(e.clientX+t.scrollLeft-r.left)/n,y:(e.clientY+t.scrollTop-r.top)/n}}function ne(e,t){let n=ie(e,t,`px`);return{[E(`transform`,D)]:n}}function re(e,t){return ie(e,t,``)}function ie({x:e,y:t},n,r){let i=`translate(${e}${r},${t}${r})`;return n&&(i=`translate(${`${typeof n.x==`string`?n.x:n.x+r}`}, ${`${typeof n.y==`string`?n.y:n.y+r}`})`+i),i}function L(e,t){return e.targetTouches&&y(e.targetTouches,e=>t===e.identifier)||e.changedTouches&&y(e.changedTouches,e=>t===e.identifier)}function ae(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function R(){return typeof __webpack_nonce__<`u`?__webpack_nonce__:void 0}function z(e,t){if(!e)return;let n=e.getElementById(`react-draggable-style-el`);if(!n){n=e.createElement(`style`),n.type=`text/css`,n.id=`react-draggable-style-el`;let r=t??R();r&&n.setAttribute(`nonce`,r),n.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
5
5
  `,n.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
6
- `,e.getElementsByTagName(`head`)[0].appendChild(n)}e.body&&oe(e.body,`react-draggable-transparent-selection`)}function B(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{V(e)}):V(e)}function V(e){if(e)try{e.body&&se(e.body,`react-draggable-transparent-selection`);let t=e.selection;if(t)t.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function oe(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function se(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}function ce(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r==`string`?r:K(r);let i=q(e);if(typeof r==`string`){let{ownerDocument:e}=i,t=e.defaultView;if(!t)throw Error(`Cannot resolve the owner window of the draggable node.`);let n;if(n=r===`parent`?i.parentNode:i.getRootNode().querySelector(r),!(n instanceof t.HTMLElement))throw Error(`Bounds selector "`+r+`" could not find an element.`);let a=n,o=t.getComputedStyle(i),s=t.getComputedStyle(a);r={left:-i.offsetLeft+S(s.paddingLeft)+S(o.marginLeft),top:-i.offsetTop+S(s.paddingTop)+S(o.marginTop),right:F(a)-N(i)-i.offsetLeft+S(s.paddingRight)-S(o.marginRight),bottom:P(a)-te(i)-i.offsetTop+S(s.paddingBottom)-S(o.marginBottom)}}return x(r.right)&&(t=Math.min(t,r.right)),x(r.bottom)&&(n=Math.min(n,r.bottom)),x(r.left)&&(t=Math.max(t,r.left)),x(r.top)&&(n=Math.max(n,r.top)),[t,n]}function H(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function U(e){return e.props.axis===`both`||e.props.axis===`x`}function le(e){return e.props.axis===`both`||e.props.axis===`y`}function ue(e,t,n){let r=typeof t==`number`?L(e,t):null;if(typeof t==`number`&&!r)return null;let i=q(n),a=n.props.offsetParent||i.offsetParent||i.ownerDocument.body;return I(r||e,a,n.props.scale)}function W(e,t,n){let r=!x(e.lastX),i=q(e);return r?{node:i,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:i,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function G(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function K(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function q(e){let t=e.findDOMNode();if(!t)throw Error(`<DraggableCore>: Unmounted during event!`);return t}var de=f(r()),J=f(Rn()),fe=f(i());function pe(...e){({}).DRAGGABLE_DEBUG&&console.log(...e)}var Y={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},X=Y.mouse,me=class extends de.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button==`number`&&e.button!==0||e.ctrlKey))return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(`<DraggableCore> not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!A(e.target,this.props.handle,t)||this.props.cancel&&A(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=ae(e);this.touchIdentifier=r;let i=ue(e,r,this);if(i==null)return;let{x:a,y:o}=i,s=W(this,a,o);pe(`DraggableCore: handleDragStart: %j`,s),pe(`calling`,this.props.onStart),!(this.props.onStart(e,s)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&z(n,this.props.nonce),this.dragging=!0,this.lastX=a,this.lastY=o,j(n,X.move,this.handleDrag),j(n,X.stop,this.handleDragStop))},this.handleDrag=e=>{let t=ue(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=H(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=W(this,n,r);if(pe(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}return}this.lastX=n,this.lastY=r},this.handleDragStop=e=>{if(!this.dragging)return;let t=ue(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=H(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=W(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&B(a.ownerDocument),pe(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&(pe(`DraggableCore: Removing handlers`),M(a.ownerDocument,X.move,this.handleDrag),M(a.ownerDocument,X.stop,this.handleDragStop))},this.onMouseDown=e=>(X=Y.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(X=Y.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(X=Y.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(X=Y.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&j(e,Y.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;M(t,Y.mouse.move,this.handleDrag),M(t,Y.touch.move,this.handleDrag),M(t,Y.mouse.stop,this.handleDragStop),M(t,Y.touch.stop,this.handleDragStop),M(e,Y.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&B(t)}}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=fe.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):(pe(`react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef`),null)}render(){return de.cloneElement(de.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};me.displayName=`DraggableCore`,me.propTypes={allowAnyClick:J.default.bool,allowMobileScroll:J.default.bool,children:J.default.node.isRequired,disabled:J.default.bool,enableUserSelectHack:J.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:J.default.arrayOf(J.default.number),handle:J.default.string,cancel:J.default.string,nodeRef:J.default.object,nonce:J.default.string,onStart:J.default.func,onDrag:J.default.func,onStop:J.default.func,onMouseDown:J.default.func,scale:J.default.number,className:C,style:C,transform:C},me.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var he=class extends h.Component{constructor(e){super(e),this.onDragStart=(e,t)=>{if(pe(`Draggable: onDragStart: %j`,t),this.props.onStart(e,G(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(e,t)=>{if(!this.state.dragging)return!1;pe(`Draggable: onDrag: %j`,t);let n=G(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=ce(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)},this.onDragStop=(e,t)=>{if(!this.state.dragging||this.props.onStop(e,G(this,t))===!1)return!1;pe(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:t}){return e&&(!t||e.x!==t.x||e.y!==t.y)?(pe(`Draggable: getDerivedStateFromProps %j`,{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=_.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):null}render(){let{axis:e,bounds:t,children:n,defaultPosition:r,defaultClassName:i,defaultClassNameDragging:a,defaultClassNameDragged:o,position:s,positionOffset:c,scale:l,...u}=this.props,d={},f=null,p=!s||this.state.dragging,m=s||r,g={x:U(this)&&p?this.state.x:m.x,y:le(this)&&p?this.state.y:m.y};this.state.isElementSVG?f=re(g,c):d=ne(g,c);let _=h.Children.only(n),y=(0,v.clsx)(_.props.className||``,i,{[a]:this.state.dragging,[o]:this.state.dragged});return h.createElement(me,{...u,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},h.cloneElement(_,{className:y,style:{..._.props.style,...d},transform:f}))}};he.displayName=`Draggable`,he.propTypes={...me.propTypes,axis:g.default.oneOf([`both`,`x`,`y`,`none`]),bounds:g.default.oneOfType([g.default.shape({left:g.default.number,right:g.default.number,top:g.default.number,bottom:g.default.number}),g.default.string,g.default.oneOf([!1])]),defaultClassName:g.default.string,defaultClassNameDragging:g.default.string,defaultClassNameDragged:g.default.string,defaultPosition:g.default.shape({x:g.default.number,y:g.default.number}),positionOffset:g.default.shape({x:g.default.oneOfType([g.default.number,g.default.string]),y:g.default.oneOfType([g.default.number,g.default.string])}),position:g.default.shape({x:g.default.number,y:g.default.number}),className:C,style:C,transform:C},he.defaultProps={...me.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1},0&&(t.exports={DraggableCore:me})})),jr=n(((e,t)=>{var n=Ar(),r=n.DraggableCore,i=n.default||n;t.exports=i,t.exports.default=i,t.exports.DraggableCore=r})),Mr=n((e=>{e.__esModule=!0,e.cloneElement=l;var t=n(r());function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i(Object(n),!0).forEach(function(t){o(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function o(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e){var t=c(e,`string`);return typeof t==`symbol`?t:t+``}function c(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function l(e,n){return n.style&&e.props.style&&(n.style=a(a({},e.props.style),n.style)),n.className&&e.props.className&&(n.className=e.props.className+` `+n.className),t.default.cloneElement(e,n)}})),Nr=n((e=>{e.__esModule=!0,e.resizableProps=void 0;var t=n(Rn());jr();function n(e){return e&&e.__esModule?e:{default:e}}e.resizableProps={axis:t.default.oneOf([`both`,`x`,`y`,`none`]),className:t.default.string,children:t.default.element.isRequired,draggableOpts:t.default.shape({allowAnyClick:t.default.bool,cancel:t.default.string,children:t.default.node,disabled:t.default.bool,enableUserSelectHack:t.default.bool,offsetParent:typeof Element<`u`?t.default.instanceOf(Element):t.default.any,grid:t.default.arrayOf(t.default.number),handle:t.default.string,nodeRef:t.default.object,onStart:t.default.func,onDrag:t.default.func,onStop:t.default.func,onMouseDown:t.default.func,scale:t.default.number}),height:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`y`?t.default.number.isRequired(...e):t.default.number(...e)},handle:t.default.oneOfType([t.default.node,t.default.func]),handleSize:t.default.arrayOf(t.default.number),lockAspectRatio:t.default.bool,maxConstraints:t.default.arrayOf(t.default.number),minConstraints:t.default.arrayOf(t.default.number),onResizeStop:t.default.func,onResizeStart:t.default.func,onResize:t.default.func,resizeHandles:t.default.arrayOf(t.default.oneOf([`s`,`w`,`e`,`n`,`sw`,`nw`,`se`,`ne`])),transformScale:t.default.number,width:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`x`?t.default.number.isRequired(...e):t.default.number(...e)}}})),Pr=n((e=>{e.__esModule=!0,e.default=void 0;var t=s(r()),n=jr(),i=Mr(),a=Nr(),o=[`children`,`className`,`draggableOpts`,`width`,`height`,`handle`,`handleSize`,`lockAspectRatio`,`axis`,`minConstraints`,`maxConstraints`,`onResize`,`onResizeStop`,`onResizeStart`,`resizeHandles`,`transformScale`];function s(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(s=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(null,arguments)}function l(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?u(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=m(e,`string`);return typeof t==`symbol`?t:t+``}function m(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var h=class extends t.Component{constructor(){super(...arguments),this.handleRefs={},this.lastHandleRect=null,this.slack=null,this.lastSize=null}componentWillUnmount(){this.resetData()}resetData(){this.lastHandleRect=this.slack=this.lastSize=null}runConstraints(e,t){let n=this.props,r=n.minConstraints,i=n.maxConstraints,a=n.lockAspectRatio;if(!r&&!i&&!a)return[e,t];if(a){let n=this.props.width/this.props.height,r=e-this.props.width,i=t-this.props.height;Math.abs(r)>Math.abs(i*n)?t=e/n:e=t*n}let o=e,s=t,c=this.slack||[0,0],l=c[0],u=c[1];return e+=l,t+=u,r&&(e=Math.max(r[0],e),t=Math.max(r[1],t)),i&&(e=Math.min(i[0],e),t=Math.min(i[1],t)),this.slack=[l+(o-e),u+(s-t)],[e,t]}resizeHandler(e,t){return(n,r)=>{let i=r.node,a=r.deltaX,o=r.deltaY;e===`onResizeStart`&&this.resetData();let s=(this.props.axis===`both`||this.props.axis===`x`)&&t!==`n`&&t!==`s`,c=(this.props.axis===`both`||this.props.axis===`y`)&&t!==`e`&&t!==`w`;if(!s&&!c)return;let l=t[0],u=t[t.length-1],d=i.getBoundingClientRect();if(this.lastHandleRect!=null){if(u===`w`){let e=d.left-this.lastHandleRect.left;a+=e}if(l===`n`){let e=d.top-this.lastHandleRect.top;o+=e}}this.lastHandleRect=d,u===`w`&&(a=-a),l===`n`&&(o=-o);let f=this.lastSize?.width??this.props.width,p=this.lastSize?.height??this.props.height,m=f+(s?a/this.props.transformScale:0),h=p+(c?o/this.props.transformScale:0);var g=this.runConstraints(m,h);if(m=g[0],h=g[1],e===`onResizeStop`&&this.lastSize){var _=this.lastSize;m=_.width,h=_.height}let v=m!==f||h!==p;e!==`onResizeStop`&&(this.lastSize={width:m,height:h});let y=typeof this.props[e]==`function`?this.props[e]:null;y&&!(e===`onResize`&&!v)&&(n.persist==null||n.persist(),y(n,{node:i,size:{width:m,height:h},handle:t})),e===`onResizeStop`&&this.resetData()}}renderResizeHandle(e,n){let r=this.props.handle;if(!r)return t.createElement(`span`,{className:`react-resizable-handle react-resizable-handle-`+e,ref:n});if(typeof r==`function`)return r(e,n);let i=typeof r.type==`string`,a=d({ref:n},i?{}:{handleAxis:e});return t.cloneElement(r,a)}render(){let e=this.props,r=e.children,a=e.className,s=e.draggableOpts;e.width,e.height,e.handle,e.handleSize,e.lockAspectRatio,e.axis,e.minConstraints,e.maxConstraints,e.onResize,e.onResizeStop,e.onResizeStart;let u=e.resizeHandles;e.transformScale;let f=l(e,o);return(0,i.cloneElement)(r,d(d({},f),{},{className:(a?a+` `:``)+`react-resizable`,children:[...t.Children.toArray(r.props.children),...u.map(e=>{let r=this.handleRefs[e]??(this.handleRefs[e]=t.createRef());return t.createElement(n.DraggableCore,c({},s,{nodeRef:r,key:`resizableHandle-`+e,onStop:this.resizeHandler(`onResizeStop`,e),onStart:this.resizeHandler(`onResizeStart`,e),onDrag:this.resizeHandler(`onResize`,e)}),this.renderResizeHandle(e,r))})]}))}};e.default=h,h.propTypes=a.resizableProps,h.defaultProps={axis:`both`,handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:[`se`],transformScale:1}})),Fr=n((e=>{e.__esModule=!0,e.default=void 0;var t=c(r()),n=s(Rn()),i=s(Pr()),a=Nr(),o=[`handle`,`handleSize`,`onResize`,`onResizeStart`,`onResizeStop`,`draggableOpts`,`minConstraints`,`maxConstraints`,`lockAspectRatio`,`axis`,`width`,`height`,`resizeHandles`,`style`,`transformScale`];function s(e){return e&&e.__esModule?e:{default:e}}function c(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(c=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l.apply(null,arguments)}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?u(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=m(e,`string`);return typeof t==`symbol`?t:t+``}function m(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var g=class extends t.Component{constructor(){super(...arguments),this.state={width:this.props.width,height:this.props.height,propsWidth:this.props.width,propsHeight:this.props.height},this.onResize=(e,t)=>{let n=t.size;this.props.onResize?(e.persist==null||e.persist(),this.setState(n,()=>this.props.onResize&&this.props.onResize(e,t))):this.setState(n)}}static getDerivedStateFromProps(e,t){return t.propsWidth!==e.width||t.propsHeight!==e.height?{width:e.width,height:e.height,propsWidth:e.width,propsHeight:e.height}:null}render(){let e=this.props,n=e.handle,r=e.handleSize;e.onResize;let a=e.onResizeStart,s=e.onResizeStop,c=e.draggableOpts,u=e.minConstraints,f=e.maxConstraints,p=e.lockAspectRatio,m=e.axis;e.width,e.height;let g=e.resizeHandles,_=e.style,v=e.transformScale,y=h(e,o);return t.createElement(i.default,{axis:m,draggableOpts:c,handle:n,handleSize:r,height:this.state.height,lockAspectRatio:p,maxConstraints:f,minConstraints:u,onResizeStart:a,onResize:this.onResize,onResizeStop:s,resizeHandles:g,transformScale:v,width:this.state.width},t.createElement(`div`,l({},y,{style:d(d({},_),{},{width:this.state.width+`px`,height:this.state.height+`px`})})))}};e.default=g,g.propTypes=d(d({},a.resizableProps),{},{children:n.default.element})})),Ir=n(((e,t)=>{t.exports=function(){throw Error(`Don't instantiate Resizable directly! Use require('react-resizable').Resizable`)},t.exports.Resizable=Pr().default,t.exports.ResizableBox=Fr().default}))(),Lr=Pn();function Rr(e){let{children:t,cols:n,containerWidth:r,margin:i,containerPadding:a,rowHeight:o,maxRows:s,isDraggable:c,isResizable:l,isBounded:u,static:d,useCSSTransforms:f=!0,usePercentages:p=!1,transformScale:m=1,positionStrategy:h,dragThreshold:g=0,droppingPosition:_,className:v=``,style:y,handle:b=``,cancel:x=``,x:S,y:C,w,h:T,minW:E=1,maxW:ee=1/0,minH:D=1,maxH:O=1/0,i:k,resizeHandles:A,resizeHandle:j,constraints:M=Zt,layoutItem:te,layout:N=[],onDragStart:P,onDrag:F,onDragStop:I,onResizeStart:ne,onResize:re,onResizeStop:ie}=e,[L,ae]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(!1),B=(0,Z.useRef)(null),V=(0,Z.useRef)({left:0,top:0}),oe=(0,Z.useRef)({top:0,left:0,width:0,height:0}),se=(0,Z.useRef)(void 0),ce=(0,Z.useRef)(N);ce.current=N;let H=(0,Z.useRef)(null),U=(0,Z.useRef)(null),le=(0,Z.useRef)(!1),ue=(0,Z.useRef)({x:0,y:0}),W=(0,Z.useRef)(!1),G=(0,Z.useMemo)(()=>({cols:n,containerPadding:a,containerWidth:r,margin:i,maxRows:s,rowHeight:o}),[n,a,r,i,s,o]),K=(0,Z.useMemo)(()=>({cols:n,maxRows:s,containerWidth:r,containerHeight:0,rowHeight:o,margin:i,layout:[]}),[n,s,r,o,i]),q=(0,Z.useCallback)(()=>({...K,layout:ce.current}),[K]),de=(0,Z.useMemo)(()=>te??{i:k,x:S,y:C,w,h:T,minW:E,maxW:ee,minH:D,maxH:O},[te,k,S,C,w,T,E,ee,D,O]),J=(0,Z.useCallback)(e=>{if(h?.calcStyle)return h.calcStyle(e);if(f)return en(e);let t=tn(e);return p?{...t,left:nn(e.left/r),width:nn(e.width/r)}:t},[h,f,p,r]),fe=(0,Z.useCallback)((e,{node:t})=>{if(!P)return;let{offsetParent:n}=t;if(!n)return;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),a=i.left/m,o=r.left/m,s=i.top/m,c=r.top/m,l;if(h?.calcDragPosition){let t=e;l=h.calcDragPosition(t.clientX,t.clientY,t.clientX-i.left,t.clientY-i.top)}else l={left:a-o+n.scrollLeft,top:s-c+n.scrollTop};if(V.current=l,g>0){let t=e;ue.current={x:t.clientX,y:t.clientY},le.current=!0,W.current=!1,ae(!0);return}ae(!0);let u=jt(G,l.top,l.left),{x:d,y:f}=Qt(M,de,u.x,u.y,q());P(k,d,f,{e,node:t,newPosition:l})},[P,m,G,h,g,M,de,q,k]),pe=(0,Z.useCallback)((e,{node:t,deltaX:n,deltaY:a})=>{if(!F||!L)return;let s=e;if(le.current&&!W.current){let n=s.clientX-ue.current.x,r=s.clientY-ue.current.y;if(Math.hypot(n,r)<g)return;if(W.current=!0,le.current=!1,P){let n=jt(G,V.current.top,V.current.left),{x:r,y:i}=Qt(M,de,n.x,n.y,q());P(k,r,i,{e,node:t,newPosition:V.current})}}let c=V.current.top+a,l=V.current.left+n;if(u){let{offsetParent:e}=t;if(e){let t=e.clientHeight-Ot(T,o,i[1]);c=Nt(c,0,t);let n=r-Ot(w,Dt(G),i[0]);l=Nt(l,0,n)}}let d={top:c,left:l};V.current=d;let f=jt(G,c,l),{x:p,y:m}=Qt(M,de,f.x,f.y,q());F(k,p,m,{e,node:t,newPosition:d})},[F,P,L,g,u,T,o,i,G,r,w,k,M,de,q]),Y=(0,Z.useCallback)((e,{node:t})=>{if(!I||!L)return;let n=le.current;if(le.current=!1,W.current=!1,ue.current={x:0,y:0},n){ae(!1),V.current={left:0,top:0};return}let{left:r,top:i}=V.current,a={top:i,left:r};ae(!1),V.current={left:0,top:0};let o=jt(G,i,r),{x:s,y:c}=Qt(M,de,o.x,o.y,q());I(k,s,c,{e,node:t,newPosition:a})},[I,L,G,M,de,q,k]);H.current=fe,U.current=pe;let X=(0,Z.useCallback)((e,{node:t,size:n,handle:i},a,o)=>{let s=o===`onResizeStart`?ne:o===`onResize`?re:ie;if(!s)return;let c;c=t?pn(i,a,n,r):{...n,top:a.top,left:a.left},oe.current=c;let l=Mt(G,c.width,c.height),{w:u,h:d}=$t(M,de,l.w,l.h,i,q());s(k,u,d,{e:e.nativeEvent,node:t,size:c,handle:i})},[ne,re,ie,r,G,k,M,de,q]),me=(0,Z.useCallback)((e,t)=>{z(!0);let n=kt(G,S,C,w,T);X(e,{...t,handle:t.handle},n,`onResizeStart`)},[X,G,S,C,w,T]),he=(0,Z.useCallback)((e,t)=>{let n=kt(G,S,C,w,T);X(e,{...t,handle:t.handle},n,`onResize`)},[X,G,S,C,w,T]),ge=(0,Z.useCallback)((e,t)=>{z(!1),oe.current={top:0,left:0,width:0,height:0};let n=kt(G,S,C,w,T);X(e,{...t,handle:t.handle},n,`onResizeStop`)},[X,G,S,C,w,T]);(0,Z.useEffect)(()=>{if(!_)return;let e=B.current;if(!e)return;let t=se.current||{left:0,top:0},n=L&&(_.left!==t.left||_.top!==t.top);if(!L){let t={node:e,deltaX:_.left,deltaY:_.top,lastX:0,lastY:0,x:_.left,y:_.top};H.current?.(_.e,t)}else if(n){let t={node:e,deltaX:_.left-V.current.left,deltaY:_.top-V.current.top,lastX:V.current.left,lastY:V.current.top,x:_.left,y:_.top};U.current?.(_.e,t)}se.current=_},[_,L,k]);let _e=kt(G,S,C,w,T,L?V.current:null,R?oe.current:null),ve=Z.Children.only(t),ye=Dt(G),be=[Ot(E,ye,i[0]),Ot(D,o,i[1])],xe=[Ot(ee,ye,i[0]),Ot(O,o,i[1])],Se=ve.props,Ce=Se.className,we=Se.style,Te=Z.cloneElement(ve,{ref:B,className:Ae(`react-grid-item`,Ce,v,{static:d,resizing:R,"react-draggable":c,"react-draggable-dragging":L,dropping:!!_,cssTransforms:f}),style:{...y,...we,...J(_e)}}),Ee=j;return Te=(0,Q.jsx)(Ir.Resizable,{draggableOpts:{disabled:!l},className:l?void 0:`react-resizable-hide`,width:_e.width,height:_e.height,minConstraints:be,maxConstraints:xe,onResizeStart:me,onResize:he,onResizeStop:ge,transformScale:m,resizeHandles:A,handle:Ee,children:Te}),Te=(0,Q.jsx)(Or,{disabled:!c,onStart:fe,onDrag:pe,onStop:Y,handle:b,cancel:`.react-resizable-handle`+(x?`,`+x:``),scale:m,nodeRef:B,children:Te}),Te}var zr=()=>{},Br=`react-grid-layout`,Vr=!1;try{Vr=/firefox/i.test(navigator.userAgent)}catch{}function Hr(e,t){let n=Z.Children.toArray(e),r=Z.Children.toArray(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t?.key!==i?.key)return!1}return!0}function Ur(e,t,n,r){let i=[],a=new Set;Z.Children.forEach(t,t=>{if(!Z.isValidElement(t)||t.key===null)return;let n=String(t.key);a.add(n);let r=e.find(e=>e.i===n);if(r)i.push(Ut(r));else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:Bt(i),w:1,h:1})}});let o=qt(i,{cols:n});return r.compact(o,n)}function Wr(e){let{children:t,width:n,gridConfig:r,dragConfig:i,resizeConfig:a,dropConfig:o,positionStrategy:s=mn,compactor:c,constraints:l=Zt,layout:u=[],droppingItem:d,autoSize:f=!0,className:p=``,style:m={},innerRef:h,onLayoutChange:g=zr,onDragStart:_=zr,onDrag:v=zr,onDragStop:y=zr,onResizeStart:b=zr,onResize:x=zr,onResizeStop:S=zr,onDrop:C=zr,onDropDragOver:w=zr}=e,T=(0,Z.useMemo)(()=>({...hn,...r}),[r]),E=(0,Z.useMemo)(()=>({...gn,...i}),[i]),ee=(0,Z.useMemo)(()=>({..._n,...a}),[a]),D=(0,Z.useMemo)(()=>({...vn,...o}),[o]),{cols:O,rowHeight:k,maxRows:A,margin:j,containerPadding:M}=T,{enabled:te,bounded:N,handle:P,cancel:F,threshold:I}=E,{enabled:ne,handles:re,handleComponent:ie}=ee,{enabled:L,defaultItem:ae,onDragOver:R}=D,z=c??On(`vertical`),B=z.type,V=z.allowOverlap,oe=z.preventCollision??!1,se=(0,Z.useMemo)(()=>d??{i:`__dropping-elem__`,...ae},[d,ae]),ce=s.type===`transform`,H=s.scale,U=M??j,[le,ue]=(0,Z.useState)(!1),[W,G]=(0,Z.useState)(()=>Ur(u,t,O,z)),[K,q]=(0,Z.useState)(null),[de,J]=(0,Z.useState)(!1),[fe,pe]=(0,Z.useState)(null),[Y,X]=(0,Z.useState)(),me=(0,Z.useRef)(null),he=(0,Z.useRef)(null),ge=(0,Z.useRef)(null),_e=(0,Z.useRef)(0),ve=(0,Z.useRef)(W),ye=(0,Z.useRef)(u),be=(0,Z.useRef)(t),xe=(0,Z.useRef)(B),Se=(0,Z.useRef)(W);Se.current=W,(0,Z.useEffect)(()=>{ue(!0),(0,Lr.deepEqual)(W,u)||g(W)},[]),(0,Z.useEffect)(()=>{if(K||fe)return;let e=!(0,Lr.deepEqual)(u,ye.current),n=!Hr(t,be.current),r=B!==xe.current;if(e||n||r){let n=Ur(e?u:W,t,O,z);(0,Lr.deepEqual)(n,W)||G(n)}ye.current=u,be.current=t,xe.current=B},[u,t,O,B,z,K,fe,W]),(0,Z.useEffect)(()=>{!K&&!(0,Lr.deepEqual)(W,ve.current)&&(ve.current=W,g(W.filter(e=>e.i!==se.i)))},[W,K,g,se.i]);let Ce=(0,Z.useMemo)(()=>{if(!f)return;let e=Bt(W),t=U[1];return e*k+(e-1)*j[1]+t*2+`px`},[f,W,k,j,U]),we=(0,Z.useCallback)((e,t,n,r)=>{let i=Se.current,a=Vt(i,e);if(!a)return;let o={w:a.w,h:a.h,x:a.x,y:a.y,i:e};me.current=Ut(a),ge.current=i,q(o),_(i,a,a,null,r.e,r.node)},[_]),Te=(0,Z.useCallback)((e,t,n,r)=>{let i=Se.current,a=me.current,o=Vt(i,e);if(!o)return;let s={w:o.w,h:o.h,x:o.x,y:o.y,i:e},c=Jt(i,o,t,n,!0,oe,B,O,V);v(c,a,o,s,r.e,r.node),G(z.compact(c,O)),q(s)},[oe,B,O,V,z,v]),Ee=(0,Z.useCallback)((e,t,n,r)=>{if(!K)return;let i=Se.current,a=me.current,o=Vt(i,e);if(!o)return;let s=Jt(i,o,t,n,!0,oe,B,O,V),c=z.compact(s,O);y(c,a,o,null,r.e,r.node);let l=ge.current;me.current=null,ge.current=null,q(null),G(c),l&&!(0,Lr.deepEqual)(l,c)&&g(c)},[K,oe,B,O,V,z,y,g]),De=(0,Z.useCallback)((e,t,n,r)=>{let i=Se.current,a=Vt(i,e);a&&(he.current=Ut(a),ge.current=i,J(!0),b(i,a,a,null,r.e,r.node))},[b]),Oe=(0,Z.useCallback)((e,t,n,r)=>{let i=Se.current,a=he.current,{handle:o}=r,s=!1,c,l,[u,d]=Kt(i,e,e=>(c=e.x,l=e.y,[`sw`,`w`,`nw`,`n`,`ne`].includes(o)&&([`sw`,`nw`,`w`].includes(o)&&(c=e.x+(e.w-t),t=e.x!==c&&c<0?e.w:t,c=c<0?0:c),[`ne`,`n`,`nw`].includes(o)&&(l=e.y+(e.h-n),n=e.y!==l&&l<0?e.h:n,l=l<0?0:l),s=!0),oe&&!V&&It(i,{...e,w:t,h:n,x:c??e.x,y:l??e.y}).filter(t=>t.i!==e.i).length>0&&(l=e.y,n=e.h,c=e.x,t=e.w,s=!1),e.w=t,e.h=n,e));if(!d)return;let f=u;s&&c!==void 0&&l!==void 0&&(f=Jt(u,d,c,l,!0,oe,B,O,V));let p={w:d.w,h:d.h,x:d.x,y:d.y,i:e,static:!0};x(f,a,d,p,r.e,r.node),G(z.compact(f,O)),q(p)},[oe,B,O,V,z,x]),ke=(0,Z.useCallback)((e,t,n,r)=>{let i=Se.current,a=he.current,o=Vt(i,e),s=z.compact(i,O);S(s,a,o??null,null,r.e,r.node);let c=ge.current;he.current=null,ge.current=null,q(null),J(!1),G(s),c&&!(0,Lr.deepEqual)(c,s)&&g(s)},[O,z,S,g]),je=(0,Z.useCallback)(()=>{let e=Se.current;if(!e.some(e=>e.i===se.i)){pe(null),q(null),X(void 0);return}G(z.compact(e.filter(e=>e.i!==se.i),O)),pe(null),q(null),X(void 0)},[se.i,O,z]),Me=(0,Z.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),Vr&&!e.nativeEvent.target?.classList.contains(Br))return!1;let t=R?R(e.nativeEvent):w(e);if(t===!1)return fe&&je(),!1;let{dragOffsetX:r=0,dragOffsetY:i=0,...a}=t??{},o={...se,...a},s=e.currentTarget.getBoundingClientRect(),c={cols:O,margin:j,maxRows:A,rowHeight:k,containerWidth:n,containerPadding:U},l=Dt(c),u=Ot(o.w,l,j[0]),d=Ot(o.h,k,j[1]),f=u/2,p=d/2,m=e.clientX-s.left+r-f,h=e.clientY-s.top+i-p,g=Math.max(0,m),_=Math.max(0,h),v={left:g/H,top:_/H,e:e.nativeEvent};if(fe)Y&&(Y.left!==v.left||Y.top!==v.top)&&X(v);else{let e=At(c,_,g,o.w,o.h);pe((0,Q.jsx)(`div`,{},o.i)),X(v),G([...Se.current.filter(e=>e.i!==o.i),{...o,x:e.x,y:e.y,static:!1,isDraggable:!0}])}},[fe,Y,se,R,w,je,H,O,j,A,k,n,U]),Ne=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),_e.current--,_e.current<0&&(_e.current=0),_e.current===0&&je()},[je]),Pe=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),_e.current++},[]),Fe=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=Se.current,n=t.find(e=>e.i===se.i);_e.current=0,je(),C(t,n,e.nativeEvent)},[se.i,je,C]),Ie=(0,Z.useCallback)((e,t)=>{if(!e||!e.key)return null;let r=Vt(W,String(e.key));if(!r)return null;let i=typeof r.isDraggable==`boolean`?r.isDraggable:!r.static&&te,a=typeof r.isResizable==`boolean`?r.isResizable:!r.static&&ne,o=r.resizeHandles||[...re],c=i&&N&&r.isBounded!==!1,u=ie;return(0,Q.jsx)(Rr,{containerWidth:n,cols:O,margin:j,containerPadding:U,maxRows:A,rowHeight:k,cancel:F,handle:P,onDragStart:we,onDrag:Te,onDragStop:Ee,onResizeStart:De,onResize:Oe,onResizeStop:ke,isDraggable:i,isResizable:a,isBounded:c,useCSSTransforms:ce&&le,usePercentages:!le,transformScale:H,positionStrategy:s,dragThreshold:I,w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,minH:r.minH,minW:r.minW,maxH:r.maxH,maxW:r.maxW,static:r.static,droppingPosition:t?Y:void 0,resizeHandles:o,resizeHandle:u,constraints:l,layoutItem:r,layout:W,children:e},r.i)},[W,n,O,j,U,A,k,F,P,we,Te,Ee,De,Oe,ke,te,ne,N,ce,le,H,s,I,Y,re,ie,l]),Le=()=>K?(0,Q.jsx)(Rr,{w:K.w,h:K.h,x:K.x,y:K.y,i:K.i,className:`react-grid-placeholder ${de?`placeholder-resizing`:``}`,containerWidth:n,cols:O,margin:j,containerPadding:U,maxRows:A,rowHeight:k,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:ce,transformScale:H,constraints:l,layout:W,children:(0,Q.jsx)(`div`,{})}):null;return(0,Q.jsxs)(`div`,{ref:h,className:Ae(Br,p),style:{height:Ce,...m},onDrop:L?Fe:void 0,onDragLeave:L?Ne:void 0,onDragEnter:L?Pe:void 0,onDragOver:L?Me:void 0,children:[Z.Children.map(t,e=>Z.isValidElement(e)?Ie(e):null),L&&fe&&Ie(fe,!0),Le()]})}var Gr={lg:1200,md:996,sm:768,xs:480,xxs:0},Kr={lg:12,md:10,sm:6,xs:4,xxs:2},qr=()=>{};function Jr(e,t,n,r){let i=[];Z.Children.forEach(t,t=>{if(!Z.isValidElement(t)||t.key===null)return;let n=String(t.key),r=e.find(e=>e.i===n);if(r)i.push({...r,i:n});else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:Bt(i),w:1,h:1})}});let a=qt(i,{cols:n});return r.compact(a,n)}function Yr(e){let{children:t,width:n,breakpoint:r,breakpoints:i=Gr,cols:a=Kr,layouts:o={},rowHeight:s=150,maxRows:c=1/0,margin:l=[10,10],containerPadding:u=null,compactor:d,onBreakpointChange:f=qr,onLayoutChange:p=qr,onWidthChange:m=qr,...h}=e,g=d??On(`vertical`),_=g.type,v=g.allowOverlap,y=(0,Z.useMemo)(()=>r??An(i,n),[]),b=(0,Z.useMemo)(()=>jn(y,a),[y,a]),x=(0,Z.useMemo)(()=>Mn(o,i,y,y,b,_),[]),[S,C]=(0,Z.useState)(y),[w,T]=(0,Z.useState)(b),[E,ee]=(0,Z.useState)(x),[D,O]=(0,Z.useState)(o),k=(0,Z.useRef)(n),A=(0,Z.useRef)(r),j=(0,Z.useRef)(i),M=(0,Z.useRef)(a),te=(0,Z.useRef)(o),N=(0,Z.useRef)(_),P=(0,Z.useRef)(D);(0,Z.useEffect)(()=>{P.current=D},[D]);let F=(0,Z.useMemo)(()=>(0,Lr.deepEqual)(o,te.current)?null:Mn(o,i,S,S,w,g),[o,i,S,w,g]),I=F??E;(0,Z.useEffect)(()=>{F!==null&&(ee(F),O(o),P.current=o,te.current=o)},[F,o]),(0,Z.useEffect)(()=>{if(_!==N.current){let e=g.compact(Wt(I),w),t={...P.current,[S]:e};ee(e),O(t),P.current=t,p(e,t),N.current=_}},[_,g,I,w,v,S,p]),(0,Z.useEffect)(()=>{let e=n!==k.current,o=r!==A.current,s=!(0,Lr.deepEqual)(i,j.current),c=!(0,Lr.deepEqual)(a,M.current);if(e||o||s||c){let e=r??An(i,n),o=jn(e,a),d=S;if(d!==e||s||c){let n={...P.current};n[d]||(n[d]=Wt(E));let r=Mn(n,i,e,d,o,g);r=Jr(r,t,o,g),n[e]=r,C(e),T(o),ee(r),O(n),P.current=n,f(e,o),p(r,n)}m(n,Nn(l,e),o,u?Nn(u,e):null),k.current=n,A.current=r,j.current=i,M.current=a}},[n,r,i,a,S,w,E,t,g,_,v,l,u,f,p,m]);let ne=(0,Z.useCallback)(e=>{let t={...P.current,[S]:e};ee(e),O(t),P.current=t,p(e,t)},[S,p]),re=(0,Z.useMemo)(()=>Nn(l,S),[l,S]),ie=(0,Z.useMemo)(()=>u===null?null:Nn(u,S),[u,S]),L=(0,Z.useMemo)(()=>({cols:w,rowHeight:s,maxRows:c,margin:re,containerPadding:ie}),[w,s,c,re,ie]);return(0,Q.jsx)(Wr,{...h,width:n,gridConfig:L,compactor:g,onLayoutChange:ne,layout:I,children:t})}function Xr({editMode:e}){let t=o();return Z.useEffect(()=>{if(e)return t.startDrag({id:`dashboard-layout`,type:`dashboard-widget`,data:{}}),()=>{t.endDrag()};t.endDrag(`dashboard`)},[e,t]),null}var Zr=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`];function Qr(e,t){if(!e.widgets?.length)return e;let n=new Map(t.map(e=>[e.i,e])),r=e.widgets.map((e,t)=>{let r=e.id||`widget-${t}`,i=n.get(r);return i?{...e,layout:{x:i.x,y:i.y,w:i.w,h:i.h}}:e});return{...e,widgets:r}}function $r(e){return{lg:e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x??t%4*3,y:e.layout?.y??Math.floor(t/4)*4,w:e.layout?.w??3,h:e.layout?.h??4}))||[]}}var ei=({schema:e,className:t,onLayoutChange:n,onSchemaChange:r,onRefresh:i})=>{let{width:a,containerRef:o,mounted:l}=Fn(),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),m=s(),h=Z.useRef(null),g=Z.useCallback(()=>{i&&(p(!0),i(),setTimeout(()=>p(!1),600))},[i]);Z.useEffect(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!i))return h.current=setInterval(g,e.refreshInterval*1e3),()=>{h.current&&clearInterval(h.current)}},[e.refreshInterval,i,g]);let[_,v]=Z.useState(()=>$r(e)),y=Z.useMemo(()=>JSON.stringify(e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x,y:e.layout?.y,w:e.layout?.w,h:e.layout?.h}))??[]),[e.widgets]);Z.useEffect(()=>{v($r(e))},[y]);let b=Z.useCallback((e,t)=>{v(t),n?.(e)},[n]),x=Z.useCallback(()=>{r?r(Qr(e,_.lg)):globalThis.process?.env?.NODE_ENV!==`production`&&console.warn("[DashboardGridLayout] Layout edits are in-memory only. Wire `onSchemaChange` to persist via your data adapter."),d(!1)},[r,e,_]),S=Z.useCallback(()=>{v($r(e))},[e]),C=Z.useCallback(e=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`bar`||t===`horizontal-bar`||t===`line`||t===`area`||t===`pie`||t===`donut`||t===`scatter`||t===`funnel`){let r=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(We(r)){let n=r.aggregate,o=n?{field:e.valueField||n.field,function:e.aggregate||n.function,groupBy:e.categoryField||n.groupBy}:void 0,s=o?.field||a;return{type:`object-chart`,chartType:t,objectName:e.object||r.object,aggregate:o,xAxisKey:i,series:[{dataKey:s}],colors:Zr,className:`h-full`}}if(!r&&e.object){let n=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`name`}:void 0;return{type:`object-chart`,chartType:t,objectName:e.object,aggregate:n,xAxisKey:i,series:[{dataKey:e.valueField||`value`}],colors:Zr,className:`h-full`}}return{type:`chart`,chartType:t,data:Array.isArray(r)?r:r?.items||[],xAxisKey:i,series:[{dataKey:a}],colors:Zr,className:`h-full`}}if(t===`table`){let t=e.data||n.data;if(We(t)){let{data:r,...i}=n;return{type:`data-table`,...i,objectName:e.object||t.object,dataProvider:t,data:[],searchable:!1,pagination:!1,className:`border-0`}}return!t&&e.object?{type:`data-table`,...n,objectName:e.object,data:[],searchable:!1,pagination:!1,className:`border-0`}:{type:`data-table`,...n,data:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}if(t===`pivot`){let t=e.data||n.data;if(We(t)){let{data:r,...i}=n;return{type:`pivot`,...i,objectName:e.object||t.object,dataProvider:t,data:[]}}return{type:`pivot`,...n,data:Array.isArray(t)?t:t?.items||[]}}return{...e,...n}},[]);return(0,Q.jsxs)(`div`,{ref:o,className:R(`w-full`,t),"data-testid":`grid-layout`,children:[m&&(0,Q.jsx)(Xr,{editMode:u}),(0,Q.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,Q.jsx)(`h2`,{className:`text-2xl font-bold`,children:e.title||`Dashboard`}),(0,Q.jsx)(`div`,{className:`flex gap-2`,children:u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(H,{onClick:x,size:`sm`,variant:`default`,children:[(0,Q.jsx)(P,{className:`h-4 w-4 mr-2`}),`Save Layout`]}),(0,Q.jsxs)(H,{onClick:S,size:`sm`,variant:`outline`,children:[(0,Q.jsx)(z,{className:`h-4 w-4 mr-2`}),`Reset`]}),(0,Q.jsx)(H,{onClick:()=>d(!1),size:`sm`,variant:`ghost`,children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[i&&(0,Q.jsxs)(H,{onClick:g,size:`sm`,variant:`outline`,disabled:f,"aria-label":`Refresh dashboard`,children:[(0,Q.jsx)(F,{className:R(`h-4 w-4 mr-2`,f&&`animate-spin`)}),f?`Refreshing…`:`Refresh All`]}),(0,Q.jsxs)(H,{onClick:()=>d(!0),size:`sm`,variant:`outline`,children:[(0,Q.jsx)(pe,{className:`h-4 w-4 mr-2`}),`Edit Layout`]})]})})]}),l&&(0,Q.jsx)(Yr,{className:`layout`,width:a,layouts:_,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},rowHeight:60,dragConfig:{enabled:u,handle:`.drag-handle`},resizeConfig:{enabled:u},onLayoutChange:b,children:e.widgets?.map((e,t)=>{let n=e.id||`widget-${t}`,r=C(e);return(0,Q.jsx)(`div`,{className:`h-full`,children:e.type===`metric`?(0,Q.jsxs)(`div`,{className:`h-full w-full relative`,children:[u&&(0,Q.jsx)(`div`,{className:`drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border`,children:(0,Q.jsx)(De,{className:`h-4 w-4`})}),(0,Q.jsx)(c,{schema:r,className:`h-full w-full`})]}):(0,Q.jsxs)(xe,{className:R(`h-full overflow-hidden border-border/50 shadow-sm transition-all`,`bg-card/50 backdrop-blur-sm`,u&&`ring-2 ring-primary/20`),children:[e.title&&(0,Q.jsxs)(_e,{className:`pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between`,children:[(0,Q.jsx)(Ce,{className:`text-base font-medium tracking-tight truncate`,title:e.title,children:e.title}),u&&(0,Q.jsx)(`div`,{className:`drag-handle cursor-move p-1 hover:bg-muted/40 rounded`,children:(0,Q.jsx)(De,{className:`h-4 w-4`})})]}),(0,Q.jsx)(Y,{className:`p-0 h-full`,children:(0,Q.jsx)(`div`,{className:R(`h-full w-full overflow-auto p-4`),children:(0,Q.jsx)(c,{schema:r})})})]})},n)})})]})},ti=k({"dashboard.trend.vsLastQuarter":`vs last quarter`,"dashboard.trend.vsLastMonth":`vs last month`,"dashboard.trend.vsLastWeek":`vs last week`,"dashboard.trend.vsLastYear":`vs last year`,"dashboard.trend.vsYesterday":`vs yesterday`,"dashboard.trend.vsPreviousPeriod":`vs previous period`},`dashboard.trend.vsLastQuarter`);function ni(e){switch(e.trim().toLowerCase().replace(/\s+/g,` `)){case`vs last quarter`:case`vs previous quarter`:return`dashboard.trend.vsLastQuarter`;case`vs last month`:case`vs previous month`:return`dashboard.trend.vsLastMonth`;case`vs last week`:case`vs previous week`:return`dashboard.trend.vsLastWeek`;case`vs last year`:case`vs previous year`:return`dashboard.trend.vsLastYear`;case`vs yesterday`:return`dashboard.trend.vsYesterday`;case`vs previous period`:case`vs prior period`:return`dashboard.trend.vsPreviousPeriod`;default:return}}function ri(e,t,n){if(e==null)return``;if(typeof e==`string`){let r=Number(e);return!isFinite(r)||e.trim()===``?e:ri(r,t,n)}if(!isFinite(e))return String(e);let r={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`},i=(t||``).trim(),a=!!n||i.length>0&&r[i[0]]!==void 0,o=i.endsWith(`%`),s=i.match(/0\.(0+)/),c=s?s[1].length:0;if(/a/i.test(i)){let t={notation:`compact`,maximumFractionDigits:c||1};a&&(t.style=`currency`,t.currency=n||r[i[0]]||`USD`);try{return new Intl.NumberFormat(`en-US`,t).format(e)}catch{}}if(a){let t=n||r[i[0]]||`USD`;try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t,minimumFractionDigits:c,maximumFractionDigits:c}).format(e)}catch{return`${t} ${e.toFixed(c)}`}}return o?`${(e>1?e:e*100).toFixed(c)}%`:new Intl.NumberFormat(`en-US`,{minimumFractionDigits:c,maximumFractionDigits:c}).format(e)}function ii(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var ai={default:`bg-muted text-muted-foreground`,blue:`bg-blue-500/10 text-blue-600 dark:text-blue-400`,teal:`bg-teal-500/10 text-teal-600 dark:text-teal-400`,orange:`bg-orange-500/10 text-orange-600 dark:text-orange-400`,purple:`bg-purple-500/10 text-purple-600 dark:text-purple-400`,success:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,warning:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,danger:`bg-rose-500/10 text-rose-600 dark:text-rose-400`},oi={default:`text-foreground`,blue:`text-blue-600 dark:text-blue-400`,teal:`text-teal-600 dark:text-teal-400`,orange:`text-orange-600 dark:text-orange-400`,purple:`text-purple-600 dark:text-purple-400`,success:`text-emerald-600 dark:text-emerald-400`,warning:`text-amber-600 dark:text-amber-400`,danger:`text-rose-600 dark:text-rose-400`},si=({label:e,value:t,trend:n,icon:r,className:i,description:a,loading:o,error:s,colorVariant:c=`default`,format:l,currency:u,prefix:d,suffix:f,onClick:p,variant:m=`card`,...h})=>{let g=ai[c]||ai.default,{t:_}=ti(),v=(0,Z.useMemo)(()=>{let e=ii(a)||ii(n?.label);if(!e)return e;let t=ni(e);return t?_(t):e},[a,n?.label,_]),y=(0,Z.useMemo)(()=>{let e=typeof t==`number`||typeof t==`string`&&t.trim()!==``&&isFinite(Number(t))?ri(t,l,u):t??``,n=String(e);return`${d&&n.startsWith(d)?``:d??``}${n}${f&&n.endsWith(f)?``:f??``}`},[t,l,u,d,f]),b=(0,Z.useMemo)(()=>{if(typeof r==`string`){let e=ve(r);return e?(0,Q.jsx)(e,{className:`h-4 w-4`}):null}return r},[r]);if(m===`bare`){let t=oi[c]||oi.default;return(0,Q.jsx)(`div`,{className:R(`flex flex-col gap-1 min-w-0`,p&&`cursor-pointer`,i),onClick:p,role:p?`button`:void 0,tabIndex:p?0:void 0,onKeyDown:p?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p())}:void 0,children:o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,Q.jsx)(U,{className:`h-4 w-4 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):s?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,Q.jsx)(ae,{className:`h-4 w-4 text-destructive shrink-0`}),(0,Q.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:s})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:R(`text-[2rem] leading-none font-extrabold tabular-nums tracking-tight truncate`,t),children:y}),(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground truncate`,children:ii(e)})]})})}return(0,Q.jsxs)(xe,{className:R(`h-full overflow-hidden`,p&&`cursor-pointer transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,i),onClick:p,role:p?`button`:void 0,tabIndex:p?0:void 0,onKeyDown:p?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p())}:void 0,...h,children:[(0,Q.jsxs)(_e,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,Q.jsx)(Ce,{className:`text-sm font-medium truncate`,children:ii(e)}),b&&(0,Q.jsx)(`div`,{className:R(`flex h-8 w-8 items-center justify-center rounded-md shrink-0`,g),children:b})]}),(0,Q.jsx)(Y,{children:o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,Q.jsx)(U,{className:`h-4 w-4 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):s?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,Q.jsx)(ae,{className:`h-4 w-4 text-destructive shrink-0`}),(0,Q.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:s})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`text-2xl font-bold tabular-nums tracking-tight truncate`,children:y}),(n||a)&&(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0`,children:[n&&(0,Q.jsxs)(`span`,{className:R(`flex items-center shrink-0 font-medium`,n.direction===`up`&&`text-emerald-600 dark:text-emerald-400`,n.direction===`down`&&`text-rose-600 dark:text-rose-400`,n.direction===`neutral`&&`text-muted-foreground`),children:[n.direction===`up`&&(0,Q.jsx)(Ee,{className:`h-3 w-3 mr-1`}),n.direction===`down`&&(0,Q.jsx)(N,{className:`h-3 w-3 mr-1`}),n.direction===`neutral`&&(0,Q.jsx)(me,{className:`h-3 w-3 mr-1`}),n.value,`%`]}),(0,Q.jsx)(`span`,{className:`truncate min-w-0`,children:v})]})]})})]})};function ci(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var li=({title:e,value:t,icon:n,trend:r,trendValue:i,description:a,className:o,loading:s,error:c,...l})=>{let u=n?ve(n):null;return(0,Q.jsxs)(xe,{className:R(`h-full`,o),...l,children:[(0,Q.jsxs)(_e,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,Q.jsx)(Ce,{className:`text-sm font-medium`,children:ci(e)}),u&&(0,Q.jsx)(u,{className:`h-4 w-4 text-muted-foreground`})]}),(0,Q.jsx)(Y,{children:s?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-card-loading`,children:[(0,Q.jsx)(U,{className:`h-4 w-4 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):c?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-card-error`,role:`alert`,children:[(0,Q.jsx)(ae,{className:`h-4 w-4 text-destructive shrink-0`}),(0,Q.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:c})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`text-2xl font-bold`,children:t}),(r||i||a)&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center mt-1`,children:[r&&i&&(0,Q.jsxs)(`span`,{className:R(`flex items-center mr-2`,r===`up`&&`text-green-500`,r===`down`&&`text-red-500`,r===`neutral`&&`text-yellow-500`),children:[r===`up`&&(0,Q.jsx)(Ee,{className:`h-3 w-3 mr-1`}),r===`down`&&(0,Q.jsx)(N,{className:`h-3 w-3 mr-1`}),r===`neutral`&&(0,Q.jsx)(me,{className:`h-3 w-3 mr-1`}),i]}),ci(a)]})]})})]})},ui=({objectName:e,aggregate:t,filter:n,label:r,fallbackValue:i,trend:a,icon:o,className:s,description:u,dataSource:d,colorVariant:f,format:_,currency:v,prefix:y,suffix:b,invert:x,drillDown:S,title:C,compareTo:w,t:T,variant:E})=>{let D=(0,Z.useContext)(l),O=d||D?.dataSource,[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(null),[te,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(!1),[I,ie]=(0,Z.useState)(null),[ae,R]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{let t=!0;if(!(!O||!e||typeof O.getObjectSchema!=`function`))return O.getObjectSchema(e).then(e=>{t&&R(e)}).catch(()=>{}),()=>{t=!1}},[O,e]);let z=(0,Z.useMemo)(()=>{let e=t?.field;if(!e||!ae?.fields)return null;let n=ae.fields;return Array.isArray(n)?n.find(t=>t?.name===e)||null:n[e]||null},[ae,t?.field]),B=(0,Z.useMemo)(()=>{if(_)return _;if(z){if(z.type===`currency`){let e=z.precision??z.scale??0;return e>0?`0,0.${`0`.repeat(e)}`:`0,0`}if(z.type===`percent`)return`0,0%`;if(z.type===`number`||z.type===`integer`)return`0,0`}},[_,z]),{currency:se}=ne(),ce=(0,Z.useMemo)(()=>{if(v)return v;if(z?.type===`currency`)return V(z,se)},[v,z,se]),H=(0,Z.useMemo)(()=>t?JSON.stringify(t):``,[t]),U=(0,Z.useMemo)(()=>ee(n),[n]),ue=(0,Z.useMemo)(()=>U?JSON.stringify(U):``,[U]),W=(0,Z.useMemo)(()=>w?JSON.stringify(w):``,[w]),q=(0,Z.useCallback)(async(n,r)=>{if(t&&typeof n.aggregate==`function`){let i=await n.aggregate(e,{field:t.field,function:t.function,groupBy:t.groupBy||`_all`,filter:r}),a=Array.isArray(i)?i:[];if(a.length===0)return 0;if(t.function===`count`){let e=`${t.field}_count`;return a.reduce((n,r)=>n+(Number(r[e])||Number(r[t.field])||Number(r.count)||0),0)}let o=a[0];return o[`${t.field}_${t.function}`]??o[t.field]??o.value??0}if(typeof n.find==`function`){let t=await n.find(e,{$filter:r});return(Array.isArray(t)?t:t?.data||t?.records||[]).length}return null},[e,H]),de=(0,Z.useCallback)(async(t,r)=>{if(!(!t||!e)){r.current&&(F(!0),ie(null));try{let e=w?m(n,w):null,[i,a]=await Promise.all([q(t,U),e?q(t,e):Promise.resolve(null)]);if(i===null)return;r.current&&(M(i),N(typeof a==`number`&&Number.isFinite(a)?a:null))}catch(e){console.error(`[ObjectMetricWidget] Fetch error:`,e),r.current&&ie(e instanceof Error?e.message:`Failed to load metric`)}finally{r.current&&F(!1)}}},[e,H,ue,W,q]);(0,Z.useEffect)(()=>{let t={current:!0};return O&&e?de(O,t):(M(null),ie(null)),()=>{t.current=!1}},[O,e,de]);let J=j===null?O?`—`:i??`—`:j;x&&typeof J==`number`&&isFinite(J)&&J>=0&&J<=1&&(J=1-J);let fe=(0,Z.useMemo)(()=>{if(!w||typeof j!=`number`||!Number.isFinite(j)||te===null)return;let e=Ge(j,te);if(!e)return;let t=p(w,n),r=`dashboard.trend.${t}`,i={vsPreviousPeriod:`vs previous period`,vsLastWeek:`vs last week`,vsLastMonth:`vs last month`,vsLastQuarter:`vs last quarter`,vsLastYear:`vs last year`,vsYesterday:`vs yesterday`},a=T?T(r,i[t]||t):i[t]||t;return{value:e.value,direction:e.direction,label:a}},[w,j,te,n,T])??a,pe=g(S)&&!!e&&!!O,Y=(0,Z.useMemo)(()=>{let e=typeof r==`string`?r:r?.defaultValue||``;return h(S,{},(typeof C==`string`?C:C?.defaultValue||``)||e||`Details`)},[S,r,C]),X=(0,Z.useMemo)(()=>{if(!pe)return null;let t=S?.target??`drawer`,n=S?.report,r=n&&typeof n==`object`&&(Array.isArray(n.columns)||`objectName`in n),i=r?null:(0,Q.jsx)(ot,{objectName:e,filter:U,onNavigate:()=>A(!1)}),a;if(r){let e=n.filter,t=e?U?{$and:[e,U]}:e:U;a=(0,Q.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,Q.jsx)(c,{schema:{type:`spec-report`,...n,filter:t}})})}else a=(0,Q.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,Q.jsx)(c,{schema:{type:`object-data-table`,objectName:e,filter:U,pageSize:25,drillDown:{enabled:!0,mode:`record`,target:`dialog`}}})});return t===`dialog`?(0,Q.jsx)(ye,{open:!0,onOpenChange:e=>!e&&A(!1),children:(0,Q.jsxs)(re,{className:`max-w-5xl`,children:[(0,Q.jsxs)(K,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,Q.jsx)(oe,{children:Y}),i]}),a]})}):(0,Q.jsx)(le,{open:!0,onOpenChange:e=>!e&&A(!1),children:(0,Q.jsxs)(G,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-5xl flex flex-col`,children:[(0,Q.jsxs)(L,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,Q.jsx)(be,{children:Y}),i]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:a})]})})},[pe,S,e,U,Y]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(si,{label:r,value:J,trend:fe,icon:o,className:s,description:u,loading:P,error:I,colorVariant:f,format:B,currency:ce,prefix:y,suffix:b,variant:E,onClick:pe?()=>A(!0):void 0}),k&&X]})};function di(){return w()(`dashboard.total`,`Total`)}function fi(){return w()(`dashboard.noDataAvailable`,`No data available`)}function pi(e,t){if(!t)return String(e);let n=``,r=``,i=!1,a,o=t,s=o.match(/^([^0-9.,#]*)/);if(s&&s[1]){let e=s[1];n=e.replace(`,`,``),e.includes(`,`)&&(i=!0),o=o.slice(s[1].length)}o.includes(`,`)&&(i=!0,o=o.replace(/,/g,``));let c=o.match(/\.(\d+)f?/);c&&(a=Number(c[1]),o=o.slice(c[0].length)),r=o.replace(/[0-9#.f]/g,``);let l=a===void 0?String(e):e.toFixed(a);if(i){let[e,t]=l.split(`.`),i=e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`);return n+(t===void 0?i:`${i}.${t}`)+r}return n+l+r}var mi=`—`;function hi(e,t){return e===``?mi:t?.[e]??e}function gi(e,t){if(e.length===0)return 0;switch(t){case`sum`:return e.reduce((e,t)=>e+t,0);case`count`:return e.length;case`avg`:return e.reduce((e,t)=>e+t,0)/e.length;case`min`:return Math.min(...e);case`max`:return Math.max(...e);default:return e.reduce((e,t)=>e+t,0)}}var _i=({schema:e,className:t,rowLabels:n,columnLabels:r,rowFieldLabel:i,onDrillDown:a})=>{let{title:o,rowField:s,columnField:c,valueField:l,aggregation:u=`sum`,data:d=[],showRowTotals:f=!1,showColumnTotals:p=!1,format:m,columnColors:h,drillDown:_}=e,v=di(),y=fi(),b=g(_)&&typeof a==`function`,x=e=>{b&&a({...e,rowLabel:e.rowKey===void 0?e.rowLabel:n?.[e.rowKey]??e.rowKey,colLabel:e.colKey===void 0?e.colLabel:r?.[e.colKey]??e.colKey})},S=e=>t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},C=b?`cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]`:``,w=Array.isArray(d)?d:[],{rowKeys:T,colKeys:E,matrix:ee,rowTotals:D,colTotals:O,grandTotal:k}=(0,Z.useMemo)(()=>{let e=new Map,t=new Map,n={};for(let r of w){let i=String(r[s]??``),a=String(r[c]??``),o=Number(r[l])||0;e.set(i,!0),t.set(a,!0),n[i]||(n[i]={}),n[i][a]||(n[i][a]=[]),n[i][a].push(o)}let r=Array.from(e.keys()),i=Array.from(t.keys()),a={},o={},d={};for(let e of r){a[e]={};let t=[];for(let r of i){let i=n[e]?.[r]??[],o=gi(i,u);a[e][r]=o,t.push(...i),!d[r]&&d[r]}o[e]=gi(t,u)}for(let e of i){let t=[];for(let i of r){let r=n[i]?.[e]??[];t.push(...r)}d[e]=gi(t,u)}let f=[];for(let e of w)f.push(Number(e[l])||0);return{rowKeys:r,colKeys:i,matrix:a,rowTotals:o,colTotals:d,grandTotal:gi(f,u)}},[w,s,c,l,u]),A=e=>pi(e,m);return w.length===0?(0,Q.jsxs)(`div`,{className:R(`overflow-auto`,t),children:[o&&(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:o}),(0,Q.jsx)(Oe,{"data-testid":`pivot-empty-state`,className:`py-8 gap-2 [&>h3]:hidden`,icon:(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Q.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`}),(0,Q.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`}),(0,Q.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`}),(0,Q.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`})]}),iconWrapperClassName:``,title:``,description:y})]}):(0,Q.jsxs)(`div`,{className:R(`overflow-auto`,t),children:[o&&(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:o}),(0,Q.jsxs)(`table`,{className:`w-full text-sm border-collapse table-auto`,role:`table`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,Q.jsx)(`th`,{className:`text-left p-2 font-medium text-muted-foreground whitespace-nowrap`,children:i||s}),E.map(e=>{let t=()=>x({scope:`column`,colKey:e});return(0,Q.jsx)(`th`,{className:R(`text-right p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,h?.[e]??`text-muted-foreground`,C),title:e===``?`${c}: (empty)`:`${c}: ${e}`,role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?t:void 0,onKeyDown:b?S(t):void 0,"aria-label":b?`Drill into ${c}: ${e||`(empty)`}`:void 0,children:hi(e,r)},e)}),f&&(0,Q.jsx)(`th`,{className:`text-right p-2 font-semibold text-muted-foreground bg-muted/20 whitespace-nowrap`,children:v})]})}),(0,Q.jsx)(`tbody`,{children:T.map(e=>(0,Q.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-muted/30`,children:[(0,Q.jsx)(`td`,{className:R(`p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`row`,rowKey:e}):void 0,onKeyDown:b?S(()=>x({scope:`row`,rowKey:e})):void 0,"aria-label":b?`Drill into ${s}: ${e||`(empty)`}`:void 0,children:hi(e,n)}),E.map(t=>{let n=ee[e]?.[t]??0,r=()=>x({scope:`cell`,rowKey:e,colKey:t,value:n});return(0,Q.jsx)(`td`,{className:R(`text-right p-2 tabular-nums`,h?.[t],C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?r:void 0,onKeyDown:b?S(r):void 0,"aria-label":b?`Drill into ${s}=${e||`(empty)`}, ${c}=${t||`(empty)`}`:void 0,children:A(n)},t)}),f&&(0,Q.jsx)(`td`,{className:R(`text-right p-2 font-semibold tabular-nums bg-muted/20`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`row`,rowKey:e,value:D[e]??0}):void 0,onKeyDown:b?S(()=>x({scope:`row`,rowKey:e,value:D[e]??0})):void 0,children:A(D[e]??0)})]},e))}),p&&(0,Q.jsx)(`tfoot`,{children:(0,Q.jsxs)(`tr`,{className:`border-t-2 border-border font-semibold bg-muted/40`,children:[(0,Q.jsx)(`td`,{className:`p-2`,children:v}),E.map(e=>(0,Q.jsx)(`td`,{className:R(`text-right p-2 tabular-nums`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`column`,colKey:e,value:O[e]??0}):void 0,onKeyDown:b?S(()=>x({scope:`column`,colKey:e,value:O[e]??0})):void 0,children:A(O[e]??0)},e)),f&&(0,Q.jsx)(`td`,{className:R(`text-right p-2 tabular-nums font-bold`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`total`,value:k}):void 0,onKeyDown:b?S(()=>x({scope:`total`,value:k})):void 0,children:A(k)})]})})]})]})},vi=({schema:e,dataSource:t,className:n})=>{let r=(0,Z.useContext)(l),i=t||r?.dataSource,a=u(e.bind),[o,s]=(0,Z.useState)([]),[c,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,_]=(0,Z.useState)({}),[v,y]=(0,Z.useState)({}),[x,S]=(0,Z.useState)(null),{fieldLabel:w,fieldOptionLabel:T}=ke(),E=(0,Z.useRef)(w),D=(0,Z.useRef)(T);(0,Z.useEffect)(()=>{E.current=w,D.current=T},[w,T]),(0,Z.useEffect)(()=>{if(!i||!e.objectName)return;let t=i.getObjectSchema;if(typeof t!=`function`)return;let n=!0;return Promise.resolve(t.call(i,e.objectName)).then(t=>{if(!n||!t?.fields)return;let r=e.objectName,i={},a={};for(let[e,n]of Object.entries(t.fields)){let t=n?.label?String(n.label):e;a[e]=E.current(r,e,t);let o=n?.options;if(Array.isArray(o)&&o.length>0){let t={};for(let n of o)if(n&&n.value!==void 0&&n.label!==void 0){let i=String(n.value),a=String(n.label);t[i]=D.current(r,e,i,a)}Object.keys(t).length>0&&(i[e]=t)}}_(i),y(a)}).catch(()=>{}),()=>{n=!1}},[i,e.objectName]),(0,Z.useEffect)(()=>{let t=!0;return e.objectName&&!a&&(!e.data||e.data.length===0)&&(async()=>{if(!(!i||!e.objectName)){t&&(d(!0),p(null));try{let n;if(typeof i.find==`function`)n=b(await i.find(e.objectName,{$filter:ee(e.filter)}));else return;t&&s(n)}catch(e){console.error(`[ObjectPivotTable] Fetch error:`,e),t&&p(e instanceof Error?e.message:`Failed to load data`)}finally{t&&d(!1)}}})(),()=>{t=!1}},[e.objectName,i,a,e.data,e.filter]);let O=a||e.data||o,k=Array.isArray(O)?O:[];if(c&&k.length===0)return(0,Q.jsxs)(`div`,{className:R(`overflow-auto`,n),"data-testid":`pivot-loading`,children:[e.title&&(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,Q.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(W,{className:`h-6 w-24`}),(0,Q.jsx)(W,{className:`h-6 w-20`}),(0,Q.jsx)(W,{className:`h-6 w-20`}),(0,Q.jsx)(W,{className:`h-6 w-20`})]}),[1,2,3].map(e=>(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(W,{className:`h-5 w-24`}),(0,Q.jsx)(W,{className:`h-5 w-20`}),(0,Q.jsx)(W,{className:`h-5 w-20`}),(0,Q.jsx)(W,{className:`h-5 w-20`})]},e))]})]});if(f)return(0,Q.jsxs)(`div`,{className:R(`overflow-auto`,n),"data-testid":`pivot-error`,children:[e.title&&(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`pivot-error-message`,children:[(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,Q.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,Q.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,Q.jsx)(`p`,{className:`text-xs`,children:f})]})]});if(!i&&e.objectName&&k.length===0)return(0,Q.jsxs)(`div`,{className:R(`overflow-auto`,n),children:[e.title&&(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,Q.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})]});let A={...e,data:k},j=e.rowField?m[e.rowField]:void 0,M=e.columnField?m[e.columnField]:void 0,te=e.rowField?v[e.rowField]:void 0,N=e.drillDown,P=g(N)?e=>S(e):void 0;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_i,{schema:A,className:n,rowLabels:j,columnLabels:M,rowFieldLabel:te,onDrillDown:P}),(()=>{if(!x||!e.objectName)return null;let t=C(N,x,{rowField:e.rowField,columnField:e.columnField}),n={...e.filter||{},...t};return(0,Q.jsx)(st,{open:!0,onClose:()=>S(null),title:h(N,x,e.title||`Details`),target:N?.target??`drawer`,objectName:e.objectName,filter:n,dataSource:i,columns:N?.columns,maxRows:N?.maxRows,report:N?.report})})()]})},yi={breadcrumb:[`Dashboard`,`Configuration`],sections:[{key:`layout`,title:`Layout`,collapsible:!0,fields:[{key:`columns`,label:`Columns`,type:`slider`,defaultValue:3,min:1,max:12,step:1},{key:`gap`,label:`Gap`,type:`slider`,defaultValue:4,min:0,max:16,step:1},{key:`rowHeight`,label:`Row height (px)`,type:`slider`,defaultValue:120,min:40,max:320,step:10}]},{key:`data`,title:`Data`,collapsible:!0,fields:[{key:`refreshInterval`,label:`Auto refresh`,type:`select`,defaultValue:`0`,options:[{value:`0`,label:`Off`},{value:`30`,label:`Every 30s`},{value:`60`,label:`Every 1 min`},{value:`300`,label:`Every 5 min`},{value:`900`,label:`Every 15 min`},{value:`1800`,label:`Every 30 min`},{value:`3600`,label:`Every 1 hour`}]}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Dashboard title`},{key:`description`,label:`Description`,type:`textarea`,placeholder:`Short summary shown under the title`},{key:`showDescription`,label:`Show description`,type:`switch`,defaultValue:!0},{key:`theme`,label:`Theme`,type:`select`,defaultValue:`auto`,options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`auto`,label:`Auto`}]}]}]};function bi({open:e,onClose:t,config:n,onSave:r,onFieldChange:i}){let{draft:a,isDirty:o,updateField:s,discard:c}=B(n,{onUpdate:i});return(0,Q.jsx)(M,{open:e,onClose:t,schema:yi,draft:a,isDirty:o,onFieldChange:s,onSave:()=>r(a),onDiscard:c})}var xi=[{value:`metric`,label:`Metric`},{value:`bar`,label:`Bar Chart`},{value:`horizontal-bar`,label:`Horizontal Bar`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`donut`,label:`Donut Chart`},{value:`area`,label:`Area Chart`},{value:`scatter`,label:`Scatter Plot`},{value:`funnel`,label:`Funnel`},{value:`table`,label:`Table`},{value:`pivot`,label:`Pivot Table`}],Si=[{value:`default`,label:`Default`},{value:`blue`,label:`Blue`},{value:`teal`,label:`Teal`},{value:`orange`,label:`Orange`},{value:`purple`,label:`Purple`},{value:`success`,label:`Success`},{value:`warning`,label:`Warning`},{value:`danger`,label:`Danger`}],Ci=[{value:`count`,label:`Count`},{value:`sum`,label:`Sum`},{value:`avg`,label:`Average`},{value:`min`,label:`Min`},{value:`max`,label:`Max`}],wi=[`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`scatter`,`funnel`],Ti=[`bar`,`horizontal-bar`,`line`,`area`,`scatter`],Ei=[`pie`,`donut`,`funnel`],Di=[`metric`,...wi],Oi=[...wi],ki=[`pivot`,`metric`,`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`scatter`,`treemap`,`sankey`,`table`,`list`];function Ai(e){return!!e&&wi.includes(e)}function ji(e){return!!e&&Ti.includes(e)}function Mi(e){return!!e&&Oi.includes(e)}function Ni(e){return!!e&&Di.includes(e)}function Pi(e){return!!e&&ki.includes(e)}var Fi=[{value:`drawer`,label:`Side drawer`},{value:`dialog`,label:`Center dialog`}],Ii=[{value:`group`,label:`Group`},{value:`value`,label:`Value`}],Li=[{value:`asc`,label:`↑`},{value:`desc`,label:`↓`}];function Ri(e,t,n,r){return{key:e,label:t,type:`custom`,render:(i,a,o)=>(0,Q.jsx)(Se,{label:t,children:(0,Q.jsx)(`div`,{"data-testid":`config-field-${e}`,children:(0,Q.jsx)(X,{options:r??[],value:i??``,onValueChange:a,placeholder:n,searchPlaceholder:`Search fields…`,emptyText:`No fields found.`,className:`h-7 w-32 text-xs`,disabled:!o.object})})})}}function zi(e,t,n){let r=e&&e.length>0,i=r?{key:`object`,label:`Data source`,type:`custom`,render:(t,n)=>(0,Q.jsx)(Se,{label:`Data source`,children:(0,Q.jsx)(`div`,{"data-testid":`config-field-object`,children:(0,Q.jsx)(X,{options:e,value:t??``,onValueChange:n,placeholder:`Select object…`,searchPlaceholder:`Search objects…`,emptyText:`No objects found.`,className:`h-7 w-32 text-xs`})})})}:{key:`object`,label:`Data source`,type:`input`,placeholder:`Object name`},a=r?{...Ri(`categoryField`,`Category field`,`Select field…`,t),helpText:`Group records by this field (one bar/slice/segment per value).`,visibleWhen:e=>Mi(e.type)}:{key:`categoryField`,label:`Category field`,type:`input`,placeholder:`e.g. status`,helpText:`Group records by this field (one bar/slice/segment per value).`,visibleWhen:e=>Mi(e.type)},o=r?{...Ri(`valueField`,`Value field`,`Select field…`,t),helpText:`Field to aggregate (sum / average / min / max).`,visibleWhen:e=>Ni(e.type)&&(e.aggregate??`count`)!==`count`}:{key:`valueField`,label:`Value field`,type:`input`,placeholder:`e.g. amount`,helpText:`Field to aggregate (sum / average / min / max).`,visibleWhen:e=>Ni(e.type)&&(e.aggregate??`count`)!==`count`},s=r?Ri(`rowField`,`Field`,`Select row field…`,t):{key:`rowField`,label:`Field`,type:`input`,placeholder:`e.g. owner`},c=r?Ri(`columnField`,`Field`,`Select column field…`,t):{key:`columnField`,label:`Field`,type:`input`,placeholder:`e.g. stage`},l=r?Ri(`valueField`,`Field`,`Select value field…`,t):{key:`valueField`,label:`Field`,type:`input`,placeholder:`e.g. amount`};return{breadcrumb:[`Dashboard`,{pivot:`Pivot table`,table:`Table`}[n??``]??(Ai(n)?`Chart`:`Widget`)],sections:[{key:`general`,title:`General`,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Widget title`},{key:`description`,label:`Description`,type:`input`,placeholder:`Widget description`},{key:`type`,label:`Widget type`,type:`select`,options:xi,defaultValue:`metric`}]},{key:`data`,title:`Data Binding`,collapsible:!0,visibleWhen:e=>e.type!==`pivot`,fields:[i,a,o,{key:`aggregate`,label:`Aggregation`,type:`select`,options:Ci,defaultValue:`count`,helpText:`Count ignores Value field; Sum / Avg / Min / Max require it.`,visibleWhen:e=>Ni(e.type)}]},{key:`pivot-data`,title:`Data`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[i]},{key:`pivot-rows`,title:`Rows`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[s,{key:`rowSortBy`,label:`Sort by`,type:`icon-group`,options:Ii,defaultValue:`group`},{key:`rowSortOrder`,label:`Sort order`,type:`icon-group`,options:Li,defaultValue:`asc`},{key:`showRowLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showRowTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-columns`,title:`Columns`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[c,{key:`columnSortBy`,label:`Sort by`,type:`icon-group`,options:Ii,defaultValue:`group`},{key:`columnSortOrder`,label:`Sort order`,type:`icon-group`,options:Li,defaultValue:`asc`},{key:`showColumnLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showColumnTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-values`,title:`Values`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[l,{key:`aggregation`,label:`Aggregation`,type:`select`,options:Ci,defaultValue:`sum`},{key:`format`,label:`Number format`,type:`input`,placeholder:`e.g. $,.2f`}]},{key:`chart-axis`,title:`Axis & Series`,collapsible:!0,visibleWhen:e=>ji(e.type),fields:[{key:`xAxisLabel`,label:`X-axis label`,type:`input`,placeholder:`e.g. Month`},{key:`yAxisLabel`,label:`Y-axis label`,type:`input`,placeholder:`e.g. Revenue`},{key:`showLegend`,label:`Show legend`,type:`switch`,defaultValue:!0}]},{key:`chart-legend`,title:`Display`,collapsible:!0,visibleWhen:e=>!!e.type&&Ei.includes(e.type),fields:[{key:`showLegend`,label:`Show legend`,type:`switch`,defaultValue:!0}]},{key:`table-options`,title:`Table options`,collapsible:!0,visibleWhen:e=>e.type===`table`,fields:[{key:`searchable`,label:`Searchable`,type:`switch`,defaultValue:!1},{key:`pagination`,label:`Pagination`,type:`switch`,defaultValue:!1}]},{key:`layout`,title:`Layout`,collapsible:!0,fields:[{key:`layoutW`,label:`Width (columns)`,type:`slider`,min:1,max:12,step:1,defaultValue:1},{key:`layoutH`,label:`Height (rows)`,type:`slider`,min:1,max:6,step:1,defaultValue:1}]},{key:`drill-down`,title:`Drill-down`,collapsible:!0,defaultCollapsed:!0,visibleWhen:e=>Pi(e.type),fields:[{key:`drillDownEnabled`,label:`Enable drill-down`,type:`switch`,defaultValue:!1,helpText:`When enabled, clicking a chart segment / pivot cell opens a filtered list of underlying records; clicking a table or list row opens that record.`},{key:`drillDownTarget`,label:`Open in`,type:`select`,options:Fi,defaultValue:`drawer`,visibleWhen:e=>!!e.drillDownEnabled}]},{key:`behavior`,title:`Behavior`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`actionUrl`,label:`Click-through URL`,type:`input`,placeholder:`https://...`}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`colorVariant`,label:`Color variant`,type:`select`,options:Si,defaultValue:`default`}]}]}}function Bi(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;return t.defaultValue||t.key||``}return String(e)}function Vi(e){let t=e.type,n={...e};return Mi(t)||delete n.categoryField,Ni(t)?(n.aggregate??`count`)===`count`&&delete n.valueField:(delete n.valueField,delete n.aggregate),ji(t)||(delete n.xAxisLabel,delete n.yAxisLabel),t===`pivot`?(delete n.aggregate,delete n.categoryField):(delete n.rowField,delete n.columnField,delete n.aggregation,delete n.rowSortBy,delete n.rowSortOrder,delete n.columnSortBy,delete n.columnSortOrder,delete n.showRowLabels,delete n.showRowTotals,delete n.showColumnLabels,delete n.showColumnTotals,delete n.format),t!==`table`&&(delete n.searchable,delete n.pagination),Pi(t)||(delete n.drillDownEnabled,delete n.drillDownTarget),n}function Hi({open:e,onClose:t,config:n,onSave:r,onFieldChange:i,headerExtra:a,availableObjects:o,availableFields:s}){let{draft:c,isDirty:l,updateField:u,discard:d}=B(Z.useMemo(()=>({...n,title:typeof n.title==`object`?Bi(n.title):n.title,description:typeof n.description==`object`?Bi(n.description):n.description}),[n]),{onUpdate:i});return(0,Q.jsx)(M,{open:e,onClose:t,schema:Z.useMemo(()=>zi(o,s,c.type),[o,s,c.type]),draft:c,isDirty:l,onFieldChange:u,onSave:()=>r(Vi(c)),onDiscard:d,headerExtra:a})}function Ui({schema:e,config:t,onConfigSave:n,onWidgetSave:r,onRefresh:i,recordCount:a,defaultConfigOpen:o=!1,className:s}){let[c,l]=(0,Z.useState)(o),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(e),[m,h]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{p(e),h(e=>e+1)},[e]);let g=Z.useMemo(()=>{if(!u||!f.widgets)return null;let e=f.widgets.find(e=>(e.id||e.title)===u);if(!e)return null;let t=e.options||{};return{...t,id:e.id??``,title:e.title??``,description:e.description??``,type:e.type??``,object:e.object??``,categoryField:e.categoryField??t.categoryField??``,valueField:e.valueField??t.valueField??``,aggregate:e.aggregate??t.aggregate??``,colorVariant:e.colorVariant??t.colorVariant??`default`,actionUrl:e.actionUrl??t.actionUrl??``,drillDownEnabled:t.drillDown?.enabled??!!(e.object&&(e.type===`pivot`||e.type===`metric`||e.type===`bar`||e.type===`horizontal-bar`||e.type===`line`||e.type===`area`||e.type===`pie`||e.type===`donut`||e.type===`funnel`)),drillDownTarget:t.drillDown?.target??`drawer`,layoutW:e.layout?.w??1,layoutH:e.layout?.h??1}},[u,m]),_=(0,Z.useCallback)(e=>{d(e),l(!0)},[]),v=(0,Z.useCallback)(()=>{d(null)},[]),y=(0,Z.useCallback)((e,t)=>{u&&p(n=>n.widgets?{...n,widgets:n.widgets.map(n=>{if((n.id||n.title)!==u)return n;if(e===`layoutW`)return{...n,layout:{...n.layout||{},w:t}};if(e===`layoutH`)return{...n,layout:{...n.layout||{},h:t}};if(e===`drillDownEnabled`||e===`drillDownTarget`){let r=n.options?.drillDown??{},i=e===`drillDownEnabled`?{...r,enabled:!!t}:{...r,target:t};return{...n,options:{...n.options||{},drillDown:i}}}return{...n,[e]:t}})}:n)},[u]),b=(0,Z.useCallback)(e=>{if(u&&r){let{drillDownEnabled:t,drillDownTarget:n,...i}=e,a={...i};(t||n)&&(a.options={...i.options||{},drillDown:{...i.options?.drillDown||{},...t===void 0?{}:{enabled:!!t},...n===void 0?{}:{target:n}}}),r(u,a)}d(null),h(e=>e+1)},[u,r]),x=(0,Z.useCallback)(()=>{l(e=>!e),d(null)},[]);return(0,Q.jsxs)(`div`,{className:R(`flex h-full w-full`,s),"data-testid":`dashboard-with-config`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-auto relative`,children:[(0,Q.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,Q.jsxs)(H,{size:`sm`,variant:c?`default`:`outline`,onClick:x,"data-testid":`dashboard-config-toggle`,children:[(0,Q.jsx)(he,{className:`h-3.5 w-3.5 mr-1`}),`Settings`]})}),(0,Q.jsx)(Et,{schema:f,onRefresh:i,recordCount:a,designMode:c,selectedWidgetId:u,onWidgetClick:_})]}),c&&(0,Q.jsx)(`div`,{className:`relative shrink-0`,children:u&&g?(0,Q.jsx)(Hi,{open:!0,onClose:v,config:g,onSave:b,onFieldChange:y}):(0,Q.jsx)(bi,{open:!0,onClose:()=>l(!1),config:t,onSave:n})})]})}var Wi=t({DashboardConfigPanel:()=>bi,DashboardGridLayout:()=>ei,DashboardRenderer:()=>Et,DashboardWithConfig:()=>Ui,DrillDownDrawer:()=>st,MetricCard:()=>li,MetricWidget:()=>si,ObjectDataTable:()=>at,ObjectMetricWidget:()=>ui,ObjectPivotTable:()=>vi,PivotTable:()=>_i,WidgetConfigPanel:()=>Hi,dashboardComponents:()=>Gi});y.register(`dashboard`,Et,{namespace:`view`,label:`Dashboard`,category:`Complex`,icon:`layout-dashboard`,inputs:[{name:`columns`,type:`number`,label:`Columns`,defaultValue:3},{name:`gap`,type:`number`,label:`Gap`,defaultValue:4},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:3,widgets:[]}}),y.register(`metric`,si,{namespace:`plugin-dashboard`,label:`Metric Widget`,category:`Dashboard`,inputs:[{name:`label`,type:`string`,label:`Label`},{name:`value`,type:`string`,label:`Value`}]}),y.register(`metric-card`,li,{namespace:`plugin-dashboard`,label:`Metric Card`,category:`Dashboard`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`value`,type:`string`,label:`Value`,required:!0},{name:`icon`,type:`string`,label:`Icon (Lucide name)`},{name:`trend`,type:`enum`,label:`Trend`,enum:[{label:`Up`,value:`up`},{label:`Down`,value:`down`},{label:`Neutral`,value:`neutral`}]},{name:`trendValue`,type:`string`,label:`Trend Value (e.g., +12%)`},{name:`description`,type:`string`,label:`Description`}],defaultProps:{title:`Metric`,value:`0`}}),y.register(`object-metric`,ui,{namespace:`plugin-dashboard`,label:`Object Metric`,category:`Dashboard`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`label`,type:`string`,label:`Label`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`},{name:`icon`,type:`string`,label:`Icon (Lucide name)`}],defaultProps:{label:`Metric`}}),y.register(`pivot`,_i,{namespace:`plugin-dashboard`,label:`Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`,data:[]}}),y.register(`object-pivot`,vi,{namespace:`plugin-dashboard`,label:`Object Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`filter`,type:`array`,label:`Filter`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`}}),y.register(`dashboard-grid`,ei,{namespace:`plugin-dashboard`,label:`Dashboard Grid (Editable)`,category:`Complex`,icon:`layout-grid`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{title:`Dashboard`,widgets:[]}}),y.register(`object-data-table`,at,{namespace:`plugin-dashboard`,label:`Object Data Table`,category:`Dashboard`,icon:`table`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`searchable`,type:`boolean`,label:`Searchable`},{name:`pagination`,type:`boolean`,label:`Pagination`}],defaultProps:{searchable:!1,pagination:!1}});var Gi={DashboardRenderer:Et,DashboardGridLayout:ei,MetricWidget:si,MetricCard:li,ObjectMetricWidget:ui,PivotTable:_i,ObjectPivotTable:vi,ObjectDataTable:at,DashboardConfigPanel:bi,WidgetConfigPanel:Hi,DashboardWithConfig:Ui};export{Et as n,st as r,Wi as t};
6
+ `,e.getElementsByTagName(`head`)[0].appendChild(n)}e.body&&oe(e.body,`react-draggable-transparent-selection`)}function B(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{V(e)}):V(e)}function V(e){if(e)try{e.body&&se(e.body,`react-draggable-transparent-selection`);let t=e.selection;if(t)t.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function oe(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function se(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}function ce(e,t,n){if(!e.props.bounds)return[t,n];let{bounds:r}=e.props;r=typeof r==`string`?r:K(r);let i=q(e);if(typeof r==`string`){let{ownerDocument:e}=i,t=e.defaultView;if(!t)throw Error(`Cannot resolve the owner window of the draggable node.`);let n;if(n=r===`parent`?i.parentNode:i.getRootNode().querySelector(r),!(n instanceof t.HTMLElement))throw Error(`Bounds selector "`+r+`" could not find an element.`);let a=n,o=t.getComputedStyle(i),s=t.getComputedStyle(a);r={left:-i.offsetLeft+S(s.paddingLeft)+S(o.marginLeft),top:-i.offsetTop+S(s.paddingTop)+S(o.marginTop),right:F(a)-N(i)-i.offsetLeft+S(s.paddingRight)-S(o.marginRight),bottom:P(a)-te(i)-i.offsetTop+S(s.paddingBottom)-S(o.marginBottom)}}return x(r.right)&&(t=Math.min(t,r.right)),x(r.bottom)&&(n=Math.min(n,r.bottom)),x(r.left)&&(t=Math.max(t,r.left)),x(r.top)&&(n=Math.max(n,r.top)),[t,n]}function H(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function U(e){return e.props.axis===`both`||e.props.axis===`x`}function le(e){return e.props.axis===`both`||e.props.axis===`y`}function ue(e,t,n){let r=typeof t==`number`?L(e,t):null;if(typeof t==`number`&&!r)return null;let i=q(n),a=n.props.offsetParent||i.offsetParent||i.ownerDocument.body;return I(r||e,a,n.props.scale)}function W(e,t,n){let r=!x(e.lastX),i=q(e);return r?{node:i,deltaX:0,deltaY:0,lastX:t,lastY:n,x:t,y:n}:{node:i,deltaX:t-e.lastX,deltaY:n-e.lastY,lastX:e.lastX,lastY:e.lastY,x:t,y:n}}function G(e,t){let n=e.props.scale;return{node:t.node,x:e.state.x+t.deltaX/n,y:e.state.y+t.deltaY/n,deltaX:t.deltaX/n,deltaY:t.deltaY/n,lastX:e.state.x,lastY:e.state.y}}function K(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function q(e){let t=e.findDOMNode();if(!t)throw Error(`<DraggableCore>: Unmounted during event!`);return t}var de=f(r()),J=f(Rn()),fe=f(i());function pe(...e){({}).DRAGGABLE_DEBUG&&console.log(...e)}var Y={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},X=Y.mouse,me=class extends de.Component{constructor(){super(...arguments),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,this.touchIdentifier=null,this.mounted=!1,this.handleDragStart=e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&(typeof e.button==`number`&&e.button!==0||e.ctrlKey))return!1;let t=this.findDOMNode();if(!t||!t.ownerDocument||!t.ownerDocument.body)throw Error(`<DraggableCore> not mounted on DragStart!`);let{ownerDocument:n}=t;if(this.props.disabled||!(e.target instanceof n.defaultView.Node)||this.props.handle&&!A(e.target,this.props.handle,t)||this.props.cancel&&A(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=ae(e);this.touchIdentifier=r;let i=ue(e,r,this);if(i==null)return;let{x:a,y:o}=i,s=W(this,a,o);pe(`DraggableCore: handleDragStart: %j`,s),pe(`calling`,this.props.onStart),!(this.props.onStart(e,s)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&z(n,this.props.nonce),this.dragging=!0,this.lastX=a,this.lastY=o,j(n,X.move,this.handleDrag),j(n,X.stop,this.handleDragStop))},this.handleDrag=e=>{let t=ue(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX,t=r-this.lastY;if([e,t]=H(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=W(this,n,r);if(pe(`DraggableCore: handleDrag: %j`,i),this.props.onDrag(e,i)===!1||this.mounted===!1){try{this.handleDragStop(new MouseEvent(`mouseup`))}catch{let e=document.createEvent(`MouseEvents`);e.initMouseEvent(`mouseup`,!0,!0,window,0,0,0,0,0,!1,!1,!1,!1,0,null),this.handleDragStop(e)}return}this.lastX=n,this.lastY=r},this.handleDragStop=e=>{if(!this.dragging)return;let t=ue(e,this.touchIdentifier,this);if(t==null)return;let{x:n,y:r}=t;if(Array.isArray(this.props.grid)){let e=n-this.lastX||0,t=r-this.lastY||0;[e,t]=H(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=W(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&B(a.ownerDocument),pe(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&(pe(`DraggableCore: Removing handlers`),M(a.ownerDocument,X.move,this.handleDrag),M(a.ownerDocument,X.stop,this.handleDragStop))},this.onMouseDown=e=>(X=Y.mouse,this.handleDragStart(e)),this.onMouseUp=e=>(X=Y.mouse,this.handleDragStop(e)),this.onTouchStart=e=>(X=Y.touch,this.handleDragStart(e)),this.onTouchEnd=e=>(X=Y.touch,this.handleDragStop(e))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&j(e,Y.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;M(t,Y.mouse.move,this.handleDrag),M(t,Y.touch.move,this.handleDrag),M(t,Y.mouse.stop,this.handleDragStop),M(t,Y.touch.stop,this.handleDragStop),M(e,Y.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&B(t)}}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=fe.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):(pe(`react-draggable: ReactDOM.findDOMNode is not available in React 19+. You must provide a nodeRef prop. See: https://github.com/react-grid-layout/react-draggable#noderef`),null)}render(){return de.cloneElement(de.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};me.displayName=`DraggableCore`,me.propTypes={allowAnyClick:J.default.bool,allowMobileScroll:J.default.bool,children:J.default.node.isRequired,disabled:J.default.bool,enableUserSelectHack:J.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:J.default.arrayOf(J.default.number),handle:J.default.string,cancel:J.default.string,nodeRef:J.default.object,nonce:J.default.string,onStart:J.default.func,onDrag:J.default.func,onStop:J.default.func,onMouseDown:J.default.func,scale:J.default.number,className:C,style:C,transform:C},me.defaultProps={allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1};var he=class extends h.Component{constructor(e){super(e),this.onDragStart=(e,t)=>{if(pe(`Draggable: onDragStart: %j`,t),this.props.onStart(e,G(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})},this.onDrag=(e,t)=>{if(!this.state.dragging)return!1;pe(`Draggable: onDrag: %j`,t);let n=G(this,t),r={x:n.x,y:n.y,slackX:0,slackY:0};if(this.props.bounds){let{x:e,y:t}=r;r.x+=this.state.slackX,r.y+=this.state.slackY;let[i,a]=ce(this,r.x,r.y);r.x=i,r.y=a,r.slackX=this.state.slackX+(e-r.x),r.slackY=this.state.slackY+(t-r.y),n.x=r.x,n.y=r.y,n.deltaX=r.x-this.state.x,n.deltaY=r.y-this.state.y}if(this.props.onDrag(e,n)===!1)return!1;this.setState(r)},this.onDragStop=(e,t)=>{if(!this.state.dragging||this.props.onStop(e,G(this,t))===!1)return!1;pe(`Draggable: onDragStop: %j`,t);let n={dragging:!1,slackX:0,slackY:0};if(this.props.position){let{x:e,y:t}=this.props.position;n.x=e,n.y=t}this.setState(n)},this.state={dragging:!1,dragged:!1,x:e.position?e.position.x:e.defaultPosition.x,y:e.position?e.position.y:e.defaultPosition.y,prevPropsPosition:{...e.position},slackX:0,slackY:0,isElementSVG:!1},e.position&&!(e.onDrag||e.onStop)&&console.warn("A `position` was applied to this <Draggable>, without drag handlers. This will make this component effectively undraggable. Please attach `onDrag` or `onStop` handlers so you can adjust the `position` of this element.")}static getDerivedStateFromProps({position:e},{prevPropsPosition:t}){return e&&(!t||e.x!==t.x||e.y!==t.y)?(pe(`Draggable: getDerivedStateFromProps %j`,{position:e,prevPropsPosition:t}),{x:e.x,y:e.y,prevPropsPosition:{...e}}):null}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){if(this.props?.nodeRef)return this.props.nodeRef.current;let e=_.default;return typeof e.findDOMNode==`function`?e.findDOMNode(this):null}render(){let{axis:e,bounds:t,children:n,defaultPosition:r,defaultClassName:i,defaultClassNameDragging:a,defaultClassNameDragged:o,position:s,positionOffset:c,scale:l,...u}=this.props,d={},f=null,p=!s||this.state.dragging,m=s||r,g={x:U(this)&&p?this.state.x:m.x,y:le(this)&&p?this.state.y:m.y};this.state.isElementSVG?f=re(g,c):d=ne(g,c);let _=h.Children.only(n),y=(0,v.clsx)(_.props.className||``,i,{[a]:this.state.dragging,[o]:this.state.dragged});return h.createElement(me,{...u,onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop},h.cloneElement(_,{className:y,style:{..._.props.style,...d},transform:f}))}};he.displayName=`Draggable`,he.propTypes={...me.propTypes,axis:g.default.oneOf([`both`,`x`,`y`,`none`]),bounds:g.default.oneOfType([g.default.shape({left:g.default.number,right:g.default.number,top:g.default.number,bottom:g.default.number}),g.default.string,g.default.oneOf([!1])]),defaultClassName:g.default.string,defaultClassNameDragging:g.default.string,defaultClassNameDragged:g.default.string,defaultPosition:g.default.shape({x:g.default.number,y:g.default.number}),positionOffset:g.default.shape({x:g.default.oneOfType([g.default.number,g.default.string]),y:g.default.oneOfType([g.default.number,g.default.string])}),position:g.default.shape({x:g.default.number,y:g.default.number}),className:C,style:C,transform:C},he.defaultProps={...me.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1},0&&(t.exports={DraggableCore:me})})),jr=n(((e,t)=>{var n=Ar(),r=n.DraggableCore,i=n.default||n;t.exports=i,t.exports.default=i,t.exports.DraggableCore=r})),Mr=n((e=>{e.__esModule=!0,e.cloneElement=l;var t=n(r());function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function a(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?i(Object(n),!0).forEach(function(t){o(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):i(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function o(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e){var t=c(e,`string`);return typeof t==`symbol`?t:t+``}function c(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function l(e,n){return n.style&&e.props.style&&(n.style=a(a({},e.props.style),n.style)),n.className&&e.props.className&&(n.className=e.props.className+` `+n.className),t.default.cloneElement(e,n)}})),Nr=n((e=>{e.__esModule=!0,e.resizableProps=void 0;var t=n(Rn());jr();function n(e){return e&&e.__esModule?e:{default:e}}e.resizableProps={axis:t.default.oneOf([`both`,`x`,`y`,`none`]),className:t.default.string,children:t.default.element.isRequired,draggableOpts:t.default.shape({allowAnyClick:t.default.bool,cancel:t.default.string,children:t.default.node,disabled:t.default.bool,enableUserSelectHack:t.default.bool,offsetParent:typeof Element<`u`?t.default.instanceOf(Element):t.default.any,grid:t.default.arrayOf(t.default.number),handle:t.default.string,nodeRef:t.default.object,onStart:t.default.func,onDrag:t.default.func,onStop:t.default.func,onMouseDown:t.default.func,scale:t.default.number}),height:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`y`?t.default.number.isRequired(...e):t.default.number(...e)},handle:t.default.oneOfType([t.default.node,t.default.func]),handleSize:t.default.arrayOf(t.default.number),lockAspectRatio:t.default.bool,maxConstraints:t.default.arrayOf(t.default.number),minConstraints:t.default.arrayOf(t.default.number),onResizeStop:t.default.func,onResizeStart:t.default.func,onResize:t.default.func,resizeHandles:t.default.arrayOf(t.default.oneOf([`s`,`w`,`e`,`n`,`sw`,`nw`,`se`,`ne`])),transformScale:t.default.number,width:function(){var e=[...arguments];let n=e[0];return n.axis===`both`||n.axis===`x`?t.default.number.isRequired(...e):t.default.number(...e)}}})),Pr=n((e=>{e.__esModule=!0,e.default=void 0;var t=s(r()),n=jr(),i=Mr(),a=Nr(),o=[`children`,`className`,`draggableOpts`,`width`,`height`,`handle`,`handleSize`,`lockAspectRatio`,`axis`,`minConstraints`,`maxConstraints`,`onResize`,`onResizeStop`,`onResizeStart`,`resizeHandles`,`transformScale`];function s(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(s=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(null,arguments)}function l(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?u(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=m(e,`string`);return typeof t==`symbol`?t:t+``}function m(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var h=class extends t.Component{constructor(){super(...arguments),this.handleRefs={},this.lastHandleRect=null,this.slack=null,this.lastSize=null}componentWillUnmount(){this.resetData()}resetData(){this.lastHandleRect=this.slack=this.lastSize=null}runConstraints(e,t){let n=this.props,r=n.minConstraints,i=n.maxConstraints,a=n.lockAspectRatio;if(!r&&!i&&!a)return[e,t];if(a){let n=this.props.width/this.props.height,r=e-this.props.width,i=t-this.props.height;Math.abs(r)>Math.abs(i*n)?t=e/n:e=t*n}let o=e,s=t,c=this.slack||[0,0],l=c[0],u=c[1];return e+=l,t+=u,r&&(e=Math.max(r[0],e),t=Math.max(r[1],t)),i&&(e=Math.min(i[0],e),t=Math.min(i[1],t)),this.slack=[l+(o-e),u+(s-t)],[e,t]}resizeHandler(e,t){return(n,r)=>{let i=r.node,a=r.deltaX,o=r.deltaY;e===`onResizeStart`&&this.resetData();let s=(this.props.axis===`both`||this.props.axis===`x`)&&t!==`n`&&t!==`s`,c=(this.props.axis===`both`||this.props.axis===`y`)&&t!==`e`&&t!==`w`;if(!s&&!c)return;let l=t[0],u=t[t.length-1],d=i.getBoundingClientRect();if(this.lastHandleRect!=null){if(u===`w`){let e=d.left-this.lastHandleRect.left;a+=e}if(l===`n`){let e=d.top-this.lastHandleRect.top;o+=e}}this.lastHandleRect=d,u===`w`&&(a=-a),l===`n`&&(o=-o);let f=this.lastSize?.width??this.props.width,p=this.lastSize?.height??this.props.height,m=f+(s?a/this.props.transformScale:0),h=p+(c?o/this.props.transformScale:0);var g=this.runConstraints(m,h);if(m=g[0],h=g[1],e===`onResizeStop`&&this.lastSize){var _=this.lastSize;m=_.width,h=_.height}let v=m!==f||h!==p;e!==`onResizeStop`&&(this.lastSize={width:m,height:h});let y=typeof this.props[e]==`function`?this.props[e]:null;y&&!(e===`onResize`&&!v)&&(n.persist==null||n.persist(),y(n,{node:i,size:{width:m,height:h},handle:t})),e===`onResizeStop`&&this.resetData()}}renderResizeHandle(e,n){let r=this.props.handle;if(!r)return t.createElement(`span`,{className:`react-resizable-handle react-resizable-handle-`+e,ref:n});if(typeof r==`function`)return r(e,n);let i=typeof r.type==`string`,a=d({ref:n},i?{}:{handleAxis:e});return t.cloneElement(r,a)}render(){let e=this.props,r=e.children,a=e.className,s=e.draggableOpts;e.width,e.height,e.handle,e.handleSize,e.lockAspectRatio,e.axis,e.minConstraints,e.maxConstraints,e.onResize,e.onResizeStop,e.onResizeStart;let u=e.resizeHandles;e.transformScale;let f=l(e,o);return(0,i.cloneElement)(r,d(d({},f),{},{className:(a?a+` `:``)+`react-resizable`,children:[...t.Children.toArray(r.props.children),...u.map(e=>{let r=this.handleRefs[e]??(this.handleRefs[e]=t.createRef());return t.createElement(n.DraggableCore,c({},s,{nodeRef:r,key:`resizableHandle-`+e,onStop:this.resizeHandler(`onResizeStop`,e),onStart:this.resizeHandler(`onResizeStart`,e),onDrag:this.resizeHandler(`onResize`,e)}),this.renderResizeHandle(e,r))})]}))}};e.default=h,h.propTypes=a.resizableProps,h.defaultProps={axis:`both`,handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:[`se`],transformScale:1}})),Fr=n((e=>{e.__esModule=!0,e.default=void 0;var t=c(r()),n=s(Rn()),i=s(Pr()),a=Nr(),o=[`handle`,`handleSize`,`onResize`,`onResizeStart`,`onResizeStop`,`draggableOpts`,`minConstraints`,`maxConstraints`,`lockAspectRatio`,`axis`,`width`,`height`,`resizeHandles`,`style`,`transformScale`];function s(e){return e&&e.__esModule?e:{default:e}}function c(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(c=function(e,t){if(!t&&e&&e.__esModule)return e;var i,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(i=t?r:n){if(i.has(e))return i.get(e);i.set(e,o)}for(let t in e)t!=="default"&&{}.hasOwnProperty.call(e,t)&&((a=(i=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?i(o,t,a):o[t]=e[t]);return o})(e,t)}function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},l.apply(null,arguments)}function u(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function d(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?u(Object(n),!0).forEach(function(t){f(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):u(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function f(e,t,n){return(t=p(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function p(e){var t=m(e,`string`);return typeof t==`symbol`?t:t+``}function m(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function h(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var g=class extends t.Component{constructor(){super(...arguments),this.state={width:this.props.width,height:this.props.height,propsWidth:this.props.width,propsHeight:this.props.height},this.onResize=(e,t)=>{let n=t.size;this.props.onResize?(e.persist==null||e.persist(),this.setState(n,()=>this.props.onResize&&this.props.onResize(e,t))):this.setState(n)}}static getDerivedStateFromProps(e,t){return t.propsWidth!==e.width||t.propsHeight!==e.height?{width:e.width,height:e.height,propsWidth:e.width,propsHeight:e.height}:null}render(){let e=this.props,n=e.handle,r=e.handleSize;e.onResize;let a=e.onResizeStart,s=e.onResizeStop,c=e.draggableOpts,u=e.minConstraints,f=e.maxConstraints,p=e.lockAspectRatio,m=e.axis;e.width,e.height;let g=e.resizeHandles,_=e.style,v=e.transformScale,y=h(e,o);return t.createElement(i.default,{axis:m,draggableOpts:c,handle:n,handleSize:r,height:this.state.height,lockAspectRatio:p,maxConstraints:f,minConstraints:u,onResizeStart:a,onResize:this.onResize,onResizeStop:s,resizeHandles:g,transformScale:v,width:this.state.width},t.createElement(`div`,l({},y,{style:d(d({},_),{},{width:this.state.width+`px`,height:this.state.height+`px`})})))}};e.default=g,g.propTypes=d(d({},a.resizableProps),{},{children:n.default.element})})),Ir=n(((e,t)=>{t.exports=function(){throw Error(`Don't instantiate Resizable directly! Use require('react-resizable').Resizable`)},t.exports.Resizable=Pr().default,t.exports.ResizableBox=Fr().default}))(),Lr=Pn();function Rr(e){let{children:t,cols:n,containerWidth:r,margin:i,containerPadding:a,rowHeight:o,maxRows:s,isDraggable:c,isResizable:l,isBounded:u,static:d,useCSSTransforms:f=!0,usePercentages:p=!1,transformScale:m=1,positionStrategy:h,dragThreshold:g=0,droppingPosition:_,className:v=``,style:y,handle:b=``,cancel:x=``,x:S,y:C,w,h:T,minW:E=1,maxW:ee=1/0,minH:D=1,maxH:O=1/0,i:k,resizeHandles:A,resizeHandle:j,constraints:M=Zt,layoutItem:te,layout:N=[],onDragStart:P,onDrag:F,onDragStop:I,onResizeStart:ne,onResize:re,onResizeStop:ie}=e,[L,ae]=(0,Z.useState)(!1),[R,z]=(0,Z.useState)(!1),B=(0,Z.useRef)(null),V=(0,Z.useRef)({left:0,top:0}),oe=(0,Z.useRef)({top:0,left:0,width:0,height:0}),se=(0,Z.useRef)(void 0),ce=(0,Z.useRef)(N);ce.current=N;let H=(0,Z.useRef)(null),U=(0,Z.useRef)(null),le=(0,Z.useRef)(!1),ue=(0,Z.useRef)({x:0,y:0}),W=(0,Z.useRef)(!1),G=(0,Z.useMemo)(()=>({cols:n,containerPadding:a,containerWidth:r,margin:i,maxRows:s,rowHeight:o}),[n,a,r,i,s,o]),K=(0,Z.useMemo)(()=>({cols:n,maxRows:s,containerWidth:r,containerHeight:0,rowHeight:o,margin:i,layout:[]}),[n,s,r,o,i]),q=(0,Z.useCallback)(()=>({...K,layout:ce.current}),[K]),de=(0,Z.useMemo)(()=>te??{i:k,x:S,y:C,w,h:T,minW:E,maxW:ee,minH:D,maxH:O},[te,k,S,C,w,T,E,ee,D,O]),J=(0,Z.useCallback)(e=>{if(h?.calcStyle)return h.calcStyle(e);if(f)return en(e);let t=tn(e);return p?{...t,left:nn(e.left/r),width:nn(e.width/r)}:t},[h,f,p,r]),fe=(0,Z.useCallback)((e,{node:t})=>{if(!P)return;let{offsetParent:n}=t;if(!n)return;let r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),a=i.left/m,o=r.left/m,s=i.top/m,c=r.top/m,l;if(h?.calcDragPosition){let t=e;l=h.calcDragPosition(t.clientX,t.clientY,t.clientX-i.left,t.clientY-i.top)}else l={left:a-o+n.scrollLeft,top:s-c+n.scrollTop};if(V.current=l,g>0){let t=e;ue.current={x:t.clientX,y:t.clientY},le.current=!0,W.current=!1,ae(!0);return}ae(!0);let u=jt(G,l.top,l.left),{x:d,y:f}=Qt(M,de,u.x,u.y,q());P(k,d,f,{e,node:t,newPosition:l})},[P,m,G,h,g,M,de,q,k]),pe=(0,Z.useCallback)((e,{node:t,deltaX:n,deltaY:a})=>{if(!F||!L)return;let s=e;if(le.current&&!W.current){let n=s.clientX-ue.current.x,r=s.clientY-ue.current.y;if(Math.hypot(n,r)<g)return;if(W.current=!0,le.current=!1,P){let n=jt(G,V.current.top,V.current.left),{x:r,y:i}=Qt(M,de,n.x,n.y,q());P(k,r,i,{e,node:t,newPosition:V.current})}}let c=V.current.top+a,l=V.current.left+n;if(u){let{offsetParent:e}=t;if(e){let t=e.clientHeight-Ot(T,o,i[1]);c=Nt(c,0,t);let n=r-Ot(w,Dt(G),i[0]);l=Nt(l,0,n)}}let d={top:c,left:l};V.current=d;let f=jt(G,c,l),{x:p,y:m}=Qt(M,de,f.x,f.y,q());F(k,p,m,{e,node:t,newPosition:d})},[F,P,L,g,u,T,o,i,G,r,w,k,M,de,q]),Y=(0,Z.useCallback)((e,{node:t})=>{if(!I||!L)return;let n=le.current;if(le.current=!1,W.current=!1,ue.current={x:0,y:0},n){ae(!1),V.current={left:0,top:0};return}let{left:r,top:i}=V.current,a={top:i,left:r};ae(!1),V.current={left:0,top:0};let o=jt(G,i,r),{x:s,y:c}=Qt(M,de,o.x,o.y,q());I(k,s,c,{e,node:t,newPosition:a})},[I,L,G,M,de,q,k]);H.current=fe,U.current=pe;let X=(0,Z.useCallback)((e,{node:t,size:n,handle:i},a,o)=>{let s=o===`onResizeStart`?ne:o===`onResize`?re:ie;if(!s)return;let c;c=t?pn(i,a,n,r):{...n,top:a.top,left:a.left},oe.current=c;let l=Mt(G,c.width,c.height),{w:u,h:d}=$t(M,de,l.w,l.h,i,q());s(k,u,d,{e:e.nativeEvent,node:t,size:c,handle:i})},[ne,re,ie,r,G,k,M,de,q]),me=(0,Z.useCallback)((e,t)=>{z(!0);let n=kt(G,S,C,w,T);X(e,{...t,handle:t.handle},n,`onResizeStart`)},[X,G,S,C,w,T]),he=(0,Z.useCallback)((e,t)=>{let n=kt(G,S,C,w,T);X(e,{...t,handle:t.handle},n,`onResize`)},[X,G,S,C,w,T]),ge=(0,Z.useCallback)((e,t)=>{z(!1),oe.current={top:0,left:0,width:0,height:0};let n=kt(G,S,C,w,T);X(e,{...t,handle:t.handle},n,`onResizeStop`)},[X,G,S,C,w,T]);(0,Z.useEffect)(()=>{if(!_)return;let e=B.current;if(!e)return;let t=se.current||{left:0,top:0},n=L&&(_.left!==t.left||_.top!==t.top);if(!L){let t={node:e,deltaX:_.left,deltaY:_.top,lastX:0,lastY:0,x:_.left,y:_.top};H.current?.(_.e,t)}else if(n){let t={node:e,deltaX:_.left-V.current.left,deltaY:_.top-V.current.top,lastX:V.current.left,lastY:V.current.top,x:_.left,y:_.top};U.current?.(_.e,t)}se.current=_},[_,L,k]);let _e=kt(G,S,C,w,T,L?V.current:null,R?oe.current:null),ve=Z.Children.only(t),ye=Dt(G),be=[Ot(E,ye,i[0]),Ot(D,o,i[1])],xe=[Ot(ee,ye,i[0]),Ot(O,o,i[1])],Se=ve.props,Ce=Se.className,we=Se.style,Te=Z.cloneElement(ve,{ref:B,className:Ae(`react-grid-item`,Ce,v,{static:d,resizing:R,"react-draggable":c,"react-draggable-dragging":L,dropping:!!_,cssTransforms:f}),style:{...y,...we,...J(_e)}}),Ee=j;return Te=(0,Q.jsx)(Ir.Resizable,{draggableOpts:{disabled:!l},className:l?void 0:`react-resizable-hide`,width:_e.width,height:_e.height,minConstraints:be,maxConstraints:xe,onResizeStart:me,onResize:he,onResizeStop:ge,transformScale:m,resizeHandles:A,handle:Ee,children:Te}),Te=(0,Q.jsx)(Or,{disabled:!c,onStart:fe,onDrag:pe,onStop:Y,handle:b,cancel:`.react-resizable-handle`+(x?`,`+x:``),scale:m,nodeRef:B,children:Te}),Te}var zr=()=>{},Br=`react-grid-layout`,Vr=!1;try{Vr=/firefox/i.test(navigator.userAgent)}catch{}function Hr(e,t){let n=Z.Children.toArray(e),r=Z.Children.toArray(t);if(n.length!==r.length)return!1;for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(t?.key!==i?.key)return!1}return!0}function Ur(e,t,n,r){let i=[],a=new Set;Z.Children.forEach(t,t=>{if(!Z.isValidElement(t)||t.key===null)return;let n=String(t.key);a.add(n);let r=e.find(e=>e.i===n);if(r)i.push(Ut(r));else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:Bt(i),w:1,h:1})}});let o=qt(i,{cols:n});return r.compact(o,n)}function Wr(e){let{children:t,width:n,gridConfig:r,dragConfig:i,resizeConfig:a,dropConfig:o,positionStrategy:s=mn,compactor:c,constraints:l=Zt,layout:u=[],droppingItem:d,autoSize:f=!0,className:p=``,style:m={},innerRef:h,onLayoutChange:g=zr,onDragStart:_=zr,onDrag:v=zr,onDragStop:y=zr,onResizeStart:b=zr,onResize:x=zr,onResizeStop:S=zr,onDrop:C=zr,onDropDragOver:w=zr}=e,T=(0,Z.useMemo)(()=>({...hn,...r}),[r]),E=(0,Z.useMemo)(()=>({...gn,...i}),[i]),ee=(0,Z.useMemo)(()=>({..._n,...a}),[a]),D=(0,Z.useMemo)(()=>({...vn,...o}),[o]),{cols:O,rowHeight:k,maxRows:A,margin:j,containerPadding:M}=T,{enabled:te,bounded:N,handle:P,cancel:F,threshold:I}=E,{enabled:ne,handles:re,handleComponent:ie}=ee,{enabled:L,defaultItem:ae,onDragOver:R}=D,z=c??On(`vertical`),B=z.type,V=z.allowOverlap,oe=z.preventCollision??!1,se=(0,Z.useMemo)(()=>d??{i:`__dropping-elem__`,...ae},[d,ae]),ce=s.type===`transform`,H=s.scale,U=M??j,[le,ue]=(0,Z.useState)(!1),[W,G]=(0,Z.useState)(()=>Ur(u,t,O,z)),[K,q]=(0,Z.useState)(null),[de,J]=(0,Z.useState)(!1),[fe,pe]=(0,Z.useState)(null),[Y,X]=(0,Z.useState)(),me=(0,Z.useRef)(null),he=(0,Z.useRef)(null),ge=(0,Z.useRef)(null),_e=(0,Z.useRef)(0),ve=(0,Z.useRef)(W),ye=(0,Z.useRef)(u),be=(0,Z.useRef)(t),xe=(0,Z.useRef)(B),Se=(0,Z.useRef)(W);Se.current=W,(0,Z.useEffect)(()=>{ue(!0),(0,Lr.deepEqual)(W,u)||g(W)},[]),(0,Z.useEffect)(()=>{if(K||fe)return;let e=!(0,Lr.deepEqual)(u,ye.current),n=!Hr(t,be.current),r=B!==xe.current;if(e||n||r){let n=Ur(e?u:W,t,O,z);(0,Lr.deepEqual)(n,W)||G(n)}ye.current=u,be.current=t,xe.current=B},[u,t,O,B,z,K,fe,W]),(0,Z.useEffect)(()=>{!K&&!(0,Lr.deepEqual)(W,ve.current)&&(ve.current=W,g(W.filter(e=>e.i!==se.i)))},[W,K,g,se.i]);let Ce=(0,Z.useMemo)(()=>{if(!f)return;let e=Bt(W),t=U[1];return e*k+(e-1)*j[1]+t*2+`px`},[f,W,k,j,U]),we=(0,Z.useCallback)((e,t,n,r)=>{let i=Se.current,a=Vt(i,e);if(!a)return;let o={w:a.w,h:a.h,x:a.x,y:a.y,i:e};me.current=Ut(a),ge.current=i,q(o),_(i,a,a,null,r.e,r.node)},[_]),Te=(0,Z.useCallback)((e,t,n,r)=>{let i=Se.current,a=me.current,o=Vt(i,e);if(!o)return;let s={w:o.w,h:o.h,x:o.x,y:o.y,i:e},c=Jt(i,o,t,n,!0,oe,B,O,V);v(c,a,o,s,r.e,r.node),G(z.compact(c,O)),q(s)},[oe,B,O,V,z,v]),Ee=(0,Z.useCallback)((e,t,n,r)=>{if(!K)return;let i=Se.current,a=me.current,o=Vt(i,e);if(!o)return;let s=Jt(i,o,t,n,!0,oe,B,O,V),c=z.compact(s,O);y(c,a,o,null,r.e,r.node);let l=ge.current;me.current=null,ge.current=null,q(null),G(c),l&&!(0,Lr.deepEqual)(l,c)&&g(c)},[K,oe,B,O,V,z,y,g]),De=(0,Z.useCallback)((e,t,n,r)=>{let i=Se.current,a=Vt(i,e);a&&(he.current=Ut(a),ge.current=i,J(!0),b(i,a,a,null,r.e,r.node))},[b]),Oe=(0,Z.useCallback)((e,t,n,r)=>{let i=Se.current,a=he.current,{handle:o}=r,s=!1,c,l,[u,d]=Kt(i,e,e=>(c=e.x,l=e.y,[`sw`,`w`,`nw`,`n`,`ne`].includes(o)&&([`sw`,`nw`,`w`].includes(o)&&(c=e.x+(e.w-t),t=e.x!==c&&c<0?e.w:t,c=c<0?0:c),[`ne`,`n`,`nw`].includes(o)&&(l=e.y+(e.h-n),n=e.y!==l&&l<0?e.h:n,l=l<0?0:l),s=!0),oe&&!V&&It(i,{...e,w:t,h:n,x:c??e.x,y:l??e.y}).filter(t=>t.i!==e.i).length>0&&(l=e.y,n=e.h,c=e.x,t=e.w,s=!1),e.w=t,e.h=n,e));if(!d)return;let f=u;s&&c!==void 0&&l!==void 0&&(f=Jt(u,d,c,l,!0,oe,B,O,V));let p={w:d.w,h:d.h,x:d.x,y:d.y,i:e,static:!0};x(f,a,d,p,r.e,r.node),G(z.compact(f,O)),q(p)},[oe,B,O,V,z,x]),ke=(0,Z.useCallback)((e,t,n,r)=>{let i=Se.current,a=he.current,o=Vt(i,e),s=z.compact(i,O);S(s,a,o??null,null,r.e,r.node);let c=ge.current;he.current=null,ge.current=null,q(null),J(!1),G(s),c&&!(0,Lr.deepEqual)(c,s)&&g(s)},[O,z,S,g]),je=(0,Z.useCallback)(()=>{let e=Se.current;if(!e.some(e=>e.i===se.i)){pe(null),q(null),X(void 0);return}G(z.compact(e.filter(e=>e.i!==se.i),O)),pe(null),q(null),X(void 0)},[se.i,O,z]),Me=(0,Z.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),Vr&&!e.nativeEvent.target?.classList.contains(Br))return!1;let t=R?R(e.nativeEvent):w(e);if(t===!1)return fe&&je(),!1;let{dragOffsetX:r=0,dragOffsetY:i=0,...a}=t??{},o={...se,...a},s=e.currentTarget.getBoundingClientRect(),c={cols:O,margin:j,maxRows:A,rowHeight:k,containerWidth:n,containerPadding:U},l=Dt(c),u=Ot(o.w,l,j[0]),d=Ot(o.h,k,j[1]),f=u/2,p=d/2,m=e.clientX-s.left+r-f,h=e.clientY-s.top+i-p,g=Math.max(0,m),_=Math.max(0,h),v={left:g/H,top:_/H,e:e.nativeEvent};if(fe)Y&&(Y.left!==v.left||Y.top!==v.top)&&X(v);else{let e=At(c,_,g,o.w,o.h);pe((0,Q.jsx)(`div`,{},o.i)),X(v),G([...Se.current.filter(e=>e.i!==o.i),{...o,x:e.x,y:e.y,static:!1,isDraggable:!0}])}},[fe,Y,se,R,w,je,H,O,j,A,k,n,U]),Ne=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),_e.current--,_e.current<0&&(_e.current=0),_e.current===0&&je()},[je]),Pe=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),_e.current++},[]),Fe=(0,Z.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=Se.current,n=t.find(e=>e.i===se.i);_e.current=0,je(),C(t,n,e.nativeEvent)},[se.i,je,C]),Ie=(0,Z.useCallback)((e,t)=>{if(!e||!e.key)return null;let r=Vt(W,String(e.key));if(!r)return null;let i=typeof r.isDraggable==`boolean`?r.isDraggable:!r.static&&te,a=typeof r.isResizable==`boolean`?r.isResizable:!r.static&&ne,o=r.resizeHandles||[...re],c=i&&N&&r.isBounded!==!1,u=ie;return(0,Q.jsx)(Rr,{containerWidth:n,cols:O,margin:j,containerPadding:U,maxRows:A,rowHeight:k,cancel:F,handle:P,onDragStart:we,onDrag:Te,onDragStop:Ee,onResizeStart:De,onResize:Oe,onResizeStop:ke,isDraggable:i,isResizable:a,isBounded:c,useCSSTransforms:ce&&le,usePercentages:!le,transformScale:H,positionStrategy:s,dragThreshold:I,w:r.w,h:r.h,x:r.x,y:r.y,i:r.i,minH:r.minH,minW:r.minW,maxH:r.maxH,maxW:r.maxW,static:r.static,droppingPosition:t?Y:void 0,resizeHandles:o,resizeHandle:u,constraints:l,layoutItem:r,layout:W,children:e},r.i)},[W,n,O,j,U,A,k,F,P,we,Te,Ee,De,Oe,ke,te,ne,N,ce,le,H,s,I,Y,re,ie,l]),Le=()=>K?(0,Q.jsx)(Rr,{w:K.w,h:K.h,x:K.x,y:K.y,i:K.i,className:`react-grid-placeholder ${de?`placeholder-resizing`:``}`,containerWidth:n,cols:O,margin:j,containerPadding:U,maxRows:A,rowHeight:k,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:ce,transformScale:H,constraints:l,layout:W,children:(0,Q.jsx)(`div`,{})}):null;return(0,Q.jsxs)(`div`,{ref:h,className:Ae(Br,p),style:{height:Ce,...m},onDrop:L?Fe:void 0,onDragLeave:L?Ne:void 0,onDragEnter:L?Pe:void 0,onDragOver:L?Me:void 0,children:[Z.Children.map(t,e=>Z.isValidElement(e)?Ie(e):null),L&&fe&&Ie(fe,!0),Le()]})}var Gr={lg:1200,md:996,sm:768,xs:480,xxs:0},Kr={lg:12,md:10,sm:6,xs:4,xxs:2},qr=()=>{};function Jr(e,t,n,r){let i=[];Z.Children.forEach(t,t=>{if(!Z.isValidElement(t)||t.key===null)return;let n=String(t.key),r=e.find(e=>e.i===n);if(r)i.push({...r,i:n});else{let e=t.props[`data-grid`];e?i.push({i:n,x:e.x??0,y:e.y??0,w:e.w??1,h:e.h??1,minW:e.minW,maxW:e.maxW,minH:e.minH,maxH:e.maxH,static:e.static,isDraggable:e.isDraggable,isResizable:e.isResizable,resizeHandles:e.resizeHandles,isBounded:e.isBounded}):i.push({i:n,x:0,y:Bt(i),w:1,h:1})}});let a=qt(i,{cols:n});return r.compact(a,n)}function Yr(e){let{children:t,width:n,breakpoint:r,breakpoints:i=Gr,cols:a=Kr,layouts:o={},rowHeight:s=150,maxRows:c=1/0,margin:l=[10,10],containerPadding:u=null,compactor:d,onBreakpointChange:f=qr,onLayoutChange:p=qr,onWidthChange:m=qr,...h}=e,g=d??On(`vertical`),_=g.type,v=g.allowOverlap,y=(0,Z.useMemo)(()=>r??An(i,n),[]),b=(0,Z.useMemo)(()=>jn(y,a),[y,a]),x=(0,Z.useMemo)(()=>Mn(o,i,y,y,b,_),[]),[S,C]=(0,Z.useState)(y),[w,T]=(0,Z.useState)(b),[E,ee]=(0,Z.useState)(x),[D,O]=(0,Z.useState)(o),k=(0,Z.useRef)(n),A=(0,Z.useRef)(r),j=(0,Z.useRef)(i),M=(0,Z.useRef)(a),te=(0,Z.useRef)(o),N=(0,Z.useRef)(_),P=(0,Z.useRef)(D);(0,Z.useEffect)(()=>{P.current=D},[D]);let F=(0,Z.useMemo)(()=>(0,Lr.deepEqual)(o,te.current)?null:Mn(o,i,S,S,w,g),[o,i,S,w,g]),I=F??E;(0,Z.useEffect)(()=>{F!==null&&(ee(F),O(o),P.current=o,te.current=o)},[F,o]),(0,Z.useEffect)(()=>{if(_!==N.current){let e=g.compact(Wt(I),w),t={...P.current,[S]:e};ee(e),O(t),P.current=t,p(e,t),N.current=_}},[_,g,I,w,v,S,p]),(0,Z.useEffect)(()=>{let e=n!==k.current,o=r!==A.current,s=!(0,Lr.deepEqual)(i,j.current),c=!(0,Lr.deepEqual)(a,M.current);if(e||o||s||c){let e=r??An(i,n),o=jn(e,a),d=S;if(d!==e||s||c){let n={...P.current};n[d]||(n[d]=Wt(E));let r=Mn(n,i,e,d,o,g);r=Jr(r,t,o,g),n[e]=r,C(e),T(o),ee(r),O(n),P.current=n,f(e,o),p(r,n)}m(n,Nn(l,e),o,u?Nn(u,e):null),k.current=n,A.current=r,j.current=i,M.current=a}},[n,r,i,a,S,w,E,t,g,_,v,l,u,f,p,m]);let ne=(0,Z.useCallback)(e=>{let t={...P.current,[S]:e};ee(e),O(t),P.current=t,p(e,t)},[S,p]),re=(0,Z.useMemo)(()=>Nn(l,S),[l,S]),ie=(0,Z.useMemo)(()=>u===null?null:Nn(u,S),[u,S]),L=(0,Z.useMemo)(()=>({cols:w,rowHeight:s,maxRows:c,margin:re,containerPadding:ie}),[w,s,c,re,ie]);return(0,Q.jsx)(Wr,{...h,width:n,gridConfig:L,compactor:g,onLayoutChange:ne,layout:I,children:t})}function Xr({editMode:e}){let t=o();return Z.useEffect(()=>{if(e)return t.startDrag({id:`dashboard-layout`,type:`dashboard-widget`,data:{}}),()=>{t.endDrag()};t.endDrag(`dashboard`)},[e,t]),null}var Zr=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`];function Qr(e,t){if(!e.widgets?.length)return e;let n=new Map(t.map(e=>[e.i,e])),r=e.widgets.map((e,t)=>{let r=e.id||`widget-${t}`,i=n.get(r);return i?{...e,layout:{x:i.x,y:i.y,w:i.w,h:i.h}}:e});return{...e,widgets:r}}function $r(e){return{lg:e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x??t%4*3,y:e.layout?.y??Math.floor(t/4)*4,w:e.layout?.w??3,h:e.layout?.h??4}))||[]}}var ei=({schema:e,className:t,onLayoutChange:n,onSchemaChange:r,onRefresh:i})=>{let{width:a,containerRef:o,mounted:s}=Fn(),[u,d]=Z.useState(!1),[f,p]=Z.useState(!1),m=c(),h=Z.useRef(null),g=Z.useCallback(()=>{i&&(p(!0),i(),setTimeout(()=>p(!1),600))},[i]);Z.useEffect(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!i))return h.current=setInterval(g,e.refreshInterval*1e3),()=>{h.current&&clearInterval(h.current)}},[e.refreshInterval,i,g]);let[_,v]=Z.useState(()=>$r(e)),y=Z.useMemo(()=>JSON.stringify(e.widgets?.map((e,t)=>({i:e.id||`widget-${t}`,x:e.layout?.x,y:e.layout?.y,w:e.layout?.w,h:e.layout?.h}))??[]),[e.widgets]);Z.useEffect(()=>{v($r(e))},[y]);let b=Z.useCallback((e,t)=>{v(t),n?.(e)},[n]),x=Z.useCallback(()=>{r?r(Qr(e,_.lg)):globalThis.process?.env?.NODE_ENV!==`production`&&console.warn("[DashboardGridLayout] Layout edits are in-memory only. Wire `onSchemaChange` to persist via your data adapter."),d(!1)},[r,e,_]),S=Z.useCallback(()=>{v($r(e))},[e]),C=Z.useCallback(e=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`bar`||t===`horizontal-bar`||t===`line`||t===`area`||t===`pie`||t===`donut`||t===`scatter`||t===`funnel`){let r=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(We(r)){let n=r.aggregate,o=n?{field:e.valueField||n.field,function:e.aggregate||n.function,groupBy:e.categoryField||n.groupBy}:void 0,s=o?.field||a;return{type:`object-chart`,chartType:t,objectName:e.object||r.object,aggregate:o,xAxisKey:i,series:[{dataKey:s}],colors:Zr,className:`h-full`}}if(!r&&e.object){let n=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`name`}:void 0;return{type:`object-chart`,chartType:t,objectName:e.object,aggregate:n,xAxisKey:i,series:[{dataKey:e.valueField||`value`}],colors:Zr,className:`h-full`}}return{type:`chart`,chartType:t,data:Array.isArray(r)?r:r?.items||[],xAxisKey:i,series:[{dataKey:a}],colors:Zr,className:`h-full`}}if(t===`table`){let t=e.data||n.data;if(We(t)){let{data:r,...i}=n;return{type:`data-table`,...i,objectName:e.object||t.object,dataProvider:t,data:[],searchable:!1,pagination:!1,className:`border-0`}}return!t&&e.object?{type:`data-table`,...n,objectName:e.object,data:[],searchable:!1,pagination:!1,className:`border-0`}:{type:`data-table`,...n,data:t?.items||[],searchable:!1,pagination:!1,className:`border-0`}}if(t===`pivot`){let t=e.data||n.data;if(We(t)){let{data:r,...i}=n;return{type:`pivot`,...i,objectName:e.object||t.object,dataProvider:t,data:[]}}return{type:`pivot`,...n,data:Array.isArray(t)?t:t?.items||[]}}return{...e,...n}},[]);return(0,Q.jsxs)(`div`,{ref:o,className:R(`w-full`,t),"data-testid":`grid-layout`,children:[m&&(0,Q.jsx)(Xr,{editMode:u}),(0,Q.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,Q.jsx)(`h2`,{className:`text-2xl font-bold`,children:e.title||`Dashboard`}),(0,Q.jsx)(`div`,{className:`flex gap-2`,children:u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(H,{onClick:x,size:`sm`,variant:`default`,children:[(0,Q.jsx)(P,{className:`h-4 w-4 mr-2`}),`Save Layout`]}),(0,Q.jsxs)(H,{onClick:S,size:`sm`,variant:`outline`,children:[(0,Q.jsx)(z,{className:`h-4 w-4 mr-2`}),`Reset`]}),(0,Q.jsx)(H,{onClick:()=>d(!1),size:`sm`,variant:`ghost`,children:`Cancel`})]}):(0,Q.jsxs)(Q.Fragment,{children:[i&&(0,Q.jsxs)(H,{onClick:g,size:`sm`,variant:`outline`,disabled:f,"aria-label":`Refresh dashboard`,children:[(0,Q.jsx)(F,{className:R(`h-4 w-4 mr-2`,f&&`animate-spin`)}),f?`Refreshing…`:`Refresh All`]}),(0,Q.jsxs)(H,{onClick:()=>d(!0),size:`sm`,variant:`outline`,children:[(0,Q.jsx)(pe,{className:`h-4 w-4 mr-2`}),`Edit Layout`]})]})})]}),s&&(0,Q.jsx)(Yr,{className:`layout`,width:a,layouts:_,breakpoints:{lg:1200,md:996,sm:768,xs:480,xxs:0},cols:{lg:12,md:10,sm:6,xs:4,xxs:2},rowHeight:60,dragConfig:{enabled:u,handle:`.drag-handle`},resizeConfig:{enabled:u},onLayoutChange:b,children:e.widgets?.map((e,t)=>{let n=e.id||`widget-${t}`,r=C(e);return(0,Q.jsx)(`div`,{className:`h-full`,children:e.type===`metric`?(0,Q.jsxs)(`div`,{className:`h-full w-full relative`,children:[u&&(0,Q.jsx)(`div`,{className:`drag-handle absolute top-2 right-2 z-10 cursor-move p-1 bg-background/80 rounded border border-border`,children:(0,Q.jsx)(De,{className:`h-4 w-4`})}),(0,Q.jsx)(l,{schema:r,className:`h-full w-full`})]}):(0,Q.jsxs)(xe,{className:R(`h-full overflow-hidden border-border/50 shadow-sm transition-all`,`bg-card/50 backdrop-blur-sm`,u&&`ring-2 ring-primary/20`),children:[e.title&&(0,Q.jsxs)(_e,{className:`pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between`,children:[(0,Q.jsx)(Ce,{className:`text-base font-medium tracking-tight truncate`,title:e.title,children:e.title}),u&&(0,Q.jsx)(`div`,{className:`drag-handle cursor-move p-1 hover:bg-muted/40 rounded`,children:(0,Q.jsx)(De,{className:`h-4 w-4`})})]}),(0,Q.jsx)(Y,{className:`p-0 h-full`,children:(0,Q.jsx)(`div`,{className:R(`h-full w-full overflow-auto p-4`),children:(0,Q.jsx)(l,{schema:r})})})]})},n)})})]})},ti=k({"dashboard.trend.vsLastQuarter":`vs last quarter`,"dashboard.trend.vsLastMonth":`vs last month`,"dashboard.trend.vsLastWeek":`vs last week`,"dashboard.trend.vsLastYear":`vs last year`,"dashboard.trend.vsYesterday":`vs yesterday`,"dashboard.trend.vsPreviousPeriod":`vs previous period`},`dashboard.trend.vsLastQuarter`);function ni(e){switch(e.trim().toLowerCase().replace(/\s+/g,` `)){case`vs last quarter`:case`vs previous quarter`:return`dashboard.trend.vsLastQuarter`;case`vs last month`:case`vs previous month`:return`dashboard.trend.vsLastMonth`;case`vs last week`:case`vs previous week`:return`dashboard.trend.vsLastWeek`;case`vs last year`:case`vs previous year`:return`dashboard.trend.vsLastYear`;case`vs yesterday`:return`dashboard.trend.vsYesterday`;case`vs previous period`:case`vs prior period`:return`dashboard.trend.vsPreviousPeriod`;default:return}}function ri(e,t,n){if(e==null)return``;if(typeof e==`string`){let r=Number(e);return!isFinite(r)||e.trim()===``?e:ri(r,t,n)}if(!isFinite(e))return String(e);let r={$:`USD`,"¥":`JPY`,"€":`EUR`,"£":`GBP`},i=(t||``).trim(),a=!!n||i.length>0&&r[i[0]]!==void 0,o=i.endsWith(`%`),s=i.match(/0\.(0+)/),c=s?s[1].length:0;if(/a/i.test(i)){let t={notation:`compact`,maximumFractionDigits:c||1};a&&(t.style=`currency`,t.currency=n||r[i[0]]||`USD`);try{return new Intl.NumberFormat(`en-US`,t).format(e)}catch{}}if(a){let t=n||r[i[0]]||`USD`;try{return new Intl.NumberFormat(`en-US`,{style:`currency`,currency:t,minimumFractionDigits:c,maximumFractionDigits:c}).format(e)}catch{return`${t} ${e.toFixed(c)}`}}return o?`${(e>1?e:e*100).toFixed(c)}%`:new Intl.NumberFormat(`en-US`,{minimumFractionDigits:c,maximumFractionDigits:c}).format(e)}function ii(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var ai={default:`bg-muted text-muted-foreground`,blue:`bg-blue-500/10 text-blue-600 dark:text-blue-400`,teal:`bg-teal-500/10 text-teal-600 dark:text-teal-400`,orange:`bg-orange-500/10 text-orange-600 dark:text-orange-400`,purple:`bg-purple-500/10 text-purple-600 dark:text-purple-400`,success:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`,warning:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,danger:`bg-rose-500/10 text-rose-600 dark:text-rose-400`},oi={default:`text-foreground`,blue:`text-blue-600 dark:text-blue-400`,teal:`text-teal-600 dark:text-teal-400`,orange:`text-orange-600 dark:text-orange-400`,purple:`text-purple-600 dark:text-purple-400`,success:`text-emerald-600 dark:text-emerald-400`,warning:`text-amber-600 dark:text-amber-400`,danger:`text-rose-600 dark:text-rose-400`},si=({label:e,value:t,trend:n,icon:r,className:i,description:a,loading:o,error:s,colorVariant:c=`default`,format:l,currency:u,prefix:d,suffix:f,onClick:p,variant:m=`card`,...h})=>{let g=ai[c]||ai.default,{t:_}=ti(),v=(0,Z.useMemo)(()=>{let e=ii(a)||ii(n?.label);if(!e)return e;let t=ni(e);return t?_(t):e},[a,n?.label,_]),y=(0,Z.useMemo)(()=>{let e=typeof t==`number`||typeof t==`string`&&t.trim()!==``&&isFinite(Number(t))?ri(t,l,u):t??``,n=String(e);return`${d&&n.startsWith(d)?``:d??``}${n}${f&&n.endsWith(f)?``:f??``}`},[t,l,u,d,f]),b=(0,Z.useMemo)(()=>{if(typeof r==`string`){let e=ve(r);return e?(0,Q.jsx)(e,{className:`h-4 w-4`}):null}return r},[r]);if(m===`bare`){let t=oi[c]||oi.default;return(0,Q.jsx)(`div`,{className:R(`flex flex-col gap-1 min-w-0`,p&&`cursor-pointer`,i),onClick:p,role:p?`button`:void 0,tabIndex:p?0:void 0,onKeyDown:p?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p())}:void 0,children:o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,Q.jsx)(U,{className:`h-4 w-4 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):s?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,Q.jsx)(ae,{className:`h-4 w-4 text-destructive shrink-0`}),(0,Q.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:s})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:R(`text-[2rem] leading-none font-extrabold tabular-nums tracking-tight truncate`,t),children:y}),(0,Q.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground truncate`,children:ii(e)})]})})}return(0,Q.jsxs)(xe,{className:R(`h-full overflow-hidden`,p&&`cursor-pointer transition-colors hover:bg-accent/40 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,i),onClick:p,role:p?`button`:void 0,tabIndex:p?0:void 0,onKeyDown:p?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),p())}:void 0,...h,children:[(0,Q.jsxs)(_e,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,Q.jsx)(Ce,{className:`text-sm font-medium truncate`,children:ii(e)}),b&&(0,Q.jsx)(`div`,{className:R(`flex h-8 w-8 items-center justify-center rounded-md shrink-0`,g),children:b})]}),(0,Q.jsx)(Y,{children:o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,Q.jsx)(U,{className:`h-4 w-4 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):s?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,Q.jsx)(ae,{className:`h-4 w-4 text-destructive shrink-0`}),(0,Q.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:s})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`text-2xl font-bold tabular-nums tracking-tight truncate`,children:y}),(n||a)&&(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 min-w-0`,children:[n&&(0,Q.jsxs)(`span`,{className:R(`flex items-center shrink-0 font-medium`,n.direction===`up`&&`text-emerald-600 dark:text-emerald-400`,n.direction===`down`&&`text-rose-600 dark:text-rose-400`,n.direction===`neutral`&&`text-muted-foreground`),children:[n.direction===`up`&&(0,Q.jsx)(Ee,{className:`h-3 w-3 mr-1`}),n.direction===`down`&&(0,Q.jsx)(N,{className:`h-3 w-3 mr-1`}),n.direction===`neutral`&&(0,Q.jsx)(me,{className:`h-3 w-3 mr-1`}),n.value,`%`]}),(0,Q.jsx)(`span`,{className:`truncate min-w-0`,children:v})]})]})})]})};function ci(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var li=({title:e,value:t,icon:n,trend:r,trendValue:i,description:a,className:o,loading:s,error:c,...l})=>{let u=n?ve(n):null;return(0,Q.jsxs)(xe,{className:R(`h-full`,o),...l,children:[(0,Q.jsxs)(_e,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,Q.jsx)(Ce,{className:`text-sm font-medium`,children:ci(e)}),u&&(0,Q.jsx)(u,{className:`h-4 w-4 text-muted-foreground`})]}),(0,Q.jsx)(Y,{children:s?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-card-loading`,children:[(0,Q.jsx)(U,{className:`h-4 w-4 animate-spin`}),(0,Q.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):c?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-card-error`,role:`alert`,children:[(0,Q.jsx)(ae,{className:`h-4 w-4 text-destructive shrink-0`}),(0,Q.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:c})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`text-2xl font-bold`,children:t}),(r||i||a)&&(0,Q.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center mt-1`,children:[r&&i&&(0,Q.jsxs)(`span`,{className:R(`flex items-center mr-2`,r===`up`&&`text-green-500`,r===`down`&&`text-red-500`,r===`neutral`&&`text-yellow-500`),children:[r===`up`&&(0,Q.jsx)(Ee,{className:`h-3 w-3 mr-1`}),r===`down`&&(0,Q.jsx)(N,{className:`h-3 w-3 mr-1`}),r===`neutral`&&(0,Q.jsx)(me,{className:`h-3 w-3 mr-1`}),i]}),ci(a)]})]})})]})},ui=({objectName:e,aggregate:t,filter:n,label:r,fallbackValue:i,trend:a,icon:o,className:s,description:c,dataSource:d,colorVariant:f,format:p,currency:v,prefix:y,suffix:b,invert:x,drillDown:S,title:C,compareTo:w,t:T,variant:E})=>{let D=(0,Z.useContext)(u),O=d||D?.dataSource,[k,A]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(null),[te,N]=(0,Z.useState)(null),[P,F]=(0,Z.useState)(!1),[I,ie]=(0,Z.useState)(null),[ae,R]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{let t=!0;if(!(!O||!e||typeof O.getObjectSchema!=`function`))return O.getObjectSchema(e).then(e=>{t&&R(e)}).catch(()=>{}),()=>{t=!1}},[O,e]);let z=(0,Z.useMemo)(()=>{let e=t?.field;if(!e||!ae?.fields)return null;let n=ae.fields;return Array.isArray(n)?n.find(t=>t?.name===e)||null:n[e]||null},[ae,t?.field]),B=(0,Z.useMemo)(()=>{if(p)return p;if(z){if(z.type===`currency`){let e=z.precision??z.scale??0;return e>0?`0,0.${`0`.repeat(e)}`:`0,0`}if(z.type===`percent`)return`0,0%`;if(z.type===`number`||z.type===`integer`)return`0,0`}},[p,z]),{currency:se}=ne(),ce=(0,Z.useMemo)(()=>{if(v)return v;if(z?.type===`currency`)return V(z,se)},[v,z,se]),H=(0,Z.useMemo)(()=>t?JSON.stringify(t):``,[t]),U=(0,Z.useMemo)(()=>ee(n),[n]),ue=(0,Z.useMemo)(()=>U?JSON.stringify(U):``,[U]),W=(0,Z.useMemo)(()=>w?JSON.stringify(w):``,[w]),q=(0,Z.useCallback)(async(n,r)=>{if(t&&typeof n.aggregate==`function`){let i=await n.aggregate(e,{field:t.field,function:t.function,groupBy:t.groupBy||`_all`,filter:r}),a=Array.isArray(i)?i:[];if(a.length===0)return 0;if(t.function===`count`){let e=`${t.field}_count`;return a.reduce((n,r)=>n+(Number(r[e])||Number(r[t.field])||Number(r.count)||0),0)}let o=a[0];return o[`${t.field}_${t.function}`]??o[t.field]??o.value??0}if(typeof n.find==`function`){let t=await n.find(e,{$filter:r});return(Array.isArray(t)?t:t?.data||t?.records||[]).length}return null},[e,H]),de=(0,Z.useCallback)(async(t,r)=>{if(!(!t||!e)){r.current&&(F(!0),ie(null));try{let e=w?h(n,w):null,[i,a]=await Promise.all([q(t,U),e?q(t,e):Promise.resolve(null)]);if(i===null)return;r.current&&(M(i),N(typeof a==`number`&&Number.isFinite(a)?a:null))}catch(e){console.error(`[ObjectMetricWidget] Fetch error:`,e),r.current&&ie(e instanceof Error?e.message:`Failed to load metric`)}finally{r.current&&F(!1)}}},[e,H,ue,W,q]);(0,Z.useEffect)(()=>{let t={current:!0};return O&&e?de(O,t):(M(null),ie(null)),()=>{t.current=!1}},[O,e,de]);let J=j===null?O?`—`:i??`—`:j;x&&typeof J==`number`&&isFinite(J)&&J>=0&&J<=1&&(J=1-J);let fe=(0,Z.useMemo)(()=>{if(!w||typeof j!=`number`||!Number.isFinite(j)||te===null)return;let e=Ge(j,te);if(!e)return;let t=m(w,n),r=`dashboard.trend.${t}`,i={vsPreviousPeriod:`vs previous period`,vsLastWeek:`vs last week`,vsLastMonth:`vs last month`,vsLastQuarter:`vs last quarter`,vsLastYear:`vs last year`,vsYesterday:`vs yesterday`},a=T?T(r,i[t]||t):i[t]||t;return{value:e.value,direction:e.direction,label:a}},[w,j,te,n,T])??a,pe=_(S)&&!!e&&!!O,Y=(0,Z.useMemo)(()=>{let e=typeof r==`string`?r:r?.defaultValue||``;return g(S,{},(typeof C==`string`?C:C?.defaultValue||``)||e||`Details`)},[S,r,C]),X=(0,Z.useMemo)(()=>{if(!pe)return null;let t=S?.target??`drawer`,n=S?.report,r=n&&typeof n==`object`&&(Array.isArray(n.columns)||`objectName`in n),i=r?null:(0,Q.jsx)(ot,{objectName:e,filter:U,onNavigate:()=>A(!1)}),a;if(r){let e=n.filter,t=e?U?{$and:[e,U]}:e:U;a=(0,Q.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,Q.jsx)(l,{schema:{type:`spec-report`,...n,filter:t}})})}else a=(0,Q.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,Q.jsx)(l,{schema:{type:`object-data-table`,objectName:e,filter:U,pageSize:25,drillDown:{enabled:!0,mode:`record`,target:`dialog`}}})});return t===`dialog`?(0,Q.jsx)(ye,{open:!0,onOpenChange:e=>!e&&A(!1),children:(0,Q.jsxs)(re,{className:`max-w-5xl`,children:[(0,Q.jsxs)(K,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,Q.jsx)(oe,{children:Y}),i]}),a]})}):(0,Q.jsx)(le,{open:!0,onOpenChange:e=>!e&&A(!1),children:(0,Q.jsxs)(G,{side:`right`,className:`w-full sm:max-w-2xl md:max-w-3xl lg:max-w-5xl flex flex-col`,children:[(0,Q.jsxs)(L,{className:`flex-row items-center justify-between gap-4 pr-8`,children:[(0,Q.jsx)(be,{children:Y}),i]}),(0,Q.jsx)(`div`,{className:`flex-1 overflow-hidden mt-2`,children:a})]})})},[pe,S,e,U,Y]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(si,{label:r,value:J,trend:fe,icon:o,className:s,description:c,loading:P,error:I,colorVariant:f,format:B,currency:ce,prefix:y,suffix:b,variant:E,onClick:pe?()=>A(!0):void 0}),k&&X]})};function di(){return w()(`dashboard.total`,`Total`)}function fi(){return w()(`dashboard.noDataAvailable`,`No data available`)}function pi(e,t){if(!t)return String(e);let n=``,r=``,i=!1,a,o=t,s=o.match(/^([^0-9.,#]*)/);if(s&&s[1]){let e=s[1];n=e.replace(`,`,``),e.includes(`,`)&&(i=!0),o=o.slice(s[1].length)}o.includes(`,`)&&(i=!0,o=o.replace(/,/g,``));let c=o.match(/\.(\d+)f?/);c&&(a=Number(c[1]),o=o.slice(c[0].length)),r=o.replace(/[0-9#.f]/g,``);let l=a===void 0?String(e):e.toFixed(a);if(i){let[e,t]=l.split(`.`),i=e.replace(/\B(?=(\d{3})+(?!\d))/g,`,`);return n+(t===void 0?i:`${i}.${t}`)+r}return n+l+r}var mi=`—`;function hi(e,t){return e===``?mi:t?.[e]??e}function gi(e,t){if(e.length===0)return 0;switch(t){case`sum`:return e.reduce((e,t)=>e+t,0);case`count`:return e.length;case`avg`:return e.reduce((e,t)=>e+t,0)/e.length;case`min`:return Math.min(...e);case`max`:return Math.max(...e);default:return e.reduce((e,t)=>e+t,0)}}var _i=({schema:e,className:t,rowLabels:n,columnLabels:r,rowFieldLabel:i,onDrillDown:a})=>{let{title:o,rowField:s,columnField:c,valueField:l,aggregation:u=`sum`,data:d=[],showRowTotals:f=!1,showColumnTotals:p=!1,format:m,columnColors:h,drillDown:g}=e,v=di(),y=fi(),b=_(g)&&typeof a==`function`,x=e=>{b&&a({...e,rowLabel:e.rowKey===void 0?e.rowLabel:n?.[e.rowKey]??e.rowKey,colLabel:e.colKey===void 0?e.colLabel:r?.[e.colKey]??e.colKey})},S=e=>t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},C=b?`cursor-pointer hover:bg-accent/40 focus-visible:outline focus-visible:outline-2 focus-visible:outline-ring focus-visible:outline-offset-[-2px]`:``,w=Array.isArray(d)?d:[],{rowKeys:T,colKeys:E,matrix:ee,rowTotals:D,colTotals:O,grandTotal:k}=(0,Z.useMemo)(()=>{let e=new Map,t=new Map,n={};for(let r of w){let i=String(r[s]??``),a=String(r[c]??``),o=Number(r[l])||0;e.set(i,!0),t.set(a,!0),n[i]||(n[i]={}),n[i][a]||(n[i][a]=[]),n[i][a].push(o)}let r=Array.from(e.keys()),i=Array.from(t.keys()),a={},o={},d={};for(let e of r){a[e]={};let t=[];for(let r of i){let i=n[e]?.[r]??[],o=gi(i,u);a[e][r]=o,t.push(...i),!d[r]&&d[r]}o[e]=gi(t,u)}for(let e of i){let t=[];for(let i of r){let r=n[i]?.[e]??[];t.push(...r)}d[e]=gi(t,u)}let f=[];for(let e of w)f.push(Number(e[l])||0);return{rowKeys:r,colKeys:i,matrix:a,rowTotals:o,colTotals:d,grandTotal:gi(f,u)}},[w,s,c,l,u]),A=e=>pi(e,m);return w.length===0?(0,Q.jsxs)(`div`,{className:R(`overflow-auto`,t),children:[o&&(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:o}),(0,Q.jsx)(Oe,{"data-testid":`pivot-empty-state`,className:`py-8 gap-2 [&>h3]:hidden`,icon:(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 opacity-40`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Q.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`}),(0,Q.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`}),(0,Q.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`}),(0,Q.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`})]}),iconWrapperClassName:``,title:``,description:y})]}):(0,Q.jsxs)(`div`,{className:R(`overflow-auto`,t),children:[o&&(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:o}),(0,Q.jsxs)(`table`,{className:`w-full text-sm border-collapse table-auto`,role:`table`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,Q.jsx)(`th`,{className:`text-left p-2 font-medium text-muted-foreground whitespace-nowrap`,children:i||s}),E.map(e=>{let t=()=>x({scope:`column`,colKey:e});return(0,Q.jsx)(`th`,{className:R(`text-right p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,h?.[e]??`text-muted-foreground`,C),title:e===``?`${c}: (empty)`:`${c}: ${e}`,role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?t:void 0,onKeyDown:b?S(t):void 0,"aria-label":b?`Drill into ${c}: ${e||`(empty)`}`:void 0,children:hi(e,r)},e)}),f&&(0,Q.jsx)(`th`,{className:`text-right p-2 font-semibold text-muted-foreground bg-muted/20 whitespace-nowrap`,children:v})]})}),(0,Q.jsx)(`tbody`,{children:T.map(e=>(0,Q.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-muted/30`,children:[(0,Q.jsx)(`td`,{className:R(`p-2 font-medium whitespace-nowrap`,e===``&&`italic text-muted-foreground/70`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`row`,rowKey:e}):void 0,onKeyDown:b?S(()=>x({scope:`row`,rowKey:e})):void 0,"aria-label":b?`Drill into ${s}: ${e||`(empty)`}`:void 0,children:hi(e,n)}),E.map(t=>{let n=ee[e]?.[t]??0,r=()=>x({scope:`cell`,rowKey:e,colKey:t,value:n});return(0,Q.jsx)(`td`,{className:R(`text-right p-2 tabular-nums`,h?.[t],C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?r:void 0,onKeyDown:b?S(r):void 0,"aria-label":b?`Drill into ${s}=${e||`(empty)`}, ${c}=${t||`(empty)`}`:void 0,children:A(n)},t)}),f&&(0,Q.jsx)(`td`,{className:R(`text-right p-2 font-semibold tabular-nums bg-muted/20`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`row`,rowKey:e,value:D[e]??0}):void 0,onKeyDown:b?S(()=>x({scope:`row`,rowKey:e,value:D[e]??0})):void 0,children:A(D[e]??0)})]},e))}),p&&(0,Q.jsx)(`tfoot`,{children:(0,Q.jsxs)(`tr`,{className:`border-t-2 border-border font-semibold bg-muted/40`,children:[(0,Q.jsx)(`td`,{className:`p-2`,children:v}),E.map(e=>(0,Q.jsx)(`td`,{className:R(`text-right p-2 tabular-nums`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`column`,colKey:e,value:O[e]??0}):void 0,onKeyDown:b?S(()=>x({scope:`column`,colKey:e,value:O[e]??0})):void 0,children:A(O[e]??0)},e)),f&&(0,Q.jsx)(`td`,{className:R(`text-right p-2 tabular-nums font-bold`,C),role:b?`button`:void 0,tabIndex:b?0:void 0,onClick:b?()=>x({scope:`total`,value:k}):void 0,onKeyDown:b?S(()=>x({scope:`total`,value:k})):void 0,children:A(k)})]})})]})]})},vi=({schema:e,dataSource:t,className:n})=>{let r=(0,Z.useContext)(u),i=t||r?.dataSource,a=d(e.bind),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)({}),[v,y]=(0,Z.useState)({}),[x,S]=(0,Z.useState)(null),{fieldLabel:w,fieldOptionLabel:T}=ke(),E=(0,Z.useRef)(w),D=(0,Z.useRef)(T);(0,Z.useEffect)(()=>{E.current=w,D.current=T},[w,T]),(0,Z.useEffect)(()=>{if(!i||!e.objectName)return;let t=i.getObjectSchema;if(typeof t!=`function`)return;let n=!0;return Promise.resolve(t.call(i,e.objectName)).then(t=>{if(!n||!t?.fields)return;let r=e.objectName,i={},a={};for(let[e,n]of Object.entries(t.fields)){let t=n?.label?String(n.label):e;a[e]=E.current(r,e,t);let o=n?.options;if(Array.isArray(o)&&o.length>0){let t={};for(let n of o)if(n&&n.value!==void 0&&n.label!==void 0){let i=String(n.value),a=String(n.label);t[i]=D.current(r,e,i,a)}Object.keys(t).length>0&&(i[e]=t)}}h(i),y(a)}).catch(()=>{}),()=>{n=!1}},[i,e.objectName]),(0,Z.useEffect)(()=>{let t=!0;return e.objectName&&!a&&(!e.data||e.data.length===0)&&(async()=>{if(!(!i||!e.objectName)){t&&(l(!0),p(null));try{let n;if(typeof i.find==`function`)n=b(await i.find(e.objectName,{$filter:ee(e.filter)}));else return;t&&s(n)}catch(e){console.error(`[ObjectPivotTable] Fetch error:`,e),t&&p(e instanceof Error?e.message:`Failed to load data`)}finally{t&&l(!1)}}})(),()=>{t=!1}},[e.objectName,i,a,e.data,e.filter]);let O=a||e.data||o,k=Array.isArray(O)?O:[];if(c&&k.length===0)return(0,Q.jsxs)(`div`,{className:R(`overflow-auto`,n),"data-testid":`pivot-loading`,children:[e.title&&(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,Q.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(W,{className:`h-6 w-24`}),(0,Q.jsx)(W,{className:`h-6 w-20`}),(0,Q.jsx)(W,{className:`h-6 w-20`}),(0,Q.jsx)(W,{className:`h-6 w-20`})]}),[1,2,3].map(e=>(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(W,{className:`h-5 w-24`}),(0,Q.jsx)(W,{className:`h-5 w-20`}),(0,Q.jsx)(W,{className:`h-5 w-20`}),(0,Q.jsx)(W,{className:`h-5 w-20`})]},e))]})]});if(f)return(0,Q.jsxs)(`div`,{className:R(`overflow-auto`,n),"data-testid":`pivot-error`,children:[e.title&&(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,Q.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`pivot-error-message`,children:[(0,Q.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,className:`h-8 w-8 mb-2 opacity-60`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,Q.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,Q.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,Q.jsx)(`p`,{className:`text-xs`,children:f})]})]});if(!i&&e.objectName&&k.length===0)return(0,Q.jsxs)(`div`,{className:R(`overflow-auto`,n),children:[e.title&&(0,Q.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,Q.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})]});let A={...e,data:k},j=e.rowField?m[e.rowField]:void 0,M=e.columnField?m[e.columnField]:void 0,te=e.rowField?v[e.rowField]:void 0,N=e.drillDown,P=_(N)?e=>S(e):void 0;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_i,{schema:A,className:n,rowLabels:j,columnLabels:M,rowFieldLabel:te,onDrillDown:P}),(()=>{if(!x||!e.objectName)return null;let t=C(N,x,{rowField:e.rowField,columnField:e.columnField}),n={...e.filter||{},...t};return(0,Q.jsx)(st,{open:!0,onClose:()=>S(null),title:g(N,x,e.title||`Details`),target:N?.target??`drawer`,objectName:e.objectName,filter:n,dataSource:i,columns:N?.columns,maxRows:N?.maxRows,report:N?.report})})()]})},yi={breadcrumb:[`Dashboard`,`Configuration`],sections:[{key:`layout`,title:`Layout`,collapsible:!0,fields:[{key:`columns`,label:`Columns`,type:`slider`,defaultValue:3,min:1,max:12,step:1},{key:`gap`,label:`Gap`,type:`slider`,defaultValue:4,min:0,max:16,step:1},{key:`rowHeight`,label:`Row height (px)`,type:`slider`,defaultValue:120,min:40,max:320,step:10}]},{key:`data`,title:`Data`,collapsible:!0,fields:[{key:`refreshInterval`,label:`Auto refresh`,type:`select`,defaultValue:`0`,options:[{value:`0`,label:`Off`},{value:`30`,label:`Every 30s`},{value:`60`,label:`Every 1 min`},{value:`300`,label:`Every 5 min`},{value:`900`,label:`Every 15 min`},{value:`1800`,label:`Every 30 min`},{value:`3600`,label:`Every 1 hour`}]}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Dashboard title`},{key:`description`,label:`Description`,type:`textarea`,placeholder:`Short summary shown under the title`},{key:`showDescription`,label:`Show description`,type:`switch`,defaultValue:!0},{key:`theme`,label:`Theme`,type:`select`,defaultValue:`auto`,options:[{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`auto`,label:`Auto`}]}]}]};function bi({open:e,onClose:t,config:n,onSave:r,onFieldChange:i}){let{draft:a,isDirty:o,updateField:s,discard:c}=B(n,{onUpdate:i});return(0,Q.jsx)(M,{open:e,onClose:t,schema:yi,draft:a,isDirty:o,onFieldChange:s,onSave:()=>r(a),onDiscard:c})}var xi=[{value:`metric`,label:`Metric`},{value:`bar`,label:`Bar Chart`},{value:`horizontal-bar`,label:`Horizontal Bar`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`donut`,label:`Donut Chart`},{value:`area`,label:`Area Chart`},{value:`scatter`,label:`Scatter Plot`},{value:`funnel`,label:`Funnel`},{value:`table`,label:`Table`},{value:`pivot`,label:`Pivot Table`}],Si=[{value:`default`,label:`Default`},{value:`blue`,label:`Blue`},{value:`teal`,label:`Teal`},{value:`orange`,label:`Orange`},{value:`purple`,label:`Purple`},{value:`success`,label:`Success`},{value:`warning`,label:`Warning`},{value:`danger`,label:`Danger`}],Ci=[{value:`count`,label:`Count`},{value:`sum`,label:`Sum`},{value:`avg`,label:`Average`},{value:`min`,label:`Min`},{value:`max`,label:`Max`}],wi=[`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`scatter`,`funnel`],Ti=[`bar`,`horizontal-bar`,`line`,`area`,`scatter`],Ei=[`pie`,`donut`,`funnel`],Di=[`metric`,...wi],Oi=[...wi],ki=[`pivot`,`metric`,`bar`,`horizontal-bar`,`line`,`area`,`pie`,`donut`,`funnel`,`scatter`,`treemap`,`sankey`,`table`,`list`];function Ai(e){return!!e&&wi.includes(e)}function ji(e){return!!e&&Ti.includes(e)}function Mi(e){return!!e&&Oi.includes(e)}function Ni(e){return!!e&&Di.includes(e)}function Pi(e){return!!e&&ki.includes(e)}var Fi=[{value:`drawer`,label:`Side drawer`},{value:`dialog`,label:`Center dialog`}],Ii=[{value:`group`,label:`Group`},{value:`value`,label:`Value`}],Li=[{value:`asc`,label:`↑`},{value:`desc`,label:`↓`}];function Ri(e,t,n,r){return{key:e,label:t,type:`custom`,render:(i,a,o)=>(0,Q.jsx)(Se,{label:t,children:(0,Q.jsx)(`div`,{"data-testid":`config-field-${e}`,children:(0,Q.jsx)(X,{options:r??[],value:i??``,onValueChange:a,placeholder:n,searchPlaceholder:`Search fields…`,emptyText:`No fields found.`,className:`h-7 w-32 text-xs`,disabled:!o.object})})})}}function zi(e,t,n){let r=e&&e.length>0,i=r?{key:`object`,label:`Data source`,type:`custom`,render:(t,n)=>(0,Q.jsx)(Se,{label:`Data source`,children:(0,Q.jsx)(`div`,{"data-testid":`config-field-object`,children:(0,Q.jsx)(X,{options:e,value:t??``,onValueChange:n,placeholder:`Select object…`,searchPlaceholder:`Search objects…`,emptyText:`No objects found.`,className:`h-7 w-32 text-xs`})})})}:{key:`object`,label:`Data source`,type:`input`,placeholder:`Object name`},a=r?{...Ri(`categoryField`,`Category field`,`Select field…`,t),helpText:`Group records by this field (one bar/slice/segment per value).`,visibleWhen:e=>Mi(e.type)}:{key:`categoryField`,label:`Category field`,type:`input`,placeholder:`e.g. status`,helpText:`Group records by this field (one bar/slice/segment per value).`,visibleWhen:e=>Mi(e.type)},o=r?{...Ri(`valueField`,`Value field`,`Select field…`,t),helpText:`Field to aggregate (sum / average / min / max).`,visibleWhen:e=>Ni(e.type)&&(e.aggregate??`count`)!==`count`}:{key:`valueField`,label:`Value field`,type:`input`,placeholder:`e.g. amount`,helpText:`Field to aggregate (sum / average / min / max).`,visibleWhen:e=>Ni(e.type)&&(e.aggregate??`count`)!==`count`},s=r?Ri(`rowField`,`Field`,`Select row field…`,t):{key:`rowField`,label:`Field`,type:`input`,placeholder:`e.g. owner`},c=r?Ri(`columnField`,`Field`,`Select column field…`,t):{key:`columnField`,label:`Field`,type:`input`,placeholder:`e.g. stage`},l=r?Ri(`valueField`,`Field`,`Select value field…`,t):{key:`valueField`,label:`Field`,type:`input`,placeholder:`e.g. amount`};return{breadcrumb:[`Dashboard`,{pivot:`Pivot table`,table:`Table`}[n??``]??(Ai(n)?`Chart`:`Widget`)],sections:[{key:`general`,title:`General`,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Widget title`},{key:`description`,label:`Description`,type:`input`,placeholder:`Widget description`},{key:`type`,label:`Widget type`,type:`select`,options:xi,defaultValue:`metric`}]},{key:`data`,title:`Data Binding`,collapsible:!0,visibleWhen:e=>e.type!==`pivot`,fields:[i,a,o,{key:`aggregate`,label:`Aggregation`,type:`select`,options:Ci,defaultValue:`count`,helpText:`Count ignores Value field; Sum / Avg / Min / Max require it.`,visibleWhen:e=>Ni(e.type)}]},{key:`pivot-data`,title:`Data`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[i]},{key:`pivot-rows`,title:`Rows`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[s,{key:`rowSortBy`,label:`Sort by`,type:`icon-group`,options:Ii,defaultValue:`group`},{key:`rowSortOrder`,label:`Sort order`,type:`icon-group`,options:Li,defaultValue:`asc`},{key:`showRowLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showRowTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-columns`,title:`Columns`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[c,{key:`columnSortBy`,label:`Sort by`,type:`icon-group`,options:Ii,defaultValue:`group`},{key:`columnSortOrder`,label:`Sort order`,type:`icon-group`,options:Li,defaultValue:`asc`},{key:`showColumnLabels`,label:`Show label`,type:`switch`,defaultValue:!0},{key:`showColumnTotals`,label:`Show totals`,type:`switch`,defaultValue:!1}]},{key:`pivot-values`,title:`Values`,collapsible:!0,visibleWhen:e=>e.type===`pivot`,fields:[l,{key:`aggregation`,label:`Aggregation`,type:`select`,options:Ci,defaultValue:`sum`},{key:`format`,label:`Number format`,type:`input`,placeholder:`e.g. $,.2f`}]},{key:`chart-axis`,title:`Axis & Series`,collapsible:!0,visibleWhen:e=>ji(e.type),fields:[{key:`xAxisLabel`,label:`X-axis label`,type:`input`,placeholder:`e.g. Month`},{key:`yAxisLabel`,label:`Y-axis label`,type:`input`,placeholder:`e.g. Revenue`},{key:`showLegend`,label:`Show legend`,type:`switch`,defaultValue:!0}]},{key:`chart-legend`,title:`Display`,collapsible:!0,visibleWhen:e=>!!e.type&&Ei.includes(e.type),fields:[{key:`showLegend`,label:`Show legend`,type:`switch`,defaultValue:!0}]},{key:`table-options`,title:`Table options`,collapsible:!0,visibleWhen:e=>e.type===`table`,fields:[{key:`searchable`,label:`Searchable`,type:`switch`,defaultValue:!1},{key:`pagination`,label:`Pagination`,type:`switch`,defaultValue:!1}]},{key:`layout`,title:`Layout`,collapsible:!0,fields:[{key:`layoutW`,label:`Width (columns)`,type:`slider`,min:1,max:12,step:1,defaultValue:1},{key:`layoutH`,label:`Height (rows)`,type:`slider`,min:1,max:6,step:1,defaultValue:1}]},{key:`drill-down`,title:`Drill-down`,collapsible:!0,defaultCollapsed:!0,visibleWhen:e=>Pi(e.type),fields:[{key:`drillDownEnabled`,label:`Enable drill-down`,type:`switch`,defaultValue:!1,helpText:`When enabled, clicking a chart segment / pivot cell opens a filtered list of underlying records; clicking a table or list row opens that record.`},{key:`drillDownTarget`,label:`Open in`,type:`select`,options:Fi,defaultValue:`drawer`,visibleWhen:e=>!!e.drillDownEnabled}]},{key:`behavior`,title:`Behavior`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`actionUrl`,label:`Click-through URL`,type:`input`,placeholder:`https://...`}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`colorVariant`,label:`Color variant`,type:`select`,options:Si,defaultValue:`default`}]}]}}function Bi(e){if(e==null)return``;if(typeof e==`string`)return e;if(typeof e==`object`){let t=e;return t.defaultValue||t.key||``}return String(e)}function Vi(e){let t=e.type,n={...e};return Mi(t)||delete n.categoryField,Ni(t)?(n.aggregate??`count`)===`count`&&delete n.valueField:(delete n.valueField,delete n.aggregate),ji(t)||(delete n.xAxisLabel,delete n.yAxisLabel),t===`pivot`?(delete n.aggregate,delete n.categoryField):(delete n.rowField,delete n.columnField,delete n.aggregation,delete n.rowSortBy,delete n.rowSortOrder,delete n.columnSortBy,delete n.columnSortOrder,delete n.showRowLabels,delete n.showRowTotals,delete n.showColumnLabels,delete n.showColumnTotals,delete n.format),t!==`table`&&(delete n.searchable,delete n.pagination),Pi(t)||(delete n.drillDownEnabled,delete n.drillDownTarget),n}function Hi({open:e,onClose:t,config:n,onSave:r,onFieldChange:i,headerExtra:a,availableObjects:o,availableFields:s}){let{draft:c,isDirty:l,updateField:u,discard:d}=B(Z.useMemo(()=>({...n,title:typeof n.title==`object`?Bi(n.title):n.title,description:typeof n.description==`object`?Bi(n.description):n.description}),[n]),{onUpdate:i});return(0,Q.jsx)(M,{open:e,onClose:t,schema:Z.useMemo(()=>zi(o,s,c.type),[o,s,c.type]),draft:c,isDirty:l,onFieldChange:u,onSave:()=>r(Vi(c)),onDiscard:d,headerExtra:a})}function Ui({schema:e,config:t,onConfigSave:n,onWidgetSave:r,onRefresh:i,recordCount:a,defaultConfigOpen:o=!1,className:s}){let[c,l]=(0,Z.useState)(o),[u,d]=(0,Z.useState)(null),[f,p]=(0,Z.useState)(e),[m,h]=(0,Z.useState)(0);(0,Z.useEffect)(()=>{p(e),h(e=>e+1)},[e]);let g=Z.useMemo(()=>{if(!u||!f.widgets)return null;let e=f.widgets.find(e=>(e.id||e.title)===u);if(!e)return null;let t=e.options||{};return{...t,id:e.id??``,title:e.title??``,description:e.description??``,type:e.type??``,object:e.object??``,categoryField:e.categoryField??t.categoryField??``,valueField:e.valueField??t.valueField??``,aggregate:e.aggregate??t.aggregate??``,colorVariant:e.colorVariant??t.colorVariant??`default`,actionUrl:e.actionUrl??t.actionUrl??``,drillDownEnabled:t.drillDown?.enabled??!!(e.object&&(e.type===`pivot`||e.type===`metric`||e.type===`bar`||e.type===`horizontal-bar`||e.type===`line`||e.type===`area`||e.type===`pie`||e.type===`donut`||e.type===`funnel`)),drillDownTarget:t.drillDown?.target??`drawer`,layoutW:e.layout?.w??1,layoutH:e.layout?.h??1}},[u,m]),_=(0,Z.useCallback)(e=>{d(e),l(!0)},[]),v=(0,Z.useCallback)(()=>{d(null)},[]),y=(0,Z.useCallback)((e,t)=>{u&&p(n=>n.widgets?{...n,widgets:n.widgets.map(n=>{if((n.id||n.title)!==u)return n;if(e===`layoutW`)return{...n,layout:{...n.layout||{},w:t}};if(e===`layoutH`)return{...n,layout:{...n.layout||{},h:t}};if(e===`drillDownEnabled`||e===`drillDownTarget`){let r=n.options?.drillDown??{},i=e===`drillDownEnabled`?{...r,enabled:!!t}:{...r,target:t};return{...n,options:{...n.options||{},drillDown:i}}}return{...n,[e]:t}})}:n)},[u]),b=(0,Z.useCallback)(e=>{if(u&&r){let{drillDownEnabled:t,drillDownTarget:n,...i}=e,a={...i};(t||n)&&(a.options={...i.options||{},drillDown:{...i.options?.drillDown||{},...t===void 0?{}:{enabled:!!t},...n===void 0?{}:{target:n}}}),r(u,a)}d(null),h(e=>e+1)},[u,r]),x=(0,Z.useCallback)(()=>{l(e=>!e),d(null)},[]);return(0,Q.jsxs)(`div`,{className:R(`flex h-full w-full`,s),"data-testid":`dashboard-with-config`,children:[(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 overflow-auto relative`,children:[(0,Q.jsx)(`div`,{className:`absolute top-2 right-2 z-10`,children:(0,Q.jsxs)(H,{size:`sm`,variant:c?`default`:`outline`,onClick:x,"data-testid":`dashboard-config-toggle`,children:[(0,Q.jsx)(he,{className:`h-3.5 w-3.5 mr-1`}),`Settings`]})}),(0,Q.jsx)(Et,{schema:f,onRefresh:i,recordCount:a,designMode:c,selectedWidgetId:u,onWidgetClick:_})]}),c&&(0,Q.jsx)(`div`,{className:`relative shrink-0`,children:u&&g?(0,Q.jsx)(Hi,{open:!0,onClose:v,config:g,onSave:b,onFieldChange:y}):(0,Q.jsx)(bi,{open:!0,onClose:()=>l(!1),config:t,onSave:n})})]})}var Wi=t({DashboardConfigPanel:()=>bi,DashboardGridLayout:()=>ei,DashboardRenderer:()=>Et,DashboardWithConfig:()=>Ui,DrillDownDrawer:()=>st,MetricCard:()=>li,MetricWidget:()=>si,ObjectDataTable:()=>at,ObjectMetricWidget:()=>ui,ObjectPivotTable:()=>vi,PivotTable:()=>_i,WidgetConfigPanel:()=>Hi,dashboardComponents:()=>Gi});s.register(`dashboard`,Et,{namespace:`view`,label:`Dashboard`,category:`Complex`,icon:`layout-dashboard`,inputs:[{name:`columns`,type:`number`,label:`Columns`,defaultValue:3},{name:`gap`,type:`number`,label:`Gap`,defaultValue:4},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{columns:3,widgets:[]}}),s.register(`metric`,si,{namespace:`plugin-dashboard`,label:`Metric Widget`,category:`Dashboard`,inputs:[{name:`label`,type:`string`,label:`Label`},{name:`value`,type:`string`,label:`Value`}]}),s.register(`metric-card`,li,{namespace:`plugin-dashboard`,label:`Metric Card`,category:`Dashboard`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`value`,type:`string`,label:`Value`,required:!0},{name:`icon`,type:`string`,label:`Icon (Lucide name)`},{name:`trend`,type:`enum`,label:`Trend`,enum:[{label:`Up`,value:`up`},{label:`Down`,value:`down`},{label:`Neutral`,value:`neutral`}]},{name:`trendValue`,type:`string`,label:`Trend Value (e.g., +12%)`},{name:`description`,type:`string`,label:`Description`}],defaultProps:{title:`Metric`,value:`0`}}),s.register(`object-metric`,ui,{namespace:`plugin-dashboard`,label:`Object Metric`,category:`Dashboard`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`label`,type:`string`,label:`Label`},{name:`aggregate`,type:`object`,label:`Aggregate`,description:`Aggregation config: { field, function, groupBy }`},{name:`icon`,type:`string`,label:`Icon (Lucide name)`}],defaultProps:{label:`Metric`}}),s.register(`pivot`,_i,{namespace:`plugin-dashboard`,label:`Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`,data:[]}}),s.register(`object-pivot`,vi,{namespace:`plugin-dashboard`,label:`Object Pivot Table`,category:`Dashboard`,icon:`table-2`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`title`,type:`string`,label:`Title`},{name:`rowField`,type:`string`,label:`Row Field`,required:!0},{name:`columnField`,type:`string`,label:`Column Field`,required:!0},{name:`valueField`,type:`string`,label:`Value Field`,required:!0},{name:`aggregation`,type:`enum`,label:`Aggregation`,enum:[{label:`Sum`,value:`sum`},{label:`Count`,value:`count`},{label:`Average`,value:`avg`},{label:`Min`,value:`min`},{label:`Max`,value:`max`}]},{name:`showRowTotals`,type:`boolean`,label:`Show Row Totals`},{name:`showColumnTotals`,type:`boolean`,label:`Show Column Totals`},{name:`filter`,type:`array`,label:`Filter`},{name:`format`,type:`string`,label:`Number Format`}],defaultProps:{rowField:``,columnField:``,valueField:``,aggregation:`sum`}}),s.register(`dashboard-grid`,ei,{namespace:`plugin-dashboard`,label:`Dashboard Grid (Editable)`,category:`Complex`,icon:`layout-grid`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{title:`Dashboard`,widgets:[]}}),s.register(`object-data-table`,at,{namespace:`plugin-dashboard`,label:`Object Data Table`,category:`Dashboard`,icon:`table`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`columns`,type:`array`,label:`Columns`},{name:`filter`,type:`array`,label:`Filter`},{name:`searchable`,type:`boolean`,label:`Searchable`},{name:`pagination`,type:`boolean`,label:`Pagination`}],defaultProps:{searchable:!1,pagination:!1}});var Gi={DashboardRenderer:Et,DashboardGridLayout:ei,MetricWidget:si,MetricCard:li,ObjectMetricWidget:ui,PivotTable:_i,ObjectPivotTable:vi,ObjectDataTable:at,DashboardConfigPanel:bi,WidgetConfigPanel:Hi,DashboardWithConfig:Ui};export{Et as n,st as r,Wi as t};