@object-ui/console 4.0.4 → 4.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AppManagementPage-ynJLzxVY.js → AppManagementPage-DvZRhEu3.js} +1 -1
- package/dist/assets/{ConsoleFloatingChatbot-C2rFxE3n.js → ConsoleFloatingChatbot-DSk3VUa6.js} +1 -1
- package/dist/assets/DashboardView-ClGhVUz7.js +1 -0
- package/dist/assets/{MetadataDetailPage-B9EzoQgu.js → MetadataDetailPage-Dn8QJ3Hw.js} +1 -1
- package/dist/assets/{MetadataFormDialog-BebGlAr3.js → MetadataFormDialog-Bf5wwigQ.js} +1 -1
- package/dist/assets/MetadataManagerPage-CLb0l4Pw.js +1 -0
- package/dist/assets/{PageView-C2GS-SQP.js → PageView-_R84mPfp.js} +2 -2
- package/dist/assets/ProfilePage-BFhufxnO.js +1 -0
- package/dist/assets/RecordDetailView-DROfHlhL.js +1 -0
- package/dist/assets/{RecordFormPage-B6mEBKMB.js → RecordFormPage-BqCa2Cez.js} +1 -1
- package/dist/assets/{ReportView-B16PsGer.js → ReportView-bv8vOOKb.js} +2 -2
- package/dist/assets/{SearchResultsPage-932jfRUX.js → SearchResultsPage-KJr5yhgC.js} +1 -1
- package/dist/assets/{SystemHubPage-CqrYgpYf.js → SystemHubPage-LGgCwgTn.js} +1 -1
- package/dist/assets/{data-adapter-BwfAq_h0.js → data-adapter-ChK5QXoY.js} +1 -1
- package/dist/assets/{getIcon-DF6zJOtU.js → getIcon-BKYKFGnN.js} +1 -1
- package/dist/assets/index-C_jWdyY_.css +2 -0
- package/dist/assets/index-DTdi5Ufa.js +2 -0
- package/dist/assets/{plugin-calendar-D1bCBBwe.js → plugin-calendar-CQkP8bUI.js} +1 -1
- package/dist/assets/{plugin-charts-x_9Q2-i_.js → plugin-charts-CJxtgGBd.js} +1 -1
- package/dist/assets/{plugin-chatbot-CgNZnFch.js → plugin-chatbot-CgD9fZFI.js} +14 -14
- package/dist/assets/plugin-form-BFt_k4to.js +1 -0
- package/dist/assets/plugin-gantt-BKC7uDlF.js +1 -0
- package/dist/assets/plugin-grid-C9RnYppl.js +8 -0
- package/dist/assets/plugin-kanban-Bi-sR7AW.js +1 -0
- package/dist/assets/{plugin-map-DZdVR1tc.js → plugin-map-zYnfrqC_.js} +1 -1
- package/dist/assets/{plugin-markdown-BlHuacDq.js → plugin-markdown-D1ozhgoT.js} +1 -1
- package/dist/assets/{plugin-timeline-OEB0nyvd.js → plugin-timeline-B93E4n2x.js} +1 -1
- package/dist/assets/plugin-view-B94g0Ssh.js +1 -0
- package/dist/assets/plugins-views-Bi5okDge.js +63 -0
- package/dist/assets/src-DwuebCF9.js +1 -0
- package/dist/assets/ui-components-BL3SEdAz.css +1 -0
- package/dist/assets/ui-components-DSSaN2w_.js +36 -0
- package/dist/assets/{ui-layout-jqAD528v.js → ui-layout-iDLUMX7R.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +30 -30
- package/dist/assets/DashboardView-x75VLMQW.js +0 -1
- package/dist/assets/MetadataManagerPage-B0xfI-4w.js +0 -1
- package/dist/assets/ProfilePage-BO3TRbTV.js +0 -1
- package/dist/assets/RecordDetailView-Clze41HE.js +0 -1
- package/dist/assets/index-CPatxDwz.js +0 -2
- package/dist/assets/index-vbGrAsEJ.css +0 -2
- package/dist/assets/plugin-form-DOfn-uRa.js +0 -1
- package/dist/assets/plugin-gantt-CHZ4HLjh.js +0 -1
- package/dist/assets/plugin-grid-Cn_T_wpz.js +0 -8
- package/dist/assets/plugin-kanban-BsgjJQam.js +0 -1
- package/dist/assets/plugin-view-CJFsgQ9v.js +0 -1
- package/dist/assets/plugins-views-DqZMtAOw.js +0 -63
- package/dist/assets/src-D5NTzWsi.js +0 -1
- package/dist/assets/ui-components-B5ROGaJH.css +0 -1
- package/dist/assets/ui-components-B7mlp0en.js +0 -36
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n}from"./rolldown-runtime-S-ySWqyJ.js";import{_ as r,g as i,t as a}from"./vendor-react-B1k2FF9f.js";import{B as o,D as s,H as c,L as l,R as u,a as d,h as f,j as p,k as m,m as h,v as g,w as _,x as v,z as y}from"./framework-CoXA0nY6.js";import{d as b,f as x}from"./infrastructure-Djv3I7gr.js";import{i as S,t as C}from"./vendor-ui-utils-Dyl9EYZi.js";import{$A as w,$k as T,$n as E,BF as D,Bt as O,CP as k,C_ as A,Cd as j,Cy as M,DP as N,El as P,FC as ee,FS as F,Hh as te,Ht as ne,IA as I,MS as L,Nd as R,OL as re,Ol as z,PL as B,Pm as V,Qn as H,RS as U,Rd as W,Tu as ie,Ut as G,Vr as ae,Vt as oe,Wt as se,X as ce,XF as le,Xn as K,Xv as q,Yn as ue,Yp as de,Z as fe,ZA as pe,Zc as me,Zn as he,_c as ge,_t as _e,ar as ve,bd as ye,br as be,c as xe,cE as Se,cI as Ce,cn as we,ct as Te,dn as J,dt as Ee,er as Y,fI as De,ff as Oe,fn as X,ft as ke,gt as Ae,hc as je,ht as Me,iI as Ne,kv as Pe,ln as Fe,ls as Ie,lt as Le,mM as Re,mo as ze,mt as Be,nO as Ve,nr as He,op as Ue,pE as We,pj as Ge,px as Ke,qE as qe,rj as Je,rk as Ye,rr as Xe,rt as Ze,tI as Qe,tr as $e,tt as et,uE as tt,um as nt,un as rt,ut as it,ux as at,vu as ot,wb as st,wh as ct,xh as lt,xm as ut,yb as dt,yr as Z,z_ as ft,zr as pt,zt as mt}from"./ui-components-B7mlp0en.js";import{i as ht}from"./plugin-grid-Cn_T_wpz.js";var Q=t(r(),1),$=a(),gt={grid:(0,$.jsx)(U,{className:`h-4 w-4`}),kanban:(0,$.jsx)(dt,{className:`h-4 w-4`}),gallery:(0,$.jsx)(Ke,{className:`h-4 w-4`}),calendar:(0,$.jsx)(Re,{className:`h-4 w-4`}),timeline:(0,$.jsx)(re,{className:`h-4 w-4`}),gantt:(0,$.jsx)(z,{className:`h-4 w-4`}),map:(0,$.jsx)(Pe,{className:`h-4 w-4`})},_t={grid:`Grid`,kanban:`Kanban`,gallery:`Gallery`,calendar:`Calendar`,timeline:`Timeline`,gantt:`Gantt`,map:`Map`},vt=({currentView:e,availableViews:t=[`grid`,`kanban`],onViewChange:n,className:r,animated:i=!0})=>{let a=Q.useCallback(t=>{if(!i||t===e){n(t);return}typeof document<`u`&&`startViewTransition`in document?document.startViewTransition(()=>n(t)):n(t)},[i,e,n]);return(0,$.jsx)(`div`,{className:B(`flex items-center gap-1 bg-transparent oui-view-switcher`,r),children:t.map(t=>{let n=e===t;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(t),"aria-label":_t[t],title:_t[t],"aria-pressed":n,"data-state":n?`on`:`off`,className:B(`inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50`,`hover:bg-muted hover:text-muted-foreground`,`gap-2 px-3 py-2`,`data-[state=on]:bg-background data-[state=on]:text-foreground data-[state=on]:shadow-sm border-transparent border data-[state=on]:border-border/50`),children:[gt[t],(0,$.jsx)(`span`,{className:`hidden sm:inline-block text-xs font-medium`,children:_t[t]})]},t)})})};function yt(e){return e?be[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null}function bt(e){return e.filter(e=>e.pinned||e.visible!==`false`&&e.visible!==!1).sort((e,t)=>(e.order??0)-(t.order??0))}var xt=({tabs:e,activeTab:t,onTabChange:n,className:r})=>{let i=Q.useMemo(()=>bt(e),[e]),a=Q.useMemo(()=>i.find(e=>e.isDefault)?.name??i[0]?.name,[i]),[o,s]=Q.useState(a),c=t??o,l=Q.useCallback(e=>{s(e.name),n?.(e)},[n]);return i.length===0?null:(0,$.jsx)(`div`,{className:B(`border-b px-2 sm:px-4 py-1 flex items-center gap-0.5 bg-background`,r),"data-testid":`view-tabs`,role:`tablist`,children:i.map(e=>{let t=yt(e.icon),n=c===e.name;return(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-3 py-1.5 text-xs rounded-none transition-colors duration-150`,n?`border-b-2 border-primary font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),"data-testid":`view-tab-${e.name}`,role:`tab`,"aria-selected":n,onClick:()=>l(e),children:[t&&(0,$.jsx)(t,{className:`h-3 w-3 mr-1.5`}),e.label]},e.name)})})};function St({config:e,objectDef:t,data:n=[],onFilterChange:r,maxVisible:i,className:a}){switch(e.element){case`dropdown`:return(0,$.jsx)(wt,{fields:e.fields||[],objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a});case`tabs`:return(0,$.jsx)(Tt,{tabs:e.tabs||[],showAllRecords:e.showAllRecords!==!1,allowAddTab:e.allowAddTab,onFilterChange:r,className:a});case`toggle`:return(0,$.jsx)(Et,{fields:e.fields||[],onFilterChange:r,className:a});default:return null}}function Ct(e,t,n){return e.map(e=>{let r=e.options?[...e.options]:[];if(r.length===0&&t?.fields){let n=Array.isArray(t.fields)?t.fields.find(t=>t.name===e.field):t.fields[e.field];n?.options&&(r=Array.isArray(n.options)?n.options.map(e=>({label:e.label??String(e.value??e),value:e.value??e,color:e.color})):Object.entries(n.options).map(([e,t])=>({label:t?.label||e,value:e,color:t?.color})))}return e.showCount&&n.length>0&&(r=r.map(t=>({...t,count:n.filter(n=>n[e.field]===t.value).length}))),{...e,options:r}})}function wt({fields:e,objectDef:t,data:n,onFilterChange:r,maxVisible:i,className:a}){let[o,s]=Q.useState(()=>{let t={};return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&(t[e.field]=e.defaultValues)}),t}),c=Q.useMemo(()=>Ct(e,t,n),[e,t,n]),l=Q.useCallback(e=>{r(Object.entries(e).filter(([,e])=>e.length>0).map(([e,t])=>[e,`in`,t]))},[r]),u=(e,t)=>{let n={...o,[e]:t};s(n),l(n)};Q.useEffect(()=>{Object.values(o).some(e=>e.length>0)&&l(o)},[]);let d=i!==void 0&&i<c.length?c.slice(0,i):c,f=i!==void 0&&i<c.length?c.slice(i):[],p=e=>{let t=o[e.field]||[],n=t.length>0;return(0,$.jsxs)(we,{children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`filter-badge-${e.field}`,className:B(`inline-flex items-center gap-1 rounded-full border h-7 px-2.5 text-xs font-medium transition-colors shrink-0`,n?`border-primary/30 bg-primary/5 text-primary`:`border-border bg-background hover:bg-accent text-foreground`),children:[(0,$.jsx)(`span`,{className:`truncate max-w-[100px]`,children:e.label||e.field}),n&&(0,$.jsx)(`span`,{className:`flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 text-[10px]`,children:t.length}),n?(0,$.jsx)(ae,{className:`h-3 w-3 opacity-60`,"data-testid":`filter-clear-${e.field}`,onClick:t=>{t.stopPropagation(),u(e.field,[])}}):(0,$.jsx)(Je,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-56 p-2`,children:(0,$.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-0.5`,"data-testid":`filter-options-${e.field}`,children:e.options.map(n=>(0,$.jsxs)(`label`,{className:B(`flex items-center gap-2 text-sm py-1.5 px-2 rounded cursor-pointer`,t.includes(n.value)?`bg-primary/5 text-primary`:`hover:bg-muted`),children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:t.includes(n.value),onChange:()=>{let r=t.includes(n.value)?t.filter(e=>e!==n.value):[...t,n.value];u(e.field,r)},className:`rounded border-input`}),n.color&&(0,$.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:n.color}}),(0,$.jsx)(`span`,{className:`truncate flex-1`,children:n.label}),n.count!==void 0&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:n.count})]},String(n.value)))})})]},e.field)};return(0,$.jsxs)(`div`,{className:B(`flex items-center gap-1 overflow-x-auto`,a),"data-testid":`user-filters-dropdown`,children:[(0,$.jsx)(ie,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),c.length===0?(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,"data-testid":`user-filters-empty`,children:`No filter fields`}):(0,$.jsxs)($.Fragment,{children:[d.map(p),f.length>0&&(0,$.jsxs)(we,{children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(`button`,{"data-testid":`user-filters-more`,className:`inline-flex items-center gap-1 rounded-full border border-border bg-background hover:bg-accent text-foreground h-7 px-2.5 text-xs font-medium transition-colors shrink-0`,children:[(0,$.jsx)(`span`,{children:`More`}),(0,$.jsx)(`span`,{className:`flex h-4 min-w-[16px] items-center justify-center rounded-full bg-muted text-[10px] font-medium`,children:f.length}),(0,$.jsx)(Je,{className:`h-3 w-3 opacity-60`})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-64 p-2`,"data-testid":`user-filters-more-content`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:f.map(p)})})]})]})]})}function Tt({tabs:e,showAllRecords:t,allowAddTab:n,onFilterChange:r,className:i}){let[a,o]=Q.useState(()=>e.find(e=>e.default)?.id||(t?`__all__`:e[0]?.id||``)),s=Q.useCallback(t=>{o(t),r(t===`__all__`?[]:e.find(e=>e.id===t)?.filters||[])},[e,r]),c=Q.useMemo(()=>{let n=[...e];return t&&n.push({id:`__all__`,label:`All records`,filters:[]}),n},[e,t]);return Q.useEffect(()=>{let t=e.find(e=>e.default);t&&r(t.filters||[])},[]),(0,$.jsxs)(`div`,{className:B(`flex items-center gap-0.5 overflow-x-auto`,i),"data-testid":`user-filters-tabs`,children:[c.map(e=>(0,$.jsx)(`button`,{"data-testid":`filter-tab-${e.id}`,onClick:()=>s(e.id),className:B(`inline-flex items-center h-7 px-3 text-xs font-medium rounded-md transition-colors shrink-0`,a===e.id?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:e.label},e.id)),n&&(0,$.jsx)(`button`,{className:`inline-flex items-center justify-center h-7 w-7 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted shrink-0`,"data-testid":`filter-tab-add`,title:`Add filter tab`,children:(0,$.jsx)(nt,{className:`h-3.5 w-3.5`})})]})}function Et({fields:e,onFilterChange:t,className:n}){let[r,i]=Q.useState(()=>{let t=new Set;return e.forEach(e=>{e.defaultValues&&e.defaultValues.length>0&&t.add(e.field)}),t}),a=Q.useCallback(n=>{t(Array.from(n).map(t=>{let n=e.find(e=>e.field===t);return n?.defaultValues?[t,`in`,n.defaultValues]:[t,`!=`,null]}))},[e,t]),o=e=>{i(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),a(n),n})};return Q.useEffect(()=>{r.size>0&&a(r)},[]),(0,$.jsx)(`div`,{className:B(`flex items-center gap-1 overflow-x-auto`,n),"data-testid":`user-filters-toggle`,children:e.map(e=>(0,$.jsx)(Z,{variant:r.has(e.field)?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs shrink-0`,"data-testid":`filter-toggle-${e.field}`,onClick:()=>o(e.field),children:e.label||e.field},e.field))})}function Dt(e){switch(e){case`equals`:case`eq`:return`=`;case`notEquals`:case`ne`:case`neq`:return`!=`;case`contains`:return`contains`;case`notContains`:return`notcontains`;case`greaterThan`:case`gt`:return`>`;case`greaterOrEqual`:case`gte`:return`>=`;case`lessThan`:case`lt`:return`<`;case`lessOrEqual`:case`lte`:return`<=`;case`in`:return`in`;case`notIn`:return`not in`;case`before`:return`<`;case`after`:return`>`;default:return e}}function Ot(e){if(!Array.isArray(e)||e.length<3)return e;let[t,n,r]=e;return typeof t==`string`&&(t===`and`||t===`or`)?[t,...e.slice(1).map(e=>Array.isArray(e)?Ot(e):e)]:n===`in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`=`,r[0]]:[`or`,...r.map(e=>[t,`=`,e])]:n===`not in`&&Array.isArray(r)?r.length===0?[]:r.length===1?[t,`!=`,r[0]]:[`and`,...r.map(e=>[t,`!=`,e])]:e}function kt(e){return e.replace(/_/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function At(e){return!Array.isArray(e)||e.length===0?[]:e.map(e=>Array.isArray(e)?Ot(e):e).filter(e=>Array.isArray(e)&&e.length>0)}function jt(e){if(!e||!e.conditions||e.conditions.length===0)return[];let t=At(e.conditions.map(e=>e.operator===`isEmpty`?[e.field,`=`,null]:e.operator===`isNotEmpty`?[e.field,`!=`,null]:[e.field,Dt(e.operator),e.value]));return t.length===0?[]:t.length===1?t[0]:[e.logic,...t]}var Mt={"list.recordCount":`{{count}} records`,"list.recordCountOne":`{{count}} record`,"list.noItems":`No items found`,"list.noItemsMessage":`There are no records to display. Try adjusting your filters or adding new data.`,"list.search":`Search`,"list.filter":`Filter`,"list.filterRecords":`Filter Records`,"list.sort":`Sort`,"list.sortRecords":`Sort Records`,"list.group":`Group`,"list.groupBy":`Group By`,"list.export":`Export`,"list.exportAs":`Export as {{format}}`,"list.color":`Color`,"list.rowColor":`Row Color`,"list.colorByField":`Color by field`,"list.clear":`Clear`,"list.none":`None`,"list.hideFields":`Hide fields`,"list.showAll":`Show all`,"list.pullToRefresh":`Pull to refresh`,"list.refreshing":`Refreshing…`,"list.dataLimitReached":`Showing first {{limit}} records. More data may be available.`,"list.addRecord":`Add record`,"list.tabs":`Tabs`,"list.allRecords":`All Records`,"list.share":`Share`,"list.print":`Print`,"list.hideFieldsTitle":`Hide Fields`};function Nt(){try{let e=d();return e.t(`list.recordCount`)===`list.recordCount`?{t:(e,t)=>{let n=Mt[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}}:{t:e.t}}catch{return{t:(e,t)=>{let n=Mt[e]||e;if(t)for(let[e,r]of Object.entries(t))n=n.replace(`{{${e}}}`,String(r));return n}}}}function Pt(){try{let{fieldLabel:e}=b();return{fieldLabel:e}}catch{return{fieldLabel:(e,t,n)=>n}}}var Ft=Q.forwardRef(({schema:e,className:t,onViewChange:n,onFilterChange:r,onSortChange:i,onSearchChange:a,onRowClick:c,showViewSwitcher:u=!1,...d},f)=>{let{t:p}=Nt(),{fieldLabel:m}=Pt(),h=Q.useMemo(()=>({...e,viewType:e.viewType||`grid`}),[e]),g=Q.useCallback((e,t)=>h.objectName?m(h.objectName,e,t):t,[h.objectName,m]),b=Q.useMemo(()=>{let e=h.userActions,t=h.addRecord?.enabled===!0&&e?.addRecordForm!==!1;return{showSearch:e?.search===void 0?h.showSearch!==!1:e.search,showSort:e?.sort===void 0?h.showSort!==!1:e.sort,showFilters:e?.filter===void 0?h.showFilters!==!1:e.filter,showDensity:e?.rowHeight===void 0?h.showDensity===!0:e.rowHeight,showHideFields:h.showHideFields===!0,showGroup:h.showGroup!==!1,showColor:h.showColor===!0,showAddRecord:t,addRecordPosition:h.addRecord?.position===`bottom`?`bottom`:`top`}},[h.userActions,h.showSearch,h.showSort,h.showFilters,h.showDensity,h.showHideFields,h.showGroup,h.showColor,h.addRecord,h.userActions?.addRecordForm]),[x,S]=Q.useState(h.viewType),[C,w]=Q.useState(``),[T,E]=Q.useState(!1),[D,O]=Q.useState(!1),[k,A]=Q.useState(()=>h.sort&&h.sort.length>0?h.sort.map(e=>{if(typeof e==`string`){let t=e.trim().split(/\s+/);return{id:crypto.randomUUID(),field:t[0],order:t[1]?.toLowerCase()===`desc`?`desc`:`asc`}}return{id:crypto.randomUUID(),field:e.field,order:e.order||`asc`}}):[]),[j,M]=Q.useState(!1),[N,P]=Q.useState({id:`root`,logic:`and`,conditions:[]}),[ee,F]=Q.useState(()=>{if(!(!h.tabs||h.tabs.length===0))return h.tabs.find(e=>e.isDefault)?.name??h.tabs[0]?.name}),ne=Q.useCallback(e=>{if(F(e.name),e.filter){let t={id:`tab-filter-${e.name}`,logic:e.filter.logic||`and`,conditions:e.filter.conditions||[]};P(t),r?.(t)}else{let e={id:`root`,logic:`and`,conditions:[]};P(e),r?.(e)}},[r]),I=d.dataSource,[R,re]=Q.useState([]),[z,V]=Q.useState(!1),[H,U]=Q.useState(null),[G,oe]=Q.useState(!1),[se,ce]=Q.useState(0),[K,q]=Q.useState(!1);Q.useImperativeHandle(f,()=>({refresh:()=>ce(e=>e+1)}),[]),Q.useEffect(()=>{if(!(!I?.onMutation||!h.objectName||h.refreshTrigger))return I.onMutation(e=>{e.resource===h.objectName&&ce(e=>e+1)})},[I,h.objectName,h.refreshTrigger]);let[ue,fe]=Q.useState(void 0),pe=ue??h.pagination?.pageSize??100,me=Q.useMemo(()=>{if(h.grouping?.fields?.length)return h.grouping;let e=typeof h.groupBy==`string`?h.groupBy.trim():``,t=typeof h.groupBy2==`string`?h.groupBy2.trim():``,n=[];return e&&n.push({field:e,order:`asc`,collapsed:!1}),t&&t!==e&&n.push({field:t,order:`asc`,collapsed:!1}),n.length>0?{fields:n}:void 0},[h.grouping,h.groupBy,h.groupBy2]),[he,ge]=Q.useState(me),[_e,ve]=Q.useState(!1),xe=Q.useRef(me);Q.useEffect(()=>{xe.current!==me&&(xe.current=me,ge(me))},[me]);let[Se,Ce]=Q.useState(h.rowColor),[Te,Ee]=Q.useState(!1),[Y,De]=Q.useState([]),Oe=Q.useRef(0),[X,ke]=Q.useState(()=>{let e=new Set;return h.quickFilters?.forEach(t=>{let n=y(t);n.defaultActive&&e.add(n.id)}),e}),[Ae,je]=Q.useState([]),Me=Q.useMemo(()=>{if(h.userFilters)return h.userFilters;if(!H?.fields)return;let e=new Set([`select`,`multi-select`,`boolean`]),t=[],n=Array.isArray(H.fields)?H.fields.map(e=>[e.name,e]):Object.entries(H.fields);for(let[r,i]of n)(e.has(i.type)||i.options&&!i.type)&&t.push({field:r,label:g(r,i.label||r),type:i.type===`boolean`?`boolean`:i.type===`multi-select`?`multi-select`:`select`});if(t.length!==0)return{element:`dropdown`,fields:t}},[h.userFilters,H]),[Ne,Pe]=Q.useState(()=>new Set(h.hiddenFields||[])),[Re,ze]=Q.useState(!1),[Be,Ve]=Q.useState(!1),He=Q.useMemo(()=>o(h.quickFilters),[h.quickFilters]),Ue=Q.useMemo(()=>{if(h.exportOptions)return Array.isArray(h.exportOptions)?{formats:h.exportOptions}:h.exportOptions},[h.exportOptions]),We=v(Q.useMemo(()=>h.densityMode?h.densityMode:h.rowHeight?{compact:`compact`,short:`compact`,medium:`comfortable`,tall:`spacious`,extra_tall:`spacious`}[h.rowHeight]||`comfortable`:`compact`,[h.densityMode,h.rowHeight])),{ref:Ge,isRefreshing:Ke,pullDistance:Je}=ht({onRefresh:Q.useCallback(async()=>{ce(e=>e+1)},[]),enabled:!!I&&!!h.objectName}),Ye=Q.useMemo(()=>h.id?`listview-${h.objectName}-${h.id}-view`:`listview-${h.objectName}-view`,[h.objectName,h.id]);Q.useEffect(()=>{let e=!0;return oe(!1),U(null),(async()=>{if(!I||!h.objectName){oe(!0);return}if(typeof I.getObjectSchema!=`function`){oe(!0);return}try{let t=await I.getObjectSchema(h.objectName);e&&U(t)}catch(e){console.warn(`Failed to fetch object schema for ListView:`,e)}finally{e&&oe(!0)}})(),()=>{e=!1}},[h.objectName,I]);let Xe=Q.useMemo(()=>l(H?.fields,h.fields),[H?.fields,h.fields]);Q.useEffect(()=>{let e=!0,t=++Oe.current;if(h.data&&typeof h.data==`object`&&!Array.isArray(h.data)){let e=h.data;if(e.provider===`value`&&Array.isArray(e.items)){let t=e.items;if(C){let e=C.toLowerCase();t=t.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))}re(t),V(!1),q(!1);return}}if(Array.isArray(h.data)){let e=h.data;if(C){let t=C.toLowerCase();e=e.filter(e=>Object.values(e).some(e=>e!=null&&String(e).toLowerCase().includes(t)))}re(e),V(!1),q(!1);return}return G?((async()=>{if(!(!I||!h.objectName)){V(!0);try{let n=[],r=h.filters||[],i=jt(N),a=[];He&&X.size>0&&He.forEach(e=>{X.has(e.id)&&e.filters&&e.filters.length>0&&a.push(e.filters)});let o=At(Ae),s=[...r.length>0?[r]:[],...i.length>0?[i]:[],...a,...o].filter(e=>Array.isArray(e)&&e.length>0);s.length>1?n=[`and`,...s]:s.length===1&&(n=s[0]);let c=k.length>0?k.filter(e=>e.field).map(e=>({field:e.field,order:e.order})):void 0,l=(()=>{let e=Array.isArray(h.fields)?h.fields.map(e=>typeof e==`string`?e:e?.field).filter(e=>typeof e==`string`&&e.length>0):[];if(e.length===0)return;let t=new Set([`id`]);for(let n of e)t.add(n);for(let e of Xe)t.add(e);let n=e=>{if(!e)return;let n=[e.groupField,e.groupBy,e.titleField,e.cardTitle,e.startDateField,e.endDateField,e.dateField,e.endField,e.colorField,e.allDayField,e.coverField,e.imageField,e.subtitleField,e.swimlaneField,e.valueField,...Array.isArray(e.cardFields)?e.cardFields:[],...Array.isArray(e.visibleFields)?e.visibleFields:[]];for(let e of n)typeof e==`string`&&e&&t.add(e)};return n(h.kanban),n(h.options?.kanban),n(h.calendar),n(h.options?.calendar),n(h.gallery),n(h.options?.gallery),n(h.timeline),n(h.options?.timeline),n(h.gantt),n(h.options?.gantt),Array.from(t)})(),u=Array.isArray(n)?n.length>0:!!n&&Object.keys(n).length>0,d=await I.find(h.objectName,{...u?{$filter:n}:{},$orderby:c,$top:pe,...l?{$select:l}:{},...Xe.length>0?{$expand:Xe}:{},...C?{$search:C,...h.searchableFields&&h.searchableFields.length>0?{$searchFields:h.searchableFields}:{}}:{}});if(!e||t!==Oe.current)return;let f=[];Array.isArray(d)?f=d:d&&typeof d==`object`&&(Array.isArray(d.data)?f=d.data:Array.isArray(d.records)?f=d.records:Array.isArray(d.value)&&(f=d.value)),re(f),q(f.length>=pe)}catch(e){t===Oe.current&&console.error(`ListView data fetch error:`,e)}finally{e&&t===Oe.current&&V(!1)}}})(),()=>{e=!1}):void 0},[h.objectName,h.data,I,h.filters,pe,k,N,X,He,Ae,se,C,h.searchableFields,Xe,G,h.refreshTrigger]);let Qe=Q.useMemo(()=>{if(h.appearance?.allowedVisualizations&&h.appearance.allowedVisualizations.length>0)return h.appearance.allowedVisualizations.filter(e=>[`grid`,`kanban`,`gallery`,`calendar`,`timeline`,`gantt`,`map`].includes(e));let e=[`grid`];return(h.kanban?.groupField||h.options?.kanban?.groupField)&&e.push(`kanban`),(h.gallery?.coverField||h.gallery?.imageField||h.options?.gallery?.imageField)&&e.push(`gallery`),(h.calendar?.startDateField||h.options?.calendar?.startDateField)&&e.push(`calendar`),(h.timeline?.startDateField||h.options?.timeline?.startDateField||h.options?.timeline?.dateField||h.options?.calendar?.startDateField)&&e.push(`timeline`),(h.gantt?.startDateField||h.options?.gantt?.startDateField)&&e.push(`gantt`),(h.options?.map?.locationField||h.options?.map?.latitudeField&&h.options?.map?.longitudeField)&&e.push(`map`),h.viewType&&!e.includes(h.viewType)&&[`grid`,`kanban`,`calendar`,`timeline`,`gantt`,`map`,`gallery`].includes(h.viewType)&&e.push(h.viewType),e},[h.options,h.viewType,h.kanban,h.calendar,h.gantt,h.gallery,h.timeline,h.appearance?.allowedVisualizations]);Q.useEffect(()=>{h.viewType&&S(h.viewType)},[h.viewType]);let $e=Q.useCallback(e=>{S(e);try{localStorage.setItem(Ye,e)}catch(e){console.warn(`Failed to save view preference to localStorage:`,e)}n?.(e)},[Ye,n]),ot=Q.useCallback(e=>{w(e),a?.(e)},[a]),st=_({navigation:h.navigation,objectName:h.objectName,onNavigate:h.onNavigate,onRowClick:c}),ct=Q.useMemo(()=>{let e=h.fields||[];if(Array.isArray(e)||(e=[]),Ne.size>0&&(e=e.filter(e=>{let t=typeof e==`string`?e:e?.name||e?.fieldName||e?.field;return t!=null&&!Ne.has(t)})),h.fieldOrder&&h.fieldOrder.length>0){let t=new Map(h.fieldOrder.map((e,t)=>[e,t]));e=[...e].sort((e,n)=>{let r=typeof e==`string`?e:e?.name||e?.fieldName||e?.field,i=typeof n==`string`?n:n?.name||n?.fieldName||n?.field;return(t.get(r)??1/0)-(t.get(i)??1/0)})}return e},[h.fields,Ne,h.fieldOrder]),lt=Q.useMemo(()=>{let e={objectName:h.objectName,fields:ct,filters:h.filters,sort:k,className:`h-full w-full`,showSearch:!1,onRowClick:st.handleClick,...h.striped==null?{}:{striped:h.striped},...h.bordered==null?{}:{bordered:h.bordered}};switch(x){case`grid`:return{type:`object-grid`,...e,columns:ct,...h.conditionalFormatting?{conditionalFormatting:h.conditionalFormatting}:{},...h.inlineEdit==null?{}:{editable:h.inlineEdit},...h.wrapHeaders==null?{}:{wrapHeaders:h.wrapHeaders},...h.virtualScroll==null?{}:{virtualScroll:h.virtualScroll},...h.resizable==null?{}:{resizable:h.resizable},...h.selection?{selection:h.selection}:{},...h.pagination?{pagination:h.pagination}:{},...he?{grouping:he}:{},...Se?{rowColor:Se}:{},...h.rowActions?{rowActions:h.rowActions}:{},...h.bulkActions?{batchActions:h.bulkActions}:{},...h.options?.grid||{}};case`kanban`:return{type:`object-kanban`,...e,groupBy:h.kanban?.groupField||h.options?.kanban?.groupField||`status`,groupField:h.kanban?.groupField||h.options?.kanban?.groupField||`status`,...h.kanban?.titleField||h.options?.kanban?.titleField?{titleField:h.kanban?.titleField||h.options?.kanban?.titleField}:{},cardFields:h.kanban?.cardFields||ct||[],...he?{grouping:he}:{},...h.options?.kanban||{},...h.kanban||{}};case`calendar`:return{type:`object-calendar`,...e,startDateField:h.calendar?.startDateField||h.options?.calendar?.startDateField||`start_date`,endDateField:h.calendar?.endDateField||h.options?.calendar?.endDateField||`end_date`,...h.calendar?.titleField||h.options?.calendar?.titleField?{titleField:h.calendar?.titleField||h.options?.calendar?.titleField}:{},...h.calendar?.defaultView?{defaultView:h.calendar.defaultView}:{},...h.options?.calendar||{},...h.calendar||{}};case`gallery`:{let t={...h.options?.gallery||{},...h.gallery||{}};return{type:`object-gallery`,...e,gallery:Object.keys(t).length>0?t:void 0,imageField:h.gallery?.coverField||h.gallery?.imageField||h.options?.gallery?.imageField,titleField:h.gallery?.titleField||h.options?.gallery?.titleField||`name`,subtitleField:h.gallery?.subtitleField||h.options?.gallery?.subtitleField,...he?{grouping:he}:{}}}case`timeline`:{let t={...h.options?.timeline||{},...h.timeline||{}};return{type:`object-timeline`,...e,timeline:Object.keys(t).length>0?t:void 0,startDateField:h.timeline?.startDateField||h.options?.timeline?.startDateField||h.options?.timeline?.dateField||`created_at`,titleField:h.timeline?.titleField||h.options?.timeline?.titleField||`name`,...h.timeline?.endDateField?{endDateField:h.timeline.endDateField}:{},...h.timeline?.groupByField?{groupByField:h.timeline.groupByField}:{},...h.timeline?.colorField?{colorField:h.timeline.colorField}:{},...h.timeline?.scale?{scale:h.timeline.scale}:{}}}case`gantt`:return{type:`object-gantt`,...e,startDateField:h.gantt?.startDateField||h.options?.gantt?.startDateField||`start_date`,endDateField:h.gantt?.endDateField||h.options?.gantt?.endDateField||`end_date`,progressField:h.gantt?.progressField||h.options?.gantt?.progressField||`progress`,dependenciesField:h.gantt?.dependenciesField||h.options?.gantt?.dependenciesField||`dependencies`,...h.gantt?.titleField?{titleField:h.gantt.titleField}:{},...h.options?.gantt||{},...h.gantt||{}};case`map`:return{type:`object-map`,...e,locationField:h.options?.map?.locationField||`location`,...h.options?.map||{}};default:return e}},[x,h,k,ct,he,Se,st.handleClick]),ut=N.conditions&&N.conditions.length>0,dt=Q.useMemo(()=>{let e;if(e=H?.fields?Object.entries(H.fields).map(([e,t])=>({value:e,label:g(e,t.label||e),type:t.type||`text`,options:t.options})):(h.fields||[]).map(e=>{if(typeof e==`string`)return{value:e,label:e,type:`text`};let t=e.name||e.fieldName;return{value:t,label:g(t,e.label||e.name),type:e.type||`text`,options:e.options}}),h.filterableFields&&h.filterableFields.length>0){let t=new Set(h.filterableFields);e=e.filter(e=>t.has(e.value))}return e},[H,h.fields,h.filterableFields]),ft=Q.useCallback(e=>{ke(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),pt=Q.useCallback(e=>{let t=Ue,n=t?.maxRecords||0,r=t?.includeHeaders!==!1,i=t?.fileNamePrefix||h.objectName||`export`,a=n>0?R.slice(0,n):R;if(e===`csv`){let e=ct.map(e=>typeof e==`string`?e:e.name||e.fieldName||e.field),t=[];r&&t.push(e.join(`,`)),a.forEach(n=>{t.push(e.map(e=>{let t=n[e],r;return r=t==null?``:Array.isArray(t)?t.map(e=>typeof e==`object`&&e?JSON.stringify(e):String(e??``)).join(`; `):typeof t==`object`?JSON.stringify(t):String(t),r.includes(`,`)||r.includes(`"`)||r.includes(`
|
|
2
|
-
`)||r.includes(`\r`)?`"${r.replace(/"/g,`""`)}"`:r}).join(`,`))});let n=new Blob([t.join(`
|
|
3
|
-
`)],{type:`text/csv;charset=utf-8;`}),o=URL.createObjectURL(n),s=document.createElement(`a`);s.href=o,s.download=`${i}.csv`,s.click(),URL.revokeObjectURL(o)}else if(e===`json`){let e=new Blob([JSON.stringify(a,null,2)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${i}.json`,n.click(),URL.revokeObjectURL(t)}Ve(!1)},[R,ct,Ue,h.objectName]),mt=Q.useMemo(()=>(h.fields||[]).map(e=>{if(typeof e==`string`)return{name:e,label:g(e,e)};let t=e.name||e.fieldName||e.field;return{name:t,label:g(t,e.label||e.name||e.field)}}),[h.fields,g]);return(0,$.jsxs)(`div`,{ref:Ge,className:B(`flex flex-col h-full bg-background relative min-w-0 overflow-hidden`,t),...h.aria?.label?{"aria-label":h.aria.label}:{},...h.aria?.describedBy?{"aria-describedby":h.aria.describedBy}:{},...h.aria?.live?{"aria-live":h.aria.live}:{},role:`region`,children:[Je>0&&(0,$.jsx)(`div`,{className:`flex items-center justify-center text-xs text-muted-foreground`,style:{height:Je},children:p(Ke?`list.refreshing`:`list.pullToRefresh`)}),u&&(0,$.jsx)(`div`,{className:`border-b px-4 py-1 flex items-center bg-background`,children:(0,$.jsx)(vt,{currentView:x,availableViews:Qe,onViewChange:$e})}),h.tabs&&h.tabs.length>0&&(0,$.jsx)(xt,{tabs:h.tabs,activeTab:ee,onTabChange:ne}),h.description&&h.appearance?.showDescription!==!1&&(0,$.jsx)(`div`,{className:`border-b px-4 py-1.5 text-xs text-muted-foreground bg-background`,"data-testid":`view-description`,children:typeof h.description==`string`?h.description:``}),(0,$.jsxs)(`div`,{className:`border-b px-2 sm:px-4 py-1 flex items-center justify-between gap-1 sm:gap-2 bg-background`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-0.5 overflow-x-auto min-w-0`,children:Me&&(0,$.jsx)(`div`,{className:`shrink-0 min-w-0`,"data-testid":`user-filters`,children:(0,$.jsx)(St,{config:Me,objectDef:H,data:R,onFilterChange:je,maxVisible:3})})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-0.5 shrink-0`,children:[b.showHideFields&&(0,$.jsxs)(we,{open:Re,onOpenChange:ze,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Ne.size>0&&`text-primary`),children:[(0,$.jsx)(tt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.hideFields`)}),Ne.size>0&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-medium text-primary`,children:Ne.size})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-64 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:p(`list.hideFieldsTitle`)}),Ne.size>0&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Pe(new Set),children:p(`list.showAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-60 overflow-y-auto space-y-1`,children:mt.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm py-1 px-1 rounded hover:bg-muted cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:!Ne.has(e.name),onChange:()=>{Pe(t=>{let n=new Set(t);return n.has(e.name)?n.delete(e.name):n.add(e.name),n})},className:`rounded border-input`}),(0,$.jsx)(`span`,{className:`truncate`,children:e.label})]},e.name))})]})})]}),b.showHideFields&&(b.showFilters||b.showSort||b.showGroup)&&(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5 shrink-0`}),b.showFilters&&(0,$.jsxs)(we,{open:j,onOpenChange:M,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,ut&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(ie,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.filter`)}),ut&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-medium text-primary`,children:N.conditions?.length||0})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:p(`list.filterRecords`)})}),(0,$.jsx)(it,{fields:dt,value:N,onChange:e=>{P(e),r&&r(e)}})]})})]}),b.showGroup&&(0,$.jsxs)(we,{open:_e,onOpenChange:ve,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,he&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(L,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.group`)}),he&&he.fields?.length>0&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-medium text-primary`,children:he.fields.length})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-72 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:p(`list.groupBy`)}),he&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>ge(void 0),"data-testid":`clear-grouping`,children:p(`list.clear`)})]}),(0,$.jsx)(`div`,{"data-testid":`group-field-list`,children:(0,$.jsx)(et,{value:he,fieldOptions:mt.map(e=>({value:e.name,label:e.label||e.name})),maxLevels:3,labels:{addGroup:p(`list.addGroup`,`Add group field`),collapseTitle:p(`list.collapsedByDefault`,`Collapsed by default`),removeTitle:p(`list.removeGroup`,`Remove`)},onChange:e=>ge(e)})})]})})]}),b.showSort&&(0,$.jsxs)(we,{open:D,onOpenChange:O,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,k.length>0&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(le,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.sort`)}),k.length>0&&(0,$.jsx)(`span`,{className:`ml-1 flex h-4 min-w-[16px] items-center justify-center rounded-full bg-primary/10 text-[10px] font-medium text-primary`,children:k.length})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-[calc(100vw-2rem)] sm:w-[600px] max-w-[600px] p-3 sm:p-4`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:p(`list.sortRecords`)})}),(0,$.jsx)(Le,{fields:dt,value:k,onChange:e=>{A(e),i&&i(e)}})]})})]}),(b.showFilters||b.showSort||b.showGroup)&&(b.showColor||b.showDensity)&&(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5 shrink-0`}),b.showColor&&(0,$.jsxs)(we,{open:Te,onOpenChange:Ee,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,Se&&`bg-primary/10 border border-primary/20 text-primary`),children:[(0,$.jsx)(te,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.color`)})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-64 p-3`,children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b pb-2`,children:[(0,$.jsx)(`h4`,{className:`font-medium text-sm`,children:p(`list.rowColor`)}),Se&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>Ce(void 0),"data-testid":`clear-row-color`,children:p(`list.clear`)})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,"data-testid":`color-field-list`,children:[(0,$.jsx)(`label`,{className:`text-xs text-muted-foreground`,children:p(`list.colorByField`)}),(0,$.jsxs)(`select`,{className:`w-full h-8 rounded border border-input bg-background px-2 text-xs`,value:Se?.field||``,onChange:e=>{let t=e.target.value;Ce(t?{field:t,colors:Se?.colors||{}}:void 0)},"data-testid":`color-field-select`,children:[(0,$.jsx)(`option`,{value:``,children:p(`list.none`)}),mt.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.label},e.name))]})]})]})})]}),b.showDensity&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 px-2 text-muted-foreground hover:text-primary text-xs hidden lg:flex transition-colors duration-150`,We.mode!==`compact`&&`bg-primary/10 border border-primary/20 text-primary`),onClick:We.cycle,title:`Density: ${We.mode}`,children:[(0,$.jsx)(Ie,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline capitalize`,children:We.mode})]}),(b.showColor||b.showDensity)&&Ue&&h.allowExport!==!1&&(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5 shrink-0`}),Ue&&h.allowExport!==!1&&(0,$.jsxs)(we,{open:Be,onOpenChange:Ve,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,children:[(0,$.jsx)(qe,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.export`)})]})}),(0,$.jsx)(Fe,{align:`start`,className:`w-48 p-2`,children:(0,$.jsx)(`div`,{className:`space-y-1`,children:(Ue.formats||[`csv`,`json`]).map(e=>(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`w-full justify-start h-8 text-xs`,onClick:()=>pt(e),children:[(0,$.jsx)(qe,{className:`h-3.5 w-3.5 mr-2`}),p(`list.exportAs`,{format:e.toUpperCase()})]},e))})})]}),(h.sharing?.enabled||h.sharing?.type)&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,title:`Sharing: ${h.sharing?.visibility||h.sharing?.type||`private`}`,"data-testid":`share-button`,children:[(0,$.jsx)(ye,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.share`)})]}),h.allowPrinting&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,onClick:()=>window.print(),"data-testid":`print-button`,children:[(0,$.jsx)(de,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.print`)})]}),(()=>{let e=h.allowPrinting||h.sharing?.enabled||h.sharing?.type||Ue&&h.allowExport!==!1;return b.showSearch&&e?(0,$.jsx)(`div`,{className:`h-4 w-px bg-border/60 mx-0.5 shrink-0`}):null})(),b.showSearch&&(0,$.jsxs)(we,{open:T,onOpenChange:E,children:[(0,$.jsx)(rt,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:B(`h-7 w-7 p-0 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,C&&`bg-primary/10 border border-primary/20 text-primary`),"data-testid":`search-icon-button`,title:p(`list.search`),children:(0,$.jsx)(W,{className:`h-3.5 w-3.5`})})}),(0,$.jsx)(Fe,{align:`end`,className:`w-[calc(100vw-2rem)] sm:w-64 p-2`,"data-testid":`search-popover`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(W,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(J,{placeholder:p(`list.search`)+`...`,value:C,onChange:e=>ot(e.target.value),className:`pl-7 h-8 text-xs`,autoFocus:!0}),C&&(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`absolute right-0.5 top-1/2 -translate-y-1/2 h-5 w-5 p-0 hover:bg-muted-foreground/20`,onClick:()=>ot(``),children:(0,$.jsx)(ae,{className:`h-3 w-3`})})]})})]}),b.showAddRecord&&b.addRecordPosition===`top`&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>d.onAddRecord?.(),children:[(0,$.jsx)(nt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.addRecord`)})]})]})]}),He&&He.length>0&&(0,$.jsx)(`div`,{className:`border-b px-2 sm:px-4 py-1 flex items-center gap-1 flex-wrap bg-background`,"data-testid":`quick-filters`,children:He.map(e=>{let t=X.has(e.id),n=e.icon?be[e.icon.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??null:null;return(0,$.jsxs)(Z,{variant:t?`default`:`outline`,size:`sm`,className:`h-7 px-3 text-xs`,onClick:()=>ft(e.id),children:[n&&(0,$.jsx)(n,{className:`h-3 w-3 mr-1.5`}),e.label]},e.id)})}),(0,$.jsx)(`div`,{className:`flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200`,children:!z&&R.length===0?(()=>{let e=h.emptyState?.icon;return(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full min-h-[200px] text-center p-8`,"data-testid":`empty-state`,children:[(0,$.jsx)(e?be[e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]??at:at,{className:`h-12 w-12 text-muted-foreground/50 mb-4`}),(0,$.jsx)(`h3`,{className:`text-lg font-medium text-foreground mb-1`,children:(typeof h.emptyState?.title==`string`?h.emptyState.title:void 0)??`No items found`}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground max-w-md`,children:(typeof h.emptyState?.message==`string`?h.emptyState.message:void 0)??`There are no records to display. Try adjusting your filters or adding new data.`}),b.showAddRecord&&(0,$.jsxs)(Z,{variant:`default`,size:`sm`,className:`mt-4`,"data-testid":`empty-state-add-record`,onClick:()=>d.onAddRecord?.(),children:[(0,$.jsx)(nt,{className:`h-4 w-4 mr-1.5`}),p(`list.addRecord`)]})]})})():(0,$.jsx)(s,{schema:lt,...d,data:R,loading:z,onRowSelect:De})},x),b.showAddRecord&&b.addRecordPosition===`bottom`&&(0,$.jsx)(`div`,{className:`border-t px-2 sm:px-4 py-1 bg-background shrink-0`,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground hover:text-primary text-xs transition-colors duration-150`,"data-testid":`add-record-button`,onClick:()=>d.onAddRecord?.(),children:[(0,$.jsx)(nt,{className:`h-3.5 w-3.5 mr-1.5`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:p(`list.addRecord`)})]})}),h.bulkActions&&h.bulkActions.length>0&&Y.length>0&&x!==`grid`&&(0,$.jsxs)(`div`,{className:`border-t px-4 py-1.5 flex items-center gap-2 text-xs bg-primary/5 shrink-0`,"data-testid":`bulk-actions-bar`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground font-medium`,children:[Y.length,` selected`]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1 ml-2`,children:h.bulkActions.map(e=>(0,$.jsx)(Z,{variant:`outline`,size:`sm`,className:`h-6 px-2 text-xs`,onClick:()=>d.onBulkAction?.(e,Y),"data-testid":`bulk-action-${e}`,children:kt(e)},e))}),(0,$.jsx)(Z,{variant:`ghost`,size:`sm`,className:`h-6 px-2 text-xs ml-auto`,onClick:()=>De([]),children:`Clear`})]}),!z&&R.length>0&&h.showRecordCount!==!1&&(0,$.jsxs)(`div`,{className:`border-t px-4 py-1.5 flex items-center gap-2 text-xs text-muted-foreground bg-background shrink-0`,"data-testid":`record-count-bar`,children:[(0,$.jsx)(`span`,{children:R.length===1?p(`list.recordCountOne`,{count:R.length}):p(`list.recordCount`,{count:R.length})}),K&&(0,$.jsx)(`span`,{className:`text-amber-600`,"data-testid":`data-limit-warning`,children:p(`list.dataLimitReached`,{limit:pe})}),h.pagination?.pageSizeOptions&&h.pagination.pageSizeOptions.length>0&&(0,$.jsx)(`select`,{className:`ml-auto h-6 rounded border border-input bg-background px-1 text-xs`,value:pe,onChange:e=>{let t=Number(e.target.value);fe(t),d.onPageSizeChange&&d.onPageSizeChange(t)},"data-testid":`page-size-selector`,children:h.pagination.pageSizeOptions.map(e=>(0,$.jsxs)(`option`,{value:e,children:[e,` / page`]},e))})]}),st.isOverlay&&(0,$.jsx)(Ze,{...st,title:h.label?`${h.label} Detail`:h.objectName?`${h.objectName.charAt(0).toUpperCase()+h.objectName.slice(1)} Detail`:`Record Detail`,children:e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,$.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})});Ft.displayName=`ListView`;var It={small:`grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6`,medium:`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`,large:`grid-cols-1 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3`},Lt={small:`aspect-square`,medium:`aspect-[4/3]`,large:`aspect-[16/10]`};c.register(`object-gallery`,e=>{let{schema:t}=e,n=(0,Q.useContext)(m),r=e.dataSource||n?.dataSource,i=p(t.bind),[a,o]=(0,Q.useState)([]),[s,c]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(null),f=_({navigation:t.navigation,objectName:t.objectName,onRowClick:e.onRowClick??e.onCardClick}),h=t.gallery,g=h?.coverField??t.imageField??`image`,v=h?.coverFit??`cover`,y=h?.cardSize??`medium`,b=h?.titleField??t.titleField??`name`,x=h?.visibleFields;(0,Q.useEffect)(()=>{let e=!0;return(async()=>{if(!(!r||typeof r.getObjectSchema!=`function`||!t.objectName))try{let n=await r.getObjectSchema(t.objectName);e&&d(n)}catch(e){console.warn(`Failed to fetch object def for ObjectGallery`,e)}})(),()=>{e=!1}},[t.objectName,r]),(0,Q.useEffect)(()=>{let n=!0;if(e.data&&Array.isArray(e.data)){o(e.data);return}return t.objectName&&!i&&!t.data&&!e.data&&(async()=>{if(!(!r||typeof r.find!=`function`||!t.objectName)){n&&c(!0);try{let e=l(u?.fields),i=await r.find(t.objectName,{$filter:t.filter,...e.length>0?{$expand:e}:{}}),a=[];if(Array.isArray(i))a=i;else if(i&&typeof i==`object`){let e=i;Array.isArray(e.records)?a=e.records:Array.isArray(e.data)&&(a=e.data)}n&&o(a)}catch(e){console.error(`[ObjectGallery] Fetch error:`,e)}finally{n&&c(!1)}}})(),()=>{n=!1}},[t.objectName,r,i,t.data,t.filter,e.data,u]);let S=e.data||i||t.data||a||[],C=(0,Q.useMemo)(()=>S.some(e=>typeof e[g]==`string`&&!!e[g]),[S,g]),w=!!h?.coverField||C,T=t.grouping?.fields,D=!!(T&&T.length>0),[O,k]=(0,Q.useState)({}),A=(0,Q.useMemo)(()=>T?T.some(e=>e.collapsed):!1,[T]),j=(0,Q.useCallback)(e=>{k(t=>({...t,[e]:t[e]===void 0?!A:!t[e]}))},[A]),M=(0,Q.useMemo)(()=>{if(!D||!T)return[];let e=new Map,t=[];for(let n of S){let r=T.map(e=>String(n[e.field]??``)).join(` / `);if(!e.has(r)){let i=T.map(e=>{let t=n[e.field];return t!=null&&t!==``?String(t):`(empty)`}).join(` / `);e.set(r,{label:i,items:[]}),t.push(r)}e.get(r).items.push(n)}let n=T[0]?.order??`asc`;return t.sort((e,t)=>{let r=e.localeCompare(t,void 0,{numeric:!0,sensitivity:`base`});return n===`desc`?-r:r}),t.map(t=>{let n=e.get(t),r=t in O?O[t]:A;return{key:t,label:n.label,items:n.items,collapsed:r}})},[S,T,D,O,A]);if(s&&!S.length)return(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading Gallery...`});if(!S.length)return(0,$.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`No items to display`});let N=(n,r)=>{let i=n.id??n._id??r,a=String(n[b]??`Untitled`),o=n[g];return(0,$.jsxs)(E,{role:`listitem`,className:B(`group overflow-hidden transition-all hover:shadow-md`,(e.onCardClick||e.onRowClick||t.navigation)&&`cursor-pointer`),onClick:()=>f.handleClick(n),children:[(0,$.jsx)(`div`,{className:B(`w-full overflow-hidden bg-muted relative`,Lt[y]),hidden:!w,children:o?(0,$.jsx)(`img`,{src:o,alt:a,className:B(`h-full w-full transition-transform group-hover:scale-105`,v===`cover`&&`object-cover`,v===`contain`&&`object-contain`)}):(0,$.jsx)(`div`,{className:`flex h-full w-full items-center justify-center bg-secondary/50 text-muted-foreground`,children:(0,$.jsx)(`span`,{className:`text-4xl font-light opacity-20`,children:a[0]?.toUpperCase()})})}),(0,$.jsxs)(Y,{className:B(`p-3`,w&&`border-t`),children:[(0,$.jsx)(`h3`,{className:`font-medium truncate text-sm`,title:a,children:a}),x&&x.length>0&&(0,$.jsx)(`div`,{className:`mt-1 space-y-0.5`,children:x.map(e=>{let t=n[e];return t==null||t===``?null:(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground truncate`,children:typeof t==`object`?t.label??t.name??t.id??JSON.stringify(t):String(t)},e)})})]})]},i)},P=e=>(0,$.jsx)(`div`,{className:B(`grid gap-4 p-4 auto-rows-min content-start`,It[y],t.className),role:`list`,children:e.map((e,t)=>N(e,t))});return(0,$.jsxs)($.Fragment,{children:[D?(0,$.jsx)(`div`,{className:`space-y-2`,children:M.map(e=>(0,$.jsxs)(`div`,{className:`border rounded-md`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors`,onClick:()=>j(e.key),children:[e.collapsed?(0,$.jsx)(pe,{className:`h-4 w-4 shrink-0`}):(0,$.jsx)(Je,{className:`h-4 w-4 shrink-0`}),(0,$.jsx)(`span`,{children:e.label}),(0,$.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.items.length})]}),!e.collapsed&&P(e.items)]},e.key))}):P(S),f.isOverlay&&(0,$.jsx)(Ze,{...f,title:`Gallery Item`,children:e=>(0,$.jsx)(`div`,{className:`space-y-3`,children:Object.entries(e).map(([e,t])=>(0,$.jsxs)(`div`,{className:`flex flex-col`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e.replace(/_/g,` `)}),(0,$.jsx)(`span`,{className:`text-sm`,children:String(t??`—`)})]},e))})})]})},{namespace:`plugin-list`,label:`Gallery View`,category:`view`}),c.register(`list-view`,Ft,{namespace:`plugin-list`,label:`List View`,category:`Views`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`fields`,type:`array`,label:`Fields`},{name:`filters`,type:`array`,label:`Filters`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}],defaultProps:{objectName:``,viewType:`grid`,fields:[],filters:[],sort:[],options:{}}}),c.register(`list`,Ft,{namespace:`view`,category:`view`,label:`List`,icon:`LayoutList`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`viewType`,type:`enum`,label:`Default View`,enum:[{label:`Grid`,value:`grid`},{label:`Kanban`,value:`kanban`},{label:`Gallery`,value:`gallery`},{label:`Calendar`,value:`calendar`},{label:`Timeline`,value:`timeline`},{label:`Gantt`,value:`gantt`},{label:`Map`,value:`map`}],defaultValue:`grid`},{name:`fields`,type:`array`,label:`Fields`},{name:`filters`,type:`array`,label:`Filters`},{name:`sort`,type:`array`,label:`Sort`},{name:`options`,type:`object`,label:`View Options`}]});var Rt=new Set([`textarea`,`markdown`,`html`,`grid`,`rich-text`,`field:textarea`,`field:markdown`,`field:html`,`field:grid`,`field:rich-text`]);function zt(e){return Rt.has(e)}function Bt(e,t){let n;if(n=e<=3?1:e<=10?2:3,t!==void 0){if(t<640)return Math.min(n,1);if(t<900)return Math.min(n,2)}return n}function Vt(e,t){return t<=1?e:e.map(e=>e.span===void 0&&e.type&&zt(e.type)?{...e,span:t}:e)}function Ht(e,t,n){if(t!==void 0)return{fields:Vt(e,t),columns:t};let r=Bt(e.length,n);return{fields:Vt(e,r),columns:r}}function Ut(e,t){return function(){try{let n=d();return n.t(t)===t?{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}:{t:n.t}}catch{return{t:(t,n)=>{let r=e[t]||t;if(n)for(let[e,t]of Object.entries(n))r=r.replace(`{{${e}}}`,String(t));return r}}}}}var Wt=Ut({"detail.back":`Back`,"detail.edit":`Edit`,"detail.editInline":`Edit inline`,"detail.save":`Save`,"detail.saveChanges":`Save changes`,"detail.editFieldsInline":`Edit fields inline`,"detail.share":`Share`,"detail.duplicate":`Duplicate`,"detail.export":`Export`,"detail.viewHistory":`View history`,"detail.delete":`Delete`,"detail.moreActions":`More actions`,"detail.addToFavorites":`Add to favorites`,"detail.removeFromFavorites":`Remove from favorites`,"detail.previousRecord":`Previous record`,"detail.nextRecord":`Next record`,"detail.recordOf":`{{current}} of {{total}}`,"detail.recordNotFound":`Record not found`,"detail.recordNotFoundDescription":`The record you are looking for does not exist or may have been deleted.`,"detail.goBack":`Go back`,"detail.details":`Details`,"detail.related":`Related`,"detail.relatedRecords":`{{count}} records`,"detail.relatedRecordOne":`{{count}} record`,"detail.noRelatedRecords":`No related records found`,"detail.loading":`Loading...`,"detail.copyToClipboard":`Copy to clipboard`,"detail.copied":`Copied!`,"detail.deleteConfirmation":`Are you sure you want to delete this record?`,"detail.editRecord":`Edit record`,"detail.viewAll":`View All`,"detail.new":`New`,"detail.emptyValue":`—`,"detail.activity":`Activity`,"detail.copyRecordId":`Copy record ID`,"detail.showEmptyFields":`Show {{count}} empty fields`,"detail.hideEmptyFields":`Hide empty fields`,"detail.editRow":`Edit`,"detail.deleteRow":`Delete`,"detail.deleteRowConfirmation":`Are you sure you want to delete this record?`,"detail.actions":`Actions`,"detail.previousPage":`Previous`,"detail.nextPage":`Next`,"detail.pageOf":`Page {{current}} of {{total}}`,"detail.sortBy":`Sort by`,"detail.filterPlaceholder":`Filter...`,"detail.highlightFields":`Key Fields`,"detail.comments":`Comments`,"detail.searchComments":`Search comments…`,"detail.addCommentPlaceholder":`Add a comment… (Ctrl+Enter to submit)`,"detail.noMatchingComments":`No matching comments`,"detail.noCommentsYet":`No comments yet`,"detail.pinned":`Pinned`,"detail.pin":`Pin`,"detail.unpin":`Unpin`,"detail.justNow":`just now`,"detail.minutesAgo":`{{count}}m ago`,"detail.hoursAgo":`{{count}}h ago`,"detail.daysAgo":`{{count}}d ago`,"detail.dropFilesToUpload":`Drop files here or click to upload`,"detail.attachmentCount":`{{count}} attachment`,"detail.attachmentCountPlural":`{{count}} attachments`,"detail.removeAttachment":`Remove attachment`,"detail.unifiedDiff":`Unified diff`,"detail.sideBySideDiff":`Side-by-side diff`,"detail.noChanges":`No changes`,"detail.previousVersion":`Previous`,"detail.currentVersion":`Current`,"detail.discussion":`Discussion`,"detail.showDiscussion":`Show Discussion ({{count}})`,"detail.hideDiscussion":`Hide discussion`,"detail.bold":`Bold (Ctrl+B)`,"detail.italic":`Italic (Ctrl+I)`,"detail.listFormat":`List`,"detail.inlineCode":`Inline code`,"detail.mentionSomeone":`Mention someone`,"detail.preview":`Preview`,"detail.submitComment":`Submit (Ctrl+Enter)`,"detail.writeComment":`Write a comment…`,"detail.subscribedTooltip":`Subscribed — click to unsubscribe`,"detail.unsubscribedTooltip":`Subscribe to notifications`,"detail.firstRecord":`First record (Home)`,"detail.previousRecordKey":`Previous record (←)`,"detail.nextRecordKey":`Next record (→)`,"detail.lastRecord":`Last record (End)`,"detail.noRecords":`No records`,"detail.searchWhileNavigating":`Search while navigating`,"detail.searchRecords":`Search records…`,"detail.allActivity":`All Activity`,"detail.commentsOnly":`Comments Only`,"detail.fieldChangesFilter":`Field Changes`,"detail.tasksOnly":`Tasks Only`,"detail.leaveCommentPlaceholder":`Leave a comment… (Ctrl+Enter to submit)`,"detail.noActivity":`No activity recorded`,"detail.loadMore":`Load more`,"detail.edited":`(edited)`,"detail.via":`via {{source}}`,"detail.replyCount":`{{count}} reply`,"detail.replyCountPlural":`{{count}} replies`,"detail.replyPlaceholder":`Reply…`,"detail.filterActivity":`Filter activity`,"detail.openDiscussion":`Open discussion panel`,"detail.closeDiscussion":`Close discussion panel`,"detail.subscribeAriaLabel":`Subscribe to notifications`,"detail.unsubscribeAriaLabel":`Unsubscribe from notifications`,"detail.clearSearch":`Clear search`},`detail.back`);function Gt(e,t){return!e||e<=1||t<=1?``:t===2?e>=2?`md:col-span-2`:``:e===2?`md:col-span-2`:e>=3?`md:col-span-2 lg:col-span-3`:``}var Kt=({section:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o,virtualScroll:c})=>{let[l,u]=Q.useState(e.defaultCollapsed??!1),[d,f]=Q.useState(null),[p,m]=Q.useState(void 0),[h,g]=Q.useState(!1),{t:_}=Wt(),{fieldLabel:v}=x(),y=Q.useCallback((e,t)=>{let n=t==null?``:String(t);navigator.clipboard.writeText(n).then(()=>{f(e),setTimeout(()=>f(null),2e3)})},[]),b=Q.useCallback(e=>{let n=t?.[e.name]??e.value;return n==null||n===``},[t]),S=Q.useMemo(()=>e.fields.filter(b).length,[e.fields,b]),C=se(),w=C?3:6,T=C?.2:.5,D=e.fields.length-S,k=!e.hideEmpty&&!a&&e.fields.length>=w&&S/e.fields.length>=T&&D>0,A=!h&&(e.hideEmpty||k)?e.fields.filter(e=>!b(e)):e.fields;if(A.length===0&&S===e.fields.length)return null;let{fields:j,columns:M}=Ht(A,e.columns),N=e=>{let n=t?.[e.name]??e.value;if(e.render)return(0,$.jsx)(s,{schema:e.render,data:{...t,value:n}});let c=Gt(e.span,M),l=(()=>{if(n==null)return(0,$.jsx)(`span`,{className:`text-muted-foreground/50 text-xs italic`,children:`—`});let t=r?.fields?.[e.name],i=e.type||t?.type,a={...e};if(t){!e.type&&t.type&&(a.type=t.type),t.options&&!a.options&&(a.options=t.options),t.currency&&!a.currency&&(a.currency=t.currency),t.precision!==void 0&&a.precision===void 0&&(a.precision=t.precision),t.format&&!a.format&&(a.format=t.format);let n=t.reference_to||t.reference;n&&!a.reference_to&&(a.reference_to=n),t.reference_field&&!a.reference_field&&(a.reference_field=t.reference_field)}if(i){let e=xe(i);if(e)return(0,$.jsx)(e,{value:n,field:a})}return String(n)})(),u=n!=null&&n!==``,f=d===e.name;return(0,$.jsxs)(`div`,{className:B(`space-y-1.5 group`,c),children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:v(i||``,e.name,e.label||e.name)}),a&&!e.readonly?(0,$.jsx)(`div`,{className:`min-h-[44px] sm:min-h-0`,children:(0,$.jsx)(`input`,{type:e.type===`number`?`number`:e.type===`date`?`date`:`text`,className:`w-full px-2 py-1.5 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-ring`,value:n==null?``:String(n),onChange:t=>o?.(e.name,t.target.value)})}):(0,$.jsxs)(`div`,{className:B(`flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md`,u&&`cursor-pointer active:bg-muted/60 transition-colors`),onClick:u?()=>y(e.name,n):void 0,onKeyDown:u?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),y(e.name,n))}:void 0,role:u?`button`:void 0,tabIndex:u?0:void 0,children:[(0,$.jsx)(`div`,{className:`text-sm flex-1 break-words py-1`,children:l}),u&&(0,$.jsx)(oe,{children:(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0`,onClick:t=>{t.stopPropagation(),y(e.name,n)},children:f?(0,$.jsx)(Ge,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(Ve,{className:`h-3 w-3`})})}),(0,$.jsx)(O,{children:_(f?`detail.copied`:`detail.copyToClipboard`)})]})})]})]},e.name)},P=c?.enabled===!0,ee=c?.batchSize??20;Q.useEffect(()=>{if(!P){m(void 0);return}if(j.length<=ee){m(void 0);return}m(ee);let e=setTimeout(()=>m(void 0),100);return()=>clearTimeout(e)},[P,j.length,ee]);let F=p===void 0?j:j.slice(0,p),te=S>0&&(e.hideEmpty||k),I=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:B(`grid gap-3 sm:gap-4`,M===1?`grid-cols-1`:M===2?`grid-cols-1 md:grid-cols-2`:`grid-cols-1 md:grid-cols-2 lg:grid-cols-3`),children:F.map(N)}),te&&(0,$.jsx)(`div`,{className:`mt-3 -ml-2`,children:(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>g(e=>!e),className:`h-7 px-2 text-xs text-muted-foreground hover:text-foreground`,children:[h?(0,$.jsx)(tt,{className:`h-3.5 w-3.5 mr-1.5`}):(0,$.jsx)(Se,{className:`h-3.5 w-3.5 mr-1.5`}),h?_(`detail.hideEmptyFields`,{defaultValue:`Hide empty fields`}):_(`detail.showEmptyFields`,{count:S,defaultValue:`Show ${S} empty field${S===1?``:`s`}`})]})})]});return!e.title&&!e.collapsible&&e.showBorder===!1?(0,$.jsx)(`div`,{className:B(n),children:I}):e.collapsible?(0,$.jsx)(ue,{open:!l,onOpenChange:e=>u(!e),className:n,children:(0,$.jsxs)(E,{children:[(0,$.jsx)(he,{asChild:!0,children:(0,$.jsxs)(He,{className:B(`cursor-pointer hover:bg-muted/50 transition-colors`,e.headerColor&&`bg-${e.headerColor}`),children:[(0,$.jsxs)(Xe,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`span`,{children:e.title}),e.fields&&(0,$.jsx)(ve,{variant:`secondary`,className:`ml-2 text-xs`,children:e.fields.length})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:l?(0,$.jsx)(pe,{className:`h-4 w-4 text-muted-foreground`}):(0,$.jsx)(Je,{className:`h-4 w-4 text-muted-foreground`})})]}),e.description&&!l&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]})}),(0,$.jsx)(K,{children:(0,$.jsx)(Y,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:I})})]})}):(0,$.jsxs)(E,{className:B(e.showBorder===!1?`border-none shadow-none`:``,n),children:[e.title&&(0,$.jsxs)(He,{className:B(e.headerColor&&`bg-${e.headerColor}`),children:[(0,$.jsx)(Xe,{className:`flex items-center justify-between`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`span`,{children:e.title})]})}),e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1.5`,children:e.description})]}),(0,$.jsx)(Y,{className:`pt-4 sm:pt-6 px-3 sm:px-6`,children:I})]})},qt=({tabs:e,data:t,className:n})=>{let[r,i]=Q.useState(e[0]?.key),a=e.filter(e=>typeof e.visible==`boolean`?e.visible:(e.visible,!0));return(0,$.jsxs)(Be,{value:r,onValueChange:i,className:n,children:[(0,$.jsx)(Ae,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:a.map(e=>(0,$.jsx)(_e,{value:e.key,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.icon&&(0,$.jsx)(`span`,{children:e.icon}),(0,$.jsx)(`span`,{children:e.label}),e.badge&&(0,$.jsx)(ve,{variant:`secondary`,className:`ml-1`,children:e.badge})]})},e.key))}),a.map(e=>(0,$.jsx)(Me,{value:e.key,className:`mt-4`,children:(0,$.jsx)(Q.Suspense,{fallback:null,children:Array.isArray(e.content)?(0,$.jsx)(`div`,{className:`space-y-4`,children:e.content.map((e,n)=>(0,$.jsx)(s,{schema:e,data:t},n))}):(0,$.jsx)(s,{schema:e.content,data:t})})},e.key))]})};function Jt(e){return e&&be[e.split(/[-_\s]/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)]||at}var Yt=({title:e,type:t,api:n,data:r=[],schema:i,columns:a,className:o,dataSource:c,objectName:l,onNew:u,onViewAll:d,onRowEdit:f,onRowDelete:p,pageSize:m,sortable:h=!1,filterable:g=!1,collapsible:_=!1,defaultCollapsed:v=!1,referenceField:y,icon:b})=>{let[S,C]=Q.useState(r),[T,D]=Q.useState(!1),[O,k]=Q.useState(0),[A,j]=Q.useState(null),[M,N]=Q.useState(`asc`),[P,ee]=Q.useState(``),[F,te]=Q.useState(null),[ne,I]=Q.useState(v),{t:L}=Wt(),{fieldLabel:R}=x();Q.useEffect(()=>{C(r)},[r]),Q.useEffect(()=>{n&&c?.getObjectSchema&&!a?.length&&c.getObjectSchema(n).then(te).catch(e=>{console.warn(`[RelatedList] Failed to fetch schema for ${n}:`,e)})},[n,c,a]),Q.useEffect(()=>{n&&!r.length&&(D(!0),c&&typeof c.find==`function`?c.find(n).then(e=>{C(Array.isArray(e)?e:Array.isArray(e?.data)?e.data:[]),D(!1)}).catch(e=>{console.error(`Failed to fetch related data:`,e),D(!1)}):fetch(n).then(e=>e.json()).then(e=>{C(Array.isArray(e)?e:e?.data||[])}).catch(e=>{console.error(`Failed to fetch related data:`,e)}).finally(()=>D(!1)))},[n,r,c]);let re=Q.useMemo(()=>{if(!P)return S;let e=P.toLowerCase();return S.filter(t=>Object.values(t).some(t=>t!=null&&String(t).toLowerCase().includes(e)))},[S,P]),z=Q.useMemo(()=>A?[...re].sort((e,t)=>{let n=e[A],r=t[A];if(n==null&&r==null)return 0;if(n==null)return 1;if(r==null)return-1;let i=String(n).localeCompare(String(r),void 0,{numeric:!0});return M===`asc`?i:-i}):re,[re,A,M]),V=m&&m>0?m:0,H=V?Math.max(1,Math.ceil(z.length/V)):1,U=V?z.slice(O*V,(O+1)*V):z;Q.useEffect(()=>{k(0)},[P,A,M]);let W=Q.useCallback(e=>{A===e?N(e=>e===`asc`?`desc`:`asc`):(j(e),N(`asc`))},[A]),ie=Q.useCallback(e=>{window.confirm(L(`detail.deleteRowConfirmation`))&&p?.(e)},[p,L]),G=Q.useMemo(()=>{let e=e=>y?e.filter(e=>(e?.accessorKey||e?.field||e?.name)!==y):e;if(a&&a.length>0)return e(a);if(!F?.fields)return[];let t=l||n||``;return Object.entries(F.fields).filter(([e])=>!e.startsWith(`_`)&&e!==`id`&&e!==y).map(([e,n])=>{let r={accessorKey:e,header:R(t,e,n.label||e)};if(n.type){let t=xe(n.type);if(t){let i={name:e,label:n.label||e,type:n.type,...n.options&&{options:n.options},...n.currency&&{currency:n.currency},...n.precision!==void 0&&{precision:n.precision},...n.format&&{format:n.format},...(n.reference_to||n.reference)&&{reference_to:n.reference_to||n.reference},...n.reference_field&&{reference_field:n.reference_field}};r.cell=e=>e==null?Q.createElement(`span`,{className:`text-muted-foreground/50 text-xs italic`},`—`):Q.createElement(t,{value:e,field:i})}}return r})},[a,F,l,n,R,y]),ae=Q.useMemo(()=>{if(i)return i;switch(t){case`grid`:case`table`:return{type:`data-table`,data:U,columns:G,pagination:!1,pageSize:V||10,searchable:!1,exportable:!1};case`list`:return{type:`data-list`,data:U};default:return{type:`div`,children:`No view configured`}}},[t,U,G,i,V]),oe=!!f||!!p,se=_?`cursor-pointer select-none`:void 0,ce=_?()=>I(e=>!e):void 0,K=Jt(b),q=!T&&S.length===0,ue=g;return(0,$.jsxs)(E,{className:B(`shadow-none`,q&&`bg-muted/20`,o),children:[(0,$.jsx)(He,{className:B(`py-3 px-4`,se),onClick:ce,children:(0,$.jsxs)(Xe,{className:`flex items-center justify-between gap-2 text-sm font-semibold`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[_&&(ne?(0,$.jsx)(pe,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}):(0,$.jsx)(Je,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})),(0,$.jsx)(K,{className:`h-4 w-4 text-muted-foreground shrink-0`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`truncate`,children:e}),(0,$.jsx)(ve,{variant:`secondary`,className:B(`text-xs font-normal h-5 px-1.5`,S.length===0&&`bg-muted text-muted-foreground`),"aria-label":`${S.length} records`,children:S.length})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[u&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),u()},className:`gap-1 h-7 text-xs`,children:[(0,$.jsx)(nt,{className:`h-3.5 w-3.5`}),L(`detail.new`)]}),d&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:e=>{e.stopPropagation(),d()},className:`gap-1 h-7 text-xs`,children:[L(`detail.viewAll`),(0,$.jsx)(We,{className:`h-3 w-3`})]})]})]})}),!ne&&(0,$.jsxs)(Y,{className:B(`pt-0`,q?`pb-3 px-4`:`pb-4 px-4`),children:[ue&&(0,$.jsx)(`div`,{className:`mb-3`,children:(0,$.jsx)(J,{placeholder:L(`detail.filterPlaceholder`),value:P,onChange:e=>ee(e.target.value),className:`h-8 text-sm`})}),h&&G&&G.length>0&&S.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-3`,children:G.map(e=>{let t=e.accessorKey||e.field||e.name;if(!t)return null;let n=e.header||e.label||t,r=A===t;return(0,$.jsxs)(Z,{variant:r?`secondary`:`ghost`,size:`sm`,className:`gap-1 h-7 text-xs`,onClick:()=>W(t),children:[(0,$.jsx)(le,{className:`h-3 w-3`}),n,r&&(M===`asc`?` ↑`:` ↓`)]},t)})}),T?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-6 text-muted-foreground text-sm`,children:L(`detail.loading`)}):q?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 py-2 text-sm`,children:[(0,$.jsx)(`span`,{className:`text-muted-foreground italic`,children:L(`detail.noRelatedRecords`)}),u===void 0&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground/70`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(s,{schema:ae}),oe&&U.length>0&&(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,"data-testid":`row-actions`,children:U.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1 text-xs border-b last:border-b-0`,children:[(0,$.jsx)(`span`,{className:`truncate text-muted-foreground`,children:e.name||e.title||e.id||`Row ${t+1}`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[f&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2`,onClick:()=>f(e),children:[(0,$.jsx)(me,{className:`h-3 w-3`}),L(`detail.editRow`)]}),p&&(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,className:`h-6 text-xs gap-1 px-2 text-destructive hover:text-destructive`,onClick:()=>ie(e),children:[(0,$.jsx)(ze,{className:`h-3 w-3`}),L(`detail.deleteRow`)]})]})]},e.id||t))})]}),V>0&&z.length>V&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mt-3 pt-3 border-t`,children:[(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:O===0,onClick:()=>k(e=>Math.max(0,e-1)),children:[(0,$.jsx)(w,{className:`h-3 w-3`}),L(`detail.previousPage`)]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:L(`detail.pageOf`,{current:O+1,total:H})}),(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,className:`h-7 text-xs gap-1`,disabled:O>=H-1,onClick:()=>k(e=>Math.min(H-1,e+1)),children:[L(`detail.nextPage`),(0,$.jsx)(pe,{className:`h-3 w-3`})]})]})]})]})},Xt=({group:e,data:t,className:n,objectSchema:r,objectName:i,isEditing:a=!1,onFieldChange:o})=>{let s=e.collapsible??!0,[c,l]=Q.useState(e.defaultCollapsed??!1),u=(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((e,n)=>(0,$.jsx)(Kt,{section:e,data:t,objectSchema:r,objectName:i,isEditing:a,onFieldChange:o},n))});return s?(0,$.jsxs)(ue,{open:!c,onOpenChange:e=>l(!e),className:n,children:[(0,$.jsx)(he,{asChild:!0,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b cursor-pointer hover:bg-muted/50 transition-colors rounded-t-md px-2 py-1.5`,children:[c?(0,$.jsx)(pe,{className:`h-4 w-4 text-muted-foreground shrink-0`}):(0,$.jsx)(Je,{className:`h-4 w-4 text-muted-foreground shrink-0`}),e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]})}),e.description&&!c&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e.description}),(0,$.jsx)(K,{children:(0,$.jsx)(`div`,{className:`mt-3`,children:u})})]}):(0,$.jsxs)(`div`,{className:B(`space-y-3`,n),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 pb-2 border-b`,children:[e.icon&&(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:e.icon}),(0,$.jsx)(`h3`,{className:`text-lg font-semibold`,children:e.title})]}),e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.description}),u]})},Zt=({fields:e,data:t,className:n,objectName:r,objectSchema:i})=>{let{fieldLabel:a}=x();if(!e.length||!t)return null;let o=e.filter(e=>{let n=t?.[e.name];return n!=null&&n!==``});return o.length===0?null:(0,$.jsx)(E,{className:B(`bg-muted/30 border-dashed`,n),children:(0,$.jsx)(Y,{className:`py-3 px-4`,children:(0,$.jsx)(`div`,{className:B(`grid gap-4`,o.length===1?`grid-cols-1`:o.length===2?`grid-cols-2`:o.length===3?`grid-cols-3`:`grid-cols-2 md:grid-cols-4`),children:o.map(e=>{let n=t[e.name],o=i?.fields?.[e.name],s=e.type||o?.type,c={name:e.name,label:e.label,type:s||`text`,...o?.options&&{options:o.options},...o?.currency&&{currency:o.currency},...o?.precision!==void 0&&{precision:o.precision},...o?.format&&{format:o.format}},l=xe(s||`text`);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`span`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[e.icon&&(0,$.jsx)(`span`,{className:`mr-1`,children:e.icon}),a(r||``,e.name,e.label)]}),(0,$.jsx)(`span`,{className:`text-sm font-semibold truncate`,children:(0,$.jsx)(l,{value:n,field:c})})]},e.name)})})})})};function Qt(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var $t=({comments:e,onAddComment:t,onTogglePin:n,searchable:r=!1,className:i})=>{let{t:a}=Wt(),[o,s]=Q.useState(``),[c,l]=Q.useState(!1),[u,d]=Q.useState(``),f=Q.useCallback(async()=>{let e=o.trim();if(!(!e||!t)){l(!0);try{await t(e),s(``)}finally{l(!1)}}},[o,t]),p=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]),m=Q.useMemo(()=>[...u.trim()?e.filter(e=>{let t=u.trim().toLowerCase();return e.text.toLowerCase().includes(t)||e.author.toLowerCase().includes(t)}):e].sort((e,t)=>e.pinned&&!t.pinned?-1:!e.pinned&&t.pinned?1:0),[e,u]);return(0,$.jsxs)(E,{className:B(``,i),children:[(0,$.jsx)(He,{children:(0,$.jsxs)(Xe,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(ft,{className:`h-4 w-4`}),a(`detail.comments`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,e.length,`)`]})]})}),(0,$.jsxs)(Y,{className:`space-y-4`,children:[r&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(W,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground`}),(0,$.jsx)(`input`,{className:`w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.searchComments`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`detail.searchComments`)}),u&&(0,$.jsx)(`button`,{className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,onClick:()=>d(``),"aria-label":a(`detail.clearSearch`),type:`button`,children:(0,$.jsx)(ae,{className:`h-3.5 w-3.5`})})]})}),t&&(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:a(`detail.addCommentPlaceholder`),value:o,onChange:e=>s(e.target.value),onKeyDown:p,disabled:c}),(0,$.jsx)(Z,{size:`icon`,variant:`default`,onClick:f,disabled:!o.trim()||c,className:`shrink-0 self-end`,children:(0,$.jsx)(R,{className:`h-4 w-4`})})]}),m.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:u.trim()?a(`detail.noMatchingComments`):a(`detail.noCommentsYet`)}):(0,$.jsx)(`div`,{className:`space-y-3`,children:m.map(e=>(0,$.jsxs)(`div`,{className:B(`flex gap-3`,e.pinned&&`bg-muted/40 rounded-md p-2 -mx-2`),children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:e.avatarUrl?(0,$.jsx)(`img`,{src:e.avatarUrl,alt:e.author,className:`h-8 w-8 rounded-full object-cover`}):(0,$.jsx)(`div`,{className:`h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground`,children:e.author.charAt(0).toUpperCase()})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium truncate`,children:e.author}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Qt(e.createdAt)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600 flex items-center gap-0.5`,children:[(0,$.jsx)(ut,{className:`h-3 w-3`}),a(`detail.pinned`)]})]}),(0,$.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words`,children:e.text}),n&&(0,$.jsxs)(`button`,{type:`button`,className:`mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1`,onClick:()=>n(e.id),"aria-label":e.pinned?a(`detail.unpin`):a(`detail.pin`),children:[(0,$.jsx)(ut,{className:`h-3 w-3`}),e.pinned?a(`detail.unpin`):a(`detail.pin`)]})]})]},e.id))})]})]})},en={field_change:me,create:T,delete:ze,comment:ft,status_change:Ne},tn={field_change:`bg-blue-100 text-blue-600`,create:`bg-green-100 text-green-600`,delete:`bg-red-100 text-red-600`,comment:`bg-purple-100 text-purple-600`,status_change:`bg-amber-100 text-amber-600`};function nn(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function rn(e){return e.description?e.description:e.type===`field_change`&&e.field?`Changed ${e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `)} from "${e.oldValue==null?`(empty)`:String(e.oldValue)}" to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:e.type===`create`?`Created this record`:e.type===`delete`?`Deleted this record`:e.type===`status_change`&&e.field?`Changed status to "${e.newValue==null?`(empty)`:String(e.newValue)}"`:`Updated record`}var an={all:`All`,field_change:`Field Changes`,create:`Creates`,delete:`Deletes`,comment:`Comments`,status_change:`Status Changes`},on=({activities:e,filterable:t=!1,defaultFilter:n=`all`,className:r})=>{let[i,a]=Q.useState(n),o=Q.useMemo(()=>i===`all`?e:e.filter(e=>e.type===i),[e,i]);return(0,$.jsxs)(E,{className:B(``,r),children:[(0,$.jsx)(He,{children:(0,$.jsxs)(Xe,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(re,{className:`h-4 w-4`}),`Activity`,(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,o.length,`)`]})]})}),(0,$.jsxs)(Y,{children:[t&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-4`,role:`group`,"aria-label":`Activity type filter`,children:Object.keys(an).map(e=>(0,$.jsxs)(`button`,{type:`button`,className:B(`inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors`,i===e?`bg-primary text-primary-foreground`:`bg-muted text-muted-foreground hover:bg-muted/80`),onClick:()=>a(e),"aria-pressed":i===e,children:[e!==`all`&&Q.createElement(en[e]||me,{className:`h-3 w-3`}),an[e]]},e))}),o.length===0?(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:`No activity recorded`}):(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,$.jsx)(`div`,{className:`space-y-4`,children:o.map(e=>{let t=en[e.type]||me;return(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:B(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,tn[e.type]||`bg-gray-100 text-gray-600`),children:(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,$.jsxs)(`p`,{className:`text-sm`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:rn(e)})]}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:nn(e.timestamp)})]})]},e.id)})})]})]})]})},sn=5;function cn(e,t,n,r){if(e&&typeof e==`object`){if(t.primaryField){let n=e[t.primaryField];if(n!=null&&n!==``)return String(n)}let r=n?.titleFormat;if(r){let t=`[-\\u2013\\u2014|/·,:]`,n=!1,i=r.replace(/\{([^{}]+)\}/g,(t,r)=>{let i=e[r.trim()];return i!=null&&i!==``?(n=!0,String(i)):`\0`});if(n){let e=i.replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\\s*${t}\\s*`,`g`),``).replace(RegExp(`\0`,`g`),``).replace(/\s+/g,` `).trim();if(e)return e}}}if(t.title)return t.title;if(e&&typeof e==`object`)for(let t of[`name`,`full_name`,`fullName`,`title`,`subject`,`label`,`display_name`,`displayName`]){let n=e[t];if(typeof n==`string`&&n.trim())return n.trim();if(n!=null&&n!==``)return String(n)}return r}var ln=({schema:e,dataSource:t,className:n,onEdit:r,onDelete:i,onBack:a,inlineEdit:o=!1,onFieldSave:c,discussionSlot:u,rightRail:d,objectLabel:f,onDataLoaded:p})=>{let[m,h]=Q.useState(e.data),[g,_]=Q.useState(!e.data&&!!(e.api&&e.resourceId||t&&e.objectName&&e.resourceId)),[v,y]=Q.useState(!1),[b,x]=Q.useState(!1),[S,C]=Q.useState({}),[T,E]=Q.useState(null),[D,k]=Q.useState(!1),{t:A}=Wt();Q.useEffect(()=>{m&&p&&p(m)},[m,p]);let j=Q.useMemo(()=>{if(e.summaryFields&&e.summaryFields.length>0)return[];let t=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]],n={};for(let e of t)n[e.name]||(n[e.name]=e);if(T?.fields)for(let[e,t]of Object.entries(T.fields))n[e]={...n[e]||{},...t,name:e};let r=e=>m?.[e]!==void 0&&m?.[e]!==null&&m?.[e]!==``,i=[],a=[`status`,`stage`,`state`,`phase`].find(e=>n[e]&&r(e))||Object.keys(n).find(e=>n[e]?.type===`select`&&r(e));a&&i.push(a);let o=Object.keys(n).find(e=>(n[e]?.type===`currency`||/amount|revenue|value|total|price/i.test(e))&&r(e));o&&!i.includes(o)&&i.push(o);let s=Object.keys(n).find(e=>(n[e]?.type===`date`||n[e]?.type===`datetime`)&&/close|due|start|end|expected/i.test(e)&&r(e));return s&&!i.includes(s)&&i.push(s),i},[e.summaryFields,e.sections,e.fields,T,m]),M=e.summaryFields&&e.summaryFields.length>0?e.summaryFields:j,N=Q.useCallback(()=>{e.resourceId&&navigator.clipboard.writeText(String(e.resourceId)).then(()=>{k(!0),setTimeout(()=>k(!1),1500)})},[e.resourceId]);Q.useEffect(()=>{let n=!0;if(e.data){h(e.data),_(!1);return}if(t&&e.objectName&&e.resourceId){_(!0),E(null),h(null);let r=e.objectName,i=e.resourceId,a=`${r}-`,o=[...e.sections?.flatMap(e=>e.fields)||[],...e.fields||[]];(t.getObjectSchema?t.getObjectSchema(r).catch(()=>null):Promise.resolve(null)).then(e=>{if(!n)return;E(e);let s=l(e?.fields,o),c=s.length>0?{$expand:s}:void 0,u=c?t.findOne(r,i,c):t.findOne(r,i),d=()=>{let e=String(i),o=e.startsWith(a)?e.slice(a.length):`${a}${e}`;return(c?t.findOne(r,o,c):t.findOne(r,o)).then(e=>{n&&(h(e),_(!1))}).catch(()=>{n&&(h(null),_(!1))})};return u.catch(()=>null).then(e=>{if(n){if(e){h(e),_(!1);return}return d()}})}).catch(e=>{n&&(console.error(`Failed to fetch detail data:`,e),_(!1))})}else e.api&&e.resourceId&&(_(!0),fetch(`${e.api}/${e.resourceId}`).then(e=>e.json()).then(e=>{n&&h(e?.data||e)}).catch(e=>{console.error(`Failed to fetch detail data:`,e)}).finally(()=>{n&&_(!1)}));return()=>{n=!1}},[e.api,e.resourceId,e.objectName,t,e.sections,e.fields]);let P=Q.useCallback(()=>{if(a)a();else if(e.onNavigate){let t=e.backUrl||(e.objectName?`/${e.objectName}`:`/`);e.onNavigate(t,{replace:!0})}else e.backUrl?window.location.href=e.backUrl:window.history.back()},[a,e]),ee=Q.useCallback(()=>{r?r():e.onNavigate&&e.editUrl?e.onNavigate(e.editUrl):e.onNavigate&&e.objectName&&e.resourceId?e.onNavigate(`/${e.objectName}/${e.resourceId}/edit`):e.editUrl&&(window.location.href=e.editUrl)},[r,e]),F=Q.useCallback(()=>{let t=e.deleteConfirmation||A(`detail.deleteConfirmation`);window.confirm(t)&&(i?.(),e.onNavigate&&e.objectName&&e.onNavigate(`/${e.objectName}`,{replace:!0}))},[i,e]),te=Q.useCallback(()=>{navigator.share&&e.objectName&&e.resourceId?navigator.share({title:e.title||A(`detail.details`),text:`${e.objectName} #${e.resourceId}`,url:window.location.href}).catch(e=>console.log(`Share failed:`,e)):navigator.clipboard.writeText(window.location.href).then(()=>{console.log(`Link copied to clipboard`)})},[e]),I=Q.useCallback(()=>{console.log(`Duplicate record:`,m)},[m]),L=Q.useCallback(()=>{console.log(`Export record:`,m)},[m]),R=Q.useCallback(()=>{console.log(`View history for record:`,e.resourceId)},[e]),re=Q.useCallback(()=>{y(!v)},[v]),z=Q.useCallback(()=>{if(b){let e=Object.entries(S);if(e.length>0){let t={...m,...S};h(t),e.forEach(([e,n])=>{c?.(e,n,t)})}C({})}x(!b)},[b,S,m,c]),V=Q.useCallback((e,t)=>{C(n=>({...n,[e]:t}))},[]);Q.useEffect(()=>{if(!e.recordNavigation)return;let t=e.recordNavigation,n=e=>{let n=e.target?.tagName;n===`INPUT`||n===`TEXTAREA`||e.target?.isContentEditable||(e.key===`ArrowLeft`&&t.currentIndex>0?(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex-1])):e.key===`ArrowRight`&&t.currentIndex<t.recordIds.length-1&&(e.preventDefault(),t.onNavigate(t.recordIds[t.currentIndex+1])))};return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e.recordNavigation]);let H=Q.useMemo(()=>{if(!e.autoDiscoverRelated||!T?.fields||e.related&&e.related.length>0)return[];let t=[],n=T.fields;for(let[e,r]of Object.entries(n)){let n=r?.reference_to||r?.reference;r&&(r.type===`lookup`||r.type===`master_detail`)&&n&&t.push({title:r.label||e.charAt(0).toUpperCase()+e.slice(1),type:`table`,objectName:n,referenceField:e})}return t},[e.autoDiscoverRelated,e.related,T]),U=Q.useMemo(()=>e.related&&e.related.length>0?e.related:H.map(e=>({title:e.title,type:e.type,api:e.objectName,data:[],referenceField:e.referenceField})),[e.related,H]),W=Q.useMemo(()=>{let t=[];t.push({name:`sys_share`,label:A(`detail.share`),icon:`share-2`,type:`script`,onClick:te}),e.showEdit&&t.push({name:`sys_edit_mobile`,label:A(`detail.edit`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:ee}),o&&t.push({name:`sys_toggle_inline_edit_mobile`,label:A(b?`detail.save`:`detail.editInline`),icon:`edit`,type:`script`,className:`sm:hidden`,onClick:z});let n=t.length>0?[`separator-before`]:void 0;return t.push({name:`sys_duplicate`,label:A(`detail.duplicate`),icon:`copy`,type:`script`,...n&&{tags:n},onClick:I}),t.push({name:`sys_export`,label:A(`detail.export`),icon:`download`,type:`script`,onClick:L}),t.push({name:`sys_view_history`,label:A(`detail.viewHistory`),icon:`history`,type:`script`,onClick:R}),e.showDelete&&t.push({name:`sys_delete`,label:A(`detail.delete`),icon:`trash-2`,type:`script`,variant:`destructive`,tags:[`separator-before`],onClick:F}),t},[A,e.showEdit,e.showDelete,o,b,te,ee,z,I,L,R,F]),ie=Q.useMemo(()=>{let t=e.actions??[];if(W.length===0)return t;let n=!1,r=t.map(e=>{let t=e;if(t&&typeof t==`object`&&t.type===`action:bar`&&(!t.location||t.location===`record_header`)){n=!0;let e=Array.isArray(t.systemActions)?t.systemActions:[];return{...t,systemActions:[...e,...W]}}return e});return n||r.push({type:`action:bar`,location:`record_header`,systemActions:W}),r},[e.actions,W]);return g||e.loading?(0,$.jsxs)(`div`,{className:B(`space-y-4`,n),children:[(0,$.jsx)(G,{className:`h-10 w-full`}),(0,$.jsx)(G,{className:`h-64 w-full`}),(0,$.jsx)(G,{className:`h-48 w-full`})]}):!m&&!e.data?(0,$.jsxs)(`div`,{className:B(`flex flex-col items-center justify-center py-16 text-center`,n),children:[(0,$.jsx)(`p`,{className:`text-lg font-semibold`,children:A(`detail.recordNotFound`)}),(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:A(`detail.recordNotFoundDescription`)}),(e.showBack??!0)&&(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:P,className:`mt-4 gap-2`,children:[(0,$.jsx)(Ce,{className:`h-4 w-4`}),A(`detail.goBack`)]})]}):(0,$.jsx)(oe,{children:(0,$.jsxs)(`div`,{className:B(`space-y-6`,n),children:[(0,$.jsxs)(`div`,{className:`flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2 sm:gap-3 flex-1 min-w-0`,children:[(e.showBack??!0)&&(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,onClick:P,className:`shrink-0 mt-1`,children:(0,$.jsx)(Ce,{className:`h-4 w-4`})})}),(0,$.jsx)(O,{children:A(`detail.back`)})]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,$.jsx)(`h1`,{className:`text-xl sm:text-2xl font-bold truncate`,children:cn(m,e,T,A(`detail.details`))}),M.map(t=>{let n=m?.[t];if(n==null||n===``)return null;let r=(e.sections||[]).flatMap(e=>e.fields).concat(e.fields||[]).find(e=>e.name===t),i=T?.fields?.[t],a=r?.type||i?.type,o=String(n),s=null;try{if(a===`currency`){let e=Number(n);Number.isNaN(e)||(o=new Intl.NumberFormat(void 0,{style:`currency`,currency:r?.currency||i?.currency||`USD`,maximumFractionDigits:0}).format(e))}else if(a===`date`||a===`datetime`){let e=new Date(n);Number.isNaN(e.getTime())||(o=a===`datetime`?e.toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):e.toLocaleDateString(void 0,{dateStyle:`medium`}))}else if(a===`percent`){let e=Number(n);if(!Number.isNaN(e)){o=`${e}%`;let t=e<=1?e*100:e;s=Math.max(0,Math.min(100,t))}}}catch{}return s===null?(0,$.jsx)(ve,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15`,"aria-label":`${t}: ${o}`,children:o},t):(0,$.jsxs)(ve,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent hover:bg-primary/15 gap-1.5 pl-2 pr-2`,"aria-label":`${t}: ${o}`,children:[(0,$.jsx)(`span`,{className:`relative inline-block h-1.5 w-12 rounded-full bg-primary/20 overflow-hidden`,"aria-hidden":!0,children:(0,$.jsx)(`span`,{className:`absolute inset-y-0 left-0 rounded-full bg-primary`,style:{width:`${s}%`}})}),o]},t)}),(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:re,"aria-label":A(v?`detail.removeFromFavorites`:`detail.addToFavorites`),children:v?(0,$.jsx)(je,{className:`h-4 w-4 fill-yellow-400 text-yellow-400`}):(0,$.jsx)(ge,{className:`h-4 w-4 text-muted-foreground`})})}),(0,$.jsx)(O,{children:A(v?`detail.removeFromFavorites`:`detail.addToFavorites`)})]})]}),e.objectName&&(0,$.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-1 flex items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`font-medium`,children:f||e.objectName}),e.resourceId&&(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-5 w-5 shrink-0 text-muted-foreground/60 hover:text-foreground`,onClick:N,"aria-label":A(`detail.copyRecordId`,{defaultValue:`Copy record ID`}),children:D?(0,$.jsx)(Ge,{className:`h-3 w-3 text-green-600`}):(0,$.jsx)(Ve,{className:`h-3 w-3`})})}),(0,$.jsx)(O,{children:D?A(`detail.copied`,{defaultValue:`Copied`}):A(`detail.copyRecordId`,{defaultValue:`Copy record ID`})})]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto`,children:[e.recordNavigation&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1 mr-2`,children:[(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex<=0,onClick:()=>{let t=e.recordNavigation;t.currentIndex>0&&t.onNavigate(t.recordIds[t.currentIndex-1])},children:(0,$.jsx)(w,{className:`h-4 w-4`})})}),(0,$.jsx)(O,{children:A(`detail.previousRecord`)})]}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground whitespace-nowrap px-1`,children:A(`detail.recordOf`,{current:e.recordNavigation.currentIndex+1,total:e.recordNavigation.recordIds.length})}),(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:`outline`,size:`icon`,className:`h-8 w-8`,disabled:e.recordNavigation.currentIndex>=e.recordNavigation.recordIds.length-1,onClick:()=>{let t=e.recordNavigation;t.currentIndex<t.recordIds.length-1&&t.onNavigate(t.recordIds[t.currentIndex+1])},children:(0,$.jsx)(pe,{className:`h-4 w-4`})})}),(0,$.jsx)(O,{children:A(`detail.nextRecord`)})]})]}),ie.map((e,t)=>(0,$.jsx)(s,{schema:e,data:m},t)),o&&(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsx)(Z,{variant:b?`default`:`outline`,size:`sm`,onClick:z,className:`gap-2 hidden sm:inline-flex`,children:b?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ge,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:A(`detail.save`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(me,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:A(`detail.editInline`)})]})})}),(0,$.jsx)(O,{children:A(b?`detail.saveChanges`:`detail.editFieldsInline`)})]}),e.showEdit&&(0,$.jsxs)(mt,{children:[(0,$.jsx)(ne,{asChild:!0,children:(0,$.jsxs)(Z,{variant:`default`,onClick:ee,className:`gap-2 hidden sm:inline-flex`,children:[(0,$.jsx)(me,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:A(`detail.edit`)})]})}),(0,$.jsx)(O,{children:A(`detail.editRecord`)})]})]})]}),e.header&&(0,$.jsx)(`div`,{children:(0,$.jsx)(s,{schema:e.header,data:m})}),e.highlightFields&&e.highlightFields.length>0&&(0,$.jsx)(Zt,{fields:e.highlightFields,data:m,objectName:e.objectName,objectSchema:T}),e.autoTabs&&!e.tabs?.length?(()=>{let n=U.length>0,r=!!e.activities&&e.activities.length>0,i=!!u,a=(0,$.jsxs)(`div`,{className:`space-y-3 sm:space-y-4`,children:[e.sectionGroups&&e.sectionGroups.length>0&&e.sectionGroups.map((t,n)=>(0,$.jsx)(Xt,{group:t,data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V},n)),e.sections&&e.sections.length>0&&e.sections.map((t,n)=>(0,$.jsx)(Kt,{section:t,data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V},n)),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,$.jsx)(Kt,{section:{fields:e.fields,columns:e.columns},data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V}),e.comments&&(0,$.jsx)($t,{comments:e.comments,onAddComment:e.onAddComment})]});return!n&&!r&&!i?(0,$.jsx)(`div`,{className:`mt-2`,children:a}):(0,$.jsxs)(Be,{defaultValue:`details`,className:`w-full`,children:[(0,$.jsxs)(Ae,{className:`w-full justify-start border-b rounded-none bg-transparent p-0`,children:[(0,$.jsx)(_e,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:A(`detail.details`)}),n&&(0,$.jsx)(_e,{value:`related`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[A(`detail.related`),(0,$.jsx)(ve,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:U.length})]})}),r&&(0,$.jsx)(_e,{value:`activity`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[A(`detail.activity`),(0,$.jsx)(ve,{variant:`secondary`,className:`text-xs bg-primary/10 text-primary border-transparent`,children:e.activities.length})]})}),i&&(0,$.jsx)(_e,{value:`discussion`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent`,children:A(`detail.discussion`,{defaultValue:`Discussion`})})]}),(0,$.jsx)(Me,{value:`details`,className:`mt-4`,children:a}),n&&(0,$.jsx)(Me,{value:`related`,className:`mt-4`,children:(0,$.jsx)(`div`,{className:`space-y-3`,children:U.map((e,n)=>(0,$.jsx)(Yt,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,collapsible:!0,pageSize:sn},n))})}),r&&(0,$.jsx)(Me,{value:`activity`,className:`mt-4`,children:(0,$.jsx)(on,{activities:e.activities})}),i&&(0,$.jsx)(Me,{value:`discussion`,className:`mt-4`,children:u})]})})():(0,$.jsxs)($.Fragment,{children:[e.sectionGroups&&e.sectionGroups.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sectionGroups.map((t,n)=>(0,$.jsx)(Xt,{group:t,data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V},n))}),e.sections&&e.sections.length>0&&(0,$.jsx)(`div`,{className:`space-y-3 sm:space-y-4`,children:e.sections.map((t,n)=>(0,$.jsx)(Kt,{section:t,data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V},n))}),e.fields&&e.fields.length>0&&!e.sections?.length&&(0,$.jsx)(Kt,{section:{fields:e.fields,columns:e.columns},data:{...m,...S},objectSchema:T,objectName:e.objectName,isEditing:b,onFieldChange:V}),e.tabs&&e.tabs.length>0&&(0,$.jsx)(qt,{tabs:e.tabs,data:m}),U.length>0&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:A(`detail.related`)}),U.map((e,n)=>(0,$.jsx)(Yt,{title:e.title,type:e.type,api:e.api,data:e.data,columns:e.columns,dataSource:t,objectName:e.api,referenceField:e.referenceField,icon:e.icon,collapsible:!0,pageSize:sn},n))]}),e.comments&&(0,$.jsx)($t,{comments:e.comments,onAddComment:e.onAddComment}),e.activities&&e.activities.length>0&&(0,$.jsx)(on,{activities:e.activities})]}),e.footer&&(0,$.jsx)(`div`,{children:(0,$.jsx)(s,{schema:e.footer,data:m})})]})})},un=({change:e,className:t})=>{let n=e.fieldLabel??e.field.charAt(0).toUpperCase()+e.field.slice(1).replace(/_/g,` `),r=e.oldDisplayValue??(e.oldValue==null?`(empty)`:String(e.oldValue)),i=e.newDisplayValue??(e.newValue==null?`(empty)`:String(e.newValue));return(0,$.jsxs)(`div`,{className:B(`flex items-center gap-1.5 text-sm flex-wrap`,t),children:[(0,$.jsx)(`span`,{className:`font-medium text-foreground`,children:n}),(0,$.jsx)(`span`,{className:`text-muted-foreground line-through`,children:r}),(0,$.jsx)(Qe,{className:`h-3 w-3 text-muted-foreground shrink-0`}),(0,$.jsx)(`span`,{className:`text-foreground`,children:i})]})},dn=[`👍`,`❤️`,`🎉`,`😂`,`😮`,`😢`],fn=({reactions:e,onToggleReaction:t,emojiOptions:n=dn,className:r})=>{let[i,a]=Q.useState(!1),o=Q.useCallback(e=>{t?.(e),a(!1)},[t]);return(0,$.jsxs)(`div`,{className:B(`flex items-center gap-1 flex-wrap`,r),children:[e.map(e=>(0,$.jsxs)(`button`,{type:`button`,className:B(`inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs border transition-colors`,e.reacted?`bg-primary/10 border-primary/30 text-primary`:`bg-muted border-border text-muted-foreground hover:bg-muted/80`),onClick:()=>o(e.emoji),disabled:!t,"aria-label":`${e.emoji} ${e.count} reaction${e.count===1?``:`s`}`,children:[(0,$.jsx)(`span`,{children:e.emoji}),(0,$.jsx)(`span`,{children:e.count})]},e.emoji)),t&&(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6`,onClick:()=>a(!i),"aria-label":`Add reaction`,children:(0,$.jsx)(ot,{className:`h-3.5 w-3.5`})}),i&&(0,$.jsx)(`div`,{className:`absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1`,role:`listbox`,"aria-label":`Emoji picker`,children:n.map(t=>(0,$.jsx)(`button`,{type:`button`,className:`hover:bg-accent rounded p-1 text-base transition-colors`,onClick:()=>o(t),role:`option`,"aria-selected":e.some(e=>e.emoji===t&&e.reacted),children:t},t))})]})]})};function pn(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}var mn=({parentItem:e,replies:t,onAddReply:n,showReplyInput:r=!0,className:i})=>{let{t:a}=Wt(),[o,s]=Q.useState(!1),[c,l]=Q.useState(``),[u,d]=Q.useState(!1),f=Q.useCallback(async()=>{let t=c.trim();if(!(!t||!n)){d(!0);try{await n(e.id,t),l(``)}finally{d(!1)}}},[c,n,e.id]),p=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),f())},[f]);return t.length===0&&!r?null:(0,$.jsxs)(`div`,{className:B(`ml-10 mt-1`,i),children:[t.length>0&&(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1`,onClick:()=>s(!o),"aria-expanded":o,children:[o?(0,$.jsx)(Je,{className:`h-3 w-3`}):(0,$.jsx)(pe,{className:`h-3 w-3`}),(0,$.jsx)(ft,{className:`h-3 w-3`}),(0,$.jsx)(`span`,{children:t.length===1?a(`detail.replyCount`,{count:t.length}):a(`detail.replyCountPlural`,{count:t.length})})]}),o&&(0,$.jsx)(`div`,{className:`space-y-2 border-l-2 border-border pl-3`,children:t.map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`div`,{className:`shrink-0`,children:e.actorAvatarUrl?(0,$.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-6 w-6 rounded-full object-cover`}):(0,$.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground`,children:e.actor.charAt(0).toUpperCase()})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium`,children:e.actor}),(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:pn(e.createdAt)})]}),(0,$.jsx)(`p`,{className:`text-xs whitespace-pre-wrap break-words`,children:e.body})]})]},e.id))}),r&&n&&(0,$.jsxs)(`div`,{className:`flex gap-1.5 mt-1.5`,children:[(0,$.jsx)(`input`,{className:`flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,placeholder:a(`detail.replyPlaceholder`),value:c,onChange:e=>l(e.target.value),onKeyDown:p,disabled:u}),(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-6 w-6 shrink-0`,onClick:f,disabled:!c.trim()||u,"aria-label":`Send reply`,children:(0,$.jsx)(R,{className:`h-3 w-3`})})]})]})},hn=({subscription:e,onToggle:t,className:n})=>{let{t:r}=Wt(),[i,a]=Q.useState(!1),o=Q.useCallback(async()=>{if(t){a(!0);try{await t(!e.subscribed)}finally{a(!1)}}},[t,e.subscribed]);return(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:B(`h-8 w-8`,n),onClick:o,disabled:i||!t,"aria-label":e.subscribed?r(`detail.unsubscribeAriaLabel`):r(`detail.subscribeAriaLabel`),title:e.subscribed?r(`detail.subscribedTooltip`):r(`detail.unsubscribedTooltip`),children:e.subscribed?(0,$.jsx)(k,{className:`h-4 w-4 text-primary`}):(0,$.jsx)(N,{className:`h-4 w-4 text-muted-foreground`})})},gn={comment:ft,field_change:me,task:P,event:Re,system:pt,email:q,call:V},_n={comment:`bg-purple-100 text-purple-600`,field_change:`bg-blue-100 text-blue-600`,task:`bg-green-100 text-green-600`,event:`bg-amber-100 text-amber-600`,system:`bg-gray-100 text-gray-600`,email:`bg-indigo-100 text-indigo-600`,call:`bg-teal-100 text-teal-600`};function vn(e){return[{value:`all`,label:e(`detail.allActivity`)},{value:`comments_only`,label:e(`detail.commentsOnly`)},{value:`changes_only`,label:e(`detail.fieldChangesFilter`)},{value:`tasks_only`,label:e(`detail.tasksOnly`)}]}function yn(e){try{let t=new Date(e),n=new Date().getTime()-t.getTime(),r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);return a<7?`${a}d ago`:t.toLocaleDateString()}catch{return e}}function bn(e,t){switch(t){case`comments_only`:return e.filter(e=>e.type===`comment`);case`changes_only`:return e.filter(e=>e.type===`field_change`);case`tasks_only`:return e.filter(e=>e.type===`task`);default:return e}}var xn=({items:e,config:t,filterMode:n,onFilterChange:r,hasMore:i=!1,onLoadMore:a,loading:o=!1,onAddComment:s,onAddReply:c,onToggleReaction:l,subscription:u,onToggleSubscription:d,collapseWhenEmpty:f=!1,className:p})=>{let{t:m}=Wt(),[h,g]=Q.useState(`all`),[_,v]=Q.useState(``),[y,b]=Q.useState(!1),[x,S]=Q.useState(!1),C=n??h,w=t?.showFilterToggle!==!1,T=t?.showCommentInput!==!1&&!!s,D=t?.enableReactions??!1,O=t?.enableThreading??!1,k=t?.showSubscriptionToggle??!1,A=Q.useMemo(()=>bn(e,C),[e,C]),j=Q.useMemo(()=>O?A.filter(e=>!e.parentId):A,[A,O]),N=Q.useMemo(()=>{if(!O)return new Map;let e=new Map;for(let t of A)if(t.parentId){let n=e.get(t.parentId)??[];n.push(t),e.set(t.parentId,n)}return e},[A,O]),P=Q.useCallback(e=>{r?r(e):g(e)},[r]),ee=Q.useCallback(async()=>{let e=_.trim();if(!(!e||!s)){b(!0);try{await s(e),v(``)}finally{b(!1)}}},[_,s]),F=Q.useCallback(e=>{e.key===`Enter`&&(e.ctrlKey||e.metaKey)&&(e.preventDefault(),ee())},[ee]),te=Q.useCallback(async()=>{if(a){S(!0);try{await a()}finally{S(!1)}}},[a]);return(0,$.jsxs)(E,{className:B(``,p),children:[(0,$.jsx)(He,{children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(Xe,{className:`flex items-center gap-2 text-base`,children:[(0,$.jsx)(re,{className:`h-4 w-4`}),m(`detail.activity`),(0,$.jsxs)(`span`,{className:`text-sm font-normal text-muted-foreground`,children:[`(`,A.length,`)`]})]}),(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:k&&u&&(0,$.jsx)(hn,{subscription:u,onToggle:d})})]})}),(0,$.jsxs)(Y,{className:`space-y-4`,children:[w&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(`select`,{className:`rounded-md border border-input bg-background px-2.5 py-1.5 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,value:C,onChange:e=>P(e.target.value),"aria-label":m(`detail.filterActivity`),children:vn(m).map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})}),T&&(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`textarea`,{className:`flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none`,placeholder:m(`detail.leaveCommentPlaceholder`),value:_,onChange:e=>v(e.target.value),onKeyDown:F,disabled:y}),(0,$.jsx)(Z,{size:`icon`,variant:`default`,onClick:ee,disabled:!_.trim()||y,className:`shrink-0 self-end`,"aria-label":m(`detail.submitComment`),children:(0,$.jsx)(ft,{className:`h-4 w-4`})})]}),A.length===0?f?null:(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground text-center py-4`,children:m(`detail.noActivity`)}):(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`div`,{className:`absolute left-4 top-2 bottom-2 w-px bg-border`}),(0,$.jsx)(`div`,{className:`space-y-4`,children:j.map(e=>{let t=gn[e.type]||pt,n=_n[e.type]||`bg-gray-100 text-gray-600`,r=N.get(e.id)??[];return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex gap-3 relative`,children:[(0,$.jsx)(`div`,{className:B(`shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10`,n),children:e.actorAvatarUrl?(0,$.jsx)(`img`,{src:e.actorAvatarUrl,alt:e.actor,className:`h-8 w-8 rounded-full object-cover`}):(0,$.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 pt-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-0.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:e.actor}),e.source&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:m(`detail.via`,{source:e.source})}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:yn(e.createdAt)}),e.edited&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground italic`,children:m(`detail.edited`)}),e.pinned&&(0,$.jsxs)(`span`,{className:`text-xs text-amber-600`,children:[`📌 `,m(`detail.pinned`)]})]}),e.body&&(0,$.jsx)(`p`,{className:`text-sm whitespace-pre-wrap break-words text-muted-foreground`,children:e.body}),e.type===`field_change`&&e.fieldChanges&&(0,$.jsx)(`div`,{className:`space-y-1 mt-1`,children:e.fieldChanges.map((e,t)=>(0,$.jsx)(un,{change:e},t))}),D&&e.reactions&&e.reactions.length>0&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(fn,{reactions:e.reactions,onToggleReaction:l?t=>l(e.id,t):void 0})}),D&&(!e.reactions||e.reactions.length===0)&&l&&(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(fn,{reactions:[],onToggleReaction:t=>l(e.id,t)})})]})]}),O&&(e.replyCount??0)>0&&(0,$.jsx)(mn,{parentItem:e,replies:r,onAddReply:c,showReplyInput:!!c})]},e.id)})})]}),i&&(0,$.jsx)(`div`,{className:`text-center pt-2`,children:(0,$.jsxs)(Z,{variant:`ghost`,size:`sm`,onClick:te,disabled:x,"aria-label":m(`detail.loadMore`),children:[x?(0,$.jsx)(M,{className:`h-4 w-4 animate-spin mr-1`}):(0,$.jsx)(Je,{className:`h-4 w-4 mr-1`}),m(`detail.loadMore`)]})})]})]})},Sn=({config:e,items:t,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f=!1,className:p})=>{let m=e?.position??`right`,h=e?.width??`360px`,g=e?.collapsible??!0,_=f&&t.length===0||(e?.defaultCollapsed??!1),{t:v}=Wt(),[y,b]=Q.useState(_);return m===`right`||m===`left`?y&&g?(0,$.jsx)(`div`,{className:B(`flex items-start pt-4`,m===`right`?`border-l`:`border-r`,p),children:(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-8 w-8 mx-1`,onClick:()=>b(!1),"aria-label":v(`detail.openDiscussion`),children:(0,$.jsx)(lt,{className:`h-4 w-4`})})}):(0,$.jsxs)(`div`,{className:B(`flex flex-col overflow-hidden`,m===`right`?`border-l`:`border-r`,p),style:{width:h,minWidth:h},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ft,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{className:`text-sm font-medium`,children:v(`detail.discussion`)})]}),g&&(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>b(!0),"aria-label":v(`detail.closeDiscussion`),children:(0,$.jsx)(ae,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:(0,$.jsx)(xn,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f,className:`border-0 shadow-none`})})]}):(0,$.jsx)(`div`,{className:B(``,p),children:g&&y?(0,$.jsxs)(Z,{variant:`ghost`,className:`w-full justify-start gap-2 text-muted-foreground`,onClick:()=>b(!1),"aria-label":v(`detail.showDiscussion`,{count:t.length}),children:[(0,$.jsx)(ft,{className:`h-4 w-4`}),(0,$.jsx)(`span`,{children:v(`detail.showDiscussion`,{count:t.length})})]}):(0,$.jsxs)(`div`,{children:[g&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium`,children:[(0,$.jsx)(ft,{className:`h-4 w-4`}),v(`detail.discussion`)]}),(0,$.jsx)(Z,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,onClick:()=>b(!0),"aria-label":v(`detail.hideDiscussion`),children:(0,$.jsx)(ct,{className:`h-3.5 w-3.5`})})]}),(0,$.jsx)(xn,{items:t,config:e?.feed,hasMore:n,onLoadMore:r,loading:i,onAddComment:a,onAddReply:o,onToggleReaction:s,subscription:c,onToggleSubscription:l,filterMode:u,onFilterChange:d,collapseWhenEmpty:f})]})})};c.register(`detail-view`,ln,{namespace:`plugin-detail`,label:`Detail View`,category:`Views`,icon:`FileText`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`objectName`,type:`string`,label:`Object Name`},{name:`resourceId`,type:`string`,label:`Resource ID`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`object`,label:`Data`},{name:`layout`,type:`enum`,label:`Layout Mode`,enum:[`vertical`,`horizontal`,`grid`]},{name:`columns`,type:`number`,label:`Grid Columns`},{name:`sections`,type:`array`,label:`Sections`},{name:`fields`,type:`array`,label:`Fields`},{name:`tabs`,type:`array`,label:`Tabs`},{name:`related`,type:`array`,label:`Related Lists`},{name:`actions`,type:`array`,label:`Actions`},{name:`showBack`,type:`boolean`,label:`Show Back Button`,defaultValue:!0},{name:`backUrl`,type:`string`,label:`Back URL`},{name:`showEdit`,type:`boolean`,label:`Show Edit Button`,defaultValue:!1},{name:`editUrl`,type:`string`,label:`Edit URL`},{name:`showDelete`,type:`boolean`,label:`Show Delete Button`,defaultValue:!1},{name:`deleteConfirmation`,type:`string`,label:`Delete Confirmation Message`},{name:`loading`,type:`boolean`,label:`Show Loading State`},{name:`header`,type:`object`,label:`Custom Header`},{name:`footer`,type:`object`,label:`Custom Footer`}],defaultProps:{title:`Detail View`,showBack:!0,showEdit:!1,showDelete:!1,sections:[],fields:[],tabs:[],related:[]}}),c.register(`detail-section`,Kt,{namespace:`plugin-detail`,label:`Detail Section`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`fields`,type:`array`,label:`Fields`,required:!0},{name:`collapsible`,type:`boolean`,label:`Collapsible`,defaultValue:!1},{name:`defaultCollapsed`,type:`boolean`,label:`Default Collapsed`,defaultValue:!1},{name:`columns`,type:`number`,label:`Columns`,defaultValue:2},{name:`showBorder`,type:`boolean`,label:`Show Border`,defaultValue:!0},{name:`headerColor`,type:`string`,label:`Header Color`}]}),c.register(`related-list`,Yt,{namespace:`plugin-detail`,label:`Related List`,category:`Detail Components`,inputs:[{name:`title`,type:`string`,label:`Title`,required:!0},{name:`type`,type:`enum`,label:`Type`,enum:[{label:`List`,value:`list`},{label:`Grid`,value:`grid`},{label:`Table`,value:`table`}],defaultValue:`table`},{name:`api`,type:`string`,label:`API Endpoint`},{name:`data`,type:`array`,label:`Data`},{name:`columns`,type:`array`,label:`Columns`}]}),c.register(`detail`,ln,{namespace:`view`,category:`view`,label:`Detail`,icon:`FileText`,inputs:[{name:`objectName`,type:`string`,label:`Object Name`,required:!0},{name:`recordId`,type:`string`,label:`Record ID`},{name:`fields`,type:`array`,label:`Fields`}]});function Cn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&e.provider===`object`}function wn(e){return e?fe(e):null}function Tn(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var En=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],Dn=(0,Q.forwardRef)(({schema:e,className:t,dataSource:n,onRefresh:r,recordCount:i,userActions:a,designMode:o,selectedWidgetId:c,onWidgetClick:l,modalHandler:u,scriptHandlers:d,...f},p)=>{let m=(()=>{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})(),h=m,_=e.gap||4,[v,y]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),C=(0,Q.useRef)(null),{executeAction:w,engine:T}=g({actions:(0,Q.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:D,dashboardDescription:O,dashboardActionLabel:k,widgetTitle:A,widgetDescription:j,fieldLabel:M}=b(),N=e.name,P=(0,Q.useCallback)(e=>N?k(N,e.actionUrl||e.label,e.label):e.label,[N,k]),ee=(0,Q.useCallback)(e=>{let t=Tn(e.title);return!N||!e.id||t===void 0?t:A(N,e.id,t)},[N,A]),F=(0,Q.useCallback)(e=>{let t=Tn(e.description);return!N||!e.id?t:j(N,e.id,t)},[N,j]);(0,Q.useEffect)(()=>{let e=T.getRunner();if(u&&e.setModalHandler(u),d)for(let[t,n]of Object.entries(d))e.registerScript(t,n)},[T,u,d]),(0,Q.useEffect)(()=>{let e=()=>S(window.innerWidth<768);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let te=(0,Q.useCallback)(()=>{r&&(y(!0),r(),setTimeout(()=>y(!1),600))},[r]);(0,Q.useEffect)(()=>{if(!(!e.refreshInterval||e.refreshInterval<=0||!r))return C.current=setInterval(te,e.refreshInterval*1e3),()=>{C.current&&clearInterval(C.current)}},[e.refreshInterval,r,te]);let ne=(0,Q.useCallback)((e,t)=>{!o||!l||!t||(e.stopPropagation(),l(t))},[o,l]),I=(0,Q.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]),L=(0,Q.useCallback)(e=>{!o||!l||e.target===e.currentTarget&&l(null)},[o,l]),R=(e,t,r)=>{let i=e.layout?{...e.layout,w:Math.min(e.layout.w,h)}:void 0,a=(()=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`metric`&&e.object){let t=n.data,r=Cn(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||(Cn(t)?t.object:void 0),aggregate:r,filter:(Cn(t)?t.filter:void 0)||e.filter,label:n.label||ee(e)||``,fallbackValue:n.value,trend:n.trend,icon:n.icon,description:n.description,colorVariant:e.colorVariant}}if((t===`gauge`||t===`solid-gauge`)&&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||ee(e)||``,fallbackValue:n.fallbackValue??n.value,icon:n.icon,description:n.description}}let r={funnel:`bar`,"horizontal-bar":`bar`}[t]||t;if(r===`bar`||r===`line`||r===`area`||r===`pie`||r===`donut`||r===`scatter`){let t=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(Cn(t)){let n=t.aggregate,o=n?{field:e.valueField||n.field,function:e.aggregate||n.function,groupBy:e.categoryField||n.groupBy}:void 0,s=o?.field||a,c=e.object||t.object;return{type:`object-chart`,chartType:r,objectName:c,aggregate:o,xAxisKey:i,series:[{dataKey:s,label:c?M(c,s,s):s}],colors:En,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(!t&&e.object){let t=e.aggregate?{field:e.valueField||`value`,function:e.aggregate,groupBy:e.categoryField||`name`}:void 0,n=e.valueField||`value`;return{type:`object-chart`,chartType:r,objectName:e.object,aggregate:t,xAxisKey:i,series:[{dataKey:n,label:M(e.object,n,n)}],colors:En,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:e.object?M(e.object,a,a):a}],colors:En,className:`h-[200px] sm:h-[250px] md:h-[300px]`}}if(t===`table`){let t=e.data||n.data;if(Cn(t)){let{data:r,...i}=n;return{type:`object-data-table`,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter,searchable:e.searchable??!1,pagination:e.pagination??!1,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,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(Cn(t)){let{data:r,...i}=n;return{type:`object-pivot`,...i,objectName:e.object||t.object,dataProvider:t,filter:t.filter||e.filter}}return!t&&e.object?{type:`object-pivot`,...n,objectName:e.object,filter:e.filter}:{type:`pivot`,...n,data:Array.isArray(t)?t:t?.items||[]}}return{...e,...n}})(),l=e.type===`metric`,u=ee(e),d=F(e),f=e.id||u||`widget-${t}`,p=o&&c===e.id,m=o?{"data-testid":`dashboard-preview-widget-${e.id}`,"data-widget-id":e.id,role:`button`,tabIndex:0,"aria-selected":p,"aria-label":`Widget: ${u||`Widget ${t+1}`}`,onClick:t=>ne(t,e.id),onKeyDown:n=>I(n,e.id,t)}:{},g=o?B(`cursor-pointer rounded-lg transition-all outline-none`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,p?`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;return l?(0,$.jsxs)(`div`,{className:B(`h-full w-full`,o&&`relative`,g),style:!x&&i?{gridColumn:`span ${i.w}`,gridRow:`span ${i.h}`}:void 0,...m,children:[(0,$.jsx)(s,{schema:a,className:B(`h-full w-full`,o&&`pointer-events-none`),dataSource:n}),o&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]},f):(0,$.jsxs)(E,{className:B(`overflow-hidden border-border/50 shadow-sm transition-all hover:shadow-md`,`bg-card/50 backdrop-blur-sm`,r&&`w-full`,o&&`relative`,g),style:!x&&i?{gridColumn:`span ${i.w}`,gridRow:`span ${i.h}`}:void 0,...m,children:[u&&(0,$.jsxs)(He,{className:`pb-2 border-b border-border/40 bg-muted/20 px-3 sm:px-6`,children:[(0,$.jsx)(Xe,{className:`text-sm sm:text-base font-medium tracking-tight truncate`,title:u,children:u}),d&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5 line-clamp-2`,children:d})]}),(0,$.jsx)(Y,{className:`p-0`,children:(0,$.jsx)(`div`,{className:B(`h-full w-full`,`p-3 sm:p-4 md:p-6`,o&&`pointer-events-none`),children:(0,$.jsx)(s,{schema:a,dataSource:n})})}),o&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10`,"aria-hidden":`true`,"data-testid":`widget-click-overlay`})]},f)},re=e.header&&(0,$.jsxs)(`div`,{className:`col-span-full mb-4`,children:[e.header.showTitle!==!1&&e.title&&(0,$.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:N?D({name:N,label:Tn(e.title)}):Tn(e.title)}),e.header.showDescription!==!1&&e.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:N?O({name:N,description:Tn(e.description)}):Tn(e.description)}),e.header.actions&&e.header.actions.length>0&&(0,$.jsx)(`div`,{className:`flex gap-2 mt-3`,children:e.header.actions.map((e,t)=>{let n=wn(e.icon);return(0,$.jsxs)(Z,{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 w(n||r);e?.success||console.warn(`[DashboardRenderer] action failed`,e?.error);return}console.warn(`[DashboardRenderer] Unknown header actionType="${t}" for "${r}"`)},children:[n&&(0,$.jsx)(n,{className:`w-4 h-4 mr-1.5`}),P(e)]},t)})})]}),z=i!==void 0&&(0,$.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[i.toLocaleString(),` records`]}),V=a?JSON.stringify(a):void 0,H=r&&(0,$.jsxs)(`div`,{className:B(`flex items-center justify-end gap-3 mb-2`,!x&&`col-span-full`),children:[z,(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:te,disabled:v,"aria-label":`Refresh dashboard`,children:[(0,$.jsx)(Ue,{className:B(`h-4 w-4 mr-2`,v&&`animate-spin`)}),v?`Refreshing…`:`Refresh All`]})]});if(x){let n=e.widgets?.filter(e=>e.type===`metric`)||[],r=e.widgets?.filter(e=>e.type!==`metric`)||[];return(0,$.jsxs)(`div`,{ref:p,className:B(`flex flex-col gap-4 px-4`,t),"data-user-actions":V,onClick:L,...f,children:[re,H,n.length>0&&(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,onClick:L,children:n.map((e,t)=>R(e,t))}),r.length>0&&(0,$.jsx)(`div`,{className:`flex flex-col gap-4`,onClick:L,children:r.map((e,t)=>R(e,t,!0))})]})}let U=e.columns!=null||m!==4;return(0,$.jsxs)(`div`,{ref:p,className:B(`grid auto-rows-min`,!U&&`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4`,t),style:{...U&&{gridTemplateColumns:`repeat(${h}, minmax(0, 1fr))`},gap:`${_*.25}rem`},"data-user-actions":V,onClick:L,...f,children:[re,H,e.widgets?.map((e,t)=>R(e,t))]})});function On(e){let{margin:t,containerPadding:n,containerWidth:r,cols:i}=e;return(r-t[0]*(i-1)-n[0]*2)/i}function kn(e,t,n){return Number.isFinite(e)?Math.round(t*e+Math.max(0,e-1)*n):e}function An(e,t,n,r,i,a,o){let{margin:s,containerPadding:c,rowHeight:l}=e,u=On(e),d,f,p,m;if(o?(d=Math.round(o.width),f=Math.round(o.height)):(d=kn(r,u,s[0]),f=kn(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 jn(e,t,n,r,i){let{margin:a,containerPadding:o,cols:s,rowHeight:c,maxRows:l}=e,u=On(e),d=Math.round((n-o[0])/(u+a[0])),f=Math.round((t-o[1])/(c+a[1]));return d=Pn(d,0,s-r),f=Pn(f,0,l-i),{x:d,y:f}}function Mn(e,t,n){let{margin:r,containerPadding:i,rowHeight:a}=e,o=On(e);return{x:Math.round((n-i[0])/(o+r[0])),y:Math.round((t-i[1])/(a+r[1]))}}function Nn(e,t,n){let{margin:r,rowHeight:i}=e,a=On(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 Pn(e,t,n){return Math.max(Math.min(e,n),t)}function Fn(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 In(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&Fn(r,t))return r}}function Ln(e,t){return e.filter(e=>Fn(e,t))}function Rn(e,t){return t===`horizontal`?Bn(e):t===`vertical`||t===`wrap`?zn(e):[...e]}function zn(e){return[...e].sort((e,t)=>e.y===t.y?e.x-t.x:e.y-t.y)}function Bn(e){return[...e].sort((e,t)=>e.x===t.x?e.y-t.y:e.x-t.x)}function Vn(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 Hn(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(r!==void 0&&r.i===t)return r}}function Un(e){return e.filter(e=>e.static===!0)}function Wn(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 Gn(e){let t=Array(e.length);for(let n=0;n<e.length;n++){let r=e[n];r!==void 0&&(t[n]=Wn(r))}return t}function Kn(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 qn(e,t,n){let r=Hn(e,t);return r?(r=n(Wn(r)),[Kn(e,r),r]):[[...e],null]}function Jn(e,t){let n=Un(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(;In(n,i);)i.y++}return e}function Yn(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=Rn(e,o);(o===`vertical`&&typeof r==`number`?u>=r:o===`horizontal`&&typeof n==`number`&&l>=n)&&(d=d.reverse());let f=Ln(d,t),p=f.length>0;if(p&&c)return Gn(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?Xn(m,n,t,i,o):Xn(m,t,n,i,o)))}return m}function Xn(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=In(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 Yn(e,n,o?a.x:void 0,s?a.y:void 0,r,c,i);if(u&&s)return Yn(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 Yn(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]:Yn(e,n,l,u,r,c,i)}function Zn(e,t,n){return Math.max(t,Math.min(n,e))}var Qn=[{name:`gridBounds`,constrainPosition(e,t,n,{cols:r,maxRows:i}){return{x:Zn(t,0,Math.max(0,r-e.w)),y:Zn(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:Zn(t,1,Math.max(1,o)),h:Zn(n,1,Math.max(1,s))}}},{name:`minMaxSize`,constrainSize(e,t,n){return{w:Zn(t,e.minW??1,e.maxW??1/0),h:Zn(n,e.minH??1,e.maxH??1/0)}}}];function $n(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 er(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 tr({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 nr({top:e,left:t,width:n,height:r}){return{top:`${e}px`,left:`${t}px`,width:`${n}px`,height:`${r}px`,position:`absolute`}}function rr(e){return e*100+`%`}function ir(e,t,n,r){return e+n>r?t:n}function ar(e,t,n){return e<0?t:n}function or(e){return Math.max(0,e)}function sr(e){return Math.max(0,e)}var cr=(e,t,n)=>{let{left:r,height:i,width:a}=t,o=e.top-(i-e.height);return{left:r,width:a,height:ar(o,e.height,i),top:sr(o)}},lr=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{top:r,height:a,width:ir(e.left,e.width,o,n),left:or(i)}},ur=(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:sr(r),left:0}:{height:i,width:a,top:sr(r),left:o}},dr=(e,t,n)=>{let{top:r,left:i,height:a,width:o}=t;return{width:o,left:i,height:ar(r,e.height,a),top:sr(r)}},fr={n:cr,ne:(e,t,n)=>cr(e,lr(e,t,n)),e:lr,se:(e,t,n)=>dr(e,lr(e,t,n)),s:dr,sw:(e,t,n)=>dr(e,ur(e,t)),w:ur,nw:(e,t,n)=>cr(e,ur(e,t))};function pr(e,t,n,r){let i=fr[e];return i?i(t,{...t,...n},r):n}var mr={type:`transform`,scale:1,calcStyle(e){return tr(e)}},hr={cols:12,rowHeight:150,margin:[10,10],containerPadding:null,maxRows:1/0},gr={enabled:!0,bounded:!1,threshold:3},_r={enabled:!0,handles:[`se`]},vr={enabled:!1,defaultItem:{w:1,h:1}};function yr(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??Un(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;Fn(t,o)&&yr(e,o,n+t[a],r,s)}}t[r]=n}function br(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&&!In(e,t);)t.y--;let i;for(;(i=In(e,t))!==void 0;)yr(n,t,i.y+i.h,`y`);return t.y=Math.max(t.y,0),t}function xr(e,t,n,r){for(t.x=Math.max(t.x,0),t.y=Math.max(t.y,0);t.x>0&&!In(e,t);)t.x--;let i;for(;(i=In(e,t))!==void 0;)if(yr(r,t,i.x+i.w,`x`),t.x+t.w>n)for(t.x=n-t.w,t.y++;t.x>0&&!In(e,t);)t.x--;return t.x=Math.max(t.x,0),t}var Sr={type:`vertical`,allowOverlap:!1,compact(e,t){let n=Un(e),r=Vn(n),i=zn(e),a=Array(e.length);for(let t=0;t<i.length;t++){let o=i[t];if(o===void 0)continue;let s=Wn(o);s.static||(s=br(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}},Cr={type:`horizontal`,allowOverlap:!1,compact(e,t){let n=Un(e),r=Bn(e),i=Array(e.length);for(let a=0;a<r.length;a++){let o=r[a];if(o===void 0)continue;let s=Wn(o);s.static||(s=xr(n,s,t,r),n.push(s));let c=e.indexOf(o);i[c]=s,s.moved=!1}return i}},wr={type:null,allowOverlap:!1,compact(e,t){return Gn(e)}},Tr={...Sr,allowOverlap:!0,compact(e,t){return Gn(e)}},Er={...Cr,allowOverlap:!0,compact(e,t){return Gn(e)}},Dr={...wr,allowOverlap:!0};function Or(e,t=!1,n=!1){let r;return r=t?e===`vertical`?Tr:e===`horizontal`?Er:Dr:e===`vertical`?Sr:e===`horizontal`?Cr:wr,n?{...r,preventCollision:n}:r}function kr(e){return Object.keys(e).sort((t,n)=>e[t]-e[n])}function Ar(e,t){let n=kr(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 jr(e,t){let n=t[e];if(n===void 0)throw Error(`ResponsiveReactGridLayout: \`cols\` entry for breakpoint ${String(e)} is missing!`);return n}function Mr(e,t,n,r,i,a){let o=e[n];if(o)return Gn(o);let s=e[r],c=kr(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=Jn(Gn(s||[]),{cols:i});return(typeof a==`object`&&a?a:Or(a)).compact(u,i)}function Nr(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 Pr=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 Arguments]`,c=`[object Boolean]`,l=`[object Date]`,u=`[object RegExp]`,d=`[object Map]`,f=`[object Number]`,p=`[object Object]`,m=`[object Set]`,h=`[object String]`,g=Object.prototype.toString;function _(e){var t=e.areArraysEqual,n=e.areDatesEqual,r=e.areMapsEqual,_=e.areObjectsEqual,v=e.areRegExpsEqual,y=e.areSetsEqual,b=e.createIsNestedEqual,x=b(S);function S(e,b,S){if(e===b)return!0;if(!e||!b||typeof e!=`object`||typeof b!=`object`)return e!==e&&b!==b;if(i(e)&&i(b))return _(e,b,x,S);var C=Array.isArray(e),w=Array.isArray(b);if(C||w)return C===w&&t(e,b,x,S);var T=g.call(e);return T===g.call(b)?T===l?n(e,b,x,S):T===u?v(e,b,x,S):T===d?r(e,b,x,S):T===m?y(e,b,x,S):T===p||T===s?a(e)||a(b)?!1:_(e,b,x,S):T===c||T===f||T===h?o(e.valueOf(),b.valueOf()):!1:!1}return S}function v(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 y=n(v);function b(e,t){return o(e.valueOf(),t.valueOf())}function x(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 S=n(x),C=`_owner`,w=Object.prototype.hasOwnProperty;function T(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===C){var s=!!e.$$typeof,c=!!t.$$typeof;if((s||c)&&s!==c)return!1}if(!w.call(t,o)||!n(e[o],t[o],o,o,e,t,r))return!1}return!0}var E=n(T);function D(e,t){return e.source===t.source&&e.flags===t.flags}function O(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 k=n(O),A=Object.freeze({areArraysEqual:v,areDatesEqual:b,areMapsEqual:x,areObjectsEqual:T,areRegExpsEqual:D,areSetsEqual:O,createIsNestedEqual:t}),j=Object.freeze({areArraysEqual:y,areDatesEqual:b,areMapsEqual:S,areObjectsEqual:E,areRegExpsEqual:D,areSetsEqual:k,createIsNestedEqual:t}),M=_(A);function N(e,t){return M(e,t,void 0)}var P=_(r(A,{createIsNestedEqual:function(){return o}}));function ee(e,t){return P(e,t,void 0)}var F=_(j);function te(e,t){return F(e,t,new WeakMap)}var ne=_(r(j,{createIsNestedEqual:function(){return o}}));function I(e,t){return ne(e,t,new WeakMap)}function L(e){return _(r(A,e(A)))}function R(e){var t=_(r(j,e(j)));return(function(e,n,r){return r===void 0&&(r=new WeakMap),t(e,n,r)})}e.circularDeepEqual=te,e.circularShallowEqual=I,e.createCustomCircularEqual=R,e.createCustomEqual=L,e.deepEqual=N,e.sameValueZeroEqual=o,e.shallowEqual=ee,Object.defineProperty(e,`__esModule`,{value:!0})}))}));function Fr(e={}){let{measureBeforeMount:t=!1,initialWidth:n=1280}=e,[r,i]=(0,Q.useState)(n),[a,o]=(0,Q.useState)(!t),s=(0,Q.useRef)(null),c=(0,Q.useRef)(null),l=(0,Q.useCallback)(()=>{let e=s.current;if(e){let t=e.offsetWidth;i(t),a||o(!0)}},[a]);return(0,Q.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 Ir=n(((e,t)=>{t.exports=`SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED`})),Lr=n(((e,t)=>{var n=Ir();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}})),Rr=n(((e,t)=>{t.exports=Lr()()})),zr=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.dontSetMe=a,e.findInArray=t,e.int=i,e.isFunction=n,e.isNum=r;function t(e,t){for(let n=0,r=e.length;n<r;n++)if(t.apply(t,[e[n],n,e]))return e[n]}function n(e){return typeof e==`function`||Object.prototype.toString.call(e)===`[object Function]`}function r(e){return typeof e==`number`&&!isNaN(e)}function i(e){return parseInt(e,10)}function a(e,t,n){if(e[t])return Error(`Invalid prop ${t} passed to ${n} - do not set this, set it on the child.`)}})),Br=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.browserPrefixToKey=r,e.browserPrefixToStyle=i,e.default=void 0,e.getPrefix=n;var t=[`Moz`,`Webkit`,`O`,`ms`];function n(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:`transform`;if(typeof window>`u`)return``;let n=window.document?.documentElement?.style;if(!n||e in n)return``;for(let i=0;i<t.length;i++)if(r(e,t[i])in n)return t[i];return``}function r(e,t){return t?`${t}${a(e)}`:e}function i(e,t){return t?`-${t.toLowerCase()}-${e}`:e}function a(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}e.default=n()})),Vr=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.addClassName=S,e.addEvent=s,e.addUserSelectStyles=y,e.createCSSTransform=m,e.createSVGTransform=h,e.getTouch=_,e.getTouchIdentifier=v,e.getTranslation=g,e.innerHeight=d,e.innerWidth=f,e.matchesSelector=a,e.matchesSelectorAndParentsTo=o,e.offsetXYFromParent=p,e.outerHeight=l,e.outerWidth=u,e.removeClassName=C,e.removeEvent=c,e.scheduleRemoveUserSelectStyles=b;var t=zr(),n=r(Br());function r(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,i=new WeakMap;return(r=function(e,t){if(!t&&e&&e.__esModule)return e;var r,a,o={__proto__:null,default:e};if(e===null||typeof e!=`object`&&typeof e!=`function`)return o;if(r=t?i:n){if(r.has(e))return r.get(e);r.set(e,o)}for(let t in e)t!==`default`&&{}.hasOwnProperty.call(e,t)&&((a=(r=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,t))&&(a.get||a.set)?r(o,t,a):o[t]=e[t]);return o})(e,t)}var i=``;function a(e,n){return i||=(0,t.findInArray)([`matches`,`webkitMatchesSelector`,`mozMatchesSelector`,`msMatchesSelector`,`oMatchesSelector`],function(n){return(0,t.isFunction)(e[n])}),(0,t.isFunction)(e[i])?e[i](n):!1}function o(e,t,n){let r=e;do{if(a(r,t))return!0;if(r===n)return!1;r=r.parentNode}while(r);return!1}function s(e,t,n,r){if(!e)return;let i={capture:!0,...r};e.addEventListener?e.addEventListener(t,n,i):e.attachEvent?e.attachEvent(`on`+t,n):e[`on`+t]=n}function c(e,t,n,r){if(!e)return;let i={capture:!0,...r};e.removeEventListener?e.removeEventListener(t,n,i):e.detachEvent?e.detachEvent(`on`+t,n):e[`on`+t]=null}function l(e){let n=e.clientHeight,r=e.ownerDocument.defaultView.getComputedStyle(e);return n+=(0,t.int)(r.borderTopWidth),n+=(0,t.int)(r.borderBottomWidth),n}function u(e){let n=e.clientWidth,r=e.ownerDocument.defaultView.getComputedStyle(e);return n+=(0,t.int)(r.borderLeftWidth),n+=(0,t.int)(r.borderRightWidth),n}function d(e){let n=e.clientHeight,r=e.ownerDocument.defaultView.getComputedStyle(e);return n-=(0,t.int)(r.paddingTop),n-=(0,t.int)(r.paddingBottom),n}function f(e){let n=e.clientWidth,r=e.ownerDocument.defaultView.getComputedStyle(e);return n-=(0,t.int)(r.paddingLeft),n-=(0,t.int)(r.paddingRight),n}function p(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 m(e,t){let r=g(e,t,`px`);return{[(0,n.browserPrefixToKey)(`transform`,n.default)]:r}}function h(e,t){return g(e,t,``)}function g(e,t,n){let{x:r,y:i}=e,a=`translate(${r}${n},${i}${n})`;return t&&(a=`translate(${`${typeof t.x==`string`?t.x:t.x+n}`}, ${`${typeof t.y==`string`?t.y:t.y+n}`})`+a),a}function _(e,n){return e.targetTouches&&(0,t.findInArray)(e.targetTouches,e=>n===e.identifier)||e.changedTouches&&(0,t.findInArray)(e.changedTouches,e=>n===e.identifier)}function v(e){if(e.targetTouches&&e.targetTouches[0])return e.targetTouches[0].identifier;if(e.changedTouches&&e.changedTouches[0])return e.changedTouches[0].identifier}function y(e){if(!e)return;let t=e.getElementById(`react-draggable-style-el`);t||(t=e.createElement(`style`),t.type=`text/css`,t.id=`react-draggable-style-el`,t.innerHTML=`.react-draggable-transparent-selection *::-moz-selection {all: inherit;}
|
|
4
|
-
`,t.innerHTML+=`.react-draggable-transparent-selection *::selection {all: inherit;}
|
|
5
|
-
`,e.getElementsByTagName(`head`)[0].appendChild(t)),e.body&&S(e.body,`react-draggable-transparent-selection`)}function b(e){window.requestAnimationFrame?window.requestAnimationFrame(()=>{x(e)}):x(e)}function x(e){if(e)try{if(e.body&&C(e.body,`react-draggable-transparent-selection`),e.selection)e.selection.empty();else{let t=(e.defaultView||window).getSelection();t&&t.type!==`Caret`&&t.removeAllRanges()}}catch{}}function S(e,t){e.classList?e.classList.add(t):e.className.match(RegExp(`(?:^|\\s)${t}(?!\\S)`))||(e.className+=` ${t}`)}function C(e,t){e.classList?e.classList.remove(t):e.className=e.className.replace(RegExp(`(?:^|\\s)${t}(?!\\S)`,`g`),``)}})),Hr=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.canDragX=a,e.canDragY=o,e.createCoreData=c,e.createDraggableData=l,e.getBoundPosition=r,e.getControlPosition=s,e.snapToGrid=i;var t=zr(),n=Vr();function r(e,r,i){if(!e.props.bounds)return[r,i];let{bounds:a}=e.props;a=typeof a==`string`?a:u(a);let o=d(e);if(typeof a==`string`){let{ownerDocument:e}=o,r=e.defaultView,i;if(i=a===`parent`?o.parentNode:o.getRootNode().querySelector(a),!(i instanceof r.HTMLElement))throw Error(`Bounds selector "`+a+`" could not find an element.`);let s=i,c=r.getComputedStyle(o),l=r.getComputedStyle(s);a={left:-o.offsetLeft+(0,t.int)(l.paddingLeft)+(0,t.int)(c.marginLeft),top:-o.offsetTop+(0,t.int)(l.paddingTop)+(0,t.int)(c.marginTop),right:(0,n.innerWidth)(s)-(0,n.outerWidth)(o)-o.offsetLeft+(0,t.int)(l.paddingRight)-(0,t.int)(c.marginRight),bottom:(0,n.innerHeight)(s)-(0,n.outerHeight)(o)-o.offsetTop+(0,t.int)(l.paddingBottom)-(0,t.int)(c.marginBottom)}}return(0,t.isNum)(a.right)&&(r=Math.min(r,a.right)),(0,t.isNum)(a.bottom)&&(i=Math.min(i,a.bottom)),(0,t.isNum)(a.left)&&(r=Math.max(r,a.left)),(0,t.isNum)(a.top)&&(i=Math.max(i,a.top)),[r,i]}function i(e,t,n){return[Math.round(t/e[0])*e[0],Math.round(n/e[1])*e[1]]}function a(e){return e.props.axis===`both`||e.props.axis===`x`}function o(e){return e.props.axis===`both`||e.props.axis===`y`}function s(e,t,r){let i=typeof t==`number`?(0,n.getTouch)(e,t):null;if(typeof t==`number`&&!i)return null;let a=d(r),o=r.props.offsetParent||a.offsetParent||a.ownerDocument.body;return(0,n.offsetXYFromParent)(i||e,o,r.props.scale)}function c(e,n,r){let i=!(0,t.isNum)(e.lastX),a=d(e);return i?{node:a,deltaX:0,deltaY:0,lastX:n,lastY:r,x:n,y:r}:{node:a,deltaX:n-e.lastX,deltaY:r-e.lastY,lastX:e.lastX,lastY:e.lastY,x:n,y:r}}function l(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 u(e){return{left:e.left,top:e.top,right:e.right,bottom:e.bottom}}function d(e){let t=e.findDOMNode();if(!t)throw Error(`<DraggableCore>: Unmounted during event!`);return t}})),Ur=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=t;function t(){}})),Wr=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=void 0;var t=d(r()),n=u(Rr()),a=u(i()),o=Vr(),s=Hr(),c=zr(),l=u(Ur());function u(e){return e&&e.__esModule?e:{default:e}}function d(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(d=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 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={touch:{start:`touchstart`,move:`touchmove`,stop:`touchend`},mouse:{start:`mousedown`,move:`mousemove`,stop:`mouseup`}},g=h.mouse,_=class extends t.Component{constructor(){super(...arguments),f(this,`dragging`,!1),f(this,`lastX`,NaN),f(this,`lastY`,NaN),f(this,`touchIdentifier`,null),f(this,`mounted`,!1),f(this,`handleDragStart`,e=>{if(this.props.onMouseDown(e),!this.props.allowAnyClick&&typeof e.button==`number`&&e.button!==0)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&&!(0,o.matchesSelectorAndParentsTo)(e.target,this.props.handle,t)||this.props.cancel&&(0,o.matchesSelectorAndParentsTo)(e.target,this.props.cancel,t))return;e.type===`touchstart`&&!this.props.allowMobileScroll&&e.preventDefault();let r=(0,o.getTouchIdentifier)(e);this.touchIdentifier=r;let i=(0,s.getControlPosition)(e,r,this);if(i==null)return;let{x:a,y:c}=i,u=(0,s.createCoreData)(this,a,c);(0,l.default)(`DraggableCore: handleDragStart: %j`,u),(0,l.default)(`calling`,this.props.onStart),!(this.props.onStart(e,u)===!1||this.mounted===!1)&&(this.props.enableUserSelectHack&&(0,o.addUserSelectStyles)(n),this.dragging=!0,this.lastX=a,this.lastY=c,(0,o.addEvent)(n,g.move,this.handleDrag),(0,o.addEvent)(n,g.stop,this.handleDragStop))}),f(this,`handleDrag`,e=>{let t=(0,s.getControlPosition)(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]=(0,s.snapToGrid)(this.props.grid,e,t),!e&&!t)return;n=this.lastX+e,r=this.lastY+t}let i=(0,s.createCoreData)(this,n,r);if((0,l.default)(`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}),f(this,`handleDragStop`,e=>{if(!this.dragging)return;let t=(0,s.getControlPosition)(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]=(0,s.snapToGrid)(this.props.grid,e,t),n=this.lastX+e,r=this.lastY+t}let i=(0,s.createCoreData)(this,n,r);if(this.props.onStop(e,i)===!1||this.mounted===!1)return!1;let a=this.findDOMNode();a&&this.props.enableUserSelectHack&&(0,o.scheduleRemoveUserSelectStyles)(a.ownerDocument),(0,l.default)(`DraggableCore: handleDragStop: %j`,i),this.dragging=!1,this.lastX=NaN,this.lastY=NaN,a&&((0,l.default)(`DraggableCore: Removing handlers`),(0,o.removeEvent)(a.ownerDocument,g.move,this.handleDrag),(0,o.removeEvent)(a.ownerDocument,g.stop,this.handleDragStop))}),f(this,`onMouseDown`,e=>(g=h.mouse,this.handleDragStart(e))),f(this,`onMouseUp`,e=>(g=h.mouse,this.handleDragStop(e))),f(this,`onTouchStart`,e=>(g=h.touch,this.handleDragStart(e))),f(this,`onTouchEnd`,e=>(g=h.touch,this.handleDragStop(e)))}componentDidMount(){this.mounted=!0;let e=this.findDOMNode();e&&(0,o.addEvent)(e,h.touch.start,this.onTouchStart,{passive:!1})}componentWillUnmount(){this.mounted=!1;let e=this.findDOMNode();if(e){let{ownerDocument:t}=e;(0,o.removeEvent)(t,h.mouse.move,this.handleDrag),(0,o.removeEvent)(t,h.touch.move,this.handleDrag),(0,o.removeEvent)(t,h.mouse.stop,this.handleDragStop),(0,o.removeEvent)(t,h.touch.stop,this.handleDragStop),(0,o.removeEvent)(e,h.touch.start,this.onTouchStart,{passive:!1}),this.props.enableUserSelectHack&&(0,o.scheduleRemoveUserSelectStyles)(t)}}findDOMNode(){return this.props?.nodeRef?this.props?.nodeRef?.current:a.default.findDOMNode(this)}render(){return t.cloneElement(t.Children.only(this.props.children),{onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onTouchEnd:this.onTouchEnd})}};e.default=_,f(_,`displayName`,`DraggableCore`),f(_,`propTypes`,{allowAnyClick:n.default.bool,allowMobileScroll:n.default.bool,children:n.default.node.isRequired,disabled:n.default.bool,enableUserSelectHack:n.default.bool,offsetParent:function(e,t){if(e[t]&&e[t].nodeType!==1)throw Error(`Draggable's offsetParent must be a DOM Node.`)},grid:n.default.arrayOf(n.default.number),handle:n.default.string,cancel:n.default.string,nodeRef:n.default.object,onStart:n.default.func,onDrag:n.default.func,onStop:n.default.func,onMouseDown:n.default.func,scale:n.default.number,className:c.dontSetMe,style:c.dontSetMe,transform:c.dontSetMe}),f(_,`defaultProps`,{allowAnyClick:!1,allowMobileScroll:!1,disabled:!1,enableUserSelectHack:!0,onStart:function(){},onDrag:function(){},onStop:function(){},onMouseDown:function(){},scale:1})})),Gr=n((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),Object.defineProperty(e,`DraggableCore`,{enumerable:!0,get:function(){return u.default}}),e.default=void 0;var t=p(r()),n=f(Rr()),a=f(i()),o=C(),s=Vr(),c=Hr(),l=zr(),u=f(Wr()),d=f(Ur());function f(e){return e&&e.__esModule?e:{default:e}}function p(e,t){if(typeof WeakMap==`function`)var n=new WeakMap,r=new WeakMap;return(p=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 m(){return m=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},m.apply(null,arguments)}function h(e,t,n){return(t=g(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function g(e){var t=_(e,`string`);return typeof t==`symbol`?t:t+``}function _(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 v=class extends t.Component{static getDerivedStateFromProps(e,t){let{position:n}=e,{prevPropsPosition:r}=t;return n&&(!r||n.x!==r.x||n.y!==r.y)?((0,d.default)(`Draggable: getDerivedStateFromProps %j`,{position:n,prevPropsPosition:r}),{x:n.x,y:n.y,prevPropsPosition:{...n}}):null}constructor(e){super(e),h(this,`onDragStart`,(e,t)=>{if((0,d.default)(`Draggable: onDragStart: %j`,t),this.props.onStart(e,(0,c.createDraggableData)(this,t))===!1)return!1;this.setState({dragging:!0,dragged:!0})}),h(this,`onDrag`,(e,t)=>{if(!this.state.dragging)return!1;(0,d.default)(`Draggable: onDrag: %j`,t);let n=(0,c.createDraggableData)(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]=(0,c.getBoundPosition)(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)}),h(this,`onDragStop`,(e,t)=>{if(!this.state.dragging||this.props.onStop(e,(0,c.createDraggableData)(this,t))===!1)return!1;(0,d.default)(`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.")}componentDidMount(){window.SVGElement!==void 0&&this.findDOMNode()instanceof window.SVGElement&&this.setState({isElementSVG:!0})}componentWillUnmount(){this.state.dragging&&this.setState({dragging:!1})}findDOMNode(){return this.props?.nodeRef?.current??a.default.findDOMNode(this)}render(){let{axis:e,bounds:n,children:r,defaultPosition:i,defaultClassName:a,defaultClassNameDragging:l,defaultClassNameDragged:d,position:f,positionOffset:p,scale:h,...g}=this.props,_={},v=null,y=!f||this.state.dragging,b=f||i,x={x:(0,c.canDragX)(this)&&y?this.state.x:b.x,y:(0,c.canDragY)(this)&&y?this.state.y:b.y};this.state.isElementSVG?v=(0,s.createSVGTransform)(x,p):_=(0,s.createCSSTransform)(x,p);let S=(0,o.clsx)(r.props.className||``,a,{[l]:this.state.dragging,[d]:this.state.dragged});return t.createElement(u.default,m({},g,{onStart:this.onDragStart,onDrag:this.onDrag,onStop:this.onDragStop}),t.cloneElement(t.Children.only(r),{className:S,style:{...r.props.style,..._},transform:v}))}};e.default=v,h(v,`displayName`,`Draggable`),h(v,`propTypes`,{...u.default.propTypes,axis:n.default.oneOf([`both`,`x`,`y`,`none`]),bounds:n.default.oneOfType([n.default.shape({left:n.default.number,right:n.default.number,top:n.default.number,bottom:n.default.number}),n.default.string,n.default.oneOf([!1])]),defaultClassName:n.default.string,defaultClassNameDragging:n.default.string,defaultClassNameDragged:n.default.string,defaultPosition:n.default.shape({x:n.default.number,y:n.default.number}),positionOffset:n.default.shape({x:n.default.oneOfType([n.default.number,n.default.string]),y:n.default.oneOfType([n.default.number,n.default.string])}),position:n.default.shape({x:n.default.number,y:n.default.number}),className:l.dontSetMe,style:l.dontSetMe,transform:l.dontSetMe}),h(v,`defaultProps`,{...u.default.defaultProps,axis:`both`,bounds:!1,defaultClassName:`react-draggable`,defaultClassNameDragging:`react-draggable-dragging`,defaultClassNameDragged:`react-draggable-dragged`,defaultPosition:{x:0,y:0},scale:1})})),Kr=n(((e,t)=>{var{default:n,DraggableCore:r}=Gr();t.exports=n,t.exports.default=n,t.exports.DraggableCore=r})),qr=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)}})),Jr=n((e=>{e.__esModule=!0,e.resizableProps=void 0;var t=n(Rr());Kr();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;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;return n.axis===`both`||n.axis===`x`?t.default.number.isRequired(...e):t.default.number(...e)}}})),Yr=n((e=>{e.__esModule=!0,e.default=void 0;var t=s(r()),n=Kr(),i=qr(),a=Jr(),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,r,i=u(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function u(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 d(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 f(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?d(Object(n),!0).forEach(function(t){p(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):d(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function p(e,t,n){return(t=m(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function m(e){var t=h(e,`string`);return typeof t==`symbol`?t:t+``}function h(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 g=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{minConstraints:n,maxConstraints:r,lockAspectRatio:i}=this.props;if(!n&&!r&&!i)return[e,t];if(i){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[a,o]=[e,t],[s,c]=this.slack||[0,0];return e+=s,t+=c,n&&(e=Math.max(n[0],e),t=Math.max(n[1],t)),r&&(e=Math.min(r[0],e),t=Math.min(r[1],t)),this.slack=[s+(a-e),c+(o-t)],[e,t]}resizeHandler(e,t){return(n,r)=>{let{node:i,deltaX:a,deltaY:o}=r;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.props.width+(s?a/this.props.transformScale:0),p=this.props.height+(c?o/this.props.transformScale:0);[f,p]=this.runConstraints(f,p),e===`onResizeStop`&&this.lastSize&&({width:f,height:p}=this.lastSize);let m=f!==this.props.width||p!==this.props.height;e!==`onResizeStop`&&(this.lastSize={width:f,height:p});let h=typeof this.props[e]==`function`?this.props[e]:null;h&&!(e===`onResize`&&!m)&&(n.persist?.(),h(n,{node:i,size:{width:f,height:p},handle:t})),e===`onResizeStop`&&this.resetData()}}renderResizeHandle(e,n){let{handle:r}=this.props;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=f({ref:n},i?{}:{handleAxis:e});return t.cloneElement(r,a)}render(){let e=this.props,{children:r,className:a,draggableOpts:s,width:u,height:d,handle:p,handleSize:m,lockAspectRatio:h,axis:g,minConstraints:_,maxConstraints:v,onResize:y,onResizeStop:b,onResizeStart:x,resizeHandles:S,transformScale:C}=e,w=l(e,o);return(0,i.cloneElement)(r,f(f({},w),{},{className:`${a?`${a} `:``}react-resizable`,children:[...t.Children.toArray(r.props.children),...S.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=g,g.propTypes=a.resizableProps,g.defaultProps={axis:`both`,handleSize:[20,20],lockAspectRatio:!1,minConstraints:[20,20],maxConstraints:[1/0,1/0],resizeHandles:[`se`],transformScale:1}})),Xr=n((e=>{e.__esModule=!0,e.default=void 0;var t=c(r()),n=s(Rr()),i=s(Yr()),a=Jr(),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,r,i=g(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function g(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 _=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{size:n}=t;this.props.onResize?(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,{handle:n,handleSize:r,onResize:a,onResizeStart:s,onResizeStop:c,draggableOpts:u,minConstraints:f,maxConstraints:p,lockAspectRatio:m,axis:g,width:_,height:v,resizeHandles:y,style:b,transformScale:x}=e,S=h(e,o);return t.createElement(i.default,{axis:g,draggableOpts:u,handle:n,handleSize:r,height:this.state.height,lockAspectRatio:m,maxConstraints:p,minConstraints:f,onResizeStart:s,onResize:this.onResize,onResizeStop:c,resizeHandles:y,transformScale:x,width:this.state.width},t.createElement(`div`,l({},S,{style:d(d({},b),{},{width:this.state.width+`px`,height:this.state.height+`px`})})))}};e.default=_,_.propTypes=d(d({},a.resizableProps),{},{children:n.default.element})})),Zr=n(((e,t)=>{t.exports=function(){throw Error(`Don't instantiate Resizable directly! Use require('react-resizable').Resizable`)},t.exports.Resizable=Yr().default,t.exports.ResizableBox=Xr().default})),Qr=Kr(),$r=Zr(),ei=Pr();function ti(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:C,y:w,w:T,h:E,minW:D=1,maxW:O=1/0,minH:k=1,maxH:A=1/0,i:j,resizeHandles:M,resizeHandle:N,constraints:P=Qn,layoutItem:ee,layout:F=[],onDragStart:te,onDrag:ne,onDragStop:I,onResizeStart:L,onResize:R,onResizeStop:re}=e,[z,B]=(0,Q.useState)(!1),[V,H]=(0,Q.useState)(!1),U=(0,Q.useRef)(null),W=(0,Q.useRef)({left:0,top:0}),ie=(0,Q.useRef)({top:0,left:0,width:0,height:0}),G=(0,Q.useRef)(void 0),ae=(0,Q.useRef)(F);ae.current=F;let oe=(0,Q.useRef)(null),se=(0,Q.useRef)(null),ce=(0,Q.useRef)(!1),le=(0,Q.useRef)({x:0,y:0}),K=(0,Q.useRef)(!1),q=(0,Q.useMemo)(()=>({cols:n,containerPadding:a,containerWidth:r,margin:i,maxRows:s,rowHeight:o}),[n,a,r,i,s,o]),ue=(0,Q.useMemo)(()=>({cols:n,maxRows:s,containerWidth:r,containerHeight:0,rowHeight:o,margin:i,layout:[]}),[n,s,r,o,i]),de=(0,Q.useCallback)(()=>({...ue,layout:ae.current}),[ue]),fe=(0,Q.useMemo)(()=>ee??{i:j,x:C,y:w,w:T,h:E,minW:D,maxW:O,minH:k,maxH:A},[ee,j,C,w,T,E,D,O,k,A]),pe=(0,Q.useCallback)(e=>{if(h?.calcStyle)return h.calcStyle(e);if(f)return tr(e);let t=nr(e);return p?{...t,left:rr(e.left/r),width:rr(e.width/r)}:t},[h,f,p,r]),me=(0,Q.useCallback)((e,{node:t})=>{if(!te)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(W.current=l,g>0){let t=e;le.current={x:t.clientX,y:t.clientY},ce.current=!0,K.current=!1,B(!0);return}B(!0);let u=Mn(q,l.top,l.left),{x:d,y:f}=$n(P,fe,u.x,u.y,de());te(j,d,f,{e,node:t,newPosition:l})},[te,m,q,h,g,P,fe,de,j]),he=(0,Q.useCallback)((e,{node:t,deltaX:n,deltaY:a})=>{if(!ne||!z)return;let s=e;if(ce.current&&!K.current){let n=s.clientX-le.current.x,r=s.clientY-le.current.y;if(Math.hypot(n,r)<g)return;if(K.current=!0,ce.current=!1,te){let n=Mn(q,W.current.top,W.current.left),{x:r,y:i}=$n(P,fe,n.x,n.y,de());te(j,r,i,{e,node:t,newPosition:W.current})}}let c=W.current.top+a,l=W.current.left+n;if(u){let{offsetParent:e}=t;if(e){let t=e.clientHeight-kn(E,o,i[1]);c=Pn(c,0,t);let n=r-kn(T,On(q),i[0]);l=Pn(l,0,n)}}let d={top:c,left:l};W.current=d;let f=Mn(q,c,l),{x:p,y:m}=$n(P,fe,f.x,f.y,de());ne(j,p,m,{e,node:t,newPosition:d})},[ne,te,z,g,u,E,o,i,q,r,T,j,P,fe,de]),ge=(0,Q.useCallback)((e,{node:t})=>{if(!I||!z)return;let n=ce.current;if(ce.current=!1,K.current=!1,le.current={x:0,y:0},n){B(!1),W.current={left:0,top:0};return}let{left:r,top:i}=W.current,a={top:i,left:r};B(!1),W.current={left:0,top:0};let o=Mn(q,i,r),{x:s,y:c}=$n(P,fe,o.x,o.y,de());I(j,s,c,{e,node:t,newPosition:a})},[I,z,q,P,fe,de,j]);oe.current=me,se.current=he;let _e=(0,Q.useCallback)((e,{node:t,size:n,handle:i},a,o)=>{let s=o===`onResizeStart`?L:o===`onResize`?R:re;if(!s)return;let c;c=t?pr(i,a,n,r):{...n,top:a.top,left:a.left},ie.current=c;let l=Nn(q,c.width,c.height),{w:u,h:d}=er(P,fe,l.w,l.h,i,de());s(j,u,d,{e:e.nativeEvent,node:t,size:c,handle:i})},[L,R,re,r,q,j,P,fe,de]),ve=(0,Q.useCallback)((e,t)=>{H(!0);let n=An(q,C,w,T,E);_e(e,{...t,handle:t.handle},n,`onResizeStart`)},[_e,q,C,w,T,E]),ye=(0,Q.useCallback)((e,t)=>{let n=An(q,C,w,T,E);_e(e,{...t,handle:t.handle},n,`onResize`)},[_e,q,C,w,T,E]),be=(0,Q.useCallback)((e,t)=>{H(!1),ie.current={top:0,left:0,width:0,height:0};let n=An(q,C,w,T,E);_e(e,{...t,handle:t.handle},n,`onResizeStop`)},[_e,q,C,w,T,E]);(0,Q.useEffect)(()=>{if(!_)return;let e=U.current;if(!e)return;let t=G.current||{left:0,top:0},n=z&&(_.left!==t.left||_.top!==t.top);if(!z){let t={node:e,deltaX:_.left,deltaY:_.top,lastX:0,lastY:0,x:_.left,y:_.top};oe.current?.(_.e,t)}else if(n){let t={node:e,deltaX:_.left-W.current.left,deltaY:_.top-W.current.top,lastX:W.current.left,lastY:W.current.top,x:_.left,y:_.top};se.current?.(_.e,t)}G.current=_},[_,z,j]);let xe=An(q,C,w,T,E,z?W.current:null,V?ie.current:null),Se=Q.Children.only(t),Ce=On(q),we=[kn(D,Ce,i[0]),kn(k,o,i[1])],Te=[kn(O,Ce,i[0]),kn(A,o,i[1])],J=Se.props,Ee=J.className,Y=J.style,De=Q.cloneElement(Se,{ref:U,className:S(`react-grid-item`,Ee,v,{static:d,resizing:V,"react-draggable":c,"react-draggable-dragging":z,dropping:!!_,cssTransforms:f}),style:{...y,...Y,...pe(xe)}}),Oe=N;return De=(0,$.jsx)($r.Resizable,{draggableOpts:{disabled:!l},className:l?void 0:`react-resizable-hide`,width:xe.width,height:xe.height,minConstraints:we,maxConstraints:Te,onResizeStart:ve,onResize:ye,onResizeStop:be,transformScale:m,resizeHandles:M,handle:Oe,children:De}),De=(0,$.jsx)(Qr.DraggableCore,{disabled:!c,onStart:me,onDrag:he,onStop:ge,handle:b,cancel:`.react-resizable-handle`+(x?`,`+x:``),scale:m,nodeRef:U,children:De}),De}var ni=()=>{},ri=`react-grid-layout`,ii=!1;try{ii=/firefox/i.test(navigator.userAgent)}catch{}function ai(e,t){let n=Q.Children.toArray(e),r=Q.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 oi(e,t,n,r){let i=[],a=new Set;Q.Children.forEach(t,t=>{if(!Q.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(Wn(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:Vn(i),w:1,h:1})}});let o=Jn(i,{cols:n});return r.compact(o,n)}function si(e){let{children:t,width:n,gridConfig:r,dragConfig:i,resizeConfig:a,dropConfig:o,positionStrategy:s=mr,compactor:c,constraints:l=Qn,layout:u=[],droppingItem:d,autoSize:f=!0,className:p=``,style:m={},innerRef:h,onLayoutChange:g=ni,onDragStart:_=ni,onDrag:v=ni,onDragStop:y=ni,onResizeStart:b=ni,onResize:x=ni,onResizeStop:C=ni,onDrop:w=ni,onDropDragOver:T=ni}=e,E=(0,Q.useMemo)(()=>({...hr,...r}),[r]),D=(0,Q.useMemo)(()=>({...gr,...i}),[i]),O=(0,Q.useMemo)(()=>({..._r,...a}),[a]),k=(0,Q.useMemo)(()=>({...vr,...o}),[o]),{cols:A,rowHeight:j,maxRows:M,margin:N,containerPadding:P}=E,{enabled:ee,bounded:F,handle:te,cancel:ne,threshold:I}=D,{enabled:L,handles:R,handleComponent:re}=O,{enabled:z,defaultItem:B,onDragOver:V}=k,H=c??Or(`vertical`),U=H.type,W=H.allowOverlap,ie=H.preventCollision??!1,G=(0,Q.useMemo)(()=>d??{i:`__dropping-elem__`,...B},[d,B]),ae=s.type===`transform`,oe=s.scale,se=P??N,[ce,le]=(0,Q.useState)(!1),[K,q]=(0,Q.useState)(()=>oi(u,t,A,H)),[ue,de]=(0,Q.useState)(null),[fe,pe]=(0,Q.useState)(!1),[me,he]=(0,Q.useState)(null),[ge,_e]=(0,Q.useState)(),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),be=(0,Q.useRef)(null),xe=(0,Q.useRef)(0),Se=(0,Q.useRef)(K),Ce=(0,Q.useRef)(u),we=(0,Q.useRef)(t),Te=(0,Q.useRef)(U),J=(0,Q.useRef)(K);J.current=K,(0,Q.useEffect)(()=>{le(!0),(0,ei.deepEqual)(K,u)||g(K)},[]),(0,Q.useEffect)(()=>{if(ue||me)return;let e=!(0,ei.deepEqual)(u,Ce.current),n=!ai(t,we.current),r=U!==Te.current;if(e||n||r){let n=oi(e?u:K,t,A,H);(0,ei.deepEqual)(n,K)||q(n)}Ce.current=u,we.current=t,Te.current=U},[u,t,A,U,H,ue,me,K]),(0,Q.useEffect)(()=>{!ue&&!(0,ei.deepEqual)(K,Se.current)&&(Se.current=K,g(K.filter(e=>e.i!==G.i)))},[K,ue,g,G.i]);let Ee=(0,Q.useMemo)(()=>{if(!f)return;let e=Vn(K),t=se[1];return e*j+(e-1)*N[1]+t*2+`px`},[f,K,j,N,se]),Y=(0,Q.useCallback)((e,t,n,r)=>{let i=J.current,a=Hn(i,e);if(!a)return;let o={w:a.w,h:a.h,x:a.x,y:a.y,i:e};ve.current=Wn(a),be.current=i,de(o),_(i,a,a,null,r.e,r.node)},[_]),De=(0,Q.useCallback)((e,t,n,r)=>{let i=J.current,a=ve.current,o=Hn(i,e);if(!o)return;let s={w:o.w,h:o.h,x:o.x,y:o.y,i:e},c=Yn(i,o,t,n,!0,ie,U,A,W);v(c,a,o,s,r.e,r.node),q(H.compact(c,A)),de(s)},[ie,U,A,W,H,v]),Oe=(0,Q.useCallback)((e,t,n,r)=>{if(!ue)return;let i=J.current,a=ve.current,o=Hn(i,e);if(!o)return;let s=Yn(i,o,t,n,!0,ie,U,A,W),c=H.compact(s,A);y(c,a,o,null,r.e,r.node);let l=be.current;ve.current=null,be.current=null,de(null),q(c),l&&!(0,ei.deepEqual)(l,c)&&g(c)},[ue,ie,U,A,W,H,y,g]),X=(0,Q.useCallback)((e,t,n,r)=>{let i=J.current,a=Hn(i,e);a&&(ye.current=Wn(a),be.current=i,pe(!0),b(i,a,a,null,r.e,r.node))},[b]),ke=(0,Q.useCallback)((e,t,n,r)=>{let i=J.current,a=ye.current,{handle:o}=r,s=!1,c,l,[u,d]=qn(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),ie&&!W&&Ln(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=Yn(u,d,c,l,!0,ie,U,A,W));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),q(H.compact(f,A)),de(p)},[ie,U,A,W,H,x]),Ae=(0,Q.useCallback)((e,t,n,r)=>{let i=J.current,a=ye.current,o=Hn(i,e),s=H.compact(i,A);C(s,a,o??null,null,r.e,r.node);let c=be.current;ye.current=null,be.current=null,de(null),pe(!1),q(s),c&&!(0,ei.deepEqual)(c,s)&&g(s)},[A,H,C,g]),je=(0,Q.useCallback)(()=>{let e=J.current;if(!e.some(e=>e.i===G.i)){he(null),de(null),_e(void 0);return}q(H.compact(e.filter(e=>e.i!==G.i),A)),he(null),de(null),_e(void 0)},[G.i,A,H]),Me=(0,Q.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),ii&&!e.nativeEvent.target?.classList.contains(ri))return!1;let t=V?V(e.nativeEvent):T(e);if(t===!1)return me&&je(),!1;let{dragOffsetX:r=0,dragOffsetY:i=0,...a}=t??{},o={...G,...a},s=e.currentTarget.getBoundingClientRect(),c={cols:A,margin:N,maxRows:M,rowHeight:j,containerWidth:n,containerPadding:se},l=On(c),u=kn(o.w,l,N[0]),d=kn(o.h,j,N[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/oe,top:_/oe,e:e.nativeEvent};if(me)ge&&(ge.left!==v.left||ge.top!==v.top)&&_e(v);else{let e=jn(c,_,g,o.w,o.h);he((0,$.jsx)(`div`,{},o.i)),_e(v),q([...J.current.filter(e=>e.i!==o.i),{...o,x:e.x,y:e.y,static:!1,isDraggable:!0}])}},[me,ge,G,V,T,je,oe,A,N,M,j,n,se]),Ne=(0,Q.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),xe.current--,xe.current<0&&(xe.current=0),xe.current===0&&je()},[je]),Pe=(0,Q.useCallback)(e=>{e.preventDefault(),e.stopPropagation(),xe.current++},[]),Fe=(0,Q.useCallback)(e=>{e.preventDefault(),e.stopPropagation();let t=J.current,n=t.find(e=>e.i===G.i);xe.current=0,je(),w(t,n,e.nativeEvent)},[G.i,je,w]),Ie=(0,Q.useCallback)((e,t)=>{if(!e||!e.key)return null;let r=Hn(K,String(e.key));if(!r)return null;let i=typeof r.isDraggable==`boolean`?r.isDraggable:!r.static&&ee,a=typeof r.isResizable==`boolean`?r.isResizable:!r.static&&L,o=r.resizeHandles||[...R],c=i&&F&&r.isBounded!==!1,u=re;return(0,$.jsx)(ti,{containerWidth:n,cols:A,margin:N,containerPadding:se,maxRows:M,rowHeight:j,cancel:ne,handle:te,onDragStart:Y,onDrag:De,onDragStop:Oe,onResizeStart:X,onResize:ke,onResizeStop:Ae,isDraggable:i,isResizable:a,isBounded:c,useCSSTransforms:ae&&ce,usePercentages:!ce,transformScale:oe,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?ge:void 0,resizeHandles:o,resizeHandle:u,constraints:l,layoutItem:r,layout:K,children:e},r.i)},[K,n,A,N,se,M,j,ne,te,Y,De,Oe,X,ke,Ae,ee,L,F,ae,ce,oe,s,I,ge,R,re,l]),Le=()=>ue?(0,$.jsx)(ti,{w:ue.w,h:ue.h,x:ue.x,y:ue.y,i:ue.i,className:`react-grid-placeholder ${fe?`placeholder-resizing`:``}`,containerWidth:n,cols:A,margin:N,containerPadding:se,maxRows:M,rowHeight:j,isDraggable:!1,isResizable:!1,isBounded:!1,useCSSTransforms:ae,transformScale:oe,constraints:l,layout:K,children:(0,$.jsx)(`div`,{})}):null;return(0,$.jsxs)(`div`,{ref:h,className:S(ri,p),style:{height:Ee,...m},onDrop:z?Fe:void 0,onDragLeave:z?Ne:void 0,onDragEnter:z?Pe:void 0,onDragOver:z?Me:void 0,children:[Q.Children.map(t,e=>Q.isValidElement(e)?Ie(e):null),z&&me&&Ie(me,!0),Le()]})}var ci={lg:1200,md:996,sm:768,xs:480,xxs:0},li={lg:12,md:10,sm:6,xs:4,xxs:2},ui=()=>{};function di(e,t,n,r){let i=[];Q.Children.forEach(t,t=>{if(!Q.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:Vn(i),w:1,h:1})}});let a=Jn(i,{cols:n});return r.compact(a,n)}function fi(e){let{children:t,width:n,breakpoint:r,breakpoints:i=ci,cols:a=li,layouts:o={},rowHeight:s=150,maxRows:c=1/0,margin:l=[10,10],containerPadding:u=null,compactor:d,onBreakpointChange:f=ui,onLayoutChange:p=ui,onWidthChange:m=ui,...h}=e,g=d??Or(`vertical`),_=g.type,v=g.allowOverlap,y=(0,Q.useMemo)(()=>r??Ar(i,n),[]),b=(0,Q.useMemo)(()=>jr(y,a),[y,a]),x=(0,Q.useMemo)(()=>Mr(o,i,y,y,b,_),[]),[S,C]=(0,Q.useState)(y),[w,T]=(0,Q.useState)(b),[E,D]=(0,Q.useState)(x),[O,k]=(0,Q.useState)(o),A=(0,Q.useRef)(n),j=(0,Q.useRef)(r),M=(0,Q.useRef)(i),N=(0,Q.useRef)(a),P=(0,Q.useRef)(o),ee=(0,Q.useRef)(_),F=(0,Q.useRef)(O);(0,Q.useEffect)(()=>{F.current=O},[O]);let te=(0,Q.useMemo)(()=>(0,ei.deepEqual)(o,P.current)?null:Mr(o,i,S,S,w,g),[o,i,S,w,g]),ne=te??E;(0,Q.useEffect)(()=>{te!==null&&(D(te),k(o),F.current=o,P.current=o)},[te,o]),(0,Q.useEffect)(()=>{if(_!==ee.current){let e=g.compact(Gn(ne),w),t={...F.current,[S]:e};D(e),k(t),F.current=t,p(e,t),ee.current=_}},[_,g,ne,w,v,S,p]),(0,Q.useEffect)(()=>{let e=n!==A.current,o=r!==j.current,s=!(0,ei.deepEqual)(i,M.current),c=!(0,ei.deepEqual)(a,N.current);if(e||o||s||c){let e=r??Ar(i,n),o=jr(e,a),d=S;if(d!==e||s||c){let n={...F.current};n[d]||(n[d]=Gn(E));let r=Mr(n,i,e,d,o,g);r=di(r,t,o,g),n[e]=r,C(e),T(o),D(r),k(n),F.current=n,f(e,o),p(r,n)}m(n,Nr(l,e),o,u?Nr(u,e):null),A.current=n,j.current=r,M.current=i,N.current=a}},[n,r,i,a,S,w,E,t,g,_,v,l,u,f,p,m]);let I=(0,Q.useCallback)(e=>{let t={...F.current,[S]:e};D(e),k(t),F.current=t,p(e,t)},[S,p]),L=(0,Q.useMemo)(()=>Nr(l,S),[l,S]),R=(0,Q.useMemo)(()=>u===null?null:Nr(u,S),[u,S]),re=(0,Q.useMemo)(()=>({cols:w,rowHeight:s,maxRows:c,margin:L,containerPadding:R}),[w,s,c,L,R]);return(0,$.jsx)(si,{...h,width:n,gridConfig:re,compactor:g,onLayoutChange:I,layout:ne,children:t})}function pi({editMode:e}){let t=h();return Q.useEffect(()=>{if(e)return t.startDrag({id:`dashboard-layout`,type:`dashboard-widget`,data:{}}),()=>{t.endDrag()};t.endDrag(`dashboard`)},[e,t]),null}var mi=[`hsl(var(--chart-1))`,`hsl(var(--chart-2))`,`hsl(var(--chart-3))`,`hsl(var(--chart-4))`,`hsl(var(--chart-5))`],hi=({schema:e,className:t,onLayoutChange:n,persistLayoutKey:r=`dashboard-layout`,onRefresh:i})=>{let{width:a,containerRef:o,mounted:c}=Fr(),[l,u]=Q.useState(!1),[d,p]=Q.useState(!1),m=f(),h=Q.useRef(null),g=Q.useCallback(()=>{i&&(p(!0),i(),setTimeout(()=>p(!1),600))},[i]);Q.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]=Q.useState(()=>{if(typeof window<`u`&&r){let e=localStorage.getItem(r);if(e)try{return JSON.parse(e)}catch(e){console.error(`Failed to parse saved layout:`,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}))||[]}}),y=Q.useCallback((e,t)=>{v(t),n?.(e)},[n]),b=Q.useCallback(()=>{typeof window<`u`&&r&&localStorage.setItem(r,JSON.stringify(_)),u(!1)},[_,r]),x=Q.useCallback(()=>{v({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}))||[]}),typeof window<`u`&&r&&localStorage.removeItem(r)},[e.widgets,r]),S=Q.useCallback(e=>{if(e.component)return e.component;let t=e.type,n=e.options||{};if(t===`bar`||t===`line`||t===`area`||t===`pie`||t===`donut`||t===`scatter`){let r=e.data||n.data,i=e.categoryField||n.xField||`name`,a=e.valueField||n.yField||`value`;if(Cn(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:mi,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:mi,className:`h-full`}}return{type:`chart`,chartType:t,data:Array.isArray(r)?r:r?.items||[],xAxisKey:i,series:[{dataKey:a}],colors:mi,className:`h-full`}}if(t===`table`){let t=e.data||n.data;if(Cn(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(Cn(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,$.jsxs)(`div`,{ref:o,className:B(`w-full`,t),"data-testid":`grid-layout`,children:[m&&(0,$.jsx)(pi,{editMode:l}),(0,$.jsxs)(`div`,{className:`mb-4 flex items-center justify-between`,children:[(0,$.jsx)(`h2`,{className:`text-2xl font-bold`,children:e.title||`Dashboard`}),(0,$.jsx)(`div`,{className:`flex gap-2`,children:l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Z,{onClick:b,size:`sm`,variant:`default`,children:[(0,$.jsx)(Oe,{className:`h-4 w-4 mr-2`}),`Save Layout`]}),(0,$.jsxs)(Z,{onClick:x,size:`sm`,variant:`outline`,children:[(0,$.jsx)(ae,{className:`h-4 w-4 mr-2`}),`Reset`]}),(0,$.jsx)(Z,{onClick:()=>u(!1),size:`sm`,variant:`ghost`,children:`Cancel`})]}):(0,$.jsxs)($.Fragment,{children:[i&&(0,$.jsxs)(Z,{onClick:g,size:`sm`,variant:`outline`,disabled:d,"aria-label":`Refresh dashboard`,children:[(0,$.jsx)(Ue,{className:B(`h-4 w-4 mr-2`,d&&`animate-spin`)}),d?`Refreshing…`:`Refresh All`]}),(0,$.jsxs)(Z,{onClick:()=>u(!0),size:`sm`,variant:`outline`,children:[(0,$.jsx)(me,{className:`h-4 w-4 mr-2`}),`Edit Layout`]})]})})]}),c&&(0,$.jsx)(fi,{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:l,handle:`.drag-handle`},resizeConfig:{enabled:l},onLayoutChange:y,children:e.widgets?.map((e,t)=>{let n=e.id||`widget-${t}`,r=S(e);return(0,$.jsx)(`div`,{className:`h-full`,children:e.type===`metric`?(0,$.jsxs)(`div`,{className:`h-full w-full relative`,children:[l&&(0,$.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,$.jsx)(F,{className:`h-4 w-4`})}),(0,$.jsx)(s,{schema:r,className:`h-full w-full`})]}):(0,$.jsxs)(E,{className:B(`h-full overflow-hidden border-border/50 shadow-sm transition-all`,`bg-card/50 backdrop-blur-sm`,l&&`ring-2 ring-primary/20`),children:[e.title&&(0,$.jsxs)(He,{className:`pb-2 border-b border-border/40 bg-muted/20 flex flex-row items-center justify-between`,children:[(0,$.jsx)(Xe,{className:`text-base font-medium tracking-tight truncate`,title:e.title,children:e.title}),l&&(0,$.jsx)(`div`,{className:`drag-handle cursor-move p-1 hover:bg-muted/40 rounded`,children:(0,$.jsx)(F,{className:`h-4 w-4`})})]}),(0,$.jsx)(Y,{className:`p-0 h-full`,children:(0,$.jsx)(`div`,{className:B(`h-full w-full overflow-auto p-4`),children:(0,$.jsx)(s,{schema:r})})})]})},n)})})]})};function gi(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var _i={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`},vi=({label:e,value:t,trend:n,icon:r,className:i,description:a,loading:o,error:s,colorVariant:c=`default`,...l})=>{let u=_i[c]||_i.default,d=(0,Q.useMemo)(()=>{if(typeof r==`string`){let e=fe(r);return e?(0,$.jsx)(e,{className:`h-4 w-4`}):null}return r},[r]);return(0,$.jsxs)(E,{className:B(`h-full overflow-hidden`,i),...l,children:[(0,$.jsxs)(He,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,$.jsx)(Xe,{className:`text-sm font-medium truncate`,children:gi(e)}),d&&(0,$.jsx)(`div`,{className:B(`flex h-8 w-8 items-center justify-center rounded-md shrink-0`,u),children:d})]}),(0,$.jsx)(Y,{children:o?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-loading`,children:[(0,$.jsx)(M,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-error`,role:`alert`,children:[(0,$.jsx)(I,{className:`h-4 w-4 text-destructive shrink-0`}),(0,$.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:s})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`text-2xl font-bold truncate`,children:t}),(n||a)&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center mt-1 truncate`,children:[n&&(0,$.jsxs)(`span`,{className:B(`flex items-center mr-2 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,$.jsx)(D,{className:`h-3 w-3 mr-1`}),n.direction===`down`&&(0,$.jsx)(De,{className:`h-3 w-3 mr-1`}),n.direction===`neutral`&&(0,$.jsx)(A,{className:`h-3 w-3 mr-1`}),n.value,`%`]}),(0,$.jsx)(`span`,{className:`truncate`,children:gi(a)||gi(n?.label)})]})]})})]})};function yi(e){if(e!=null)return typeof e==`string`?e:e.defaultValue||e.key}var bi=({title:e,value:t,icon:n,trend:r,trendValue:i,description:a,className:o,loading:s,error:c,...l})=>{let u=n?fe(n):null;return(0,$.jsxs)(E,{className:B(`h-full`,o),...l,children:[(0,$.jsxs)(He,{className:`flex flex-row items-center justify-between space-y-0 pb-2`,children:[(0,$.jsx)(Xe,{className:`text-sm font-medium`,children:yi(e)}),u&&(0,$.jsx)(u,{className:`h-4 w-4 text-muted-foreground`})]}),(0,$.jsx)(Y,{children:s?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-muted-foreground`,"data-testid":`metric-card-loading`,children:[(0,$.jsx)(M,{className:`h-4 w-4 animate-spin`}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Loading…`})]}):c?(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,"data-testid":`metric-card-error`,role:`alert`,children:[(0,$.jsx)(I,{className:`h-4 w-4 text-destructive shrink-0`}),(0,$.jsx)(`span`,{className:`text-xs text-destructive truncate`,children:c})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`text-2xl font-bold`,children:t}),(r||i||a)&&(0,$.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center mt-1`,children:[r&&i&&(0,$.jsxs)(`span`,{className:B(`flex items-center mr-2`,r===`up`&&`text-green-500`,r===`down`&&`text-red-500`,r===`neutral`&&`text-yellow-500`),children:[r===`up`&&(0,$.jsx)(D,{className:`h-3 w-3 mr-1`}),r===`down`&&(0,$.jsx)(De,{className:`h-3 w-3 mr-1`}),r===`neutral`&&(0,$.jsx)(A,{className:`h-3 w-3 mr-1`}),i]}),yi(a)]})]})})]})},xi=({objectName:e,aggregate:t,filter:n,label:r,fallbackValue:i,trend:a,icon:o,className:s,description:c,dataSource:l,colorVariant:u})=>{let d=(0,Q.useContext)(m),f=l||d?.dataSource,[p,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=(0,Q.useCallback)(async(r,i)=>{if(!(!r||!e)){i.current&&(_(!0),y(null));try{let a;if(t&&typeof r.aggregate==`function`){let i=await r.aggregate(e,{field:t.field,function:t.function,groupBy:t.groupBy||`_all`,filter:n}),o=Array.isArray(i)?i:[];a=o.length===0?0:t.function===`count`?o.reduce((e,n)=>e+(Number(n[t.field])||Number(n.count)||0),0):o[0][t.field]??0}else if(typeof r.find==`function`){let t=await r.find(e,{$filter:n});a=(Array.isArray(t)?t:t?.data||t?.records||[]).length}else return;i.current&&h(a)}catch(e){console.error(`[ObjectMetricWidget] Fetch error:`,e),i.current&&y(e instanceof Error?e.message:`Failed to load metric`)}finally{i.current&&_(!1)}}},[e,(0,Q.useMemo)(()=>t?JSON.stringify(t):``,[t]),(0,Q.useMemo)(()=>n?JSON.stringify(n):``,[n])]);return(0,Q.useEffect)(()=>{let t={current:!0};return f&&e?b(f,t):(h(null),y(null)),()=>{t.current=!1}},[f,e,b]),(0,$.jsx)(vi,{label:r,value:p===null?f?`—`:i??`—`:p,trend:a,icon:o,className:s,description:c,loading:g,error:v,colorVariant:u})};function Si(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}function Ci(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 wi=({schema:e,className:t})=>{let{title:n,rowField:r,columnField:i,valueField:a,aggregation:o=`sum`,data:s=[],showRowTotals:c=!1,showColumnTotals:l=!1,format:u,columnColors:d}=e,f=Array.isArray(s)?s:[],{rowKeys:p,colKeys:m,matrix:h,rowTotals:g,colTotals:_,grandTotal:v}=(0,Q.useMemo)(()=>{let e=new Map,t=new Map,n={};for(let o of f){let s=String(o[r]??``),c=String(o[i]??``),l=Number(o[a])||0;e.set(s,!0),t.set(c,!0),n[s]||(n[s]={}),n[s][c]||(n[s][c]=[]),n[s][c].push(l)}let s=Array.from(e.keys()),c=Array.from(t.keys()),l={},u={},d={};for(let e of s){l[e]={};let t=[];for(let r of c){let i=n[e]?.[r]??[],a=Ci(i,o);l[e][r]=a,t.push(...i),!d[r]&&d[r]}u[e]=Ci(t,o)}for(let e of c){let t=[];for(let r of s){let i=n[r]?.[e]??[];t.push(...i)}d[e]=Ci(t,o)}let p=[];for(let e of f)p.push(Number(e[a])||0);return{rowKeys:s,colKeys:c,matrix:l,rowTotals:u,colTotals:d,grandTotal:Ci(p,o)}},[f,r,i,a,o]),y=e=>Si(e,u);return f.length===0?(0,$.jsxs)(`div`,{className:B(`overflow-auto`,t),children:[n&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:n}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,"data-testid":`pivot-empty-state`,children:[(0,$.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,$.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`}),(0,$.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`}),(0,$.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`}),(0,$.jsx)(`rect`,{x:`14`,y:`14`,width:`7`,height:`7`})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:`No data available`})]})]}):(0,$.jsxs)(`div`,{className:B(`overflow-auto`,t),children:[n&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:n}),(0,$.jsxs)(`table`,{className:`w-full text-sm border-collapse`,role:`table`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{className:`border-b border-border`,children:[(0,$.jsx)(`th`,{className:`text-left p-2 font-medium text-muted-foreground`,children:r}),m.map(e=>(0,$.jsx)(`th`,{className:B(`text-right p-2 font-medium`,d?.[e]??`text-muted-foreground`),children:e},e)),c&&(0,$.jsx)(`th`,{className:`text-right p-2 font-semibold text-muted-foreground bg-muted/20`,children:`Total`})]})}),(0,$.jsx)(`tbody`,{children:p.map(e=>(0,$.jsxs)(`tr`,{className:`border-b border-border/50 hover:bg-muted/30`,children:[(0,$.jsx)(`td`,{className:`p-2 font-medium`,children:e}),m.map(t=>(0,$.jsx)(`td`,{className:B(`text-right p-2 tabular-nums`,d?.[t]),children:y(h[e]?.[t]??0)},t)),c&&(0,$.jsx)(`td`,{className:`text-right p-2 font-semibold tabular-nums bg-muted/20`,children:y(g[e]??0)})]},e))}),l&&(0,$.jsx)(`tfoot`,{children:(0,$.jsxs)(`tr`,{className:`border-t-2 border-border font-semibold bg-muted/40`,children:[(0,$.jsx)(`td`,{className:`p-2`,children:`Total`}),m.map(e=>(0,$.jsx)(`td`,{className:`text-right p-2 tabular-nums`,children:y(_[e]??0)},e)),c&&(0,$.jsx)(`td`,{className:`text-right p-2 tabular-nums font-bold`,children:y(v)})]})})]})]})},Ti=({schema:e,dataSource:t,className:n})=>{let r=(0,Q.useContext)(m),i=t||r?.dataSource,a=p(e.bind),[o,s]=(0,Q.useState)([]),[c,l]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let t=!0;return e.objectName&&!a&&(!e.data||e.data.length===0)&&(async()=>{if(!(!i||!e.objectName)){t&&(l(!0),f(null));try{let n;if(typeof i.find==`function`)n=u(await i.find(e.objectName,{$filter:e.filter}));else return;t&&s(n)}catch(e){console.error(`[ObjectPivotTable] Fetch error:`,e),t&&f(e instanceof Error?e.message:`Failed to load data`)}finally{t&&l(!1)}}})(),()=>{t=!1}},[e.objectName,i,a,e.data,e.filter]);let h=a||e.data||o,g=Array.isArray(h)?h:[];return c&&g.length===0?(0,$.jsxs)(`div`,{className:B(`overflow-auto`,n),"data-testid":`pivot-loading`,children:[e.title&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,$.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{className:`h-6 w-24`}),(0,$.jsx)(G,{className:`h-6 w-20`}),(0,$.jsx)(G,{className:`h-6 w-20`}),(0,$.jsx)(G,{className:`h-6 w-20`})]}),[1,2,3].map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{className:`h-5 w-24`}),(0,$.jsx)(G,{className:`h-5 w-20`}),(0,$.jsx)(G,{className:`h-5 w-20`}),(0,$.jsx)(G,{className:`h-5 w-20`})]},e))]})]}):d?(0,$.jsxs)(`div`,{className:B(`overflow-auto`,n),"data-testid":`pivot-error`,children:[e.title&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`pivot-error-message`,children:[(0,$.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,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,$.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,$.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:d})]})]}):!i&&e.objectName&&g.length===0?(0,$.jsxs)(`div`,{className:B(`overflow-auto`,n),children:[e.title&&(0,$.jsx)(`h3`,{className:`text-sm font-semibold mb-2`,children:e.title}),(0,$.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,$.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})]}):(0,$.jsx)(wi,{schema:{...e,data:g},className:n})};function Ei(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)}var Di=({schema:e,dataSource:t,className:n})=>{let r=(0,Q.useContext)(m),i=t||r?.dataSource,a=p(e.bind),{fieldLabel:o,fieldOptionLabel:c}=x(),[l,d]=(0,Q.useState)([]),[f,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let t=!0;return e.objectName&&!a&&(!e.data||e.data.length===0)&&(async()=>{if(!(!i||!e.objectName)){t&&(_(!0),y(null));try{let n;if(typeof i.find==`function`)n=u(await i.find(e.objectName,{$filter:e.filter}));else return;t&&d(n)}catch(e){console.error(`[ObjectDataTable] Fetch error:`,e),t&&y(e instanceof Error?e.message:`Failed to load data`)}finally{t&&_(!1)}}})(),()=>{t=!1}},[e.objectName,i,a,e.data,e.filter]),(0,Q.useEffect)(()=>{let t=!0;if(!(!i||!e.objectName||typeof i.getObjectSchema!=`function`))return i.getObjectSchema(e.objectName).then(e=>{t&&h(e)}).catch(()=>{}),()=>{t=!1}},[e.objectName,i]);let b=a||e.data||l,S=Array.isArray(b)?b:[],C=(0,Q.useMemo)(()=>{let t=e.objectName,n=e=>{let n=e.charAt(0).toUpperCase()+e.slice(1).replace(/([A-Z])/g,` $1`);return t?o(t,e,n):n};if(e.columns&&e.columns.length>0){let n=Ei(e.columns);return t?n.map(e=>({...e,header:o(t,e.accessorKey,e.header)})):n}return S.length===0?[]:Object.keys(S[0]).filter(e=>!e.startsWith(`_`)).map(e=>({header:n(e),accessorKey:e}))},[e.columns,e.objectName,S,o]),w=(0,Q.useMemo)(()=>{let t=e.objectName;if(!t||!f?.fields||S.length===0)return S;let n={};for(let e of C){let t=f.fields[e.accessorKey];if(!t)continue;let r=t.type;if(r!==`select`&&r!==`picklist`&&r!==`dropdown`)continue;let i=t.options||[],a={};for(let e of i)typeof e==`string`?a[e]=e:e&&typeof e==`object`&&(a[String(e.value)]=e.label||String(e.value));n[e.accessorKey]=a}return Object.keys(n).length===0?S:S.map(e=>{let r={...e};for(let[i,a]of Object.entries(n)){let n=e[i];if(n==null||n===``)continue;let o=String(n);r[i]=c(t,i,o,a[o]||o)}return r})},[S,C,f,e.objectName,c]);return g&&S.length===0?(0,$.jsx)(`div`,{className:B(`overflow-auto`,n),"data-testid":`table-loading`,children:(0,$.jsxs)(`div`,{className:`space-y-2 p-2`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{className:`h-6 w-1/4`}),(0,$.jsx)(G,{className:`h-6 w-1/4`}),(0,$.jsx)(G,{className:`h-6 w-1/4`}),(0,$.jsx)(G,{className:`h-6 w-1/4`})]}),[1,2,3,4].map(e=>(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(G,{className:`h-5 w-1/4`}),(0,$.jsx)(G,{className:`h-5 w-1/4`}),(0,$.jsx)(G,{className:`h-5 w-1/4`}),(0,$.jsx)(G,{className:`h-5 w-1/4`})]},e))]})}):v?(0,$.jsx)(`div`,{className:B(`overflow-auto`,n),"data-testid":`table-error`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-destructive`,"data-testid":`table-error-message`,children:[(0,$.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,$.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,$.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12`,y2:`12`}),(0,$.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12.01`,y2:`16`})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:v})]})}):!i&&e.objectName&&S.length===0?(0,$.jsx)(`div`,{className:B(`overflow-auto`,n),children:(0,$.jsx)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:(0,$.jsxs)(`p`,{className:`text-xs`,children:[`No data source available for “`,e.objectName,`”`]})})}):S.length===0?(0,$.jsx)(`div`,{className:B(`overflow-auto`,n),"data-testid":`table-empty-state`,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-8 text-muted-foreground`,children:[(0,$.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,$.jsx)(`rect`,{x:`3`,y:`3`,width:`18`,height:`18`,rx:`2`,ry:`2`}),(0,$.jsx)(`line`,{x1:`3`,y1:`9`,x2:`21`,y2:`9`}),(0,$.jsx)(`line`,{x1:`9`,y1:`21`,x2:`9`,y2:`9`})]}),(0,$.jsx)(`p`,{className:`text-xs`,children:`No data available`})]})}):(0,$.jsx)(s,{schema:{...e,type:`data-table`,data:w,columns:C},className:n})},Oi={breadcrumb:[`Dashboard`,`Configuration`],sections:[{key:`layout`,title:`Layout`,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`,type:`input`,defaultValue:`120`,placeholder:`e.g. 120`}]},{key:`data`,title:`Data`,collapsible:!0,fields:[{key:`refreshInterval`,label:`Refresh interval`,type:`select`,defaultValue:`0`,options:[{value:`0`,label:`Manual`},{value:`30`,label:`30s`},{value:`60`,label:`1 min`},{value:`300`,label:`5 min`}]}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Dashboard 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 ki({open:e,onClose:t,config:n,onSave:r,onFieldChange:i}){let{draft:a,isDirty:o,updateField:s,discard:c}=ce(n,{onUpdate:i});return(0,$.jsx)(Te,{open:e,onClose:t,schema:Oi,draft:a,isDirty:o,onFieldChange:s,onSave:()=>r(a),onDiscard:c})}var Ai=[{value:`metric`,label:`Metric`},{value:`bar`,label:`Bar Chart`},{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:`table`,label:`Table`},{value:`pivot`,label:`Pivot Table`},{value:`list`,label:`List`},{value:`custom`,label:`Custom`}],ji=[{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`}],Mi=[{value:`count`,label:`Count`},{value:`sum`,label:`Sum`},{value:`avg`,label:`Average`},{value:`min`,label:`Min`},{value:`max`,label:`Max`}],Ni=[`bar`,`line`,`area`,`pie`,`donut`,`scatter`];function Pi(e){return!!e&&Ni.includes(e)}var Fi=[{value:`group`,label:`Group`},{value:`value`,label:`Value`}],Ii=[{value:`asc`,label:`↑`},{value:`desc`,label:`↓`}];function Li(e,t,n,r){return{key:e,label:t,type:`custom`,render:(i,a,o)=>(0,$.jsx)(Ee,{label:t,children:(0,$.jsx)(`div`,{"data-testid":`config-field-${e}`,children:(0,$.jsx)(ke,{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 Ri(e,t,n){let r=e&&e.length>0,i=r?{key:`object`,label:`Data source`,type:`custom`,render:(t,n)=>(0,$.jsx)(Ee,{label:`Data source`,children:(0,$.jsx)(`div`,{"data-testid":`config-field-object`,children:(0,$.jsx)(ke,{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?Li(`categoryField`,`Category field`,`Select field…`,t):{key:`categoryField`,label:`Category field`,type:`input`,placeholder:`e.g. status`},o=r?Li(`valueField`,`Value field`,`Select field…`,t):{key:`valueField`,label:`Value field`,type:`input`,placeholder:`e.g. amount`},s=r?Li(`rowField`,`Field`,`Select row field…`,t):{key:`rowField`,label:`Field`,type:`input`,placeholder:`e.g. owner`},c=r?Li(`columnField`,`Field`,`Select column field…`,t):{key:`columnField`,label:`Field`,type:`input`,placeholder:`e.g. stage`},l=r?Li(`pivotValueField`,`Field`,`Select value field…`,t):{key:`pivotValueField`,label:`Field`,type:`input`,placeholder:`e.g. amount`};return{breadcrumb:[`Dashboard`,{pivot:`Pivot table`,table:`Table`}[n??``]??(Pi(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:Ai,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:Mi,defaultValue:`count`}]},{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:Fi,defaultValue:`group`},{key:`rowSortOrder`,label:`Sort order`,type:`icon-group`,options:Ii,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:Fi,defaultValue:`group`},{key:`columnSortOrder`,label:`Sort order`,type:`icon-group`,options:Ii,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:Mi,defaultValue:`sum`},{key:`format`,label:`Number format`,type:`input`,placeholder:`e.g. $,.2f`}]},{key:`chart-axis`,title:`Axis & Series`,collapsible:!0,visibleWhen:e=>Pi(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:`table-columns`,title:`Columns`,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:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`colorVariant`,label:`Color variant`,type:`select`,options:ji,defaultValue:`default`},{key:`actionUrl`,label:`Action URL`,type:`input`,placeholder:`https://...`}]}]}}function zi(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 Bi({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}=ce(Q.useMemo(()=>({...n,title:typeof n.title==`object`?zi(n.title):n.title,description:typeof n.description==`object`?zi(n.description):n.description}),[n]),{onUpdate:i});return(0,$.jsx)(Te,{open:e,onClose:t,schema:Q.useMemo(()=>Ri(o,s,c.type),[o,s,c.type]),draft:c,isDirty:l,onFieldChange:u,onSave:()=>r(c),onDiscard:d,headerExtra:a})}c.register(`dashboard`,Dn,{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:[]}}),c.register(`metric`,vi,{namespace:`plugin-dashboard`,label:`Metric Widget`,category:`Dashboard`,inputs:[{name:`label`,type:`string`,label:`Label`},{name:`value`,type:`string`,label:`Value`}]}),c.register(`metric-card`,bi,{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`}}),c.register(`object-metric`,xi,{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`}}),c.register(`pivot`,wi,{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:[]}}),c.register(`object-pivot`,Ti,{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`}}),c.register(`dashboard-grid`,hi,{namespace:`plugin-dashboard`,label:`Dashboard Grid (Editable)`,category:`Complex`,icon:`layout-grid`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`persistLayoutKey`,type:`string`,label:`Layout Storage Key`,defaultValue:`dashboard-layout`},{name:`className`,type:`string`,label:`CSS Class`}],defaultProps:{title:`Dashboard`,widgets:[],persistLayoutKey:`dashboard-layout`}}),c.register(`object-data-table`,Di,{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 Vi=({schema:e})=>{let{title:t,description:n,data:r,columns:i}=e;e.chart?.type;let a=!!e.chart;return(0,$.jsxs)(E,{className:`h-full flex flex-col ${e.className||``}`,children:[(0,$.jsxs)(He,{children:[t&&(0,$.jsx)(Xe,{children:t}),n&&(0,$.jsx)($e,{children:n})]}),(0,$.jsxs)(Y,{className:`flex-1 overflow-auto space-y-4`,children:[a&&(()=>{let t=e.chart?.type,n=t?c.get(t):null;return n||=c.get(`chart`),n?(0,$.jsx)(`div`,{className:`min-h-[300px] border rounded-lg p-4 bg-background/50`,children:(0,$.jsx)(n,{schema:{...e.chart,data:e.chart.data||r}})}):(0,$.jsxs)(`div`,{className:`min-h-[100px] border rounded-md p-4 bg-muted/20 text-muted-foreground flex items-center justify-center`,children:[`Unknown component type: `,t||`chart`]})})(),r&&r.length>0&&(0,$.jsx)(`div`,{className:`border rounded-lg`,children:(()=>{let e=c.get(`aggrid`)||c.get(`table`);return e?(0,$.jsx)(e,{schema:{type:`aggrid`,rowData:r,columnDefs:i,domLayout:`autoHeight`}}):(0,$.jsx)(`div`,{className:`overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm text-left`,children:[(0,$.jsx)(`thead`,{className:`text-xs uppercase bg-muted`,children:(0,$.jsx)(`tr`,{children:i?.map(e=>(0,$.jsx)(`th`,{className:`px-6 py-3`,children:e.headerName||e.label||e.field},e.field))})}),(0,$.jsx)(`tbody`,{children:r.map((e,t)=>(0,$.jsx)(`tr`,{className:`bg-background border-b`,children:i?.map(t=>(0,$.jsx)(`td`,{className:`px-6 py-4`,children:e[t.field]},t.field))},t))})]})})})()})]})]})};function Hi(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=Yi(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
6
|
-
`))?`"${n.replace(/"/g,`""`)}"`:n??``}));Qi([...n?.includeHeaders===!1?[]:[i.join(`,`)],...a.map(e=>e.join(`,`))].join(`
|
|
7
|
-
`),n?.filename||`${e.title||`report`}.csv`,`text/csv`)}function Ui(e,t,n){let r={title:e.title,description:e.description,generatedAt:new Date().toISOString(),data:t};Qi(JSON.stringify(r,null,2),n?.filename||`${e.title||`report`}.json`,`application/json`)}function Wi(e,t,n){let r=e.fields||[],i=Zi(n?.orientation),a=Xi(n?.pageSize);Qi(`<!DOCTYPE html>
|
|
8
|
-
<html>
|
|
9
|
-
<head>
|
|
10
|
-
<meta charset="utf-8">
|
|
11
|
-
<title>${Ji(e.title||`Report`)}</title>
|
|
12
|
-
<style>
|
|
13
|
-
@page { size: ${a} ${i}; margin: 20mm; }
|
|
14
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
15
|
-
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
16
|
-
.description { color: #666; margin-bottom: 24px; }
|
|
17
|
-
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
18
|
-
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
19
|
-
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
20
|
-
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
21
|
-
tr:nth-child(even) { background: #fafafa; }
|
|
22
|
-
</style>
|
|
23
|
-
</head>
|
|
24
|
-
<body>
|
|
25
|
-
<h1>${Ji(e.title||`Report`)}</h1>
|
|
26
|
-
${e.description?`<p class="description">${Ji(e.description)}</p>`:``}
|
|
27
|
-
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
28
|
-
<table>
|
|
29
|
-
<thead><tr>${r.map(e=>`<th>${Ji(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
30
|
-
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${Ji(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
31
|
-
</table>
|
|
32
|
-
</body>
|
|
33
|
-
</html>`,n?.filename||`${e.title||`report`}.html`,`text/html`)}function Gi(e,t,n){let r=e.fields||[],i=Zi(n?.orientation),a=Xi(n?.pageSize),o=window.open(``,`_blank`);if(!o){Wi(e,t,{...n,format:`html`,filename:n?.filename?.replace(/\.pdf$/,`.html`)||`${e.title||`report`}.html`});return}o.document.write(`<!DOCTYPE html>
|
|
34
|
-
<html>
|
|
35
|
-
<head>
|
|
36
|
-
<meta charset="utf-8">
|
|
37
|
-
<title>${Ji(e.title||`Report`)}</title>
|
|
38
|
-
<style>
|
|
39
|
-
@page { size: ${a} ${i}; margin: 20mm; }
|
|
40
|
-
@media print { .no-print { display: none; } }
|
|
41
|
-
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #333; }
|
|
42
|
-
h1 { font-size: 24px; margin-bottom: 8px; }
|
|
43
|
-
.description { color: #666; margin-bottom: 24px; }
|
|
44
|
-
.meta { color: #999; font-size: 12px; margin-bottom: 16px; }
|
|
45
|
-
table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
46
|
-
th { background: #f5f5f5; text-align: left; padding: 8px 12px; border: 1px solid #ddd; font-weight: 600; }
|
|
47
|
-
td { padding: 8px 12px; border: 1px solid #ddd; }
|
|
48
|
-
tr:nth-child(even) { background: #fafafa; }
|
|
49
|
-
</style>
|
|
50
|
-
</head>
|
|
51
|
-
<body>
|
|
52
|
-
<h1>${Ji(e.title||`Report`)}</h1>
|
|
53
|
-
${e.description?`<p class="description">${Ji(e.description)}</p>`:``}
|
|
54
|
-
<p class="meta">Generated: ${new Date().toLocaleString()}</p>
|
|
55
|
-
<table>
|
|
56
|
-
<thead><tr>${r.map(e=>`<th>${Ji(e.label||e.name)}</th>`).join(``)}</tr></thead>
|
|
57
|
-
<tbody>${t.map(e=>`<tr>${r.map(t=>`<td>${Ji(String(e[t.name]??``))}</td>`).join(``)}</tr>`).join(``)}</tbody>
|
|
58
|
-
</table>
|
|
59
|
-
</body>
|
|
60
|
-
</html>`),o.document.close(),o.onload=()=>{o.print()}}function Ki(e,t,n){let r=e.fields||[],i=r.map(e=>e.label||e.name),a=t.map(e=>r.map(t=>{let n=e[t.name];return n=Yi(n),typeof n==`string`&&(n.includes(`,`)||n.includes(`"`)||n.includes(`
|
|
61
|
-
`)||n.includes(` `))?`"${n.replace(/"/g,`""`)}"`:n??``}));Qi(``+[...n?.includeHeaders===!1?[]:[i.join(` `)],...a.map(e=>e.join(` `))].join(`
|
|
62
|
-
`),n?.filename||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function qi(e,t,n,r){switch(e){case`csv`:Hi(t,n,r);break;case`json`:Ui(t,n,r);break;case`html`:Wi(t,n,r);break;case`pdf`:Gi(t,n,r);break;case`excel`:Ki(t,n,r);break;default:console.warn(`Unsupported export format: ${e}`)}}function Ji(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`).replace(/'/g,`'`)}function Yi(e){if(typeof e==`string`&&e.length>0){let t=e.charAt(0);if(t===`=`||t===`+`||t===`-`||t===`@`||t===`|`)return`\t${e}`}return e}function Xi(e){return[`A4`,`A3`,`Letter`,`Legal`].includes(e||``)?e:`A4`}function Zi(e){return e===`landscape`?`landscape`:`portrait`}function Qi(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}function $i(e,t){if(e==null||e===``)return``;let n=t?.type,r=t?.format;if(n===`date`||r===`date`||ea(e))return ta(e);if(n===`number`||typeof e==`number`){let t=typeof e==`number`?e:Number(e);return isNaN(t)?String(e):r===`currency`||r===`currency_cny`?`¥${t.toLocaleString(`en-US`,{minimumFractionDigits:0,maximumFractionDigits:0})}`:r===`currency_usd`?`$${t.toLocaleString(`en-US`,{minimumFractionDigits:0,maximumFractionDigits:0})}`:r===`percent`?`${t.toLocaleString(`en-US`,{minimumFractionDigits:1,maximumFractionDigits:1})}%`:t.toLocaleString(`en-US`)}return String(e)}function ea(e){return typeof e==`string`?/^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}:\d{2})?/.test(e):!1}function ta(e){try{let t=new Date(e);return isNaN(t.getTime())?String(e):`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)}`}catch{return String(e)}}function na(e,t){if(!t||t.length===0||!e||e.length===0)return null;let n=t[0],r=n.field,i=new Map;for(let t of e){let e=String(t[r]??`(empty)`);i.has(e)||i.set(e,[]),i.get(e).push(t)}let a=[];for(let[e,t]of i)a.push({key:e,label:`${n.label||r}: ${e}`,rows:t});let o=n.sort===`desc`?-1:1;return a.sort((e,t)=>e.key.localeCompare(t.key)*o),a}var ra=({schema:e,onRefresh:t})=>{let{report:n,data:r,showToolbar:i=!0,allowExport:a=!0,allowPrint:o=!0,loading:l=!1}=e,u=e=>{if(!n){console.warn(`ReportViewer: Cannot export, no report defined`);return}qi(e,n,r||[],n.exportConfigs?.[e])},d=()=>{window.print()},f=()=>{t?.()},p=(e,t)=>{if(!r)return 0;let n=r.map(t=>Number(t[e])||0);switch(t){case`count`:return r.length;case`sum`:return n.reduce((e,t)=>e+t,0);case`avg`:return n.length>0?(n.reduce((e,t)=>e+t,0)/n.length).toFixed(2):0;case`min`:return n.length>0?Math.min(...n):0;case`max`:return n.length>0?Math.max(...n):0;default:return``}},m=(e,t)=>{let r=n?.conditionalFormatting;if(!(!r||!Array.isArray(r)))for(let n of r){if(n.field!==e)continue;let r=String(t??``),i=String(n.value??``),a=!1;switch(n.operator){case`equals`:a=r===i;break;case`not_equals`:a=r!==i;break;case`contains`:a=r.includes(i);break;case`greater_than`:a=Number(t)>Number(n.value);break;case`less_than`:a=Number(t)<Number(n.value);break}if(a){let e={};return n.backgroundColor&&(e.backgroundColor=n.backgroundColor),n.textColor&&(e.color=n.textColor),e}}},h=(e,t)=>e==null||e===``?``:t.renderAs===`badge`?(0,$.jsx)(ve,{className:t.colorMap?.[String(e)]||``,children:String(e)}):$i(e,t);return n?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[i&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 p-4 bg-card rounded-lg border`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,children:n.title}),n.description&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n.description})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n.refreshInterval&&(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:f,children:[(0,$.jsx)(Ue,{className:`h-4 w-4 mr-2`}),`Refresh`]}),o&&(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:d,children:[(0,$.jsx)(de,{className:`h-4 w-4 mr-2`}),`Print`]}),a&&n.showExportButtons&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:()=>u(`pdf`),children:[(0,$.jsx)(qe,{className:`h-4 w-4 mr-2`}),`PDF`]}),(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:()=>u(`excel`),children:[(0,$.jsx)(qe,{className:`h-4 w-4 mr-2`}),`Excel`]}),(0,$.jsxs)(Z,{variant:`outline`,size:`sm`,onClick:()=>u(`csv`),children:[(0,$.jsx)(qe,{className:`h-4 w-4 mr-2`}),`CSV`]})]})]})]}),(0,$.jsxs)(E,{children:[(0,$.jsxs)(He,{children:[!i&&n.title&&(0,$.jsx)(Xe,{children:n.title}),!i&&n.description&&(0,$.jsx)($e,{children:n.description})]}),(0,$.jsxs)(Y,{className:`space-y-6`,children:[l&&(0,$.jsxs)(`div`,{className:`space-y-6`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[1,2,3].map(e=>(0,$.jsx)(E,{children:(0,$.jsxs)(Y,{className:`p-4 space-y-2`,children:[(0,$.jsx)(G,{className:`h-4 w-20`}),(0,$.jsx)(G,{className:`h-8 w-28`})]})},e))}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(G,{className:`h-10 w-full`}),[1,2,3,4,5].map(e=>(0,$.jsx)(G,{className:`h-8 w-full`},e))]})]}),!l&&n.sections?.map((e,t)=>e.visible===!1?null:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[e.title&&e.type!==`header`&&(0,$.jsx)(`h3`,{className:`text-lg font-semibold border-b pb-2`,children:e.title}),e.type===`header`&&e.title&&(0,$.jsx)(`div`,{className:`text-2xl font-bold py-4`,children:e.title}),e.type===`summary`&&(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:n.fields?.filter(e=>e.showInSummary).map((e,t)=>(0,$.jsx)(E,{children:(0,$.jsxs)(Y,{className:`p-4`,children:[(0,$.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e.label||e.name}),(0,$.jsx)(`div`,{className:`text-2xl font-bold`,children:$i(p(e.name,e.aggregation),e)})]})},t))}),e.type===`chart`&&e.chart&&(0,$.jsx)(`div`,{className:`min-h-[300px]`,children:(()=>{let t=e.chart.type,n=!!e.chart.chartType;!t&&n&&(t=`chart`),t&&c.get(t)||(t=`chart`);let i=t===`chart`?{xAxisKey:e.chart.xAxisKey||e.chart.xAxisField||`name`,series:e.chart.series||(e.chart.yAxisFields?e.chart.yAxisFields.map(e=>({dataKey:e})):[]),chartType:e.chart.chartType||`bar`}:{};return(0,$.jsx)(s,{schema:{...e.chart,type:t,...i,data:r||e.chart.data,className:e.chart.className||`w-full h-[350px]`}})})()}),e.type===`table`&&(0,$.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,$.jsx)(`thead`,{className:`bg-muted`,children:(0,$.jsx)(`tr`,{children:e.columns?.map((e,t)=>(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,$.jsx)(`tbody`,{children:(()=>{let t=na(r||[],n.groupBy||[]);return t?t.map(t=>(0,$.jsxs)(Q.Fragment,{children:[(0,$.jsx)(`tr`,{className:`bg-muted/60`,children:(0,$.jsxs)(`td`,{colSpan:e.columns?.length||1,className:`px-4 py-2 font-semibold text-sm`,children:[t.label,` (`,t.rows.length,`)`]})}),t.rows.map((t,n)=>(0,$.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,$.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:m(e.name,t[e.name]),children:h(t[e.name],e)},n))},n))]},t.key)):r?.map((t,n)=>(0,$.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:e.columns?.map((e,n)=>(0,$.jsx)(`td`,{className:`px-4 py-2 ${e.type===`number`?`text-right tabular-nums`:``}`,style:m(e.name,t[e.name]),children:h(t[e.name],e)},n))},n))})()})]})}),e.type===`text`&&e.text&&(0,$.jsx)(`div`,{className:`prose max-w-none`,children:(0,$.jsx)(`p`,{children:e.text})}),e.type===`page-break`&&(0,$.jsx)(`div`,{className:`border-t-2 border-dashed my-8 print:page-break-after-always`}),e.content&&(0,$.jsx)(s,{schema:e.content})]},t)),!n.sections&&r&&r.length>0&&(0,$.jsx)(`div`,{className:`border rounded-lg overflow-x-auto`,children:(0,$.jsxs)(`table`,{className:`w-full text-sm min-w-[600px]`,children:[(0,$.jsx)(`thead`,{className:`bg-muted`,children:(0,$.jsx)(`tr`,{children:n.fields?.map((e,t)=>(0,$.jsx)(`th`,{className:`px-4 py-2 font-medium ${e.type===`number`?`text-right`:`text-left`}`,children:e.label||e.name},t))})}),(0,$.jsx)(`tbody`,{children:r.map((e,t)=>(0,$.jsx)(`tr`,{className:`border-t hover:bg-muted/50 even:bg-muted/20`,children:n.fields?.map((t,n)=>(0,$.jsx)(`td`,{className:`px-4 py-2 ${t.type===`number`?`text-right tabular-nums`:``}`,style:m(t.name,e[t.name]),children:h(e[t.name],t)},n))},t))})]})})]})]})]}):(0,$.jsx)(E,{children:(0,$.jsx)(Y,{className:`p-8 text-center text-muted-foreground`,children:`No report to display`})})},ia=({schedule:e,onChange:t})=>{let[n,r]=(0,Q.useState)(e||{enabled:!1,frequency:`weekly`,time:`09:00`,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,recipients:[],formats:[`pdf`]}),i=e=>{let i={...n,...e};r(i),t?.(i)};return(0,$.jsxs)(E,{children:[(0,$.jsx)(He,{children:(0,$.jsxs)(Xe,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Re,{className:`h-5 w-5`}),`Schedule Configuration`]})}),(0,$.jsxs)(Y,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`schedule-enabled`,checked:n.enabled||!1,onChange:e=>i({enabled:e.target.checked}),className:`rounded`}),(0,$.jsx)(X,{htmlFor:`schedule-enabled`,children:`Enable Scheduled Report`})]}),n.enabled&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Frequency`}),(0,$.jsx)(`select`,{className:`w-full border rounded-md p-2 bg-background`,value:n.frequency||`weekly`,onChange:e=>i({frequency:e.target.value}),children:[{value:`once`,label:`Once`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`},{value:`quarterly`,label:`Quarterly`},{value:`yearly`,label:`Yearly`}].map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),n.frequency===`weekly`&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Day of Week`}),(0,$.jsx)(`select`,{className:`w-full border rounded-md p-2 bg-background`,value:n.dayOfWeek??1,onChange:e=>i({dayOfWeek:Number(e.target.value)}),children:[{value:0,label:`Sunday`},{value:1,label:`Monday`},{value:2,label:`Tuesday`},{value:3,label:`Wednesday`},{value:4,label:`Thursday`},{value:5,label:`Friday`},{value:6,label:`Saturday`}].map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),n.frequency===`monthly`&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Day of Month`}),(0,$.jsx)(J,{type:`number`,min:1,max:31,value:n.dayOfMonth??1,onChange:e=>i({dayOfMonth:Number(e.target.value)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(X,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Ye,{className:`h-4 w-4`}),`Time`]}),(0,$.jsx)(J,{type:`time`,value:n.time||`09:00`,onChange:e=>i({time:e.target.value})})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Timezone`}),(0,$.jsx)(J,{value:n.timezone||``,onChange:e=>i({timezone:e.target.value}),placeholder:`e.g. America/New_York`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Export Formats`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:[{value:`pdf`,label:`PDF`},{value:`excel`,label:`Excel`},{value:`csv`,label:`CSV`},{value:`html`,label:`HTML`}].map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-1.5 px-3 py-1.5 border rounded-md cursor-pointer hover:bg-muted/50`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n.formats?.includes(e.value)||!1,onChange:t=>{let r=n.formats||[];i({formats:t.target.checked?[...r,e.value]:r.filter(t=>t!==e.value)})},className:`rounded`}),(0,$.jsx)(`span`,{className:`text-sm`,children:e.label})]},e.value))})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(X,{className:`flex items-center gap-2`,children:[(0,$.jsx)(q,{className:`h-4 w-4`}),`Email Recipients`]}),(0,$.jsx)(J,{placeholder:`email1@example.com, email2@example.com`,value:n.recipients?.join(`, `)||``,onChange:e=>i({recipients:e.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)})})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Email Subject`}),(0,$.jsx)(J,{value:n.subject||``,onChange:e=>i({subject:e.target.value}),placeholder:`Scheduled Report: {report_title}`})]})]})]})]})},aa=({schema:e})=>{let{report:t,dataSources:n=[],availableFields:r=[],showPreview:i=!0,onSave:a,onCancel:o}=e,[s,c]=(0,Q.useState)(t||{type:`report`,title:`New Report`,fields:[],filters:[],groupBy:[],sections:[],showExportButtons:!0,showPrintButton:!0}),[l,u]=(0,Q.useState)(s.fields||[]),[d,f]=(0,Q.useState)(s.filters||[]),[p,m]=(0,Q.useState)(s.groupBy||[]),[h,g]=(0,Q.useState)(s.sections||[]),_=()=>{if(r.length>0&&l.length<r.length){let e=r.find(e=>!l.some(t=>t.name===e.name));if(e){let t=[...l,e];u(t),c({...s,fields:t})}}},v=e=>{let t=l.filter((t,n)=>n!==e);u(t),c({...s,fields:t})},y=(e,t)=>{let n=[...l];n[e]=t,u(n),c({...s,fields:n})},b=()=>{let e={field:r[0]?.name||``,operator:`equals`,value:``},t=[...d,e];f(t),c({...s,filters:t})},x=e=>{let t=d.filter((t,n)=>n!==e);f(t),c({...s,filters:t})},S=(e,t)=>{let n=[...d];n[e]=t,f(n),c({...s,filters:n})},C=()=>{let e={field:r[0]?.name||``,sort:`asc`},t=[...p,e];m(t),c({...s,groupBy:t})},w=e=>{let t=p.filter((t,n)=>n!==e);m(t),c({...s,groupBy:t})},T=(e,t)=>{let n=[...p];n[e]=t,m(n),c({...s,groupBy:n})},D=e=>{let t={type:e,title:`New ${e} Section`},n=[...h,t];g(n),c({...s,sections:n})},O=e=>{let t=h.filter((t,n)=>n!==e);g(t),c({...s,sections:t})},k=(e,t)=>{let n=[...h];n[e]=t,g(n),c({...s,sections:n})};return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(E,{children:[(0,$.jsxs)(He,{children:[(0,$.jsx)(Xe,{children:`Report Builder`}),(0,$.jsx)($e,{children:`Configure your report settings, fields, filters, and sections`})]}),(0,$.jsxs)(Y,{children:[(0,$.jsxs)(Be,{defaultValue:`basic`,className:`w-full`,children:[(0,$.jsxs)(Ae,{className:`grid w-full grid-cols-6`,children:[(0,$.jsxs)(_e,{value:`basic`,children:[(0,$.jsx)(j,{className:`h-4 w-4 mr-2`}),`Basic`]}),(0,$.jsxs)(_e,{value:`fields`,children:[(0,$.jsx)(st,{className:`h-4 w-4 mr-2`}),`Fields`]}),(0,$.jsxs)(_e,{value:`filters`,children:[(0,$.jsx)(ee,{className:`h-4 w-4 mr-2`}),`Filters`]}),(0,$.jsxs)(_e,{value:`grouping`,children:[(0,$.jsx)(st,{className:`h-4 w-4 mr-2`}),`Group By`]}),(0,$.jsxs)(_e,{value:`sections`,children:[(0,$.jsx)(st,{className:`h-4 w-4 mr-2`}),`Sections`]}),(0,$.jsxs)(_e,{value:`schedule`,children:[(0,$.jsx)(Re,{className:`h-4 w-4 mr-2`}),`Schedule`]})]}),(0,$.jsx)(Me,{value:`basic`,className:`space-y-4 mt-4`,children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{htmlFor:`report-title`,children:`Report Title`}),(0,$.jsx)(J,{id:`report-title`,value:s.title||``,onChange:e=>c({...s,title:e.target.value}),placeholder:`Enter report title`})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{htmlFor:`report-description`,children:`Description`}),(0,$.jsx)(J,{id:`report-description`,value:s.description||``,onChange:e=>c({...s,description:e.target.value}),placeholder:`Enter report description`})]}),n.length>0&&(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Data Source`}),(0,$.jsxs)(`select`,{className:`w-full border rounded-md p-2`,children:[(0,$.jsx)(`option`,{value:``,children:`Select a data source`}),n.map((e,t)=>(0,$.jsxs)(`option`,{value:t,children:[`Data Source `,t+1]},t))]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{children:`Export Options`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:s.showExportButtons||!1,onChange:e=>c({...s,showExportButtons:e.target.checked})}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Show Export Buttons`})]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:s.showPrintButton||!1,onChange:e=>c({...s,showPrintButton:e.target.checked})}),(0,$.jsx)(`span`,{className:`text-sm`,children:`Show Print Button`})]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(X,{htmlFor:`export-format`,children:`Default Export Format`}),(0,$.jsxs)(`select`,{id:`export-format`,className:`w-full border rounded-md p-2`,value:s.defaultExportFormat||`pdf`,onChange:e=>c({...s,defaultExportFormat:e.target.value}),children:[(0,$.jsx)(`option`,{value:`pdf`,children:`PDF`}),(0,$.jsx)(`option`,{value:`excel`,children:`Excel`}),(0,$.jsx)(`option`,{value:`csv`,children:`CSV`}),(0,$.jsx)(`option`,{value:`json`,children:`JSON`}),(0,$.jsx)(`option`,{value:`html`,children:`HTML`})]})]})]})}),(0,$.jsxs)(Me,{value:`fields`,className:`space-y-4 mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(X,{children:`Report Fields`}),(0,$.jsxs)(Z,{size:`sm`,variant:`outline`,onClick:_,disabled:l.length>=r.length,children:[(0,$.jsx)(nt,{className:`h-4 w-4 mr-2`}),`Add Field`]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[l.map((e,t)=>(0,$.jsx)(`div`,{className:`flex items-center gap-2 p-3 border rounded-lg`,children:(0,$.jsxs)(`div`,{className:`flex-1 grid grid-cols-4 gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Field Name`}),(0,$.jsx)(`div`,{className:`text-sm font-medium`,children:e.name})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Label`}),(0,$.jsx)(J,{className:`h-8 text-sm`,value:e.label||e.name,onChange:n=>y(t,{...e,label:n.target.value})})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Aggregation`}),(0,$.jsxs)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.aggregation||``,onChange:n=>y(t,{...e,aggregation:n.target.value}),children:[(0,$.jsx)(`option`,{value:``,children:`None`}),(0,$.jsx)(`option`,{value:`sum`,children:`Sum`}),(0,$.jsx)(`option`,{value:`count`,children:`Count`}),(0,$.jsx)(`option`,{value:`avg`,children:`Average`}),(0,$.jsx)(`option`,{value:`min`,children:`Min`}),(0,$.jsx)(`option`,{value:`max`,children:`Max`})]})]}),(0,$.jsx)(`div`,{className:`flex items-end justify-end`,children:(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50`,onClick:()=>v(t),children:(0,$.jsx)(ze,{className:`h-4 w-4`})})})]})},t)),l.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No fields selected. Click "Add Field" to begin.`})]})]}),(0,$.jsxs)(Me,{value:`filters`,className:`space-y-4 mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(X,{children:`Report Filters`}),(0,$.jsxs)(Z,{size:`sm`,variant:`outline`,onClick:b,children:[(0,$.jsx)(nt,{className:`h-4 w-4 mr-2`}),`Add Filter`]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[d.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border rounded-lg`,children:[(0,$.jsxs)(`div`,{className:`flex-1 grid grid-cols-3 gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Field`}),(0,$.jsx)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.field,onChange:n=>S(t,{...e,field:n.target.value}),children:r.map((e,t)=>(0,$.jsx)(`option`,{value:e.name,children:e.label||e.name},t))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Operator`}),(0,$.jsxs)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.operator,onChange:n=>S(t,{...e,operator:n.target.value}),children:[(0,$.jsx)(`option`,{value:`equals`,children:`Equals`}),(0,$.jsx)(`option`,{value:`contains`,children:`Contains`}),(0,$.jsx)(`option`,{value:`gt`,children:`Greater Than`}),(0,$.jsx)(`option`,{value:`lt`,children:`Less Than`}),(0,$.jsx)(`option`,{value:`between`,children:`Between`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Value`}),(0,$.jsx)(J,{className:`h-8 text-sm`,value:String(e.value),onChange:n=>S(t,{...e,value:n.target.value})})]})]}),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50 self-end`,onClick:()=>x(t),children:(0,$.jsx)(ze,{className:`h-4 w-4`})})]},t)),d.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No filters defined.`})]})]}),(0,$.jsxs)(Me,{value:`grouping`,className:`space-y-4 mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(X,{children:`Grouping Rules`}),(0,$.jsxs)(Z,{size:`sm`,variant:`outline`,onClick:C,children:[(0,$.jsx)(nt,{className:`h-4 w-4 mr-2`}),`Add Group`]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[p.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border rounded-lg`,children:[(0,$.jsxs)(`div`,{className:`flex-1 grid grid-cols-2 gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Field`}),(0,$.jsx)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.field,onChange:n=>T(t,{...e,field:n.target.value}),children:r.map((e,t)=>(0,$.jsx)(`option`,{value:e.name,children:e.label||e.name},t))})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Sort Order`}),(0,$.jsxs)(`select`,{className:`w-full border rounded-md h-8 text-sm px-2`,value:e.sort||`asc`,onChange:n=>T(t,{...e,sort:n.target.value}),children:[(0,$.jsx)(`option`,{value:`asc`,children:`Ascending`}),(0,$.jsx)(`option`,{value:`desc`,children:`Descending`})]})]})]}),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50 self-end`,onClick:()=>w(t),children:(0,$.jsx)(ze,{className:`h-4 w-4`})})]},t)),p.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No grouping rules applied.`})]})]}),(0,$.jsxs)(Me,{value:`sections`,className:`space-y-4 mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(X,{children:`Report Sections`}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(Z,{size:`sm`,variant:`outline`,onClick:()=>D(`header`),children:[(0,$.jsx)(nt,{className:`h-4 w-4 mr-2`}),`Header`]}),(0,$.jsxs)(Z,{size:`sm`,variant:`outline`,onClick:()=>D(`chart`),children:[(0,$.jsx)(nt,{className:`h-4 w-4 mr-2`}),`Chart`]}),(0,$.jsxs)(Z,{size:`sm`,variant:`outline`,onClick:()=>D(`table`),children:[(0,$.jsx)(nt,{className:`h-4 w-4 mr-2`}),`Table`]})]})]}),(0,$.jsxs)(`div`,{className:`space-y-2`,children:[h.map((e,t)=>(0,$.jsxs)(`div`,{className:`p-3 border rounded-lg space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`font-medium flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`text-xs bg-muted px-2 py-0.5 rounded uppercase`,children:e.type}),e.title]}),(0,$.jsx)(Z,{size:`sm`,variant:`ghost`,className:`text-red-500 hover:text-red-700 hover:bg-red-50`,onClick:()=>O(t),children:(0,$.jsx)(ze,{className:`h-4 w-4`})})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Title`}),(0,$.jsx)(J,{className:`h-8 text-sm`,value:e.title||``,onChange:n=>k(t,{...e,title:n.target.value})})]}),e.type===`text`&&(0,$.jsxs)(`div`,{className:`col-span-2`,children:[(0,$.jsx)(X,{className:`text-xs`,children:`Content`}),(0,$.jsx)(J,{className:`h-8 text-sm`,value:e.text||``,onChange:n=>k(t,{...e,text:n.target.value})})]}),e.type===`chart`&&(0,$.jsxs)(`div`,{className:`col-span-2 grid grid-cols-2 gap-2 mt-2 p-2 bg-muted/20 rounded`,children:[(0,$.jsx)(`div`,{className:`col-span-2`,children:(0,$.jsx)(X,{className:`text-xs font-semibold`,children:`Chart Configuration`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`Chart Type`}),(0,$.jsxs)(`select`,{className:`flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,value:e.chart?.chartType||`bar`,onChange:n=>k(t,{...e,chart:{...e.chart,type:`chart`,chartType:n.target.value}}),children:[(0,$.jsx)(`option`,{value:`bar`,children:`Bar`}),(0,$.jsx)(`option`,{value:`line`,children:`Line`}),(0,$.jsx)(`option`,{value:`area`,children:`Area`}),(0,$.jsx)(`option`,{value:`pie`,children:`Pie`})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(X,{className:`text-xs`,children:`X-Axis Field`}),(0,$.jsxs)(`select`,{className:`flex h-8 w-full rounded-md border border-input bg-background px-3 py-1 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50`,value:e.chart?.xAxisField||``,onChange:n=>k(t,{...e,chart:{...e.chart,type:`chart`,xAxisField:n.target.value}}),children:[(0,$.jsx)(`option`,{value:``,children:`Select Field...`}),r.map(e=>(0,$.jsx)(`option`,{value:e.name,children:e.label||e.name},e.name)),r.length===0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`option`,{value:`name`,children:`Name`}),(0,$.jsx)(`option`,{value:`month`,children:`Month`})]})]})]}),(0,$.jsxs)(`div`,{className:`col-span-2`,children:[(0,$.jsx)(X,{className:`text-xs`,children:`Y-Axis Fields (comma separated)`}),(0,$.jsx)(J,{className:`h-8 text-sm`,placeholder:`e.g. value, count`,value:e.chart?.yAxisFields?.join(`, `)||``,onChange:n=>k(t,{...e,chart:{...e.chart,type:`chart`,yAxisFields:n.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)}})})]})]})]})]},t)),h.length===0&&(0,$.jsx)(`div`,{className:`text-center py-8 text-muted-foreground border-2 border-dashed rounded-lg`,children:`No customized sections. The default report layout will be used.`})]})]}),(0,$.jsx)(Me,{value:`schedule`,className:`space-y-4 mt-4`,children:(0,$.jsx)(ia,{schedule:s.schedule,onChange:e=>c({...s,schedule:e})})})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 mt-6 pt-4 border-t`,children:[(0,$.jsx)(Z,{variant:`outline`,onClick:()=>{o&&console.log(`Report cancelled:`,o)},children:`Cancel`}),(0,$.jsxs)(Z,{onClick:()=>{console.log(`Saving report:`,s),a&&alert(`Report saved! (Handler: `+a+`)`)},children:[(0,$.jsx)(Oe,{className:`h-4 w-4 mr-2`}),`Save Report`]})]})]})]}),i&&(0,$.jsxs)(E,{className:`mt-8 border-2 border-blue-100`,children:[(0,$.jsx)(He,{className:`bg-blue-50/50`,children:(0,$.jsx)(Xe,{className:`text-blue-900 text-sm uppercase tracking-wide`,children:`Live Preview`})}),(0,$.jsx)(Y,{className:`pt-6`,children:(0,$.jsx)(ra,{schema:{type:`report-viewer`,report:{...s,fields:l,filters:d,groupBy:p,sections:h},data:[{id:1,name:`Sample Item A`,value:100,status:`New`},{id:2,name:`Sample Item B`,value:250,status:`Active`},{id:3,name:`Sample Item C`,value:75,status:`Closed`}]}})})]})]})},oa=[{value:``,label:`None`},{value:`sum`,label:`Sum`},{value:`count`,label:`Count`},{value:`avg`,label:`Average`},{value:`min`,label:`Min`},{value:`max`,label:`Max`}];function sa({availableFields:e,value:t,onChange:n}){let r=Array.isArray(t)?t.map(e=>typeof e==`string`?{name:e,label:e,type:`string`}:{name:e.name||e.field||e.value,label:e.label||e.name||``,type:e.type||`string`,aggregation:e.aggregation}):[],i=r.map(e=>e.name),a=t=>{let a=i.includes(t),o;if(a)o=r.filter(e=>e.name!==t);else{let n=e.find(e=>e.value===t);o=[...r,{name:t,label:n?.label||t,type:n?.type||`string`}]}n(o)},o=(e,t)=>{n(r.map(n=>n.name===e?{...n,aggregation:t||void 0,showInSummary:!!t}:n))};return e.length===0?(0,$.jsx)(`div`,{className:`text-xs text-muted-foreground py-2`,"data-testid":`field-picker-empty`,children:`No fields available`}):(0,$.jsx)(`div`,{className:`space-y-1 py-1`,"data-testid":`field-picker`,children:e.map(e=>{let t=i.includes(e.value),n=r.find(t=>t.name===e.value);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-0.5 rounded hover:bg-muted/50 text-xs`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 flex-1 cursor-pointer`,children:[(0,$.jsx)(H,{checked:t,onCheckedChange:()=>a(e.value),"data-testid":`field-picker-${e.value}`}),(0,$.jsx)(`span`,{className:`flex-1`,children:e.label}),e.type&&(0,$.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e.type})]}),t&&(0,$.jsx)(`select`,{className:`h-5 text-[10px] border rounded px-1 bg-background`,value:n?.aggregation||``,onChange:t=>o(e.value,t.target.value),"data-testid":`field-agg-${e.value}`,children:oa.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]},e.value)})})}var ca=[{value:``,label:`None`},{value:`bar`,label:`Bar Chart`},{value:`line`,label:`Line Chart`},{value:`pie`,label:`Pie Chart`},{value:`area`,label:`Area Chart`},{value:`donut`,label:`Donut Chart`},{value:`scatter`,label:`Scatter Plot`}];function la({availableFields:e,value:t,onChange:n}){let r=t||{},i=e=>n({...r,...e});return(0,$.jsxs)(`div`,{className:`space-y-2 py-1`,"data-testid":`chart-config`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] text-muted-foreground`,children:`Chart type`}),(0,$.jsx)(`select`,{className:`w-full h-7 text-xs border rounded px-2 bg-background`,value:r.chartType||``,onChange:e=>i({chartType:e.target.value||void 0}),"data-testid":`chart-type-select`,children:ca.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),r.chartType&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] text-muted-foreground`,children:`X-axis field`}),(0,$.jsxs)(`select`,{className:`w-full h-7 text-xs border rounded px-2 bg-background`,value:r.xAxisField||``,onChange:e=>i({xAxisField:e.target.value||void 0}),"data-testid":`chart-x-field`,children:[(0,$.jsx)(`option`,{value:``,children:`Select field…`}),e.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] text-muted-foreground`,children:`Y-axis field`}),(0,$.jsxs)(`select`,{className:`w-full h-7 text-xs border rounded px-2 bg-background`,value:r.yAxisFields?.[0]||``,onChange:e=>i({yAxisFields:e.target.value?[e.target.value]:[]}),"data-testid":`chart-y-field`,children:[(0,$.jsx)(`option`,{value:``,children:`Select field…`}),e.filter(e=>e.type===`number`).map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]})]})]})}var ua=[{value:`equals`,label:`=`},{value:`not_equals`,label:`≠`},{value:`greater_than`,label:`>`},{value:`less_than`,label:`<`},{value:`contains`,label:`Contains`}];function da({availableFields:e,value:t,onChange:n}){let r=Array.isArray(t)?t:[],i=()=>{n([...r,{field:e[0]?.value||``,operator:`equals`,value:``,backgroundColor:`#fef9c3`,textColor:``}])},a=e=>{n(r.filter((t,n)=>n!==e))},o=(e,t)=>{n(r.map((n,r)=>r===e?{...n,...t}:n))};return(0,$.jsxs)(`div`,{className:`space-y-2 py-1`,"data-testid":`conditional-format-rules`,children:[r.map((t,n)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] p-1 border rounded bg-muted/20`,children:[(0,$.jsx)(`select`,{className:`h-5 text-[10px] border rounded px-1 bg-background flex-1`,value:t.field,onChange:e=>o(n,{field:e.target.value}),"data-testid":`cf-rule-field-${n}`,children:e.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,$.jsx)(`select`,{className:`h-5 text-[10px] border rounded px-1 bg-background w-12`,value:t.operator,onChange:e=>o(n,{operator:e.target.value}),children:ua.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,$.jsx)(`input`,{className:`h-5 text-[10px] border rounded px-1 bg-background w-16`,value:t.value,placeholder:`value`,onChange:e=>o(n,{value:e.target.value}),"data-testid":`cf-rule-value-${n}`}),(0,$.jsx)(`input`,{type:`color`,className:`h-5 w-5 rounded border cursor-pointer`,value:t.backgroundColor||`#fef9c3`,onChange:e=>o(n,{backgroundColor:e.target.value}),title:`Background color`}),(0,$.jsx)(Z,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0`,onClick:()=>a(n),"data-testid":`cf-rule-remove-${n}`,children:(0,$.jsx)(ze,{className:`h-3 w-3`})})]},n)),(0,$.jsxs)(Z,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 text-[10px] w-full`,onClick:i,"data-testid":`cf-add-rule`,children:[(0,$.jsx)(nt,{className:`h-3 w-3 mr-1`}),`Add Rule`]})]})}var fa=[{value:`header`,label:`Header`},{value:`summary`,label:`Summary`},{value:`table`,label:`Table`},{value:`chart`,label:`Chart`},{value:`text`,label:`Text`}];function pa({value:e,onChange:t}){let n=Array.isArray(e)?e:[],r=e=>{t([...n,{type:e,title:`New ${e}`,visible:!0}])},i=e=>{t(n.filter((t,n)=>n!==e))},a=(e,r)=>{t(n.map((t,n)=>n===e?{...t,...r}:t))},o=(e,r)=>{let i=e+r;if(i<0||i>=n.length)return;let a=[...n];[a[e],a[i]]=[a[i],a[e]],t(a)};return(0,$.jsxs)(`div`,{className:`space-y-2 py-1`,"data-testid":`section-manager`,children:[n.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1 text-[10px] p-1.5 border rounded bg-muted/20`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 mr-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,disabled:t===0,onClick:()=>o(t,-1),"data-testid":`section-up-${t}`,children:`▲`}),(0,$.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground disabled:opacity-30`,disabled:t===n.length-1,onClick:()=>o(t,1),"data-testid":`section-down-${t}`,children:`▼`})]}),(0,$.jsx)(`span`,{className:`text-[9px] bg-muted px-1.5 py-0.5 rounded uppercase font-medium shrink-0`,children:e.type}),(0,$.jsx)(`input`,{className:`h-5 text-[10px] border rounded px-1 bg-background flex-1 min-w-0`,value:e.title||``,placeholder:`Section title`,onChange:e=>a(t,{title:e.target.value}),"data-testid":`section-title-${t}`}),(0,$.jsx)(Z,{type:`button`,size:`sm`,variant:`ghost`,className:`h-5 w-5 p-0 shrink-0`,onClick:()=>i(t),"data-testid":`section-remove-${t}`,children:(0,$.jsx)(ze,{className:`h-3 w-3`})})]},t)),(0,$.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:fa.map(e=>(0,$.jsxs)(Z,{type:`button`,size:`sm`,variant:`outline`,className:`h-6 text-[10px]`,onClick:()=>r(e.value),"data-testid":`section-add-${e.value}`,children:[(0,$.jsx)(nt,{className:`h-3 w-3 mr-0.5`}),e.label]},e.value))})]})}function ma(e=[]){return{breadcrumb:[`Report`,`Configuration`],sections:[{key:`basic`,title:`Basic`,fields:[{key:`title`,label:`Title`,type:`input`,placeholder:`Report title`},{key:`description`,label:`Description`,type:`input`,placeholder:`Report description`},{key:`reportType`,label:`Report type`,type:`select`,defaultValue:`tabular`,options:[{value:`tabular`,label:`Tabular`},{value:`summary`,label:`Summary`},{value:`matrix`,label:`Matrix`}],helpText:`Tabular: flat table. Summary: grouped with subtotals. Matrix: pivot table (planned).`}]},{key:`data`,title:`Data`,collapsible:!0,fields:[{key:`objectName`,label:`Data source`,type:`input`,placeholder:`e.g. opportunity`,helpText:`Object name to query data from`},{key:`limit`,label:`Row limit`,type:`input`,defaultValue:`100`,placeholder:`e.g. 100`}]},{key:`columns`,title:`Columns`,collapsible:!0,hint:`Select fields to display as report columns. Set aggregation per column for summary reports.`,fields:[{key:`fields`,label:`Report columns`,type:`custom`,render:(t,n)=>(0,$.jsx)(sa,{availableFields:e,value:t,onChange:n})}]},{key:`filters`,title:`Filters`,collapsible:!0,hint:`Define filter conditions for the report data`,fields:[{key:`filters`,label:`Conditions`,type:`filter`,fields:e}]},{key:`groupBy`,title:`Group By`,collapsible:!0,hint:`Group report data and compute aggregations`,fields:[{key:`groupBy`,label:`Grouping`,type:`sort`,fields:e}]},{key:`chart`,title:`Chart`,collapsible:!0,hint:`Add a chart visualization to the report`,fields:[{key:`chartConfig`,label:`Chart`,type:`custom`,render:(t,n)=>(0,$.jsx)(la,{availableFields:e,value:t,onChange:n})}]},{key:`conditionalFormatting`,title:`Conditional Format`,collapsible:!0,defaultCollapsed:!0,hint:`Highlight cells based on field value conditions`,fields:[{key:`conditionalFormatting`,label:`Rules`,type:`custom`,render:(t,n)=>(0,$.jsx)(da,{availableFields:e,value:t,onChange:n})}]},{key:`sections`,title:`Sections`,collapsible:!0,defaultCollapsed:!0,hint:`Manage report layout blocks (header, table, chart, summary)`,fields:[{key:`sections`,label:`Report sections`,type:`custom`,render:(e,t)=>(0,$.jsx)(pa,{value:e,onChange:t})}]},{key:`export`,title:`Export`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`showExportButtons`,label:`Show export buttons`,type:`switch`,defaultValue:!0},{key:`showPrintButton`,label:`Show print button`,type:`switch`,defaultValue:!0},{key:`defaultExportFormat`,label:`Default export format`,type:`select`,defaultValue:`pdf`,options:[{value:`pdf`,label:`PDF`},{value:`excel`,label:`Excel`},{value:`csv`,label:`CSV`},{value:`json`,label:`JSON`},{value:`html`,label:`HTML`}]}]},{key:`schedule`,title:`Schedule`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`schedule`,label:`Schedule`,type:`custom`,render:(e,t)=>(0,$.jsx)(ia,{schedule:e,onChange:t})}]},{key:`appearance`,title:`Appearance`,collapsible:!0,defaultCollapsed:!0,fields:[{key:`showToolbar`,label:`Show toolbar`,type:`switch`,defaultValue:!0},{key:`refreshInterval`,label:`Refresh interval`,type:`select`,defaultValue:`0`,options:[{value:`0`,label:`Manual`},{value:`30`,label:`30s`},{value:`60`,label:`1 min`},{value:`300`,label:`5 min`}]}]}]}}function ha({open:e,onClose:t,config:n,onSave:r,onFieldChange:i,availableFields:a}){let{draft:o,isDirty:s,updateField:c,discard:l,undo:u,redo:d,canUndo:f,canRedo:p}=ce(n,{onUpdate:i});return(0,$.jsx)(Te,{open:e,onClose:t,schema:Q.useMemo(()=>ma(a),[a]),draft:o,isDirty:s,onFieldChange:c,onSave:()=>r(o),onDiscard:l,onUndo:u,onRedo:d,canUndo:f,canRedo:p})}async function ga(e,t){let{dataSource:n,resource:r,queryParams:i,format:a,exportConfig:o}=t,s=a||e.defaultExportFormat||`pdf`;try{let t=(await n.find(r,i)).data||[];return qi(s,e,t,{format:s,...e.exportConfigs?.[s],...o}),{success:!0,recordCount:t.length,format:s}}catch(e){return{success:!1,recordCount:0,format:s,error:e.message}}}function _a(e,t,n={}){let{columns:r,filename:i,includeAggregationRow:a=!1}=n,o=r||(e.fields||[]).map(ya),s=o.map(e=>e.header),c=t.map((e,t)=>o.map(n=>{if(n.formula)return n.formula.replace(/\{ROW\}/g,String(t+2));let r=e[n.name];return ba(r,n.numberFormat)}));if(a&&t.length>0){let n=o.map((n,r)=>{let i=(e.fields||[]).find(e=>e.name===n.name);if(i?.aggregation){let e=Sa(r),n=t.length+1;switch(i.aggregation){case`sum`:return`=SUM(${e}2:${e}${n})`;case`avg`:return`=AVERAGE(${e}2:${e}${n})`;case`count`:return`=COUNTA(${e}2:${e}${n})`;case`min`:return`=MIN(${e}2:${e}${n})`;case`max`:return`=MAX(${e}2:${e}${n})`;default:return``}}return``});c.push(n)}wa(``+[s.join(` `),...c.map(e=>e.join(` `))].join(`
|
|
63
|
-
`),i||`${e.title||`report`}.tsv`,`text/tab-separated-values`)}function va(e,t,n,r){return async()=>{let i=e.schedule;if(!i?.enabled)return[];let a=i.formats||[e.defaultExportFormat||`pdf`],o=[];for(let r of a){let i=await ga(e,{dataSource:t,resource:n,format:r});o.push(i)}return r(e,i),o}}function ya(e){return{name:e.name,header:e.label||e.name}}function ba(e,t){return e==null?``:typeof e==`number`&&t?e.toLocaleString(`en-US`,xa(t)):Ca(String(e))}function xa(e){if(e.includes(`%`))return{style:`percent`,minimumFractionDigits:0};let t=(e.match(/0/g)||[]).length;return{minimumFractionDigits:Math.max(0,t-1),maximumFractionDigits:Math.max(0,t-1)}}function Sa(e){let t=``,n=e;for(;n>=0;)t=String.fromCharCode(n%26+65)+t,n=Math.floor(n/26)-1;return t}function Ca(e){if(e.length>0){let t=e.charAt(0);if(t===`=`||t===`+`||t===`-`||t===`@`||t===`|`)return`'${e}`}return e}function wa(e,t,n){let r=new Blob([e],{type:`${n};charset=utf-8`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=t,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i)}var Ta=e({ReportBuilder:()=>aa,ReportConfigPanel:()=>ha,ReportRenderer:()=>Vi,ReportViewer:()=>ra,ScheduleConfig:()=>ia,createScheduleTrigger:()=>va,exportAsCSV:()=>Hi,exportAsExcel:()=>Ki,exportAsHTML:()=>Wi,exportAsJSON:()=>Ui,exportAsPDF:()=>Gi,exportExcelWithFormulas:()=>_a,exportReport:()=>qi,exportWithLiveData:()=>ga,formatValue:()=>$i});c.register(`report`,Vi,{namespace:`report`,label:`Report`,category:`Report`,inputs:[{name:`title`,type:`string`,label:`Title`},{name:`description`,type:`string`,label:`Description`},{name:`chart`,type:`code`,label:`Chart Configuration`}]}),c.register(`report-viewer`,ra,{namespace:`report`,label:`Report Viewer`,category:`Report`,inputs:[{name:`report`,type:`code`,label:`Report Definition`},{name:`showToolbar`,type:`boolean`,label:`Show Toolbar`}]}),c.register(`report-builder`,aa,{namespace:`report`,label:`Report Builder`,category:`Report`,inputs:[{name:`report`,type:`code`,label:`Initial Report`}]});export{Sn as a,Dn as i,Bi as n,ln as o,ki as r,Ft as s,Ta as t};
|