@object-ui/console 3.1.3 → 3.1.4
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/AddressField-BLYuFwUv.js +1 -0
- package/dist/assets/AdvancedChartImpl-Dvg6YIfN.js +7 -0
- package/dist/assets/AppManagementPage-C3hg63SY.js +1 -0
- package/dist/assets/AuditLogPage-BQ8vLOcD.js +1 -0
- package/dist/assets/AuthPageLayout-DDjJTsQ6.js +1 -0
- package/dist/assets/AutoNumberField-DLmi_0fk.js +1 -0
- package/dist/assets/AvatarField-BfoEDA_D.js +1 -0
- package/dist/assets/BooleanField-W3_x7RAZ.js +1 -0
- package/dist/assets/ChartImpl-Cwo6IWnY.js +1 -0
- package/dist/assets/CodeField-BWFqblAU.js +1 -0
- package/dist/assets/ColorField-Y8WM1wXE.js +1 -0
- package/dist/assets/CreateAppPage-Do3sVvxx.js +1 -0
- package/dist/assets/CurrencyField-BeuE1bRa.js +1 -0
- package/dist/assets/DashboardDesignPage-B2PH_3Ly.js +1 -0
- package/dist/assets/DashboardView-DxTi63mN.js +1 -0
- package/dist/assets/DateField-2Lf9jstN.js +1 -0
- package/dist/assets/DateTimeField-BkMuhOZJ.js +1 -0
- package/dist/assets/EditAppPage-j0L1x2UT.js +1 -0
- package/dist/assets/EmailField-CP_O7tmo.js +1 -0
- package/dist/assets/FileField-CcczwlRk.js +1 -0
- package/dist/assets/ForgotPasswordPage-Slo6CHvD.js +1 -0
- package/dist/assets/FormulaField-DLdg1ImO.js +1 -0
- package/dist/assets/GeolocationField-DqeMjnyo.js +1 -0
- package/dist/assets/GridField-DaWMYyuc.js +1 -0
- package/dist/assets/ImageField-DAn05d1y.js +1 -0
- package/dist/assets/KanbanEnhanced-Dj7Qccu2.js +1 -0
- package/dist/assets/KanbanImpl-D9BbG_RT.js +1 -0
- package/dist/assets/LocationField-DYHVF_gq.js +1 -0
- package/dist/assets/LoginPage-D2CqpSi0.js +1 -0
- package/dist/assets/LookupField-BF9vCmht.js +1 -0
- package/dist/assets/MarkdownImpl-B0Iew7iJ.js +29 -0
- package/dist/assets/MasterDetailField-Dw4RRQ5W.js +1 -0
- package/dist/assets/NumberField-BKuVHBrN.js +1 -0
- package/dist/assets/ObjectField-z00gmFEc.js +1 -0
- package/dist/assets/OrgManagementPage-BTNWvRHI.js +1 -0
- package/dist/assets/PageDesignPage-B62v76Qo.js +1 -0
- package/dist/assets/PageView-CzF68bdQ.js +2 -0
- package/dist/assets/PasswordField-B_rXL4g9.js +1 -0
- package/dist/assets/PercentField-Bn_SIbNe.js +1 -0
- package/dist/assets/PermissionManagementPage-PWrxdXgQ.js +1 -0
- package/dist/assets/PhoneField-DuheMaUR.js +1 -0
- package/dist/assets/ProfilePage-CUo-xIgl.js +1 -0
- package/dist/assets/QRCodeField-IPS2Rpmi.js +1 -0
- package/dist/assets/RatingField-M6qZlpA4.js +1 -0
- package/dist/assets/RecordDetailView-FkYkjMEZ.js +1 -0
- package/dist/assets/RegisterPage-D7PJIabW.js +1 -0
- package/dist/assets/ReportView-pQJYBCo1.js +1 -0
- package/dist/assets/RichTextField-CDGy9V9x.js +1 -0
- package/dist/assets/RoleManagementPage-cNU9Z5K1.js +1 -0
- package/dist/assets/SearchResultsPage-DJU7W1Zx.js +1 -0
- package/dist/assets/SelectField-F6UDlyvf.js +1 -0
- package/dist/assets/SignatureField-CHN7xBII.js +1 -0
- package/dist/assets/SliderField-BOfEMQyU.js +1 -0
- package/dist/assets/SummaryField-CZ8KzmBZ.js +1 -0
- package/dist/assets/SystemHubPage-BxKsLijB.js +1 -0
- package/dist/assets/TextAreaField-1E39zZ_x.js +1 -0
- package/dist/assets/TextField-CwuU0Crc.js +1 -0
- package/dist/assets/TimeField-CEWXxhLE.js +1 -0
- package/dist/assets/UrlField-BtUImn9B.js +1 -0
- package/dist/assets/UserField-DSSEoy5L.js +1 -0
- package/dist/assets/UserManagementPage-D2qUebpD.js +1 -0
- package/dist/assets/VectorField-BjfQeTZT.js +1 -0
- package/dist/assets/data-adapter-wZ81OFjZ.js +39 -0
- package/dist/assets/framework-DJlDX9E6.js +1 -0
- package/dist/assets/index-D9-L0QBO.css +2 -0
- package/dist/assets/index-RiB5-8aY.js +8 -0
- package/dist/assets/infrastructure-C6Ph6Ug0.js +3 -0
- package/dist/assets/maplibre-gl-DsUGuDud.js +756 -0
- package/dist/assets/plugins-core-Cfhp_BXE.css +2 -0
- package/dist/assets/plugins-core-PiAAytWV.js +136 -0
- package/dist/assets/plugins-views-CE0VP3vl.js +62 -0
- package/dist/assets/plugins-views-DnNKJB60.css +1 -0
- package/dist/assets/rolldown-runtime-Dw2cE7zH.js +1 -0
- package/dist/assets/skeletons-DcGqw3b1.js +1 -0
- package/dist/assets/src-oeWLmiqa.js +1 -0
- package/dist/assets/systemObjects-5--4zaiX.js +1 -0
- package/dist/assets/ui-layout-DdDX0gzI.js +3 -0
- package/dist/assets/vendor-charts-Bl5l0H2K.js +3 -0
- package/dist/assets/vendor-objectstack-BtztJIHv.js +1 -0
- package/dist/assets/vendor-react-BwtAzZZ3.js +9 -0
- package/dist/index.html +15 -24
- package/dist/mockServiceWorker.js +1 -1
- package/package.json +44 -44
- package/dist/assets/AdvancedChartImpl-BvIFxlPf.js +0 -7
- package/dist/assets/AppManagementPage-6bzxYNlP.js +0 -1
- package/dist/assets/AuditLogPage-qCzdxaNq.js +0 -1
- package/dist/assets/AuthPageLayout-DkrxSZOE.js +0 -1
- package/dist/assets/ChartImpl-DYQ9eXJz.js +0 -1
- package/dist/assets/CreateAppPage-DNKskVHK.js +0 -1
- package/dist/assets/DashboardDesignPage-T9tEAHAx.js +0 -1
- package/dist/assets/DashboardView-jCJCERzJ.js +0 -1
- package/dist/assets/EditAppPage-UGT9V29B.js +0 -1
- package/dist/assets/ForgotPasswordPage-Ca0lLZwY.js +0 -1
- package/dist/assets/KanbanEnhanced-CyIdmKhW.js +0 -1
- package/dist/assets/KanbanImpl-PGPpv-gu.js +0 -1
- package/dist/assets/LoginPage-BR2RpoGG.js +0 -1
- package/dist/assets/MarkdownImpl-eDhoPCJp.js +0 -29
- package/dist/assets/OrgManagementPage-DjT2mZ2x.js +0 -1
- package/dist/assets/PageDesignPage-DTEQcEuR.js +0 -1
- package/dist/assets/PageView-CFJhE0CN.js +0 -2
- package/dist/assets/PermissionManagementPage-C_FPnvGW.js +0 -1
- package/dist/assets/ProfilePage-CQkgvEEi.js +0 -1
- package/dist/assets/RecordDetailView-ClpxNRz2.js +0 -1
- package/dist/assets/RegisterPage-6IYU4bdp.js +0 -1
- package/dist/assets/ReportView-DecAJ58u.js +0 -1
- package/dist/assets/RoleManagementPage-v0ia3MGn.js +0 -1
- package/dist/assets/SearchResultsPage-CaSb54ho.js +0 -1
- package/dist/assets/SystemHubPage-PNaxZEht.js +0 -1
- package/dist/assets/UserManagementPage-KAZy5fgy.js +0 -1
- package/dist/assets/data-adapter-DCM4pdG4.js +0 -1
- package/dist/assets/framework-jBjO8CT3.js +0 -10
- package/dist/assets/index-BwkHrw9s.js +0 -1
- package/dist/assets/index-DXak0mZe.css +0 -1
- package/dist/assets/index-tta28Q_N.js +0 -9
- package/dist/assets/infrastructure-CWeiQ12V.js +0 -1
- package/dist/assets/maplibre-gl-CENyyZ0G.js +0 -811
- package/dist/assets/plugins-core-BV7ym-7D.js +0 -8
- package/dist/assets/plugins-views-P3eB-els.css +0 -1
- package/dist/assets/plugins-views-gxDbTdkX.js +0 -62
- package/dist/assets/systemObjects-DSpePIIy.js +0 -1
- package/dist/assets/ui-components-BCiSmwiC.css +0 -1
- package/dist/assets/ui-components-BRpbeVr1.js +0 -36
- package/dist/assets/ui-layout-VeUu0ZVf.js +0 -1
- package/dist/assets/vendor-charts-DthMRf4E.js +0 -60
- package/dist/assets/vendor-dndkit-_-PfuStg.js +0 -5
- package/dist/assets/vendor-i18n-B3GHNV0X.js +0 -9
- package/dist/assets/vendor-icons-CnLeuN7Z.js +0 -8566
- package/dist/assets/vendor-objectstack-BkRCrdfn.js +0 -34
- package/dist/assets/vendor-radix-BPVlBHPl.js +0 -56
- package/dist/assets/vendor-react-Dvo_9NuO.js +0 -60
- package/dist/assets/vendor-ui-utils-CU11aiRA.js +0 -1
- package/dist/assets/vendor-zod-CZmssJWz.js +0 -39
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChartImpl-DYQ9eXJz.js","assets/vendor-react-Dvo_9NuO.js","assets/vendor-charts-DthMRf4E.js","assets/vendor-ui-utils-CU11aiRA.js","assets/vendor-i18n-B3GHNV0X.js","assets/AdvancedChartImpl-BvIFxlPf.js","assets/KanbanImpl-PGPpv-gu.js","assets/vendor-dndkit-_-PfuStg.js","assets/ui-components-BRpbeVr1.js","assets/framework-jBjO8CT3.js","assets/vendor-objectstack-BkRCrdfn.js","assets/vendor-zod-CZmssJWz.js","assets/vendor-icons-CnLeuN7Z.js","assets/vendor-radix-BPVlBHPl.js","assets/infrastructure-CWeiQ12V.js","assets/ui-components-BCiSmwiC.css","assets/KanbanEnhanced-CyIdmKhW.js","assets/plugins-core-BV7ym-7D.js","assets/plugins-views-gxDbTdkX.js","assets/plugins-views-P3eB-els.css","assets/RecordDetailView-ClpxNRz2.js","assets/data-adapter-DCM4pdG4.js","assets/ui-layout-VeUu0ZVf.js","assets/DashboardView-jCJCERzJ.js","assets/PageView-CFJhE0CN.js","assets/ReportView-DecAJ58u.js","assets/SearchResultsPage-CaSb54ho.js","assets/CreateAppPage-DNKskVHK.js","assets/index-BwkHrw9s.js","assets/EditAppPage-UGT9V29B.js","assets/PageDesignPage-DTEQcEuR.js","assets/DashboardDesignPage-T9tEAHAx.js","assets/LoginPage-BR2RpoGG.js","assets/AuthPageLayout-DkrxSZOE.js","assets/RegisterPage-6IYU4bdp.js","assets/ForgotPasswordPage-Ca0lLZwY.js","assets/SystemHubPage-PNaxZEht.js","assets/AppManagementPage-6bzxYNlP.js","assets/UserManagementPage-KAZy5fgy.js","assets/systemObjects-DSpePIIy.js","assets/OrgManagementPage-DjT2mZ2x.js","assets/RoleManagementPage-v0ia3MGn.js","assets/PermissionManagementPage-C_FPnvGW.js","assets/AuditLogPage-qCzdxaNq.js","assets/ProfilePage-CQkgvEEi.js","assets/maplibre-gl-CENyyZ0G.js","assets/MarkdownImpl-eDhoPCJp.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as i,j as t,f as Pe,L as we,R as ae,u as Kn,h as Ge,i as ss,B as rs,k as ct,l as z,N as qe,c as Yn,m as os}from"./vendor-react-Dvo_9NuO.js";import{aP as Jn,aE as is,aF as ls,aw as Ae,aB as Te,w as Ce,x as Se,aC as ye,y as ke,aQ as ln,z as ie,aK as it,aH as cs,at as $e,au as Xe,av as ze,aG as ds,aD as us,aI as ms,aR as cn,aS as dn,aT as un,aU as ps,B as Y,c as q,S as hs,aV as gs,h as fs,i as xs,j as bs,G as js,as as ys,ax as vs,aW as ws,aX as Ns,aY as Cs,aZ as Ss,a_ as ks,a$ as Ds,b0 as Fs,b1 as _s,b2 as Es,b3 as As,b4 as ve,b5 as pe,b6 as jt,b7 as mt,b8 as pt,b9 as ht,ba as Ts,_ as J,p as Ke,N as De,P as Rs,J as Vs,K as Ms,bb as Os,a0 as Zn,a1 as Qn,a2 as Xn,a3 as ea,a4 as Ne,aN as U,ab as X,bc as Ve,ac as Re,aJ as Ps,ad as Is,aL as Ls,aM as $s,D as ta,O as na,l as aa,n as sa,o as ra,bd as mn}from"./ui-components-BRpbeVr1.js";import{V as zs,O as pn,M as Us}from"./plugins-core-BV7ym-7D.js";import{E as Kt,t as Bs,C as Z,c as Hs,d as Yt,s as Ie,g as Le,i as Ye,j as Je,v as qs,w as oa,S as Ws,x as Gs,y as Ks}from"./framework-jBjO8CT3.js";import{G as Ys}from"./vendor-objectstack-BkRCrdfn.js";import{b as K,T as Js,a as ia}from"./vendor-ui-utils-CU11aiRA.js";import{c as gt,u as me,b as la,d as ca,g as hn,A as yt,P as Zs,e as vt,I as Qs}from"./infrastructure-CWeiQ12V.js";import{O as da}from"./data-adapter-DCM4pdG4.js";import{N as Xs,A as er}from"./ui-layout-VeUu0ZVf.js";import{k as gn,aQ as Me,m as Fe,at as ua,n as et,aw as tr,S as We,a as ft,aa as nr,Q as ma,aF as ar,aR as sr,w as je,aS as St,aT as kt,aU as pa,as as rr,aV as fn,L as dt,g as Jt,aI as xn,aP as or,aB as ir,l as lr,C as Dt,aW as cr,aX as ha,ak as dr,aY as ga,T as fa,r as ur,aZ as mr,b as xa,j as ba,d as pr,_ as hr,a_ as gr,G as lt,J as fr,K as xr,ar as Ft,a$ as br,av as jr,V as yr,b0 as vr,ah as wr,ai as Nr,b1 as Cr,R as ja,c as Sr,O as kr,I as Dr,b2 as Fr,b3 as _r}from"./vendor-icons-CnLeuN7Z.js";import{u as ya,L as Er,D as Ar,R as Tr,M as Rr}from"./plugins-views-gxDbTdkX.js";import{u as Vr,a as bn,K as Mr,P as Or,b as Pr,D as Ir,c as Lr,S as $r,v as zr,d as Ur,C as Br}from"./vendor-dndkit-_-PfuStg.js";import{o as Zt,s as te,_ as Hr,t as qr,n as wt}from"./vendor-zod-CZmssJWz.js";import"./vendor-radix-BPVlBHPl.js";import"./vendor-i18n-B3GHNV0X.js";import"./vendor-charts-DthMRf4E.js";(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))o(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const l of r.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&o(l)}).observe(document,{childList:!0,subtree:!0});function a(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function o(s){if(s.ep)return;s.ep=!0;const r=a(s);fetch(s.href,r)}})();const va=i.createContext(null);function Ue(e){return e&&typeof e=="object"&&"items"in e&&Array.isArray(e.items)?e.items:[]}async function jn(e){const n=e.getClient(),[a,o,s,r,l]=await Promise.all([n.meta.getItems("app").catch(()=>({items:[]})),n.meta.getItems("object").catch(()=>({items:[]})),n.meta.getItems("dashboard").catch(()=>({items:[]})),n.meta.getItems("report").catch(()=>({items:[]})),n.meta.getItems("page").catch(()=>({items:[]}))]);return{apps:Ue(a),objects:Ue(o),dashboards:Ue(s),reports:Ue(r),pages:Ue(l)}}function Wr({children:e,adapter:n}){const[a,o]=i.useState({apps:[],objects:[],dashboards:[],reports:[],pages:[],loading:!0,error:null}),s=i.useRef(n);s.current=n;const r=i.useCallback(async()=>{o(c=>({...c,loading:!0,error:null}));try{const c=await jn(s.current);o({...c,loading:!1,error:null})}catch(c){o(d=>({...d,loading:!1,error:c instanceof Error?c:new Error(String(c))}))}},[]);i.useEffect(()=>{let c=!1;return(async()=>{try{const d=await jn(n);c||o({...d,loading:!1,error:null})}catch(d){c||o(u=>({...u,loading:!1,error:d instanceof Error?d:new Error(String(d))}))}})(),()=>{c=!0}},[n]);const l={...a,refresh:r};return t.jsx(va.Provider,{value:l,children:e})}function Ze(){const e=i.useContext(va);if(!e)throw new Error("useMetadata must be used within a <MetadataProvider>");return e}const wa=i.createContext(null);function Qe(){return i.useContext(wa)}function Gr({children:e,adapter:n}){const[a,o]=i.useState(n??null);return i.useEffect(()=>{if(n){o(n);return}let s=!1;async function r(){try{const l=new da({baseUrl:"",autoReconnect:!0,maxReconnectAttempts:5,reconnectDelay:1e3,cache:{maxSize:50,ttl:3e5}});await l.connect(),s||o(l)}catch(l){s||console.error("[Console] Failed to initialize:",l)}}return r(),()=>{s=!0}},[n]),t.jsx(wa.Provider,{value:a,children:e})}const Na=i.createContext(null);function Kr({children:e,user:n={},app:a={},data:o={}}){const s=i.useMemo(()=>{const r={user:n,app:a,data:o},l=new Kt(r);return{user:n,app:a,data:o,evaluator:l}},[n,a,o]);return t.jsx(Na.Provider,{value:s,children:e})}function Ca(){const e=i.useContext(Na);if(!e){const n={user:{},app:{},data:{}};return{...n,evaluator:new Kt(n)}}return e}function ut(e,n){if(e==null||e===!0||e==="true")return!0;if(e===!1||e==="false")return!1;if(typeof e=="string"&&e.includes("${"))try{return n.evaluateCondition(e)}catch{return!0}return!0}const Sa="objectui-recent-items",Yr=8;function yn(){try{const e=localStorage.getItem(Sa);return e?JSON.parse(e):[]}catch{return[]}}function vn(e){try{localStorage.setItem(Sa,JSON.stringify(e))}catch{}}function ka(){const[e,n]=i.useState(yn);i.useEffect(()=>{n(yn())},[]);const a=i.useCallback(s=>{n(r=>{const l=r.filter(d=>d.id!==s.id),c=[{...s,visitedAt:new Date().toISOString()},...l].slice(0,Yr);return vn(c),c})},[]),o=i.useCallback(()=>{n([]),vn([])},[]);return{recentItems:e,addRecentItem:a,clearRecentItems:o}}const Da="objectui-favorites",wn=20;function Nn(){try{const e=localStorage.getItem(Da);return e?JSON.parse(e):[]}catch{return[]}}function tt(e){try{localStorage.setItem(Da,JSON.stringify(e))}catch{}}function Jr(){const[e,n]=i.useState(Nn);i.useEffect(()=>{n(Nn())},[]);const a=i.useCallback(c=>{n(d=>{if(d.some(m=>m.id===c.id))return d;const u=[{...c,favoritedAt:new Date().toISOString()},...d].slice(0,wn);return tt(u),u})},[]),o=i.useCallback(c=>{n(d=>{const u=d.filter(m=>m.id!==c);return tt(u),u})},[]),s=i.useCallback(c=>{n(d=>{const m=d.some(p=>p.id===c.id)?d.filter(p=>p.id!==c.id):[{...c,favoritedAt:new Date().toISOString()},...d].slice(0,wn);return tt(m),m})},[]),r=i.useCallback(c=>e.some(d=>d.id===c),[e]),l=i.useCallback(()=>{n([]),tt([])},[]);return{favorites:e,addFavorite:a,removeFavorite:o,toggleFavorite:s,isFavorite:r,clearFavorites:l}}const Fa="objectui-nav-pins",Zr=20;function Cn(){try{const e=localStorage.getItem(Fa);if(!e)return[];const n=JSON.parse(e);return Array.isArray(n)?n.filter(a=>typeof a=="string"):[]}catch{return[]}}function Sn(e){try{localStorage.setItem(Fa,JSON.stringify(e))}catch{}}function Qr(){const[e,n]=i.useState(Cn);i.useEffect(()=>{n(Cn())},[]);const a=i.useCallback((l,c)=>{n(d=>{const u=d.filter(p=>p!==l),m=c?[...u,l].slice(0,Zr):u;return Sn(m),m})},[]),o=i.useCallback(l=>e.includes(l),[e]),s=i.useCallback(l=>l.map(c=>{const d=e.includes(c.id),u=c.children?.length?s(c.children):c.children;return d!==(c.pinned??!1)||u!==c.children?{...c,pinned:d,children:u}:c}),[e]),r=i.useCallback(()=>{n([]),Sn([])},[]);return{pinnedIds:e,togglePin:a,isPinned:o,applyPins:s,clearPins:r}}function ee(e,n){if(e!=null){if(typeof e=="string")return e;if(n){const a=n(e.key,{defaultValue:e.defaultValue,...e.params});if(a&&a!==e.key)return a}return e.defaultValue||e.key}}function Xr(e){const n=`objectui-nav-order-${e}`,[a,o]=i.useState(()=>{try{const c=localStorage.getItem(n);if(!c)return{};const d=JSON.parse(c);if(typeof d!="object"||d===null||Array.isArray(d))return{};const u={};for(const[m,p]of Object.entries(d))Array.isArray(p)&&p.every(g=>typeof g=="string")&&(u[m]=p);return u}catch{return{}}}),s=i.useCallback(c=>{o(c);try{localStorage.setItem(n,JSON.stringify(c))}catch{}},[n]),r=i.useCallback(c=>{const d=a.__root__;if(!d)return c;const u=new Map(c.map(p=>[p.id,p])),m=[];for(const p of d){const g=u.get(p);g&&(m.push(g),u.delete(p))}return u.forEach(p=>m.push(p)),m},[a]),l=i.useCallback(c=>{const d=c.map(u=>u.id);s({...a,__root__:d})},[a,s]);return{applyOrder:r,handleReorder:l}}function Be(e){if(!e)return Me;if(je[e])return je[e];const n=e.split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join("");return je[n]?je[n]:Me}function eo({activeAppName:e,onAppChange:n}){const{isMobile:a}=Jn(),{user:o,signOut:s}=gt(),r=Pe(),{t:l}=me(),{objectLabel:c}=la();i.useEffect(()=>{let W=0;const Q=le=>{W=le.touches[0].clientX},se=le=>{const ce=le.changedTouches[0].clientX-W;W<30&&ce>50&&a&&document.querySelector('[data-sidebar="trigger"]')?.dispatchEvent(new MouseEvent("click",{bubbles:!0}))};return document.addEventListener("touchstart",Q,{passive:!0}),document.addEventListener("touchend",se,{passive:!0}),()=>{document.removeEventListener("touchstart",Q),document.removeEventListener("touchend",se)}},[a]);const{recentItems:d}=ka(),{favorites:u,removeFavorite:m}=Jr(),{apps:p}=Ze(),x=(p||[]).filter(D=>D.active!==!1),h=x.find(D=>D.name===e)||x[0],F=h?.branding?.logo,v=h?.branding?.primaryColor,{applyOrder:b,handleReorder:S}=Xr(e),{togglePin:E,applyPins:f}=Qr(),w=h?.areas||[],[j,y]=i.useState(()=>w.length>0?w[0].id:null);i.useEffect(()=>{w.length>0?y(D=>w.some(G=>G.id===D)?D:w[0].id):y(null)},[e,w.length]);const V=w.find(D=>D.id===j)?.navigation||h?.navigation||[],k=i.useMemo(()=>{const D=b(V);return f(D)},[V,b,f]),[M,N]=i.useState(""),[A,R]=i.useState(!1),{evaluator:L}=Ca(),B=i.useCallback(D=>ut(D,L),[L]),{can:P}=ca(),$=i.useCallback(D=>D.every(G=>{const W=G.split(":"),[Q,se]=W.length>=2?[W[0],W[1]]:[G,"read"];return P(Q,se)}),[P]),O=h?`/apps/${e}`:"",I=i.useMemo(()=>[{id:"sys-settings",label:"System Settings",type:"url",url:"/system",icon:"settings"},{id:"sys-apps",label:"Applications",type:"url",url:"/system/apps",icon:"layout-grid"},{id:"sys-users",label:"Users",type:"url",url:"/system/users",icon:"users"},{id:"sys-orgs",label:"Organizations",type:"url",url:"/system/organizations",icon:"building-2"},{id:"sys-roles",label:"Roles",type:"url",url:"/system/roles",icon:"shield"},{id:"sys-create-app",label:"Create App",type:"url",url:"/create-app",icon:"plus"}],[]);return t.jsxs(t.Fragment,{children:[t.jsxs(is,{collapsible:"icon",children:[t.jsx(ls,{children:t.jsx(Ae,{children:t.jsx(Te,{children:h?t.jsxs(Ce,{children:[t.jsx(Se,{asChild:!0,children:t.jsxs(ye,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[t.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground",style:v?{backgroundColor:v}:void 0,children:F?t.jsx("img",{src:F,alt:ee(h.label,l),className:"size-6 object-contain"}):i.createElement(Be(h.icon),{className:"size-4"})}),t.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[t.jsx("span",{className:"truncate font-semibold",children:ee(h.label,l)}),t.jsx("span",{className:"truncate text-xs",children:ee(h.description,l)||`${x.length} Apps Available`})]}),t.jsx(gn,{className:"ml-auto"})]})}),t.jsxs(ke,{className:"w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg",align:"start",side:a?"bottom":"right",sideOffset:4,children:[t.jsx(ln,{className:"text-xs text-muted-foreground",children:"Switch Application"}),x.map(D=>t.jsxs(ie,{onClick:()=>n(D.name),className:"gap-2 p-2",children:[t.jsx("div",{className:"flex size-6 items-center justify-center rounded-sm border",children:D.icon?i.createElement(Be(D.icon),{className:"size-3"}):t.jsx(Me,{className:"size-3"})}),ee(D.label,l),h.name===D.name&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]},D.name)),t.jsx(it,{}),t.jsxs(ie,{className:"gap-2 p-2",onClick:()=>r(`/apps/${e}/create-app`),"data-testid":"add-app-btn",children:[t.jsx("div",{className:"flex size-6 items-center justify-center rounded-md border bg-background",children:t.jsx(Fe,{className:"size-4"})}),t.jsx("div",{className:"font-medium text-muted-foreground",children:"Add App"})]}),t.jsxs(ie,{className:"gap-2 p-2",onClick:()=>r(`/apps/${e}/edit-app/${e}`),"data-testid":"edit-app-btn",children:[t.jsx("div",{className:"flex size-6 items-center justify-center rounded-md border bg-background",children:t.jsx(ua,{className:"size-4"})}),t.jsx("div",{className:"font-medium text-muted-foreground",children:"Edit App"})]}),t.jsxs(ie,{className:"gap-2 p-2",onClick:()=>r(`/apps/${e}/system/apps`),"data-testid":"manage-all-apps-btn",children:[t.jsx("div",{className:"flex size-6 items-center justify-center rounded-md border bg-background",children:t.jsx(et,{className:"size-4"})}),t.jsx("div",{className:"font-medium text-muted-foreground",children:"Manage All Apps"})]})]})]}):t.jsxs(ye,{size:"lg",onClick:()=>r("/system"),"data-testid":"system-sidebar-header",children:[t.jsx("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-primary text-primary-foreground",children:t.jsx(et,{className:"size-4"})}),t.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[t.jsx("span",{className:"truncate font-semibold",children:"System Console"}),t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:"No apps configured"})]})]})})})}),t.jsx(cs,{children:h?t.jsxs(t.Fragment,{children:[w.length>1&&t.jsxs($e,{children:[t.jsxs(Xe,{className:"flex items-center gap-1.5",children:[t.jsx(tr,{className:"h-3.5 w-3.5"}),"Area"]}),t.jsx(ze,{children:t.jsx(Ae,{children:w.map(D=>{const G=Be(D.icon),W=D.id===j;return t.jsx(Te,{children:t.jsxs(ye,{isActive:W,tooltip:D.label,onClick:()=>y(D.id),children:[t.jsx(G,{className:"h-4 w-4"}),t.jsx("span",{children:D.label})]})},D.id)})})})]}),t.jsx($e,{className:"py-0",children:t.jsxs(ze,{className:"relative",children:[t.jsx(We,{className:"pointer-events-none absolute left-2 top-1/2 size-4 -translate-y-1/2 select-none opacity-70"}),t.jsx(ds,{placeholder:"Search navigation...",value:M,onChange:D=>N(D.target.value),className:"pl-8"})]})}),t.jsx(Xs,{items:k,basePath:O,evaluateVisibility:B,checkPermission:$,searchQuery:M,enablePinning:!0,onPinToggle:E,enableReorder:!0,onReorder:S,resolveObjectLabel:(D,G)=>c({name:D,label:G}),t:l}),d.length>0&&t.jsxs($e,{children:[t.jsxs(Xe,{className:"flex items-center gap-1.5 cursor-pointer select-none",onClick:()=>R(D=>!D),children:[t.jsx(ft,{className:`h-3 w-3 transition-transform duration-150 ${A?"rotate-90":""}`}),t.jsx(nr,{className:"h-3.5 w-3.5"}),"Recent"]}),A&&t.jsx(ze,{children:t.jsx(Ae,{children:d.slice(0,5).map(D=>t.jsx(Te,{children:t.jsx(ye,{asChild:!0,tooltip:D.label,children:t.jsxs(we,{to:D.href,children:[t.jsx("span",{className:"text-muted-foreground",children:D.type==="dashboard"?"📊":D.type==="report"?"📈":"📄"}),t.jsx("span",{className:"truncate",children:D.label})]})})},D.id))})})]}),u.length>0&&t.jsxs($e,{children:[t.jsxs(Xe,{className:"flex items-center gap-1.5",children:[t.jsx(ma,{className:"h-3.5 w-3.5"}),"Favorites"]}),t.jsx(ze,{children:t.jsx(Ae,{children:u.slice(0,8).map(D=>t.jsxs(Te,{children:[t.jsx(ye,{asChild:!0,tooltip:D.label,children:t.jsxs(we,{to:D.href,children:[t.jsx("span",{className:"text-muted-foreground",children:D.type==="dashboard"?"📊":D.type==="report"?"📈":D.type==="page"?"📄":"📋"}),t.jsx("span",{className:"truncate",children:D.label})]})}),t.jsx(us,{showOnHover:!0,onClick:G=>{G.stopPropagation(),m(D.id)},"aria-label":`Remove ${D.label} from favorites`,children:t.jsx(ar,{className:"h-3 w-3"})})]},D.id))})})]})]}):t.jsxs($e,{"data-testid":"system-fallback-nav",children:[t.jsxs(Xe,{className:"flex items-center gap-1.5",children:[t.jsx(et,{className:"h-3.5 w-3.5"}),"System"]}),t.jsx(ze,{children:t.jsx(Ae,{children:I.map(D=>{const G=Be(D.icon);return t.jsx(Te,{children:t.jsx(ye,{asChild:!0,tooltip:D.label,children:t.jsxs(we,{to:D.url||"/system",children:[t.jsx(G,{className:"h-4 w-4"}),t.jsx("span",{children:D.label})]})})},D.id)})})})]})}),t.jsx(ms,{children:t.jsx(Ae,{children:t.jsx(Te,{children:t.jsxs(Ce,{children:[t.jsx(Se,{asChild:!0,children:t.jsxs(ye,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[t.jsxs(cn,{className:"h-8 w-8 rounded-lg",children:[t.jsx(dn,{src:o?.image??"/avatars/user.jpg",alt:o?.name??"User"}),t.jsx(un,{className:"rounded-lg bg-primary text-primary-foreground",children:hn(o)})]}),t.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[t.jsx("span",{className:"truncate font-semibold",children:o?.name??"User"}),t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:o?.email??""})]}),t.jsx(gn,{className:"ml-auto size-4"})]})}),t.jsxs(ke,{className:"w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg",side:a?"bottom":"right",align:"end",sideOffset:4,children:[t.jsx(ln,{className:"p-0 font-normal",children:t.jsxs("div",{className:"flex items-center gap-2 px-1 py-1.5 text-left text-sm",children:[t.jsxs(cn,{className:"h-8 w-8 rounded-lg",children:[t.jsx(dn,{src:o?.image??"/avatars/user.jpg",alt:o?.name??"User"}),t.jsx(un,{className:"rounded-lg bg-primary text-primary-foreground",children:hn(o)})]}),t.jsxs("div",{className:"grid flex-1 text-left text-sm leading-tight",children:[t.jsx("span",{className:"truncate font-semibold",children:o?.name??"User"}),t.jsx("span",{className:"truncate text-xs text-muted-foreground",children:o?.email??""})]})]})}),t.jsx(it,{}),t.jsx(ps,{children:t.jsxs(ie,{onClick:()=>r(h?`/apps/${e}/system`:"/system"),children:[t.jsx(et,{className:"mr-2 h-4 w-4"}),"Settings"]})}),t.jsx(it,{}),t.jsxs(ie,{className:"text-destructive focus:text-destructive",onClick:()=>s(),children:[t.jsx(sr,{className:"mr-2 h-4 w-4"}),"Log out"]})]})]})})})})]}),a&&t.jsx("div",{className:"fixed bottom-0 left-0 right-0 z-50 flex items-center justify-around border-t bg-background/95 backdrop-blur-sm px-2 py-1 sm:hidden safe-area-bottom",children:(h?V:I).filter(D=>D.type!=="group").slice(0,5).map(D=>{const G=Be(D.icon),W=h?`/apps/${e}`:"";let Q=D.url||"#";return D.type==="object"?(Q=`${W}/${D.objectName}`,D.viewName&&(Q+=`/view/${D.viewName}`)):D.type==="dashboard"?Q=D.dashboardName?`${W}/dashboard/${D.dashboardName}`:"#":D.type==="page"&&(Q=D.pageName?`${W}/page/${D.pageName}`:"#"),t.jsxs(we,{to:Q,className:"flex flex-col items-center gap-0.5 px-2 py-1.5 text-muted-foreground hover:text-foreground transition-colors min-w-[44px] min-h-[44px] justify-center",children:[t.jsx(G,{className:"h-5 w-5"}),t.jsx("span",{className:"text-[10px] truncate max-w-[60px]",children:ee(D.label,l)})]},D.id)})})]})}function to(e){const{url:n,channel:a,autoReconnect:o=!0,reconnectInterval:s=1e3,maxReconnectAttempts:r=10,authToken:l}=e,[c,d]=i.useState("disconnected"),[u,m]=i.useState(null),[p,g]=i.useState([]),[x,h]=i.useState(null),F=i.useRef(null),v=i.useRef(0),b=i.useRef(null),S=i.useRef(new Map),E=i.useRef([]),f=i.useRef(!0),w=i.useRef(!1),j=i.useCallback(()=>{b.current!==null&&(clearTimeout(b.current),b.current=null)},[]),y=i.useCallback(A=>{for(;E.current.length>0;){const R=E.current.shift(),L={type:R.type,channel:a,data:R.data,timestamp:new Date().toISOString()};A.send(JSON.stringify(L))}},[a]),C=i.useCallback(()=>{if(typeof WebSocket>"u"){h(new Error("WebSocket is not available in this environment")),d("error");return}if(!n){h(new Error("WebSocket URL is required")),d("error");return}try{const L=new URL(n);if(L.protocol!=="ws:"&&L.protocol!=="wss:"){h(new Error("WebSocket URL must use ws: or wss: protocol")),d("error");return}}catch{h(new Error("Invalid WebSocket URL")),d("error");return}F.current&&(w.current=!0,F.current.close(),F.current=null),w.current=!1,d("connecting"),h(null);const A=l?`${n}?token=${encodeURIComponent(l)}&channel=${encodeURIComponent(a)}`:`${n}?channel=${encodeURIComponent(a)}`;let R;try{R=new WebSocket(A)}catch(L){if(!f.current)return;const B=L instanceof Error?L:new Error("Failed to create WebSocket connection");h(B),d("error");return}F.current=R,R.onopen=()=>{f.current&&(d("connected"),h(null),v.current=0,y(R))},R.onmessage=L=>{if(f.current)try{const B=JSON.parse(String(L.data));if(B.channel!==a)return;m(B),g($=>[...$,B]);const P=S.current.get(B.type);P&&P.forEach($=>$(B.data))}catch{}},R.onerror=()=>{f.current&&(h(new Error("WebSocket connection error")),d("error"))},R.onclose=()=>{if(f.current){if(F.current=null,w.current){d("disconnected");return}if(o&&v.current<r){d("reconnecting");const L=Math.min(s*Math.pow(2,v.current),3e4);v.current+=1,b.current=setTimeout(()=>{f.current&&C()},L)}else d("disconnected")}}},[n,a,l,o,s,r,y]),V=i.useCallback(()=>{j(),w.current=!0,v.current=0,F.current&&(F.current.close(),F.current=null),d("disconnected")},[j]),k=i.useCallback(()=>{j(),v.current=0,C()},[C,j]),M=i.useCallback((A,R)=>{const L=F.current;if(L&&L.readyState===WebSocket.OPEN){const B={type:A,channel:a,data:R,timestamp:new Date().toISOString()};L.send(JSON.stringify(B))}else E.current.push({type:A,data:R})},[a]),N=i.useCallback((A,R)=>(S.current.has(A)||S.current.set(A,new Set),S.current.get(A).add(R),()=>{const L=S.current.get(A);L&&(L.delete(R),L.size===0&&S.current.delete(A))}),[]);return i.useEffect(()=>(f.current=!0,n&&C(),()=>{f.current=!1,j(),w.current=!0,F.current&&(F.current.close(),F.current=null)}),[n,a,l]),{connectionState:c,isConnected:c==="connected",lastMessage:u,messages:p,send:M,subscribe:N,disconnect:V,reconnect:k,error:x}}let kn=0;function no(){return kn+=1,`conflict-${Date.now()}-${kn}`}let Dn=0;function nt(){return Dn+=1,`ver-${Date.now()}-${Dn}`}function ao(e,n,a){const[o,s]=i.useState([]),[r,l]=i.useState([]),c=i.useMemo(()=>o.length===0?0:o[o.length-1].version,[o]),d=r.length>0,u=i.useCallback((v,b)=>{s(S=>{const E=S.length===0?1:S[S.length-1].version+1,f={id:nt(),version:E,timestamp:new Date().toISOString(),userId:e,userName:n,changes:v,message:b};return[...S,f]})},[e,n]),m=i.useCallback((v,b,S)=>{l(E=>{const f=E.find(j=>j.id===v);if(!f)return E;let w;switch(b){case"local":w=f.localValue;break;case"remote":w=f.remoteValue;break;case"merge":w=S??f.localValue;break}return s(j=>{const y=j.length===0?1:j[j.length-1].version+1,C={id:nt(),version:y,timestamp:new Date().toISOString(),userId:e,userName:n,changes:{[f.field]:{before:f.baseValue,after:w}},message:`Resolved conflict on "${f.field}" using ${b} strategy`};return[...j,C]}),E.filter(j=>j.id!==v)})},[e,n]),p=i.useCallback(v=>{l(b=>{if(b.length===0)return b;const S={};for(const E of b)S[E.field]={before:E.baseValue,after:v==="local"?E.localValue:E.remoteValue};return s(E=>{const f=E.length===0?1:E[E.length-1].version+1,w={id:nt(),version:f,timestamp:new Date().toISOString(),userId:e,userName:n,changes:S,message:`Resolved all conflicts using ${v} strategy`};return[...E,w]}),[]})},[e,n]),g=i.useCallback(v=>{const b=o.findIndex(w=>w.id===v);if(b===-1)return null;const S={};for(let w=0;w<=b;w++){const j=o[w];for(const[y,C]of Object.entries(j.changes))S[y]=C.after}const E={},f={};for(const w of o)for(const[j,y]of Object.entries(w.changes))f[j]=y.after;for(const[w,j]of Object.entries(S))f[w]!==j&&(E[w]={before:f[w],after:j});return Object.keys(E).length>0&&s(w=>{const j=w.length===0?1:w[w.length-1].version+1,y={id:nt(),version:j,timestamp:new Date().toISOString(),userId:e,userName:n,changes:E,message:`Reverted to version ${o[b].version}`};return[...w,y]}),S},[o,e,n]),x=i.useCallback((v,b)=>{const S=o.findIndex(M=>M.id===v),E=o.findIndex(M=>M.id===b);if(S===-1||E===-1)return null;const[f,w]=S<E?[S,E]:[E,S],j=M=>{const N={};for(let A=0;A<=M;A++)for(const[R,L]of Object.entries(o[A].changes))N[R]=L.after;return N},y=j(f),C=j(w),V=new Set([...Object.keys(y),...Object.keys(C)]),k={};for(const M of V){const N=y[M],A=C[M];N!==A&&(k[M]={before:N,after:A})}return k},[o]),h=i.useCallback(v=>{const b={...v,id:no()};l(S=>[...S,b])},[]),F=i.useCallback(()=>{s([]),l([])},[]);return{versions:o,currentVersion:c,conflicts:r,hasConflicts:d,recordVersion:u,resolveConflict:m,resolveAllConflicts:p,revertToVersion:g,compareVersions:x,addConflict:h,clearHistory:F}}const so={sm:24,md:32,lg:40},ro={active:"#22c55e",idle:"#f59e0b",away:"#94a3b8"};function oo(e){return e.split(" ").map(n=>n[0]).join("").toUpperCase().slice(0,2)}function io({users:e,maxVisible:n=5,size:a="md",showStatus:o=!0,className:s}){const r=so[a],l=Math.round(r*.3),c=Math.round(r*.35),d=Math.max(8,Math.round(r*.28)),u=i.useMemo(()=>e.slice(0,n),[e,n]),m=Math.max(0,e.length-n),p={display:"inline-flex",alignItems:"center",flexDirection:"row-reverse",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'},g={width:`${r}px`,height:`${r}px`,borderRadius:"50%",border:"2px solid #fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${c}px`,fontWeight:600,color:"#fff",position:"relative",flexShrink:0,overflow:"hidden",boxSizing:"border-box"},x={...g,backgroundColor:"#e2e8f0",color:"#475569",marginLeft:`-${l}px`},h={position:"absolute",bottom:"-1px",right:"-1px",width:`${d}px`,height:`${d}px`,borderRadius:"50%",border:"2px solid #fff",boxSizing:"border-box"},F=i.useMemo(()=>[...u].reverse(),[u]);return ae.createElement("div",{style:p,className:s,role:"group","aria-label":`${e.length} user${e.length!==1?"s":""} present`},m>0&&ae.createElement("div",{key:"overflow",style:x,title:`${m} more user${m!==1?"s":""}`},`+${m}`),F.map((v,b)=>ae.createElement("div",{key:v.userId,style:{...g,backgroundColor:v.color,marginLeft:b>0||m>0?`-${l}px`:"0"},title:`${v.userName} (${v.status})`},v.avatar?ae.createElement("img",{src:v.avatar,alt:v.userName,style:{width:"100%",height:"100%",objectFit:"cover"}}):oo(v.userName),o&&ae.createElement("span",{style:{...h,backgroundColor:ro[v.status]}}))))}const lo={theme:"system",setTheme:()=>null},_a=i.createContext(lo);function co({children:e,defaultTheme:n="system",storageKey:a="vite-ui-theme",...o}){const[s,r]=i.useState(()=>localStorage.getItem(a)||n);i.useEffect(()=>{const c=window.document.documentElement;if(c.classList.remove("light","dark"),s==="system"){const d=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";c.classList.add(d);return}c.classList.add(s)},[s]);const l={theme:s,setTheme:c=>{localStorage.setItem(a,c),r(c)}};return t.jsx(_a.Provider,{...o,value:l,children:e})}const Qt=()=>{const e=i.useContext(_a);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};function uo(){const{theme:e,setTheme:n}=Qt(),{t:a}=me();return t.jsxs(Ce,{children:[t.jsx(Se,{asChild:!0,children:t.jsxs(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[t.jsx(St,{className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),t.jsx(kt,{className:"absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100"}),t.jsx("span",{className:"sr-only",children:a("console.theme.toggle")})]})}),t.jsxs(ke,{align:"end",children:[t.jsxs(ie,{onClick:()=>n("light"),className:"gap-2",children:[t.jsx(St,{className:"h-4 w-4"}),a("console.theme.light"),e==="light"&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]}),t.jsxs(ie,{onClick:()=>n("dark"),className:"gap-2",children:[t.jsx(kt,{className:"h-4 w-4"}),a("console.theme.dark"),e==="dark"&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]}),t.jsxs(ie,{onClick:()=>n("system"),className:"gap-2",children:[t.jsx(pa,{className:"h-4 w-4"}),a("console.theme.system"),e==="system"&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]})]})]})}const mo=[{code:"en",label:"English"},{code:"zh",label:"中文"},{code:"ja",label:"日本語"},{code:"ko",label:"한국어"},{code:"de",label:"Deutsch"},{code:"fr",label:"Français"},{code:"es",label:"Español"},{code:"pt",label:"Português"},{code:"ru",label:"Русский"},{code:"ar",label:"العربية"}];function po(){const{t:e,language:n,changeLanguage:a}=me();return t.jsxs(Ce,{children:[t.jsx(Se,{asChild:!0,children:t.jsxs(Y,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[t.jsx(rr,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:e("console.localeSwitcher.label")})]})}),t.jsx(ke,{align:"end",className:"max-h-72 overflow-y-auto",children:mo.map(o=>t.jsxs(ie,{onClick:()=>a(o.code),className:"gap-2",children:[o.label,n===o.code&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]},o.code))})]})}const ho={connected:{label:"Connected",color:"text-green-500",icon:Jt},connecting:{label:"Connecting...",color:"text-yellow-500",icon:dt},reconnecting:{label:"Reconnecting...",color:"text-yellow-500",icon:dt},disconnected:{label:"Disconnected",color:"text-muted-foreground",icon:fn},error:{label:"Connection Error",color:"text-destructive",icon:fn}};function go({state:e,className:n}){const a=ho[e],o=a.icon,[s,r]=i.useState(!1);return i.useEffect(()=>{if(e==="connected"){r(!0);const l=setTimeout(()=>r(!1),2e3);return()=>clearTimeout(l)}r(!1)},[e]),e==="connected"&&!s?null:t.jsxs("div",{className:q("flex items-center gap-1.5 text-xs font-medium px-2 py-1 rounded-md transition-opacity duration-300",a.color,e==="connected"&&"bg-green-500/10",e==="error"&&"bg-destructive/10",e==="reconnecting"&&"bg-yellow-500/10",n),title:a.label,children:[t.jsx(o,{className:q("h-3.5 w-3.5",(e==="connecting"||e==="reconnecting")&&"animate-spin")}),t.jsx("span",{className:"hidden sm:inline",children:a.label})]})}const Nt={create:{icon:Fe,color:"text-green-500"},update:{icon:ua,color:"text-blue-500"},delete:{icon:lr,color:"text-red-500"},comment:{icon:ir,color:"text-amber-500"}};function fo(e){const n=new Date(e).getTime();if(Number.isNaN(n))return"";const a=Math.floor((Date.now()-n)/1e3);if(a<60)return`${Math.max(a,0)}s ago`;const o=Math.floor(a/60);if(o<60)return`${o}m ago`;const s=Math.floor(o/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}function xo({activities:e=[],className:n}){const[a,o]=i.useState(!1),[s,r]=i.useState(!1),[l,c]=i.useState({create:!0,update:!0,delete:!0,comment:!0}),d=m=>{c(p=>({...p,[m]:!p[m]}))},u=e.filter(m=>l[m.type]);return t.jsxs(hs,{open:a,onOpenChange:o,children:[t.jsx(gs,{asChild:!0,children:t.jsxs(Y,{variant:"ghost",size:"icon",className:n??"h-8 w-8","aria-label":"Activity feed",children:[t.jsx(xn,{className:"h-4 w-4"}),e.length>0&&t.jsx("span",{className:"absolute -top-0.5 -right-0.5 h-3.5 w-3.5 rounded-full bg-primary text-[9px] font-bold text-primary-foreground flex items-center justify-center",children:e.length>9?"9+":e.length})]})}),t.jsxs(fs,{side:"right",className:"w-80 sm:w-96",children:[t.jsx(xs,{children:t.jsxs(bs,{className:"flex items-center justify-between",children:["Recent Activity",t.jsxs(Y,{variant:s?"secondary":"ghost",size:"sm",className:"h-7 px-2",onClick:()=>r(!s),children:[t.jsx(or,{className:"h-3.5 w-3.5 mr-1"}),"Filter"]})]})}),s&&t.jsx("div",{className:"flex flex-wrap gap-1.5 mt-3 px-1",children:Object.keys(Nt).map(m=>{const{icon:p,color:g}=Nt[m],x=l[m];return t.jsxs(js,{variant:x?"default":"outline",className:"cursor-pointer select-none gap-1 capitalize",onClick:()=>d(m),children:[t.jsx(p,{className:`h-3 w-3 ${x?"":g}`}),m]},m)})}),u.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-16 text-muted-foreground",children:[t.jsx(xn,{className:"h-8 w-8 opacity-40"}),t.jsx("p",{className:"text-sm",children:"No recent activity"})]}):t.jsx("ul",{className:"mt-4 space-y-1 overflow-y-auto max-h-[calc(100vh-8rem)]",children:u.map(m=>{const{icon:p,color:g}=Nt[m.type];return t.jsxs("li",{className:"flex items-start gap-3 rounded-md px-2 py-2 hover:bg-muted/50 transition-colors",children:[t.jsx("span",{className:`mt-0.5 shrink-0 ${g}`,children:t.jsx(p,{className:"h-4 w-4"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("p",{className:"text-sm leading-snug",children:m.description}),t.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[m.user," · ",fo(m.timestamp)]})]})]},m.id)})})]})]})}function He(e){return e.replace(/[-_]/g," ").replace(/\b\w/g,n=>n.toUpperCase())}const bo=[{userId:"u1",userName:"Alice Chen",color:"#3498db",status:"active",lastActivity:new Date().toISOString()},{userId:"u2",userName:"Bob Smith",color:"#2ecc71",status:"idle",lastActivity:new Date().toISOString()},{userId:"u3",userName:"Carol Li",color:"#e74c3c",status:"active",lastActivity:new Date().toISOString()}];function jo({appName:e,objects:n,connectionState:a,presenceUsers:o,activities:s}){const r=Kn(),l=Ge(),{isOnline:c}=Bs(),d=Qe(),{t:u}=me(),[m,p]=i.useState(null),[g,x]=i.useState(null),h=i.useCallback(async()=>{if(d)try{const[y,C]=await Promise.all([d.find("sys_presence").catch(()=>({data:[]})),d.find("sys_activity",{$orderby:{timestamp:"desc"},$top:20}).catch(()=>({data:[]}))]);if(y.data?.length){const k=y.data.filter(M=>typeof M.userId=="string");k.length&&p(k)}if(C.data?.length){const k=C.data.filter(M=>typeof M.type=="string");k.length&&x(k)}}catch{}},[d]);i.useEffect(()=>{h()},[h]);const F=o??m??bo,v=s??g??[],b=r.pathname.split("/").filter(Boolean),S=l.appName||b[1],E=b[2],f=`/apps/${S}`,w=n.map(y=>({label:y.label||y.name,href:`${f}/${y.name}`})),j=[{label:e,href:f}];if(E==="dashboard")j.push({label:u("console.breadcrumb.dashboards"),href:`${j[0].href}`}),b[3]&&j.push({label:He(b[3])});else if(E==="page")j.push({label:u("console.breadcrumb.pages"),href:`${j[0].href}`}),b[3]&&j.push({label:He(b[3])});else if(E==="report")j.push({label:u("console.breadcrumb.reports"),href:`${j[0].href}`}),b[3]&&j.push({label:He(b[3])});else if(E==="system")j.push({label:u("console.breadcrumb.system")}),b[3]&&j.push({label:He(b[3])});else if(E){const y=n.find(C=>C.name===E);if(y)if(j.push({label:y.label||E,href:`/apps/${S}/${E}`,siblings:w}),b[3]==="record"&&b[4]){const C=b[4].length>12?`${b[4].slice(0,8)}…`:b[4];j.push({label:`#${C}`})}else b[3]==="view"&&b[4]&&j.push({label:He(b[4])})}return t.jsxs("div",{className:"flex items-center justify-between w-full h-full px-2 sm:px-3 md:px-4 gap-1.5 sm:gap-2",children:[t.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 min-w-0 flex-1",children:[t.jsx(ys,{className:"md:hidden shrink-0"}),t.jsx(vs,{orientation:"vertical",className:"h-4 md:hidden shrink-0"}),t.jsx(ws,{className:"hidden sm:flex min-w-0",children:t.jsx(Ns,{children:j.map((y,C)=>t.jsxs(i.Fragment,{children:[C>0&&t.jsx(Cs,{}),t.jsx(Ss,{children:C===j.length-1||!y.href?y.siblings&&y.siblings.length>1?t.jsxs(Ce,{children:[t.jsxs(Se,{className:"flex items-center gap-1 text-sm font-medium",children:[y.label,t.jsx(Dt,{className:"h-3 w-3"})]}),t.jsx(ke,{align:"start",className:"max-h-64 overflow-y-auto",children:y.siblings.map(V=>t.jsx(ie,{asChild:!0,children:t.jsx(we,{to:V.href,className:"w-full",children:V.label})},V.href))})]}):t.jsx(ks,{className:"truncate max-w-[200px]",children:y.label}):y.siblings&&y.siblings.length>1?t.jsxs(Ce,{children:[t.jsxs(Se,{className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[y.label,t.jsx(Dt,{className:"h-3 w-3"})]}),t.jsx(ke,{align:"start",className:"max-h-64 overflow-y-auto",children:y.siblings.map(V=>t.jsx(ie,{asChild:!0,children:t.jsx(we,{to:V.href,className:"w-full",children:V.label})},V.href))})]}):t.jsx(Ds,{asChild:!0,children:t.jsx(we,{to:y.href,className:"truncate max-w-[150px]",children:y.label})})})]},C))})}),t.jsx("span",{className:"text-sm font-medium sm:hidden truncate min-w-0",children:j[j.length-1]?.label||e})]}),t.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1 md:gap-2 shrink-0",children:[!c&&t.jsxs("div",{className:"flex items-center gap-1 px-2 py-1 rounded-full bg-yellow-100 dark:bg-yellow-900/30 text-yellow-800 dark:text-yellow-200 text-xs font-medium",children:[t.jsx("span",{className:"h-2 w-2 rounded-full bg-yellow-500 animate-pulse"}),"Offline"]}),a&&t.jsx(go,{state:a}),F.length>0&&t.jsx("div",{className:"hidden md:flex items-center shrink-0",title:"Users currently online",children:t.jsx(io,{users:F,size:"sm",maxVisible:3,showStatus:!0})}),t.jsxs("button",{onClick:()=>document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0})),className:"hidden lg:flex relative items-center gap-2 w-50 xl:w-70 h-8 px-3 text-sm rounded-md border bg-muted/50 text-muted-foreground hover:bg-muted transition-colors",children:[t.jsx(We,{className:"h-4 w-4"}),t.jsx("span",{className:"flex-1 text-left",children:"Search..."}),t.jsxs("kbd",{className:"pointer-events-none inline-flex h-5 items-center gap-0.5 rounded border bg-muted px-1.5 text-[10px] font-medium text-muted-foreground",children:[t.jsx("span",{className:"text-xs",children:"⌘"}),"K"]})]}),t.jsx(Y,{variant:"ghost",size:"icon",className:"lg:hidden h-8 w-8 shrink-0",onClick:()=>document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0})),children:t.jsx(We,{className:"h-4 w-4"})}),t.jsx("div",{className:"hidden sm:flex shrink-0 relative",children:t.jsx(xo,{activities:v})}),t.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8 hidden md:flex shrink-0",children:t.jsx(cr,{className:"h-4 w-4"})}),t.jsx("div",{className:"hidden sm:flex shrink-0",children:t.jsx(uo,{})}),t.jsx("div",{className:"hidden sm:flex shrink-0",children:t.jsx(po,{})})]})]})}const yo=768,vo=1024;function wo(){const{setOpen:e,isMobile:n}=Jn();i.useEffect(()=>{function a(){const o=window.innerWidth;o>=yo&&o<vo&&e(!1)}return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[e,n])}function No({children:e}){return wo(),t.jsx(t.Fragment,{children:e})}function Co({children:e,activeAppName:n,activeApp:a,onAppChange:o,objects:s,connectionState:r}){return t.jsx(er,{sidebar:t.jsx(eo,{activeAppName:n,onAppChange:o}),navbar:t.jsx(jo,{appName:ee(a?.label)||n,objects:s,connectionState:r}),className:"p-0 overflow-hidden bg-muted/5",branding:a?.branding?{primaryColor:a.branding.primaryColor,accentColor:a.branding.accentColor,favicon:a.branding.favicon,logo:a.branding.logo,title:a.label?`${ee(a.label)} — ObjectStack Console`:void 0}:void 0,children:t.jsx(No,{children:e})})}function Fn(e){if(!e)return Me;if(je[e])return je[e];const n=e.split("-").map(a=>a.charAt(0).toUpperCase()+a.slice(1)).join("");return je[n]?je[n]:Me}function So({apps:e,activeApp:n,objects:a,onAppChange:o}){const[s,r]=i.useState(!1),l=Pe(),{appName:c}=Ge(),{setTheme:d}=Qt(),{evaluator:u}=Ca(),{t:m}=me();i.useEffect(()=>{const h=F=>{F.key==="k"&&(F.metaKey||F.ctrlKey)&&(F.preventDefault(),r(v=>!v))};return document.addEventListener("keydown",h),()=>document.removeEventListener("keydown",h)},[]);const p=`/apps/${c||n?.name}`,g=i.useCallback(h=>{r(!1),h()},[]),x=Ea(n?.navigation||[]).filter(h=>ut(h.visible??h.visibleOn,u));return t.jsxs(Fs,{open:s,onOpenChange:r,children:[t.jsx(_s,{placeholder:m("console.commandPalette.placeholder")}),t.jsxs(Es,{children:[t.jsx(As,{children:m("console.commandPalette.noResults")}),x.filter(h=>h.type==="object").length>0&&t.jsx(ve,{heading:m("console.commandPalette.objects"),children:x.filter(h=>h.type==="object").map(h=>{const F=Fn(h.icon);return t.jsxs(pe,{value:`object ${ee(h.label,m)} ${h.objectName}`,onSelect:()=>g(()=>l(`${p}/${h.objectName}`)),children:[t.jsx(F,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:ee(h.label,m)})]},h.id)})}),x.filter(h=>h.type==="dashboard").length>0&&t.jsx(ve,{heading:m("console.commandPalette.dashboards"),children:x.filter(h=>h.type==="dashboard").map(h=>t.jsxs(pe,{value:`dashboard ${ee(h.label,m)} ${h.dashboardName}`,onSelect:()=>g(()=>l(`${p}/dashboard/${h.dashboardName}`)),children:[t.jsx(ha,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:ee(h.label,m)})]},h.id))}),x.filter(h=>h.type==="page").length>0&&t.jsx(ve,{heading:m("console.commandPalette.pages"),children:x.filter(h=>h.type==="page").map(h=>t.jsxs(pe,{value:`page ${ee(h.label,m)} ${h.pageName}`,onSelect:()=>g(()=>l(`${p}/page/${h.pageName}`)),children:[t.jsx(dr,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:ee(h.label,m)})]},h.id))}),x.filter(h=>h.type==="report").length>0&&t.jsx(ve,{heading:m("console.commandPalette.reports"),children:x.filter(h=>h.type==="report").map(h=>t.jsxs(pe,{value:`report ${ee(h.label,m)} ${h.reportName}`,onSelect:()=>g(()=>l(`${p}/report/${h.reportName}`)),children:[t.jsx(ga,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:ee(h.label,m)})]},h.id))}),e.filter(h=>h.active!==!1).length>1&&t.jsxs(t.Fragment,{children:[t.jsx(jt,{}),t.jsx(ve,{heading:m("console.commandPalette.switchApp"),children:e.filter(h=>h.active!==!1).map(h=>{const F=Fn(h.icon);return t.jsxs(pe,{value:`app ${ee(h.label,m)} ${h.name}`,onSelect:()=>g(()=>o(h.name)),children:[t.jsx(F,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:ee(h.label,m)}),h.name===n?.name&&t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:m("console.commandPalette.current")})]},h.name)})})]}),t.jsx(jt,{}),t.jsxs(ve,{heading:m("console.commandPalette.preferences"),children:[t.jsxs(pe,{value:"theme light",onSelect:()=>g(()=>d("light")),children:[t.jsx(St,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:m("console.commandPalette.lightTheme")})]}),t.jsxs(pe,{value:"theme dark",onSelect:()=>g(()=>d("dark")),children:[t.jsx(kt,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:m("console.commandPalette.darkTheme")})]}),t.jsxs(pe,{value:"theme system",onSelect:()=>g(()=>d("system")),children:[t.jsx(pa,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:m("console.commandPalette.systemTheme")})]})]}),t.jsx(jt,{}),t.jsxs(ve,{heading:m("console.commandPalette.actions"),children:[t.jsxs(pe,{value:"create new app application",onSelect:()=>g(()=>l(`${p}/create-app`)),children:[t.jsx(Fe,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:m("console.commandPalette.createApp")})]}),t.jsxs(pe,{value:"search all results full page",onSelect:()=>g(()=>l(`${p}/search`)),children:[t.jsx(We,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:m("console.commandPalette.openFullSearch")})]})]})]})]})}function Ea(e){const n=[];for(const a of e)a.type==="group"&&a.children?n.push(...Ea(a.children)):n.push(a);return n}function ko({error:e,onReset:n}){const{t:a}=me();return t.jsx("div",{className:"flex h-full items-center justify-center p-8",children:t.jsxs("div",{className:"max-w-md text-center",children:[t.jsxs(mt,{children:[t.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10",children:t.jsx(fa,{className:"h-6 w-6 text-destructive"})}),t.jsx(pt,{children:a("console.errors.somethingWentWrong")}),t.jsx(ht,{className:"mb-4",children:e.message||a("console.errors.unexpectedError")}),t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsxs(Y,{variant:"outline",size:"sm",onClick:n,className:"gap-2",children:[t.jsx(ur,{className:"h-4 w-4"}),a("console.errors.tryAgain")]}),t.jsxs(Y,{variant:"ghost",size:"sm",onClick:()=>{window.location.href="/"},className:"gap-2",children:[t.jsx(mr,{className:"h-4 w-4"}),a("console.errors.goHome")]})]})]}),!1]})})}class Do extends i.Component{constructor(n){super(n),this.state={hasError:!1,error:null}}static getDerivedStateFromError(n){return{hasError:!0,error:n}}componentDidCatch(n,a){console.error("[ErrorBoundary] Caught error:",n,a),this.props.onError?.(n,a)}resetErrorBoundary=()=>{this.setState({hasError:!1,error:null})};render(){return this.state.hasError&&this.state.error?this.props.fallback?typeof this.props.fallback=="function"?this.props.fallback({error:this.state.error,reset:this.resetErrorBoundary}):this.props.fallback:t.jsx(ko,{error:this.state.error,onReset:this.resetErrorBoundary}):this.props.children}}function de({message:e}){const{t:n}=me(),[a,o]=i.useState(0),s=i.useMemo(()=>[n("console.loadingSteps.connecting"),n("console.loadingSteps.loadingConfig"),n("console.loadingSteps.preparingWorkspace")],[n]);return i.useEffect(()=>{if(e)return;const r=setInterval(()=>{o(l=>Math.min(l+1,s.length-1))},1200);return()=>clearInterval(r)},[e,s.length]),t.jsx("div",{className:"flex flex-col items-center justify-center h-screen bg-background",children:t.jsxs("div",{className:"flex flex-col items-center gap-6",children:[t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-0 bg-primary/20 rounded-2xl blur-xl animate-pulse"}),t.jsx("div",{className:"relative bg-linear-to-br from-primary to-primary/80 p-4 rounded-2xl shadow-lg",children:t.jsx(Me,{className:"h-10 w-10 text-primary-foreground"})})]}),t.jsxs("div",{className:"text-center space-y-2",children:[t.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:n("console.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:n("console.initializing")})]}),e?t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 bg-muted/50 rounded-full",children:[t.jsx(Ts,{className:"h-4 w-4 text-primary"}),t.jsx("span",{className:"text-sm text-muted-foreground",children:e})]}):t.jsx("div",{className:"flex flex-col gap-2 w-64",children:s.map((r,l)=>t.jsxs("div",{className:"flex items-center gap-2.5 text-sm transition-opacity duration-300",style:{opacity:l<=a?1:.3},children:[l<a?t.jsx(Jt,{className:"h-4 w-4 text-primary shrink-0"}):l===a?t.jsx(dt,{className:"h-4 w-4 text-primary shrink-0 animate-spin"}):t.jsx("div",{className:"h-4 w-4 rounded-full border border-muted-foreground/30 shrink-0"}),t.jsx("span",{className:l<=a?"text-foreground":"text-muted-foreground",children:r})]},r))})]})})}const Fo=ae.lazy(()=>J(()=>import("./ChartImpl-DYQ9eXJz.js"),__vite__mapDeps([0,1,2,3,4]))),_o=ae.lazy(()=>J(()=>import("./AdvancedChartImpl-BvIFxlPf.js"),__vite__mapDeps([5,1,2,3,4]))),Eo=({schema:e})=>t.jsx(i.Suspense,{fallback:t.jsx(Ke,{className:"w-full h-48 sm:h-64 md:h-80 lg:h-[400px]"}),children:t.jsx(Fo,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),_e=({schema:e})=>{const n=ae.useMemo(()=>{let a=e.series,o=e.xAxisKey,s=e.config;if(o||(e.index?o=e.index:e.category&&(o=e.category)),a||(e.categories?a=e.categories.map(r=>({dataKey:r})):e.value&&(a=[{dataKey:e.value}])),!s&&a){const r=e.colors||["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))"],l={};a.forEach((c,d)=>{l[c.dataKey]={label:c.dataKey,color:r[d%r.length]}}),s=l}return{chartType:e.chartType,data:Array.isArray(e.data)?e.data:[],config:s,xAxisKey:o,series:a,className:e.className}},[e]);return t.jsx(i.Suspense,{fallback:t.jsx(Ke,{className:"w-full h-48 sm:h-64 md:h-80 lg:h-[400px]"}),children:t.jsx(_o,{chartType:n.chartType,data:n.data,config:n.config,xAxisKey:n.xAxisKey,series:n.series,className:n.className})})};function Ao(e,n){const{field:a,function:o,groupBy:s}=n,r={};for(const l of e){const c=String(l[s]??"Unknown");r[c]||(r[c]=[]),r[c].push(l)}return Object.entries(r).map(([l,c])=>{const d=c.map(m=>Number(m[a])||0);let u;switch(o){case"count":u=c.length;break;case"avg":u=d.length>0?d.reduce((m,p)=>m+p,0)/d.length:0;break;case"min":u=d.length>0?Math.min(...d):0;break;case"max":u=d.length>0?Math.max(...d):0;break;case"sum":default:u=d.reduce((m,p)=>m+p,0);break}return{[s]:l,[a]:u}})}const Xt=e=>{const{schema:n}=e,a=i.useContext(Hs),o=e.dataSource||a?.dataSource,s=Yt(n.bind),[r,l]=i.useState([]),[c,d]=i.useState(!1);i.useEffect(()=>{let g=!0;const x=async()=>{if(!(!o||!n.objectName)){g&&d(!0);try{let h;if(n.aggregate&&typeof o.aggregate=="function"){const F=await o.aggregate(n.objectName,{field:n.aggregate.field,function:n.aggregate.function,groupBy:n.aggregate.groupBy,filter:n.filter});h=Array.isArray(F)?F:[]}else if(typeof o.find=="function"){const F=await o.find(n.objectName,{$filter:n.filter});h=Ie(F),n.aggregate&&h.length>0&&(h=Ao(h,n.aggregate))}else return;g&&l(h)}catch(h){console.error("[ObjectChart] Fetch error:",h)}finally{g&&d(!1)}}};return n.objectName&&!s&&!n.data&&x(),()=>{g=!1}},[n.objectName,o,s,n.data,n.filter,n.aggregate]);const u=s||n.data||r,m=Array.isArray(u)?u:[],p={...n,data:m};return c&&m.length===0?t.jsx("div",{className:"flex items-center justify-center text-muted-foreground text-sm p-4 "+(n.className||""),children:"Loading chart data…"}):!o&&n.objectName&&m.length===0?t.jsxs("div",{className:"flex items-center justify-center text-muted-foreground text-sm p-4 "+(n.className||""),children:['No data source available for "',n.objectName,'"']}):t.jsx(_e,{...e,schema:p})};Z.register("object-chart",Xt,{namespace:"plugin-charts",label:"Object Chart",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"data",type:"array",label:"Data",description:"Optional static data"},{name:"filter",type:"array",label:"Filter"},{name:"aggregate",type:"object",label:"Aggregate",description:"Aggregation config: { field, function, groupBy }"}]});Z.register("bar-chart",Eo,{namespace:"plugin-charts",label:"Bar Chart",category:"plugin",inputs:[{name:"data",type:"array",label:"Data",required:!0},{name:"dataKey",type:"string",label:"Data Key",defaultValue:"value"},{name:"xAxisKey",type:"string",label:"X-Axis Key",defaultValue:"name"},{name:"height",type:"number",label:"Height",defaultValue:400},{name:"color",type:"color",label:"Color",defaultValue:"#8884d8"}],defaultProps:{data:[{name:"Jan",value:400},{name:"Feb",value:300},{name:"Mar",value:600},{name:"Apr",value:800},{name:"May",value:500}],dataKey:"value",xAxisKey:"name",height:400,color:"#8884d8"}});Z.register("chart",Xt,{namespace:"view",category:"view",label:"Chart",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"type",type:"string",label:"Chart Type"},{name:"categoryField",type:"string",label:"Category Field"},{name:"valueField",type:"string",label:"Value Field"}]});Z.register("chart",_e,{namespace:"plugin-charts",label:"Chart",category:"plugin",inputs:[{name:"chartType",type:"enum",label:"Chart Type",enum:[{label:"Bar",value:"bar"},{label:"Line",value:"line"},{label:"Area",value:"area"},{label:"Pie",value:"pie"},{label:"Donut",value:"donut"},{label:"Radar",value:"radar"},{label:"Scatter",value:"scatter"}],defaultValue:"bar"},{name:"data",type:"code",label:"Data (JSON)",required:!0},{name:"config",type:"code",label:"Config (JSON)"},{name:"xAxisKey",type:"string",label:"X Axis Key",defaultValue:"name"},{name:"series",type:"code",label:"Series (JSON Array)",required:!0},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{chartType:"bar",data:[{name:"Jan",sales:400,revenue:240},{name:"Feb",sales:300,revenue:139},{name:"Mar",sales:600,revenue:380},{name:"Apr",sales:800,revenue:430},{name:"May",sales:500,revenue:220}],config:{sales:{label:"Sales",color:"#8884d8"},revenue:{label:"Revenue",color:"#82ca9d"}},xAxisKey:"name",series:[{dataKey:"sales"},{dataKey:"revenue"}]}});Z.register("chart:bar",_e,{namespace:"plugin-charts",label:"Bar Chart (Alias)",category:"plugin",defaultProps:{chartType:"bar"}});Z.register("pie-chart",_e,{namespace:"plugin-charts",label:"Pie Chart",category:"plugin",defaultProps:{chartType:"pie"}});Z.register("donut-chart",_e,{namespace:"plugin-charts",label:"Donut Chart",category:"plugin",defaultProps:{chartType:"donut"}});Z.register("radar-chart",_e,{namespace:"plugin-charts",label:"Radar Chart",category:"plugin",defaultProps:{chartType:"radar"}});Z.register("scatter-chart",_e,{namespace:"plugin-charts",label:"Scatter Chart",category:"plugin",defaultProps:{chartType:"scatter"}});const To=({schema:e,dataSource:n,className:a,onRowClick:o,onCardClick:s,...r})=>{const[l,c]=i.useState([]),[d,u]=i.useState(null),[m,p]=i.useState(!1),[g,x]=i.useState(null),h=Yt(e.bind);i.useEffect(()=>{let j=!0;return(async()=>{if(!(!n||!e.objectName))try{const C=await n.getObjectSchema(e.objectName);j&&u(C)}catch(C){console.warn("Failed to fetch object def",C)}})(),()=>{j=!1}},[e.objectName,n]),i.useEffect(()=>{let j=!0;const y=async()=>{if(!(!n||typeof n.find!="function"||!e.objectName)){j&&p(!0);try{const C=Ye(d?.fields),V=await n.find(e.objectName,{options:{$top:100},$filter:e.filter,...C.length>0?{$expand:C}:{}}),k=Ie(V);console.log(`[ObjectKanban] Extracted data (length: ${k.length})`),j&&c(k)}catch(C){console.error("[ObjectKanban] Fetch error:",C),j&&x(C)}finally{j&&p(!1)}}};return e.objectName&&!h&&!e.data&&!r.data&&y(),()=>{j=!1}},[e.objectName,n,h,e.data,e.filter,r.data,d]);const F=r.data||h||e.data||l,v=i.useMemo(()=>{if(!Array.isArray(F))return[];let j=e.cardTitle||e.titleField;if(!j&&d){if(d.titleFormat){const C=/\{(.+?)\}/.exec(d.titleFormat);C&&(j=C[1])}!j&&d.NAME_FIELD_KEY&&(j=d.NAME_FIELD_KEY)}const y=["name","title","subject","label","display_name"];return F.map(C=>{let V=j?C[j]:void 0;if(!V){for(const k of y)if(C[k]){V=C[k];break}}return{...C,id:C.id||C._id,title:V||"Untitled"}})},[F,e,d]),b=i.useMemo(()=>{if(e.columns&&e.columns.length>0)if(typeof e.columns[0]=="string"){if(!e.groupBy)return e.columns.map(j=>({id:j,title:j}))}else return e.columns;if(e.groupBy&&d?.fields?.[e.groupBy]?.options)return d.fields[e.groupBy].options.map(j=>({id:j.value,title:j.label}));if(e.groupBy&&v.length>0){const j=new Set(v.map(y=>y[e.groupBy]));return Array.from(j).map(y=>({id:String(y),title:String(y)}))}return[]},[e.columns,e.groupBy,v,d]),S=e.swimlaneField||e.grouping?.fields?.[0]?.field,E={...e,data:v,columns:b,className:a||e.className,...S?{swimlaneField:S}:{}},f=Le({navigation:e.navigation,objectName:e.objectName,onRowClick:o??s});if(g)return t.jsxs("div",{className:"p-4 border border-destructive/50 rounded bg-destructive/10 text-destructive",children:["Error loading kanban data: ",g.message]});const w=e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1).replace(/_/g," ")} Detail`:"Card Details";return t.jsxs(t.Fragment,{children:[t.jsx(Aa,{schema:{...E,onCardClick:j=>{f.handleClick(j),s?.(j)}}}),f.isOverlay&&t.jsx(De,{...f,title:w,children:j=>t.jsx("div",{className:"space-y-3",children:Object.entries(j).map(([y,C])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:y.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(C??"—")})]},y))})})]})},Ro=ae.lazy(()=>J(()=>import("./KanbanImpl-PGPpv-gu.js"),__vite__mapDeps([6,1,7,8,9,10,11,3,12,13,4,2,14,15]))),Vo=ae.lazy(()=>J(()=>import("./KanbanEnhanced-CyIdmKhW.js"),__vite__mapDeps([16,1,17,8,9,10,11,3,12,13,4,2,14,15,7,18,19]))),Aa=({schema:e})=>{const n=ae.useMemo(()=>{const{columns:a=[],data:o,groupBy:s,coverImageField:r}=e,l=c=>{if(!r)return c;const d=c[r];if(!d)return c;const u=typeof d=="string"?d:d?.url;return u?{...c,coverImage:u}:c};if(o&&s&&Array.isArray(o)){const c={};a.forEach(u=>{u.id&&(c[String(u.id).toLowerCase()]=u.id),u.title&&(c[String(u.title).toLowerCase()]=u.id)});const d=o.reduce((u,m)=>{const p=String(m[s]??""),g=c[p.toLowerCase()]??p;return u[g]||(u[g]=[]),u[g].push(l(m)),u},{});return a.map(u=>({...u,cards:[...(u.cards||[]).map(l),...d[u.id]||[]]}))}return a.map(c=>({...c,cards:(c.cards||[]).map(l)}))},[e]);return t.jsx(i.Suspense,{fallback:t.jsx(Ke,{className:"w-full h-[600px]"}),children:t.jsx(Ro,{columns:n,onCardMove:e.onCardMove,onCardClick:e.onCardClick,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,coverImageField:e.coverImageField,conditionalFormatting:e.conditionalFormatting,swimlaneField:e.swimlaneField})})};Z.register("kanban-ui",Aa,{namespace:"plugin-kanban",label:"Kanban Board",icon:"LayoutDashboard",category:"plugin",inputs:[{name:"columns",type:"array",label:"Columns",description:"Array of { id, title, cards, limit, className }",required:!0},{name:"onCardMove",type:"code",label:"On Card Move",description:"Callback when a card is moved",advanced:!0},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{columns:[{id:"todo",title:"To Do",cards:[{id:"card-1",title:"Task 1",description:"This is the first task",badges:[{label:"High Priority",variant:"destructive"},{label:"Feature",variant:"default"}]},{id:"card-2",title:"Task 2",description:"This is the second task",badges:[{label:"Bug",variant:"destructive"}]}]},{id:"in-progress",title:"In Progress",limit:3,cards:[{id:"card-3",title:"Task 3",description:"Currently working on this",badges:[{label:"In Progress",variant:"default"}]}]},{id:"done",title:"Done",cards:[{id:"card-4",title:"Task 4",description:"This task is completed",badges:[{label:"Completed",variant:"outline"}]},{id:"card-5",title:"Task 5",description:"Another completed task",badges:[{label:"Completed",variant:"outline"}]}]}],className:"w-full"}});Z.register("kanban-enhanced",({schema:e})=>{const n=ae.useMemo(()=>{const{columns:a=[],data:o,groupBy:s}=e;if(o&&s&&Array.isArray(o)){const r=o.reduce((l,c)=>{const d=c[s];return l[d]||(l[d]=[]),l[d].push(c),l},{});return a.map(l=>({...l,cards:[...l.cards||[],...r[l.id]||[]]}))}return a},[e]);return t.jsx(i.Suspense,{fallback:t.jsx(Ke,{className:"w-full h-[600px]"}),children:t.jsx(Vo,{columns:n,onCardMove:e.onCardMove,onColumnToggle:e.onColumnToggle,enableVirtualScrolling:e.enableVirtualScrolling,virtualScrollThreshold:e.virtualScrollThreshold,className:e.className,quickAdd:e.quickAdd,onQuickAdd:e.onQuickAdd,conditionalFormatting:e.conditionalFormatting})})},{namespace:"plugin-kanban",label:"Kanban Board (Enhanced)",icon:"LayoutGrid",category:"plugin",inputs:[{name:"columns",type:"array",label:"Columns",required:!0},{name:"enableVirtualScrolling",type:"boolean",label:"Virtual Scrolling",defaultValue:!1},{name:"virtualScrollThreshold",type:"number",label:"Virtual Scroll Threshold",defaultValue:50},{name:"onCardMove",type:"code",label:"On Card Move",advanced:!0},{name:"onColumnToggle",type:"code",label:"On Column Toggle",advanced:!0},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{columns:[],enableVirtualScrolling:!1,virtualScrollThreshold:50,className:"w-full"}});const Ta=({schema:e,...n})=>{const{dataSource:a}=Je()||{};return t.jsx(To,{schema:e,dataSource:a,...n})};Z.register("object-kanban",Ta,{namespace:"plugin-kanban",label:"Object Kanban",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"}]});Z.register("kanban",Ta,{namespace:"view",label:"Kanban Board",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"}]});const en="bg-blue-500 text-white",Mo=new Date,_n={"calendar.today":"Today","calendar.month":"Month","calendar.week":"Week","calendar.day":"Day","calendar.newEvent":"New event","calendar.moreEvents":"+{{count}} more"};function Ra(){try{const e=me();return e.t("calendar.today")==="calendar.today"?{t:(a,o)=>{let s=_n[a]||a;if(o)for(const[r,l]of Object.entries(o))s=s.replace(`{{${r}}}`,String(l));return s},language:"en"}:{t:e.t,language:e.language}}catch{return{t:(e,n)=>{let a=_n[e]||e;if(n)for(const[o,s]of Object.entries(n))a=a.replace(`{{${o}}}`,String(s));return a},language:"en"}}}function Va({events:e=[],view:n="month",currentDate:a=Mo,locale:o="default",onEventClick:s,onDateClick:r,onViewChange:l,onNavigate:c,onAddClick:d,onEventDrop:u,className:m}){const[p,g]=i.useState(n),[x,h]=i.useState(a),{t:F,language:v}=Ra(),b=o!=="default"?o:v;i.useEffect(()=>{h(a)},[a]),i.useEffect(()=>{g(n)},[n]);const S=i.useRef(l);S.current=l,i.useEffect(()=>{const N=window.matchMedia("(max-width: 639px)"),A=R=>{R.matches&&(g("day"),S.current?.("day"))};return A(N),N.addEventListener("change",A),()=>N.removeEventListener("change",A)},[]);const E=()=>{const N=new Date(x);p==="month"?N.setMonth(N.getMonth()-1):p==="week"?N.setDate(N.getDate()-7):N.setDate(N.getDate()-1),h(N),c?.(N)},f=()=>{const N=new Date(x);p==="month"?N.setMonth(N.getMonth()+1):p==="week"?N.setDate(N.getDate()+7):N.setDate(N.getDate()+1),h(N),c?.(N)},w=()=>{const N=new Date;h(N),c?.(N)},j=N=>{g(N),l?.(N)},y=()=>{if(p==="month")return x.toLocaleDateString(b,{month:"long",year:"numeric"});if(p==="week"){const N=Ma(x),A=new Date(N);return A.setDate(A.getDate()+6),`${N.toLocaleDateString(b,{month:"short",day:"numeric"})} - ${A.toLocaleDateString(b,{month:"short",day:"numeric",year:"numeric"})}`}else return x.toLocaleDateString(b,{weekday:"long",month:"long",day:"numeric",year:"numeric"})},C=i.useRef(0),V=N=>{C.current=N.touches[0].clientX},k=N=>{const A=C.current-N.changedTouches[0].clientX;if(Math.abs(A)>50){const R=new Date(x);p==="day"?R.setDate(R.getDate()+(A>0?1:-1)):p==="week"?R.setDate(R.getDate()+(A>0?7:-7)):R.setMonth(R.getMonth()+(A>0?1:-1)),h(R),c?.(R)}},M=N=>{N&&(h(N),c?.(N))};return t.jsxs("div",{role:"region","aria-label":"Calendar",className:q("flex flex-col h-full bg-background min-w-0 overflow-hidden",m),children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 p-2 sm:p-4 border-b min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-4",children:[t.jsxs("div",{className:"flex items-center bg-muted/50 rounded-lg p-1 gap-1",children:[t.jsx(Y,{variant:"ghost",size:"sm",onClick:w,className:"h-8","aria-label":"Go to today",children:F("calendar.today")}),t.jsx("div",{className:"h-4 w-px bg-border mx-1"}),t.jsx(Y,{variant:"ghost",size:"icon","aria-label":"Previous period",onClick:E,className:"h-8 w-8",children:t.jsx(xa,{className:"h-4 w-4"})}),t.jsx(Y,{variant:"ghost",size:"icon","aria-label":"Next period",onClick:f,className:"h-8 w-8",children:t.jsx(ft,{className:"h-4 w-4"})})]}),t.jsxs(Rs,{children:[t.jsx(Vs,{asChild:!0,children:t.jsxs(Y,{variant:"ghost","aria-label":`Current date: ${y()}`,className:q("text-base sm:text-xl font-semibold h-auto px-2 sm:px-3 py-1 hover:bg-muted/50 transition-colors","flex items-center gap-2"),children:[t.jsx(ba,{className:"h-5 w-5 text-muted-foreground"}),t.jsx("span",{children:y()})]})}),t.jsx(Ms,{className:"w-auto p-0",align:"start",children:t.jsx(Os,{mode:"single",selected:x,onSelect:M,initialFocus:!0,fromYear:2e3,toYear:2050})})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Zn,{value:p,onValueChange:j,children:[t.jsx(Qn,{className:"w-32 bg-background",children:t.jsx(Xn,{})}),t.jsxs(ea,{children:[t.jsx(Ne,{value:"day",children:F("calendar.day")}),t.jsx(Ne,{value:"week",children:F("calendar.week")}),t.jsx(Ne,{value:"month",children:F("calendar.month")})]})]}),d&&t.jsxs(Y,{onClick:d,size:"sm",className:"gap-1",children:[t.jsx(Fe,{className:"h-4 w-4"}),F("calendar.newEvent")]})]})]}),t.jsxs("div",{className:"flex-1 overflow-auto",onTouchStart:V,onTouchEnd:k,children:[p==="month"&&t.jsx(Po,{date:x,events:e,locale:b,onEventClick:s,onDateClick:r,onEventDrop:u}),p==="week"&&t.jsx(Io,{date:x,events:e,locale:b,onEventClick:s,onDateClick:r}),p==="day"&&t.jsx(Lo,{date:x,events:e,onEventClick:s,onDateClick:r})]})]})}function Ma(e){const n=new Date(e),a=n.getDay(),o=n.getDate()-a;return n.setDate(o),n}function Oo(e){const n=e.getFullYear(),a=e.getMonth(),o=new Date(n,a,1),s=new Date(n,a+1,0),r=o.getDay(),l=[];for(let d=r-1;d>=0;d--){const u=new Date(o.getTime());u.setDate(u.getDate()-(d+1)),l.push(u)}for(let d=1;d<=s.getDate();d++)l.push(new Date(n,a,d));const c=42-l.length;for(let d=1;d<=c;d++){const u=new Date(s.getTime());u.setDate(u.getDate()+d),l.push(u)}return l}function Oa(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function Pa(e,n){return n.filter(a=>{const o=new Date(a.start),s=a.end?new Date(a.end):new Date(o),r=new Date(e);r.setHours(0,0,0,0);const l=new Date(e);l.setHours(23,59,59,999);const c=new Date(o);c.setHours(0,0,0,0);const d=new Date(s);return d.setHours(23,59,59,999),r<=d&&l>=c})}function Po({date:e,events:n,locale:a="default",onEventClick:o,onDateClick:s,onEventDrop:r}){const l=i.useMemo(()=>Oo(e),[e.getFullYear(),e.getMonth()]),c=i.useMemo(()=>new Date,[]),{t:d}=Ra(),u=i.useMemo(()=>{const f=new Date(2024,0,7);return Array.from({length:7},(w,j)=>{const y=new Date(f);return y.setDate(y.getDate()+j),y.toLocaleDateString(a,{weekday:"short"})})},[a]),[m,p]=i.useState(null),[g,x]=i.useState(null),h=i.useMemo(()=>{const f=new Map;for(const w of n){const j=new Date(w.start),y=w.end?new Date(w.end):new Date(j);j.setHours(0,0,0,0),y.setHours(0,0,0,0);const C=new Date(j);for(;C<=y;){const V=`${C.getFullYear()}-${C.getMonth()}-${C.getDate()}`,k=f.get(V);k?k.push(w):f.set(V,[w]),C.setDate(C.getDate()+1)}}return f},[n]),F=(f,w)=>{p(w.id),f.dataTransfer.effectAllowed="move",f.dataTransfer.setData("text/plain",String(w.id))},v=()=>{p(null),x(null)},b=(f,w)=>{f.preventDefault(),f.dataTransfer.dropEffect="move",x(w)},S=f=>{f.currentTarget.contains(f.relatedTarget)||x(null)},E=(f,w)=>{if(f.preventDefault(),x(null),p(null),!r)return;const j=f.dataTransfer.getData("text/plain"),y=n.find(R=>String(R.id)===j);if(!y)return;const C=new Date(y.start),V=new Date(C);V.setHours(0,0,0,0);const k=new Date(w);k.setHours(0,0,0,0);const M=k.getTime()-V.getTime();if(M===0)return;const N=new Date(C.getTime()+M);let A;y.end&&(A=new Date(new Date(y.end).getTime()+M)),r(y,N,A)};return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx("div",{role:"row",className:"grid grid-cols-7 border-b",children:u.map(f=>t.jsx("div",{role:"columnheader",className:"p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",children:f},f))}),t.jsx("div",{role:"grid","aria-label":"Calendar grid",className:"grid grid-cols-7 flex-1 auto-rows-fr",children:l.map((f,w)=>{const j=`${f.getFullYear()}-${f.getMonth()}-${f.getDate()}`,y=h.get(j)||[],C=f.getMonth()===e.getMonth(),V=Oa(f,c);return t.jsxs("div",{role:"gridcell","aria-label":`${f.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${y.length>0?`, ${y.length} event${y.length>1?"s":""}`:""}`,className:q("border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50",!C&&"bg-muted/50 text-muted-foreground opacity-50",g===w&&"ring-2 ring-primary"),onClick:()=>s?.(f),onDragOver:k=>b(k,w),onDragLeave:S,onDrop:k=>E(k,f),children:[t.jsx("div",{className:q("text-sm font-medium mb-2",V&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),...V?{"aria-current":"date"}:{},children:f.getDate()}),t.jsxs("div",{className:"space-y-1",children:[y.slice(0,3).map(k=>t.jsx("div",{role:"button",title:k.title,"aria-label":k.title,draggable:!!r,onDragStart:M=>F(M,k),onDragEnd:v,className:q("text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",k.color?.startsWith("#")?"text-white":k.color||en,m===k.id&&"opacity-50"),style:k.color&&k.color.startsWith("#")?{backgroundColor:k.color}:void 0,onClick:M=>{M.stopPropagation(),o?.(k)},children:k.title},k.id)),y.length>3&&t.jsx("div",{className:"text-xs text-muted-foreground px-2",children:d("calendar.moreEvents",{count:y.length-3})})]})]},w)})})]})}function Io({date:e,events:n,locale:a="default",onEventClick:o,onDateClick:s}){const r=i.useRef(null),l=p=>{s&&(r.current=setTimeout(()=>{s(p)},500))},c=()=>{r.current&&(clearTimeout(r.current),r.current=null)},d=Ma(e),u=Array.from({length:7},(p,g)=>{const x=new Date(d);return x.setDate(x.getDate()+g),x}),m=new Date;return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx("div",{className:"grid grid-cols-7 border-b",children:u.map(p=>{const g=Oa(p,m);return t.jsxs("div",{className:"p-3 text-center border-r last:border-r-0",children:[t.jsx("div",{className:"text-sm font-medium text-muted-foreground",children:p.toLocaleDateString(a,{weekday:"short"})}),t.jsx("div",{className:q("text-lg font-semibold mt-1",g&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"),children:p.getDate()})]},p.toISOString())})}),t.jsx("div",{role:"grid",className:"grid grid-cols-7 flex-1",children:u.map(p=>{const g=Pa(p,n);return t.jsx("div",{role:"gridcell","aria-label":`${p.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${g.length>0?`, ${g.length} event${g.length>1?"s":""}`:""}`,className:"border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",onClick:()=>s?.(p),onTouchStart:()=>l(p),onTouchEnd:c,children:t.jsx("div",{className:"space-y-2",children:g.map(x=>t.jsxs("div",{role:"button",title:x.title,"aria-label":x.title,className:q("text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",x.color?.startsWith("#")?"text-white":x.color||en),style:x.color&&x.color.startsWith("#")?{backgroundColor:x.color}:void 0,onClick:h=>{h.stopPropagation(),o?.(x)},children:[t.jsx("div",{className:"font-medium truncate",children:x.title}),!x.allDay&&t.jsx("div",{className:"text-xs opacity-90 mt-1",children:x.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})})]},x.id))})},p.toISOString())})})]})}function Lo({date:e,events:n,onEventClick:a,onDateClick:o}){const s=Pa(e,n),r=Array.from({length:24},(u,m)=>m),l=i.useRef(null),c=u=>{o&&(l.current=setTimeout(()=>{const m=new Date(e);m.setHours(u,0,0,0),o(m)},500))},d=()=>{l.current&&(clearTimeout(l.current),l.current=null)};return t.jsx("div",{className:"flex flex-col h-full",children:t.jsx("div",{role:"list",className:"flex-1 overflow-auto",children:r.map(u=>{const m=s.filter(p=>p.allDay?u===0:p.start.getHours()===u);return t.jsxs("div",{role:"listitem",className:"flex border-b min-h-[60px]",children:[t.jsx("div",{className:"w-20 p-2 text-sm text-muted-foreground border-r",children:u===0?"12 AM":u<12?`${u} AM`:u===12?"12 PM":`${u-12} PM`}),t.jsx("div",{className:"flex-1 p-2 space-y-2",onTouchStart:()=>c(u),onTouchEnd:d,children:m.map(p=>t.jsxs("div",{title:p.title,"aria-label":p.title,className:q("px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",p.color?.startsWith("#")?"text-white":p.color||en),style:p.color&&p.color.startsWith("#")?{backgroundColor:p.color}:void 0,onClick:()=>a?.(p),children:[t.jsx("div",{className:"font-medium truncate",children:p.title}),!p.allDay&&t.jsxs("div",{className:"text-xs opacity-90 mt-1",children:[p.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"}),p.end&&` - ${p.end.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})}`]})]},p.id))})]},u)})})})}function $o(e){return"data"in e&&e.data?e.data:"staticData"in e&&e.staticData?{provider:"value",items:e.staticData}:e.objectName?{provider:"object",object:e.objectName}:null}function zo(e){if(e){if(typeof e=="string"){const n=e.split(" "),a=n[0],o=n[1]?.toLowerCase()==="desc"?"desc":"asc";return{[a]:o}}if(Array.isArray(e))return e.reduce((n,a)=>(a.field&&a.order&&(n[a.field]=a.order),n),{})}}function Uo(e){return"filter"in e&&e.filter&&typeof e.filter=="object"&&"calendar"in e.filter?e.filter.calendar:e.calendar?e.calendar:e.startDateField||e.dateField?{startDateField:e.startDateField||e.dateField,endDateField:e.endDateField||e.endField,titleField:e.titleField||"name",colorField:e.colorField,allDayField:e.allDayField}:null}const Bo=({schema:e,dataSource:n,className:a,onEventClick:o,onRowClick:s,onDateClick:r,onNavigate:l,onViewChange:c,onEventDrop:d,locale:u,...m})=>{const[p,g]=i.useState([]),[x,h]=i.useState(!0),[F,v]=i.useState(null),[b,S]=i.useState(null),[E,f]=i.useState(new Date),[w,j]=i.useState("month"),[y,C]=i.useState(0),V=i.useCallback(async()=>{C(O=>O+1)},[]),{ref:k,isRefreshing:M,pullDistance:N}=ya({onRefresh:V,enabled:!!n&&!!e.objectName}),A=i.useMemo(()=>$o(e),[e.data,e.staticData,e.objectName]),R=i.useMemo(()=>Uo(e),[e.filter,e.calendar,e.dateField,e.endField,e.titleField,e.colorField]),L=A?.provider==="value",B=i.useRef(null);B.current=b,i.useEffect(()=>{let O=!0;return(async()=>{try{if(!O)return;if(h(!0),L&&A?.provider==="value"){O&&(g(A.items),h(!1));return}if(e.data||m.data){const D=e.data||m.data;if(Array.isArray(D)){g(D),h(!1);return}}if(!n||typeof n.find!="function")throw new Error("DataSource required for object/api providers");if(A?.provider==="object"){const D=A.object,G=Ye(B.current?.fields),W=await n.find(D,{$filter:e.filter,$orderby:zo(e.sort),...G.length>0?{$expand:G}:{}});let Q=Ie(W);O&&g(Q)}else A?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectCalendar"),O&&g([]));O&&h(!1)}catch(D){console.error("[ObjectCalendar] Error fetching data:",D),O&&(v(D),h(!1))}})(),()=>{O=!1}},[A,n,L,e.filter,e.sort,y]),i.useEffect(()=>{!L&&n&&(async()=>{try{if(!n)return;const I=A?.provider==="object"?A.object:e.objectName;if(!I)return;const D=await n.getObjectSchema(I);S(D)}catch(I){console.error("Failed to fetch object schema:",I)}})()},[e.objectName,n,L,A]);const P=i.useMemo(()=>{if(!R||!p.length)return[];const{startDateField:O,endDateField:I,titleField:D,colorField:G}=R;return p.map((W,Q)=>{const se=W[O],le=I?W[I]:null,ce=W[D]||"Untitled",bt=G?W[G]:void 0;return{id:W.id||W._id||`event-${Q}`,title:ce,start:se?new Date(se):new Date,end:le?new Date(le):void 0,color:bt,allDay:!le,data:W}}).filter(W=>!isNaN(W.start.getTime()))},[p,R]);i.useCallback(()=>{r?.(new Date)},[r]);const $=Le({navigation:e.navigation,objectName:e.objectName,onRowClick:s});return x?t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsx("div",{className:"text-muted-foreground",children:"Loading calendar..."})})}):F?t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsxs("div",{className:"text-destructive",children:["Error: ",F.message]})})}):R?t.jsxs("div",{ref:k,className:a,children:[N>0&&t.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:N},children:M?"Refreshing…":"Pull to refresh"}),t.jsx("div",{className:"border rounded-lg bg-background h-[calc(100vh-120px)] sm:h-[calc(100vh-160px)] md:h-[calc(100vh-200px)] min-h-[400px] sm:min-h-[600px]",children:t.jsx(Va,{events:P,currentDate:E,view:e.defaultView||"month",locale:u,onEventClick:O=>{$.handleClick(O.data),o?.(O.data)},onDateClick:r,onNavigate:O=>{f(O),l?.(O)},onViewChange:O=>{j(O),c?.(O)},onAddClick:void 0,onEventDrop:d?(O,I,D)=>{d(O.data,I,D)}:void 0})}),$.isOverlay&&t.jsx(De,{...$,title:"Event Details",children:O=>t.jsx("div",{className:"space-y-3",children:Object.entries(O).map(([I,D])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:I.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(D??"—")})]},I))})})]}):t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsx("div",{className:"text-muted-foreground",children:"Calendar configuration required. Please specify startDateField and titleField."})})})};Z.register("calendar-view",({schema:e,className:n,onAction:a,...o})=>{const s=ae.useMemo(()=>!e.data||!Array.isArray(e.data)?[]:e.data.map((l,c)=>{const d=e.titleField||"title",u=e.startDateField||"start",m=e.endDateField||"end",p=e.colorField||"color",g=e.allDayField||"allDay";return{id:l.id||l._id||c,title:l[d]||"Untitled Event",start:new Date(l[u]),end:l[m]?new Date(l[m]):void 0,allDay:l[g],color:l[p],data:l}}),[e.data,e.titleField,e.startDateField,e.endDateField,e.colorField,e.allDayField]),r=l=>{a?.({type:"event-click",payload:l})};return t.jsx(Va,{className:n,events:s,onEventClick:r,...o})},{namespace:"plugin-calendar",label:"Calendar View",inputs:[{name:"data",type:"array",label:"Data",description:"Array of record objects to display as events"},{name:"titleField",type:"string",label:"Title Field",defaultValue:"title",description:"Field name to use for event title"},{name:"startDateField",type:"string",label:"Start Date Field",defaultValue:"start",description:"Field name for event start date"},{name:"endDateField",type:"string",label:"End Date Field",defaultValue:"end",description:"Field name for event end date (optional)"},{name:"allDayField",type:"string",label:"All Day Field",defaultValue:"allDay",description:"Field name for all-day flag"},{name:"colorField",type:"string",label:"Color Field",defaultValue:"color",description:"Field name for event color"},{name:"colorMapping",type:"object",label:"Color Mapping",description:'Map field values to colors (e.g., {meeting: "blue", deadline: "red"})'},{name:"view",type:"enum",enum:["month","week","day"],defaultValue:"month",label:"View Mode",description:"Calendar view mode (month, week, or day)"},{name:"currentDate",type:"string",label:"Current Date",description:"ISO date string for initial calendar date"},{name:"allowCreate",type:"boolean",label:"Allow Create",defaultValue:!1,description:"Allow creating events by clicking on dates"},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{view:"month",titleField:"title",startDateField:"start",endDateField:"end",allDayField:"allDay",colorField:"color",allowCreate:!1,data:[{id:1,title:"Team Meeting",start:new Date(new Date().setHours(10,0,0,0)).toISOString(),end:new Date(new Date().setHours(11,0,0,0)).toISOString(),color:"#3b82f6",allDay:!1},{id:2,title:"Project Deadline",start:new Date(new Date().setDate(new Date().getDate()+3)).toISOString(),color:"#ef4444",allDay:!0},{id:3,title:"Conference",start:new Date(new Date().setDate(new Date().getDate()+7)).toISOString(),end:new Date(new Date().setDate(new Date().getDate()+9)).toISOString(),color:"#10b981",allDay:!0}],className:"h-[600px] border rounded-lg"}});const Ia=({schema:e,data:n,loading:a,...o})=>{const{dataSource:s}=Je()||{};return t.jsx(Bo,{schema:e,dataSource:s,...o})};Z.register("object-calendar",Ia,{namespace:"plugin-calendar",label:"Object Calendar",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"calendar",type:"object",label:"Calendar Config",description:"startDateField, endDateField, titleField, colorField"}]});Z.register("calendar",Ia,{namespace:"view",label:"Calendar View",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"calendar",type:"object",label:"Calendar Config",description:"startDateField, endDateField, titleField, colorField"}]});function Ho({open:e,onToggle:n,className:a}){return t.jsxs(Y,{size:"sm",variant:e?"secondary":"outline",onClick:n,className:`shadow-none gap-2 ${a||""}`,title:"Toggle Metadata Inspector",children:[t.jsx(gr,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden lg:inline",children:"Metadata"})]})}function qo({sections:e,open:n}){if(!n)return null;const[a,o]=i.useState(["0"]),[s,r]=i.useState(null),l=async(d,u)=>{try{await navigator.clipboard.writeText(JSON.stringify(d,null,2)),r(u),setTimeout(()=>r(null),2e3)}catch(m){console.error("Failed to copy:",m)}},c=d=>{o(u=>u.includes(d)?u.filter(m=>m!==d):[...u,d])};return t.jsxs("div",{className:"w-80 border-l bg-background p-0 overflow-hidden flex flex-col shrink-0 z-20 transition-all",children:[t.jsxs("div",{className:"px-4 py-3 border-b bg-muted/5 flex items-center justify-between",children:[t.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Metadata Inspector"}),t.jsx("span",{className:"text-[10px] text-muted-foreground/60",children:"JSON"})]}),t.jsx("div",{className:"flex-1 overflow-auto",children:e.map((d,u)=>{const m=String(u),p=a.includes(m),g=s===u;return t.jsxs("div",{className:"border-b last:border-b-0",children:[t.jsxs("div",{className:"flex items-center justify-between px-4 py-3 hover:bg-muted/5 transition-colors",children:[t.jsxs("button",{onClick:()=>c(m),className:"flex-1 flex items-center justify-between text-left",children:[t.jsx("h4",{className:"text-xs font-semibold text-foreground",children:d.title}),p?t.jsx(Dt,{className:"h-3 w-3 text-muted-foreground ml-2"}):t.jsx(ft,{className:"h-3 w-3 text-muted-foreground ml-2"})]}),t.jsx("button",{onClick:()=>l(d.data,u),className:"p-1 hover:bg-muted rounded transition-colors ml-2",title:"Copy JSON",children:g?t.jsx(pr,{className:"h-3 w-3 text-green-600"}):t.jsx(hr,{className:"h-3 w-3 text-muted-foreground"})})]}),p&&t.jsx("div",{className:"px-4 pb-4",children:t.jsx("div",{className:"relative rounded-md border border-border/50 bg-muted/5 overflow-hidden",children:t.jsx("pre",{className:"text-[11px] leading-relaxed p-3 overflow-auto max-h-96 font-mono text-foreground/90",children:JSON.stringify(d.data,null,2)})})})]},u)})})]})}function Wo(){const e=i.useMemo(()=>{try{return typeof window<"u"?qs(window.location.search).enabled:!1}catch{return!1}},[]),[n,a]=i.useState(e);return{showDebug:n,toggleDebug:()=>a(o=>!o)}}const La={"=":"equals","==":"equals","!=":"notEquals","<>":"notEquals",">":"greaterThan","<":"lessThan",">=":"greaterOrEqual","<=":"lessOrEqual",contains:"contains",not_contains:"notContains",is_empty:"isEmpty",is_not_empty:"isNotEmpty",in:"in",not_in:"notIn","not in":"notIn",before:"before",after:"after",between:"between",equals:"equals",notEquals:"notEquals",greaterThan:"greaterThan",lessThan:"lessThan",greaterOrEqual:"greaterOrEqual",lessOrEqual:"lessOrEqual",notContains:"notContains",isEmpty:"isEmpty",isNotEmpty:"isNotEmpty",notIn:"notIn"},Go={equals:"=",notEquals:"!=",greaterThan:">",lessThan:"<",greaterOrEqual:">=",lessOrEqual:"<=",contains:"contains",notContains:"not_contains",isEmpty:"is_empty",isNotEmpty:"is_not_empty",in:"in",notIn:"not in",before:"before",after:"after",between:"between"};function Ko(e){const n=(e||"").toLowerCase();return["integer","int","float","double","number","currency","money","percent","rating"].includes(n)?"number":["date","datetime","datetime_tz","timestamp","time"].includes(n)?"date":["boolean","bool","checkbox","switch"].includes(n)?"boolean":["select","picklist","single_select","multi_select","enum","status","lookup","master_detail","user","owner"].includes(n)?"select":"text"}function _t(e){if(!Array.isArray(e)||e.length<2)return null;const[n,a,o]=e;return typeof n!="string"||typeof a!="string"?null:{id:crypto.randomUUID(),field:n,operator:La[a]||a,value:o??""}}function En(e){if(Array.isArray(e)){const n=_t(e);return n?[n]:[]}return typeof e=="object"&&e!==null&&e.field?[{id:e.id||crypto.randomUUID(),field:e.field,operator:La[e.operator]||e.operator||"equals",value:e.value??""}]:[]}function Yo(e){if(!Array.isArray(e)||e.length===0)return{logic:"and",conditions:[]};if(typeof e[0]=="string"&&(e[0]==="and"||e[0]==="or")){const a=e[0],s=e.slice(1).flatMap(r=>En(r));return{logic:a,conditions:s}}if(e.length>=2&&e.length<=3&&typeof e[0]=="string"&&typeof e[1]=="string"&&!Array.isArray(e[0])&&!Array.isArray(e[2])){const a=_t(e);return{logic:"and",conditions:a?[a]:[]}}if(Array.isArray(e[0])||typeof e[0]=="object"&&e[0]!==null&&!Array.isArray(e[0]))return{logic:"and",conditions:e.flatMap(o=>En(o))};const n=_t(e);return{logic:"and",conditions:n?[n]:[]}}function Jo(e,n){const a=n.filter(o=>o.field).map(o=>[o.field,Go[o.operator]||o.operator,o.value]);return a.length===0?[]:a.length===1&&e==="and"?a[0]:e==="or"?["or",...a]:a}function An(e){return e.split(",").map(n=>n.trim()).filter(Boolean)}function Zo(e){return e.split(",").map(n=>Number(n.trim())).filter(n=>!isNaN(n)&&n>0)}const tn={grid:"Grid",kanban:"Kanban",calendar:"Calendar",gallery:"Gallery",timeline:"Timeline",gantt:"Gantt",map:"Map",chart:"Chart"},Qo=Object.keys(tn),Xo=[{value:"compact",gapClass:"gap-0"},{value:"short",gapClass:"gap-px"},{value:"medium",gapClass:"gap-0.5"},{value:"tall",gapClass:"gap-1"},{value:"extra_tall",gapClass:"gap-1.5"}];function ei(e){return e.fields?Object.entries(e.fields).map(([n,a])=>({value:n,label:a.label||n,type:Ko(a.type),options:a.options})):[]}function ti(e){const n=Yo(e);return{id:"root",logic:n.logic,conditions:n.conditions}}function ni(e){return(Array.isArray(e)?e:[]).map(n=>({id:n.id||crypto.randomUUID(),field:n.field||"",order:n.order||n.direction||"asc"}))}function fe({renderSummary:e,children:n}){const[a,o]=ae.useState(!1);return t.jsxs(t.Fragment,{children:[e(()=>o(s=>!s)),a&&n]})}const ai=5;function si({colName:e,label:n,idx:a,total:o,onToggle:s,onMove:r}){const{attributes:l,listeners:c,setNodeRef:d,transform:u,transition:m,isDragging:p}=Ur({id:e}),g={transform:Br.Transform.toString(u),transition:m,zIndex:p?10:void 0,opacity:p?.5:void 0};return t.jsxs("div",{ref:d,style:g,"data-field-name":e,"data-field-label":n,className:"flex items-center gap-1 text-xs hover:bg-accent/50 rounded-sm py-0.5 px-1 -mx-1 group",children:[t.jsx("span",{...l,...c,className:"shrink-0 cursor-grab touch-none","data-testid":`col-drag-handle-${e}`,children:t.jsx(lt,{className:"h-3 w-3 text-muted-foreground/50"})}),t.jsx("button",{type:"button","data-testid":`col-eye-${e}`,className:"h-5 w-5 flex items-center justify-center rounded hover:bg-accent shrink-0",onClick:()=>s(e,!1),"aria-label":`Hide ${n}`,children:t.jsx(xr,{className:"h-3.5 w-3.5 text-primary"})}),t.jsx("span",{className:"truncate flex-1",children:n}),t.jsx("button",{type:"button","data-testid":`col-move-up-${e}`,className:"h-5 w-5 flex items-center justify-center rounded hover:bg-accent disabled:opacity-30 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",disabled:a===0,onClick:()=>r(e,"up"),"aria-label":`Move ${n} up`,children:t.jsx(lt,{className:"h-3 w-3 rotate-90"})}),t.jsx("button",{type:"button","data-testid":`col-move-down-${e}`,className:"h-5 w-5 flex items-center justify-center rounded hover:bg-accent disabled:opacity-30 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",disabled:a===o-1,onClick:()=>r(e,"down"),"aria-label":`Move ${n} down`,children:t.jsx(lt,{className:"h-3 w-3 -rotate-90"})})]})}function ri({columns:e,fieldOptions:n,onToggle:a,onMove:o,onReorder:s}){const r=Vr(bn(Or,{activationConstraint:{distance:ai}}),bn(Mr)),l=ae.useCallback(c=>{const{active:d,over:u}=c;if(!u||d.id===u.id)return;const m=e.indexOf(String(d.id)),p=e.indexOf(String(u.id));m===-1||p===-1||s(Pr(e,m,p))},[e,s]);return t.jsx(Ir,{sensors:r,collisionDetection:Lr,onDragEnd:l,children:t.jsx($r,{items:e,strategy:zr,children:e.map((c,d)=>{const u=n.find(m=>m.value===c);return t.jsx(si,{colName:c,label:u?.label||c,idx:d,total:e.length,onToggle:a,onMove:o},c)})})})}const ue=e=>e.type==null||e.type==="grid",oi=e=>e.type==null||["grid","kanban","gallery"].includes(e.type),$a=e=>e.type==null||["grid","calendar","timeline","gantt"].includes(e.type),ii=e=>e.type==null||["grid","kanban"].includes(e.type),Tn=e=>e.type==null||["grid","kanban"].includes(e.type),li=e=>e.type==null||["grid","gallery"].includes(e.type);function ci(e){const{t:n,fieldOptions:a,objectDef:o,updateField:s,filterGroupValue:r,sortItemsValue:l}=e,c=a.map(u=>({value:u.value,label:u.label})),d=[{value:"",label:n("console.objectView.none")},...c];return{breadcrumb:[n("console.objectView.page")],sections:[di(n,o),ui(n),mi(n,s),pi(n,s),hi(n,s),gi(n,a,d,o,s,r,l),fi(n,a,d,s),xi(n,s),bi(n,s),ji(n,s)]}}function di(e,n){return{key:"general",title:e("console.objectView.general"),hint:e("console.objectView.generalHint"),fields:[{key:"label",label:e("console.objectView.title"),type:"custom",render:(a,o)=>t.jsx(U,{label:e("console.objectView.title"),children:t.jsx(X,{"data-testid":"view-title-input",className:"h-7 text-xs w-32 text-right",value:a||"",onChange:s=>o(s.target.value)})})},{key:"description",label:e("console.objectView.description"),type:"custom",render:(a,o)=>t.jsx(U,{label:e("console.objectView.description"),children:t.jsx(X,{"data-testid":"view-description-input",className:"h-7 text-xs w-32 text-right",value:a??"",placeholder:n.description||e("console.objectView.noDescription"),onChange:s=>o(s.target.value)})})},{key:"type",label:e("console.objectView.viewType"),type:"custom",render:(a,o)=>t.jsx(U,{label:e("console.objectView.viewType"),children:t.jsx("select",{"data-testid":"view-type-select",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground",value:a||"grid",onChange:s=>o(s.target.value),children:Qo.map(s=>t.jsx("option",{value:s,children:tn[s]},s))})})}]}}function ui(e){const n=["showSearch","showSort","showFilters","showHideFields","showGroup","showColor","showDensity"];return{key:"toolbar",title:e("console.objectView.toolbar"),hint:e("console.objectView.toolbarHint"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_toolbarSummary",label:e("console.objectView.toolbar"),type:"custom",render:(a,o,s)=>{const r=n.length,l=n.filter(c=>s[c]!==!1).length;return t.jsx("div",{className:"flex items-center gap-1.5 py-1","data-testid":"toolbar-summary-chip",children:t.jsx("span",{className:"inline-flex items-center rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground",children:e("console.objectView.toolbarEnabledCount",{count:l,total:r})})})}},ne("showSearch",e("console.objectView.enableSearch"),"toggle-showSearch",!0),ne("showSort",e("console.objectView.enableSort"),"toggle-showSort",!0),ne("showFilters",e("console.objectView.enableFilter"),"toggle-showFilters",!0),ne("showHideFields",e("console.objectView.enableHideFields"),"toggle-showHideFields",!0),ne("showGroup",e("console.objectView.enableGroup"),"toggle-showGroup",!0,!1,void 0,oi),ne("showColor",e("console.objectView.enableColor"),"toggle-showColor",!0,!1,void 0,$a),ne("showDensity",e("console.objectView.enableDensity"),"toggle-showDensity",!0,!1,void 0,ue)]}}function mi(e,n){return{key:"navigation",title:e("console.objectView.navigationSection"),hint:e("console.objectView.navigationHint"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_navigationMode",label:e("console.objectView.navigationMode"),type:"custom",render:(a,o,s)=>{const r=s.navigation?.mode||"page";return t.jsx(U,{label:e("console.objectView.navigationMode"),children:t.jsxs("select",{"data-testid":"select-navigation-mode",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]",value:r,onChange:l=>{const c=l.target.value;n("navigation",{...s.navigation||{},mode:c}),n("clickIntoRecordDetails",c!=="none")},children:[t.jsx("option",{value:"page",children:"Page"}),t.jsx("option",{value:"drawer",children:"Drawer"}),t.jsx("option",{value:"modal",children:"Modal"}),t.jsx("option",{value:"split",children:"Split"}),t.jsx("option",{value:"popover",children:"Popover"}),t.jsx("option",{value:"new_window",children:"New Window"}),t.jsx("option",{value:"none",children:"None"})]})})}},{key:"_navigationWidth",label:e("console.objectView.navigationWidth"),type:"custom",helpText:e("console.objectView.navigationWidthHint"),visibleWhen:a=>["drawer","modal","split"].includes(a.navigation?.mode||"page"),render:(a,o,s)=>{const r=s.navigation?.mode||"page";return t.jsx(U,{label:e("console.objectView.navigationWidth"),children:t.jsx(X,{"data-testid":"input-navigation-width",className:"h-7 text-xs w-24 text-right",value:s.navigation?.width??"",placeholder:"600px",onChange:l=>n("navigation",{...s.navigation||{},mode:r,width:l.target.value})})})}},{key:"_navigationOpenNewTab",label:e("console.objectView.openNewTab"),type:"custom",helpText:e("console.objectView.openNewTabHint"),visibleWhen:a=>["page","new_window"].includes(a.navigation?.mode||"page"),render:(a,o,s)=>{const r=s.navigation?.mode||"page";return t.jsx(U,{label:e("console.objectView.openNewTab"),children:t.jsx(Ve,{"data-testid":"toggle-navigation-openNewTab",checked:s.navigation?.openNewTab===!0,onCheckedChange:l=>n("navigation",{...s.navigation||{},mode:r,openNewTab:l}),className:"scale-75"})})}}]}}function pi(e,n){return{key:"records",title:e("console.objectView.records"),hint:e("console.objectView.recordsHint"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_selectionType",label:e("console.objectView.selectionMode"),type:"custom",render:(a,o,s)=>t.jsx(U,{label:e("console.objectView.selectionMode"),children:t.jsxs("select",{"data-testid":"select-selection-type",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]",value:s.selection?.type||"multiple",onChange:r=>n("selection",{type:r.target.value}),children:[t.jsx("option",{value:"none",children:e("console.objectView.selectionNone")}),t.jsx("option",{value:"single",children:e("console.objectView.selectionSingle")}),t.jsx("option",{value:"multiple",children:e("console.objectView.selectionMultiple")})]})})},{key:"_addRecord",label:e("console.objectView.addRecordEnabled"),type:"custom",render:(a,o,s)=>{const r=s.addRecordViaForm===!0||s.addRecord?.enabled===!0;return t.jsxs(t.Fragment,{children:[t.jsx(U,{label:e("console.objectView.addRecordEnabled"),children:t.jsx(Ve,{"data-testid":"toggle-addRecord-enabled",checked:r,onCheckedChange:l=>{n("addRecordViaForm",l),n("addRecord",{...s.addRecord||{},enabled:l})},className:"scale-75"})}),r&&t.jsxs(t.Fragment,{children:[t.jsx(U,{label:e("console.objectView.addRecordPosition"),children:t.jsxs("select",{"data-testid":"select-addRecord-position",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[100px]",value:s.addRecord?.position||"top",onChange:l=>n("addRecord",{...s.addRecord||{},enabled:!0,position:l.target.value}),children:[t.jsx("option",{value:"top",children:"Top"}),t.jsx("option",{value:"bottom",children:"Bottom"})]})}),t.jsx(U,{label:e("console.objectView.addRecordMode"),children:t.jsxs("select",{"data-testid":"select-addRecord-mode",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[100px]",value:s.addRecord?.mode||"form",onChange:l=>n("addRecord",{...s.addRecord||{},enabled:!0,mode:l.target.value}),children:[t.jsx("option",{value:"inline",children:"Inline"}),t.jsx("option",{value:"form",children:"Form"}),t.jsx("option",{value:"modal",children:"Modal"})]})}),t.jsx(U,{label:e("console.objectView.addRecordFormView"),children:t.jsx(X,{"data-testid":"input-addRecord-formView",className:"h-7 text-xs w-24 text-right",value:s.addRecord?.formView??"",onChange:l=>n("addRecord",{...s.addRecord||{},enabled:!0,formView:l.target.value})})})]})]})}}]}}function hi(e,n){return{key:"exportPrint",title:e("console.objectView.exportPrint"),hint:e("console.objectView.exportPrintHint"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_export",label:e("console.objectView.allowExport"),type:"custom",render:(a,o,s)=>{const r=s.exportOptions!=null||s.allowExport===!0;return t.jsxs(t.Fragment,{children:[t.jsx(U,{label:e("console.objectView.allowExport"),children:t.jsx(Ve,{"data-testid":"toggle-allowExport",checked:r,onCheckedChange:l=>n("allowExport",l),className:"scale-75"})}),r&&t.jsxs(t.Fragment,{children:[t.jsx(U,{label:e("console.objectView.exportFormats"),children:t.jsx("div",{"data-testid":"export-formats",className:"flex flex-wrap gap-1",children:["csv","xlsx","json","pdf"].map(l=>t.jsxs("label",{className:"flex items-center gap-1 text-xs cursor-pointer",children:[t.jsx(Re,{"data-testid":`export-format-${l}`,checked:(s.exportOptions?.formats||[]).includes(l),onCheckedChange:c=>{const d=s.exportOptions?.formats||[],u=c?[...d,l]:d.filter(m=>m!==l);n("exportOptions",{...s.exportOptions||{},formats:u})},className:"h-3.5 w-3.5"}),l]},l))})}),t.jsx(U,{label:e("console.objectView.exportMaxRecords"),children:t.jsx(X,{"data-testid":"input-export-maxRecords",className:"h-7 text-xs w-20 text-right",type:"number",value:s.exportOptions?.maxRecords??"",placeholder:"0",onChange:l=>n("exportOptions",{...s.exportOptions||{},maxRecords:Number(l.target.value)||void 0})})}),t.jsx(U,{label:e("console.objectView.exportIncludeHeaders"),children:t.jsx(Ve,{"data-testid":"toggle-export-includeHeaders",checked:s.exportOptions?.includeHeaders!==!1,onCheckedChange:l=>n("exportOptions",{...s.exportOptions||{},includeHeaders:l}),className:"scale-75"})}),t.jsx(U,{label:e("console.objectView.exportFileNamePrefix"),children:t.jsx(X,{"data-testid":"input-export-fileNamePrefix",className:"h-7 text-xs w-24 text-right",value:s.exportOptions?.fileNamePrefix??"",placeholder:"export",onChange:l=>n("exportOptions",{...s.exportOptions||{},fileNamePrefix:l.target.value})})})]})]})}},ne("showRecordCount",e("console.objectView.showRecordCount"),"toggle-showRecordCount",!1,!0,void 0,ue),ne("allowPrinting",e("console.objectView.allowPrinting"),"toggle-allowPrinting",!1,!0,void 0,ue)]}}function gi(e,n,a,o,s,r,l){return{key:"data",title:e("console.objectView.data"),hint:e("console.objectView.listConfigHint"),collapsible:!0,fields:[{key:"_source",label:e("console.objectView.source"),type:"custom",render:()=>t.jsx(U,{label:e("console.objectView.source"),value:o.label||o.name})},{key:"_columns",label:e("console.objectView.fields"),type:"custom",render:(c,d,u)=>{const m=Array.isArray(u.columns)?u.columns.length:0,p=m>0?e("console.objectView.fieldsVisible",{count:m}):e("console.objectView.none"),g=(v,b)=>{const S=Array.isArray(u.columns)?[...u.columns]:[];if(b&&!S.includes(v))S.push(v);else if(!b){const E=S.indexOf(v);E>=0&&S.splice(E,1)}s("columns",S)},x=(v,b)=>{const S=Array.isArray(u.columns)?[...u.columns]:[],E=S.indexOf(v);if(E<0)return;const f=b==="up"?E-1:E+1;f<0||f>=S.length||([S[E],S[f]]=[S[f],S[E]],s("columns",S))},h=()=>{s("columns",n.map(v=>v.value))},F=()=>{s("columns",[])};return t.jsx(fe,{renderSummary:v=>t.jsx(U,{label:e("console.objectView.fields"),value:p,onClick:v}),children:t.jsxs("div",{"data-testid":"column-selector",className:"pb-2 space-y-1",children:[t.jsxs("div",{className:"flex items-center gap-1 pb-1",children:[t.jsx(X,{"data-testid":"column-search-input",className:"h-6 text-xs flex-1",placeholder:e("console.objectView.searchFields"),onChange:v=>{const b=v.target,S=b.closest('[data-testid="column-selector"]');if(!S)return;const E=b.value.toLowerCase();S.querySelectorAll("[data-field-name]").forEach(f=>{const w=f.getAttribute("data-field-name")||"",j=f.getAttribute("data-field-label")||"";f.style.display=!E||w.toLowerCase().includes(E)||j.toLowerCase().includes(E)?"":"none"})}}),t.jsx("button",{type:"button","data-testid":"column-show-all",className:"text-xs text-primary hover:underline whitespace-nowrap",onClick:h,children:e("console.objectView.showAllFields")}),t.jsx("button",{type:"button","data-testid":"column-hide-all",className:"text-xs text-primary hover:underline whitespace-nowrap",onClick:F,children:e("console.objectView.hideAllFields")})]}),t.jsxs("div",{className:"space-y-0.5 max-h-48 overflow-auto",children:[Array.isArray(u.columns)&&u.columns.length>0&&t.jsx("div",{"data-testid":"selected-columns",className:"space-y-0.5 pb-1 mb-1 border-b border-border/50",children:t.jsx(ri,{columns:u.columns,fieldOptions:n,onToggle:g,onMove:x,onReorder:v=>s("columns",v)})}),n.filter(v=>!Array.isArray(u.columns)||!u.columns.includes(v.value)).map(v=>t.jsxs("div",{"data-field-name":v.value,"data-field-label":v.label,className:"flex items-center gap-1 text-xs cursor-pointer hover:bg-accent/50 rounded-sm py-0.5 px-1 -mx-1",children:[t.jsx(lt,{className:"h-3 w-3 text-muted-foreground/20 shrink-0"}),t.jsx("button",{type:"button","data-testid":`col-eye-${v.value}`,className:"h-5 w-5 flex items-center justify-center rounded hover:bg-accent shrink-0",onClick:()=>g(v.value,!0),"aria-label":`Show ${v.label}`,children:t.jsx(fr,{className:"h-3.5 w-3.5 text-muted-foreground"})}),t.jsx("span",{className:"truncate text-muted-foreground",children:v.label})]},v.value))]})]})})}},{key:"_filterBy",label:e("console.objectView.filterBy"),type:"custom",render:(c,d,u)=>{const m=r.conditions.length,p=m>0?e("console.objectView.filtersCount",{count:m}):e("console.objectView.none");return t.jsx(fe,{renderSummary:g=>t.jsx(U,{label:e("console.objectView.filterBy"),value:p,onClick:g}),children:t.jsx("div",{"data-testid":"inline-filter-builder",className:"pb-2",children:t.jsx(Ps,{fields:n,value:r,onChange:g=>{const x=Jo(g.logic,g.conditions.map(h=>({field:h.field,operator:h.operator,value:h.value})));s("filter",x)},className:"[&_button]:h-7 [&_button]:text-xs [&_input]:h-7 [&_input]:text-xs",showClearAll:!0})})})}},{key:"_sortBy",label:e("console.objectView.sortBy"),type:"custom",render:(c,d,u)=>{const m=Array.isArray(u.sort)?u.sort.filter(g=>g.field).length:0,p=m>0?e("console.objectView.sortsCount",{count:m}):e("console.objectView.none");return t.jsx(fe,{renderSummary:g=>t.jsx(U,{label:e("console.objectView.sortBy"),value:p,onClick:g}),children:t.jsx("div",{"data-testid":"inline-sort-builder",className:"pb-2",children:t.jsx(Is,{fields:n.map(g=>({value:g.value,label:g.label})),value:l,onChange:g=>{const x=g.map(h=>({id:h.id,field:h.field,order:h.order}));s("sort",x)},className:"[&_button]:h-7 [&_button]:text-xs"})})})}},{key:"_groupBy",label:e("console.objectView.groupBy"),type:"custom",visibleWhen:li,render:(c,d,u)=>{const m=u.type||"grid",p=u.kanban?.groupByField||u.kanban?.groupField||u.groupBy||"";return t.jsx(U,{label:e("console.objectView.groupBy"),children:t.jsxs("select",{"data-testid":"data-groupBy",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]",value:p,onChange:g=>{if(s("groupBy",g.target.value),m==="kanban"){const x=u.kanban||{};s("kanban",{...x,groupByField:g.target.value})}},children:[t.jsx("option",{value:"",children:e("console.objectView.none")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})})}},{key:"_pageSize",label:e("console.objectView.pageSize"),type:"custom",render:(c,d,u)=>t.jsx(U,{label:e("console.objectView.pageSize"),children:t.jsx(X,{"data-testid":"input-pagination-pageSize",className:"h-7 text-xs w-20 text-right",type:"number",value:u.pagination?.pageSize??"",placeholder:"25",onChange:m=>{const p=Number(m.target.value)||void 0;s("pagination",{...u.pagination||{},pageSize:p})}})})},{key:"_pageSizeOptions",label:e("console.objectView.pageSizeOptions"),type:"custom",render:(c,d,u)=>t.jsx(U,{label:e("console.objectView.pageSizeOptions"),children:t.jsx(X,{"data-testid":"input-pagination-pageSizeOptions",className:"h-7 text-xs w-28 text-right",value:(u.pagination?.pageSizeOptions||[]).join(", "),placeholder:"10, 25, 50, 100",onChange:m=>{const p=Zo(m.target.value);s("pagination",{...u.pagination||{},pageSizeOptions:p.length?p:void 0})}})})},Ct("searchableFields",e("console.objectView.searchableFields"),"searchable-fields-selector","searchable-field",n,s,"selected"),Ct("filterableFields",e("console.objectView.filterableFields"),"filterable-fields-selector","filterable-field",n,s,"selected"),Ct("hiddenFields",e("console.objectView.hiddenFields"),"hidden-fields-selector","hidden-field",n,s,"hidden"),{key:"_quickFilters",label:e("console.objectView.quickFilters"),type:"custom",render:(c,d,u)=>t.jsx(fe,{renderSummary:m=>t.jsx(U,{label:e("console.objectView.quickFilters"),value:`${(u.quickFilters||[]).length} filters`,onClick:m}),children:t.jsxs("div",{"data-testid":"quick-filters-editor",className:"pb-2 space-y-1",children:[(u.quickFilters||[]).map((m,p)=>t.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[t.jsx(X,{"data-testid":`quick-filter-label-${p}`,className:"h-6 text-xs flex-1",value:m.label||"",placeholder:"Label",onChange:g=>{const x=[...u.quickFilters||[]];x[p]={...x[p],label:g.target.value},s("quickFilters",x)}}),t.jsx(Re,{"data-testid":`quick-filter-default-${p}`,checked:m.defaultActive===!0,onCheckedChange:g=>{const x=[...u.quickFilters||[]];x[p]={...x[p],defaultActive:g},s("quickFilters",x)},className:"h-3.5 w-3.5"}),t.jsx("button",{type:"button",className:"text-destructive hover:text-destructive/80 text-xs",onClick:()=>{const g=(u.quickFilters||[]).filter((x,h)=>h!==p);s("quickFilters",g)},children:"✕"})]},m.id||p)),t.jsxs("button",{type:"button","data-testid":"add-quick-filter",className:"text-xs text-primary hover:underline",onClick:()=>{const m={id:crypto.randomUUID(),label:"",filters:[],defaultActive:!1};s("quickFilters",[...u.quickFilters||[],m])},children:["+ ",e("console.objectView.addQuickFilter")]})]})})},{key:"_userFilters",label:e("console.objectView.userFilters"),type:"custom",render:(c,d,u)=>{const m=u.userFilters||{element:"dropdown",fields:[]},p=m.element||"dropdown",g=m.fields||[],x=m.tabs||[],h=n.filter(b=>{const S=Array.isArray(b.options)&&b.options.length>0,E=b.type==="select"||b.type==="boolean";return S||E}).map(b=>b.value),F=[{value:"dropdown",label:e("console.objectView.ufDropdown")},{value:"tabs",label:e("console.objectView.ufTabs")},{value:"toggle",label:e("console.objectView.ufToggle")}],v=p==="tabs"?x.length>0?x.map(b=>b.label||b.id).join(", "):e("console.objectView.none"):g.length>0?g.map(b=>n.find(E=>E.value===b.field)?.label||b.field).join(", "):e("console.objectView.none");return t.jsx(fe,{renderSummary:b=>t.jsx(U,{label:e("console.objectView.userFilters"),value:v,onClick:b}),children:t.jsxs("div",{"data-testid":"user-filters-editor",className:"pb-2 space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.ufElements")}),t.jsx("div",{className:"flex gap-1",children:F.map(b=>t.jsx("button",{type:"button","data-testid":`uf-element-${b.value}`,className:`text-xs px-2 py-0.5 rounded border ${p===b.value?"bg-primary text-primary-foreground border-primary":"border-border hover:bg-accent"}`,onClick:()=>{s("userFilters",{...m,element:b.value})},children:b.label},b.value))})]}),(p==="dropdown"||p==="toggle")&&t.jsxs("div",{"data-testid":"uf-fields-section",className:"space-y-1",children:[g.map((b,S)=>t.jsxs("div",{"data-testid":`uf-field-${S}`,className:"flex items-center gap-1 text-xs",children:[t.jsx("span",{className:"flex-1 truncate",children:n.find(E=>E.value===b.field)?.label||b.field}),t.jsx("button",{type:"button","data-testid":`uf-remove-field-${S}`,className:"text-destructive hover:text-destructive/80 text-xs",onClick:()=>{const E=g.filter((f,w)=>w!==S);s("userFilters",{...m,fields:E})},children:"✕"})]},b.field||S)),h.length>0?t.jsxs("select",{"data-testid":"uf-add-field",className:"text-xs h-6 w-full border rounded px-1",value:"",onChange:b=>{if(!b.target.value)return;const S={field:b.target.value};s("userFilters",{...m,fields:[...g,S]}),b.target.value=""},children:[t.jsx("option",{value:"",children:e("console.objectView.ufAddField")}),h.filter(b=>!g.some(S=>S.field===b)).map(b=>{const S=n.find(E=>E.value===b);return t.jsx("option",{value:b,children:S?.label||b},b)})]}):t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.ufNoFields")})]}),p==="tabs"&&t.jsxs("div",{"data-testid":"uf-tabs-section",className:"space-y-1",children:[x.map((b,S)=>t.jsxs("div",{"data-testid":`uf-tab-${S}`,className:"flex items-center gap-1 text-xs",children:[t.jsx(X,{"data-testid":`uf-tab-label-${S}`,className:"h-6 text-xs flex-1",value:b.label||"",placeholder:e("console.objectView.ufTabLabel"),onChange:E=>{const f=[...x];f[S]={...f[S],label:E.target.value},s("userFilters",{...m,tabs:f})}}),t.jsx(Re,{"data-testid":`uf-tab-default-${S}`,checked:b.default===!0,onCheckedChange:E=>{const f=x.map((w,j)=>({...w,default:j===S?E:!1}));s("userFilters",{...m,tabs:f})},className:"h-3.5 w-3.5"}),t.jsx("button",{type:"button","data-testid":`uf-remove-tab-${S}`,className:"text-destructive hover:text-destructive/80 text-xs",onClick:()=>{const E=x.filter((f,w)=>w!==S);s("userFilters",{...m,tabs:E})},children:"✕"})]},b.id||S)),t.jsx("button",{type:"button","data-testid":"uf-add-tab",className:"text-xs text-primary hover:underline",onClick:()=>{const b={id:crypto.randomUUID(),label:"",filters:[],default:!1};s("userFilters",{...m,tabs:[...x,b]})},children:e("console.objectView.ufAddTab")}),t.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[t.jsx(Re,{"data-testid":"uf-show-all-records",checked:m.showAllRecords!==!1,onCheckedChange:b=>{s("userFilters",{...m,showAllRecords:b?void 0:!1})},className:"h-3.5 w-3.5"}),t.jsx("span",{className:"text-xs",children:e("console.objectView.ufShowAllRecords")})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(Re,{"data-testid":"uf-allow-add-tab",checked:m.allowAddTab===!0,onCheckedChange:b=>{s("userFilters",{...m,allowAddTab:b})},className:"h-3.5 w-3.5"}),t.jsx("span",{className:"text-xs",children:e("console.objectView.ufAllowAddTab")})]})]})]})})}},ne("virtualScroll",e("console.objectView.virtualScroll"),"toggle-virtualScroll",!1,!0,void 0,ue),{key:"_typeOptions",label:"Type-specific options",type:"custom",render:(c,d,u)=>{const m=u.type||"grid",p=(g,x,h)=>{const F=u[g]||{};s(g,{...F,[x]:h})};return m==="grid"?t.jsx("div",{"data-testid":"type-options-section",className:"hidden"}):t.jsxs("div",{"data-testid":"type-options-section",className:"pt-1 space-y-2",children:[m==="kanban"&&t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.groupByField")}),t.jsxs("select",{"data-testid":"type-opt-kanban-groupByField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.kanban?.groupByField||u.kanban?.groupField||"",onChange:g=>p("kanban","groupByField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),m==="calendar"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.startDateField")}),t.jsxs("select",{"data-testid":"type-opt-calendar-startDateField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.calendar?.startDateField||"",onChange:g=>p("calendar","startDateField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.endDateField")}),t.jsxs("select",{"data-testid":"type-opt-calendar-endDateField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.calendar?.endDateField||"",onChange:g=>p("calendar","endDateField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.titleField")}),t.jsxs("select",{"data-testid":"type-opt-calendar-titleField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.calendar?.titleField||"",onChange:g=>p("calendar","titleField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]})]}),m==="map"&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.latitudeField")}),t.jsxs("select",{"data-testid":"type-opt-map-latitudeField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.map?.latitudeField||"",onChange:g=>p("map","latitudeField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.longitudeField")}),t.jsxs("select",{"data-testid":"type-opt-map-longitudeField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.map?.longitudeField||"",onChange:g=>p("map","longitudeField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]})]}),m==="gallery"&&t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.imageField")}),t.jsxs("select",{"data-testid":"type-opt-gallery-imageField",className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u.gallery?.imageField||"",onChange:g=>p("gallery","imageField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),(m==="timeline"||m==="gantt")&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.dateField")}),t.jsxs("select",{"data-testid":`type-opt-${m}-dateField`,className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u[m]?.dateField||u[m]?.startDateField||"",onChange:g=>p(m,"dateField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]}),t.jsxs("div",{children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:e("console.objectView.titleField")}),t.jsxs("select",{"data-testid":`type-opt-${m}-titleField`,className:"w-full text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground mt-1",value:u[m]?.titleField||"",onChange:g=>p(m,"titleField",g.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.selectField")}),n.map(g=>t.jsx("option",{value:g.value,children:g.label},g.value))]})]})]})]})}}]}}function fi(e,n,a,o){return{key:"appearance",title:e("console.objectView.appearance"),collapsible:!0,defaultCollapsed:!0,fields:[ne("striped",e("console.objectView.striped"),"toggle-striped",!1,!0,void 0,ue),ne("bordered",e("console.objectView.bordered"),"toggle-bordered",!1,!0,void 0,ue),{key:"color",label:e("console.objectView.color"),type:"custom",visibleWhen:$a,render:(s,r)=>t.jsx(U,{label:e("console.objectView.color"),children:t.jsxs("select",{"data-testid":"appearance-color",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]",value:s||"",onChange:l=>r(l.target.value),children:[t.jsx("option",{value:"",children:e("console.objectView.none")}),n.map(l=>t.jsx("option",{value:l.value,children:l.label},l.value))]})})},ne("wrapHeaders",e("console.objectView.wrapHeaders"),"toggle-wrapHeaders",!1,!0,void 0,ue),ne("showDescription",e("console.objectView.showFieldDescriptions"),"toggle-showDescription",!0),ne("resizable",e("console.objectView.resizableColumns"),"toggle-resizable",!1,!0,void 0,ue),{key:"rowHeight",label:e("console.objectView.rowHeight"),type:"custom",visibleWhen:ue,render:(s,r)=>t.jsx(U,{label:e("console.objectView.rowHeight"),children:t.jsx("div",{className:"flex gap-0.5","data-testid":"appearance-rowHeight",role:"radiogroup","aria-label":e("console.objectView.rowHeight"),children:Xo.map(l=>t.jsx("button",{type:"button",role:"radio","aria-checked":(s||"compact")===l.value,"aria-label":l.value,"data-testid":`row-height-${l.value}`,className:`h-7 w-7 rounded border flex items-center justify-center ${(s||"compact")===l.value?"border-primary bg-primary/10 text-primary":"border-input text-muted-foreground hover:bg-accent/50"}`,onClick:()=>r(l.value),title:l.value,children:t.jsxs("div",{className:`flex flex-col items-center justify-center w-4 h-4 ${l.gapClass}`,children:[t.jsx("div",{className:"w-3.5 h-px bg-current rounded-full"}),t.jsx("div",{className:"w-3.5 h-px bg-current rounded-full"}),t.jsx("div",{className:"w-3.5 h-px bg-current rounded-full"})]})},l.value))})})},{key:"_conditionalFormatting",label:e("console.objectView.conditionalFormatting"),type:"custom",visibleWhen:ii,render:(s,r,l)=>t.jsx(fe,{renderSummary:c=>t.jsx(U,{label:e("console.objectView.conditionalFormatting"),value:`${(l.conditionalFormatting||[]).length} rules`,onClick:c}),children:t.jsxs("div",{"data-testid":"conditional-formatting-editor",className:"pb-2 space-y-1",children:[(l.conditionalFormatting||[]).map((c,d)=>t.jsxs("div",{className:"flex items-center gap-1 text-xs border rounded p-1",children:[t.jsxs("select",{"data-testid":`cf-field-${d}`,className:"text-xs h-6 rounded border border-input bg-background px-1 flex-1",value:c.field||"",onChange:u=>{const m=[...l.conditionalFormatting||[]];m[d]={...m[d],field:u.target.value},o("conditionalFormatting",m)},children:[t.jsx("option",{value:"",children:"Field"}),n.map(u=>t.jsx("option",{value:u.value,children:u.label},u.value))]}),t.jsxs("select",{"data-testid":`cf-operator-${d}`,className:"text-xs h-6 rounded border border-input bg-background px-1",value:c.operator||"equals",onChange:u=>{const m=[...l.conditionalFormatting||[]];m[d]={...m[d],operator:u.target.value},o("conditionalFormatting",m)},children:[t.jsx("option",{value:"equals",children:"="}),t.jsx("option",{value:"not_equals",children:"≠"}),t.jsx("option",{value:"contains",children:"contains"}),t.jsx("option",{value:"greater_than",children:">"}),t.jsx("option",{value:"less_than",children:"<"}),t.jsx("option",{value:"in",children:"in"})]}),t.jsx(X,{"data-testid":`cf-value-${d}`,className:"h-6 text-xs w-16",value:String(c.value??""),placeholder:"Value",onChange:u=>{const m=[...l.conditionalFormatting||[]];m[d]={...m[d],value:u.target.value},o("conditionalFormatting",m)}}),t.jsx("button",{type:"button",className:"text-destructive hover:text-destructive/80 text-xs",onClick:()=>{const u=(l.conditionalFormatting||[]).filter((m,p)=>p!==d);o("conditionalFormatting",u)},children:"✕"})]},d)),t.jsxs("button",{type:"button","data-testid":"add-conditional-rule",className:"text-xs text-primary hover:underline",onClick:()=>{const c={field:"",operator:"equals",value:""};o("conditionalFormatting",[...l.conditionalFormatting||[],c])},children:["+ ",e("console.objectView.addRule")]})]})})},{key:"_emptyState",label:"Empty state",type:"custom",render:(s,r,l)=>t.jsxs(t.Fragment,{children:[t.jsx(U,{label:e("console.objectView.emptyStateTitle"),children:t.jsx(X,{"data-testid":"input-emptyState-title",className:"h-7 text-xs w-28 text-right",value:l.emptyState?.title??"",onChange:c=>o("emptyState",{...l.emptyState||{},title:c.target.value})})}),t.jsx(U,{label:e("console.objectView.emptyStateMessage"),children:t.jsx(X,{"data-testid":"input-emptyState-message",className:"h-7 text-xs w-28 text-right",value:l.emptyState?.message??"",onChange:c=>o("emptyState",{...l.emptyState||{},message:c.target.value})})}),t.jsx(U,{label:e("console.objectView.emptyStateIcon"),children:t.jsx(X,{"data-testid":"input-emptyState-icon",className:"h-7 text-xs w-28 text-right",value:l.emptyState?.icon??"",onChange:c=>o("emptyState",{...l.emptyState||{},icon:c.target.value})})})]})}]}}function xi(e,n){return{key:"userActions",title:e("console.objectView.userActions"),collapsible:!0,defaultCollapsed:!0,fields:[ne("inlineEdit",e("console.objectView.inlineEdit"),"toggle-inlineEdit",!0,!1,void 0,ue),ne("addDeleteRecordsInline",e("console.objectView.addDeleteRecordsInline"),"toggle-addDeleteRecordsInline",!0,!1,void 0,ue),{key:"_rowActions",label:e("console.objectView.rowActions"),type:"custom",visibleWhen:Tn,render:(a,o,s)=>t.jsx(fe,{renderSummary:r=>t.jsx(U,{label:e("console.objectView.rowActions"),value:`${(s.rowActions||[]).length} actions`,onClick:r}),children:t.jsx("div",{"data-testid":"row-actions-selector",className:"pb-2 space-y-0.5 max-h-36 overflow-auto",children:t.jsx(X,{"data-testid":"input-rowActions",className:"h-7 text-xs w-full",value:(s.rowActions||[]).join(", "),placeholder:"edit, delete, duplicate",onChange:r=>{n("rowActions",An(r.target.value))}})})})},{key:"_bulkActions",label:e("console.objectView.bulkActions"),type:"custom",visibleWhen:Tn,render:(a,o,s)=>t.jsx(fe,{renderSummary:r=>t.jsx(U,{label:e("console.objectView.bulkActions"),value:`${(s.bulkActions||[]).length} actions`,onClick:r}),children:t.jsx("div",{"data-testid":"bulk-actions-selector",className:"pb-2 space-y-0.5 max-h-36 overflow-auto",children:t.jsx(X,{"data-testid":"input-bulkActions",className:"h-7 text-xs w-full",value:(s.bulkActions||[]).join(", "),placeholder:"delete, export, assign",onChange:r=>{n("bulkActions",An(r.target.value))}})})})}]}}function bi(e,n){return{key:"sharing",title:e("console.objectView.sharing"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_sharingEnabled",label:e("console.objectView.sharingEnabled"),type:"custom",render:(a,o,s)=>t.jsx(U,{label:e("console.objectView.sharingEnabled"),children:t.jsx(Ve,{"data-testid":"toggle-sharing-enabled",checked:s.sharing?.enabled===!0,onCheckedChange:r=>n("sharing",{...s.sharing||{},enabled:r}),className:"scale-75"})})},{key:"_sharingVisibility",label:e("console.objectView.sharingVisibility"),type:"custom",visibleWhen:a=>a.sharing?.enabled===!0,render:(a,o,s)=>t.jsx(U,{label:e("console.objectView.sharingVisibility"),children:t.jsxs("select",{"data-testid":"select-sharing-visibility",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[120px]",value:s.sharing?.visibility||"private",onChange:r=>n("sharing",{...s.sharing||{},enabled:!0,visibility:r.target.value}),children:[t.jsx("option",{value:"private",children:"Private"}),t.jsx("option",{value:"team",children:"Team"}),t.jsx("option",{value:"organization",children:"Organization"}),t.jsx("option",{value:"public",children:"Public"})]})})}]}}function ji(e,n){return{key:"accessibility",title:e("console.objectView.accessibility"),collapsible:!0,defaultCollapsed:!0,fields:[{key:"_ariaLabel",label:e("console.objectView.ariaLabel"),type:"custom",render:(a,o,s)=>t.jsx(U,{label:e("console.objectView.ariaLabel"),children:t.jsx(X,{"data-testid":"input-aria-label",className:"h-7 text-xs w-28 text-right",value:s.aria?.label??"",onChange:r=>n("aria",{...s.aria||{},label:r.target.value})})})},{key:"_ariaDescribedBy",label:e("console.objectView.ariaDescribedBy"),type:"custom",render:(a,o,s)=>t.jsx(U,{label:e("console.objectView.ariaDescribedBy"),children:t.jsx(X,{"data-testid":"input-aria-describedBy",className:"h-7 text-xs w-28 text-right",value:s.aria?.describedBy??"",onChange:r=>n("aria",{...s.aria||{},describedBy:r.target.value})})})},{key:"_ariaLive",label:e("console.objectView.ariaLive"),type:"custom",render:(a,o,s)=>t.jsx(U,{label:e("console.objectView.ariaLive"),children:t.jsxs("select",{"data-testid":"select-aria-live",className:"text-xs h-7 rounded-md border border-input bg-background px-2 text-foreground max-w-[100px]",value:s.aria?.live||"off",onChange:r=>n("aria",{...s.aria||{},live:r.target.value}),children:[t.jsx("option",{value:"off",children:"Off"}),t.jsx("option",{value:"polite",children:"Polite"}),t.jsx("option",{value:"assertive",children:"Assertive"})]})})}]}}function ne(e,n,a,o=!1,s=!1,r,l){return{key:e,label:n,type:"custom",disabledWhen:r,visibleWhen:l,render:(c,d,u)=>t.jsx(U,{label:n,children:t.jsx(Ve,{"data-testid":a,checked:s?c===!0:o?c!==!1:!!c,disabled:!1,onCheckedChange:m=>d(m),className:"scale-75"})})}}function Ct(e,n,a,o,s,r,l,c){return{key:`_${e}`,label:n,type:"custom",visibleWhen:c,render:(d,u,m)=>t.jsx(fe,{renderSummary:p=>t.jsx(U,{label:n,value:`${(m[e]||[]).length} ${l}`,onClick:p}),children:t.jsx("div",{"data-testid":a,className:"pb-2 space-y-0.5 max-h-36 overflow-auto",children:s.map(p=>t.jsxs("label",{className:"flex items-center gap-2 text-xs cursor-pointer hover:bg-accent/50 rounded-sm py-0.5 px-1 -mx-1",children:[t.jsx(Re,{"data-testid":`${o}-${p.value}`,checked:(m[e]||[]).includes(p.value),onCheckedChange:g=>{const x=m[e]||[],h=g?[...x,p.value]:x.filter(F=>F!==p.value);r(e,h)},className:"h-3.5 w-3.5"}),t.jsx("span",{className:"truncate",children:p.label})]},p.value))})})}}function yi({open:e,onClose:n,mode:a="edit",activeView:o,objectDef:s,onViewUpdate:r,onSave:l,onCreate:c}){const{t:d}=me(),u=i.useRef(null),m=i.useMemo(()=>({id:`view_${Date.now()}`,label:d("console.objectView.newView"),type:"grid",columns:[],filter:[],sort:[],showSearch:!0,showFilters:!0,showSort:!0}),[]),p=a==="create"?"create":o.id,g=i.useMemo(()=>({...o}),[p]),x=a==="create"?m:g,{draft:h,isDirty:F,updateField:v,discard:b,undo:S,redo:E,canUndo:f,canRedo:w}=Ls(x,{mode:a,onUpdate:r});i.useEffect(()=>{e&&u.current&&u.current.focus()},[e]);const j=i.useMemo(()=>ei(s),[s.fields]),y=i.useMemo(()=>ti(h.filter),[h.filter]),C=i.useMemo(()=>ni(h.sort),[h.sort]),V=i.useMemo(()=>ci({t:d,fieldOptions:j,objectDef:s,updateField:v,filterGroupValue:y,sortItemsValue:C}),[d,j,s,v,y,C]),k=h.type||"grid",M=i.useMemo(()=>({...V,breadcrumb:[d("console.objectView.page"),tn[k]||k]}),[V,d,k]),N=i.useCallback(()=>{a==="create"?c?.(h):l?.(h),b()},[h,l,c,a,b]),A=i.useCallback(()=>{if(a==="create"){n();return}b()},[b,a,n]),R=d(a==="create"?"console.objectView.createView":"console.objectView.configureView");return t.jsx($s,{open:e,onClose:n,schema:M,draft:h,isDirty:F,onFieldChange:v,onSave:N,onDiscard:A,onUndo:S,onRedo:E,canUndo:f,canRedo:w,undoLabel:d("designer.undo"),redoLabel:d("designer.redo"),objectDef:s,saveLabel:d("console.objectView.save"),discardLabel:d("console.objectView.discard"),panelRef:u,role:"complementary",ariaLabel:R,tabIndex:-1,testId:"view-config-panel",closeTitle:d("console.objectView.closePanel"),footerTestId:"view-config-footer",saveTestId:"view-config-save",discardTestId:"view-config-discard",className:"transition-all overflow-hidden"})}function vi({objectName:e,objectLabel:n,dataSource:a,onEdit:o,onRefresh:s}){const r=Pe(),{appName:l}=Ge(),c=`/apps/${l}`,{execute:d,loading:u,error:m,runner:p}=oa({context:{objectName:e,objectLabel:n||e,baseUrl:c}});i.useEffect(()=>{p.registerHandler("create",async()=>(o?.(null),{success:!0})),p.registerHandler("delete",async v=>{const b=v.params?.recordId||v.recordId;if(!b)return{success:!1,error:"No record ID provided"};try{return await a.delete(e,b),s?.(),K.success(`${n||e} deleted successfully`),{success:!0,reload:!0}}catch(S){return K.error(`Failed to delete ${n||e}`,{description:S.message}),{success:!1,error:S.message}}}),p.registerHandler("navigate",async v=>{const b=v.params?.url||v.url;return b&&r(b.startsWith("/")?b:`${c}/${b}`),{success:!0}}),p.registerHandler("refresh",async()=>(s?.(),{success:!0,reload:!0}))},[p,e,a,o,s,r,c]);const g=i.useCallback(()=>{o?.(null)},[o]),x=i.useCallback(async v=>d({type:"delete",confirmText:"Are you sure you want to delete this record?",params:{recordId:v}}),[d]),h=i.useCallback(v=>{r(`${c}/${e}/view/${v}`)},[r,c,e]),F=i.useCallback(v=>{r(`${c}/${e}/record/${encodeURIComponent(v)}`)},[r,c,e]);return{execute:d,create:g,deleteRecord:x,navigateToView:h,navigateToRecord:F,loading:u,error:m}}const wi={grid:Ft,kanban:Cr,calendar:ba,gallery:Nr,timeline:wr,gantt:vr,map:yr,chart:ga},Ni={id:"current-user",name:"Demo User"};function Rn({objectDef:e,recordId:n,dataSource:a,onEdit:o}){const{user:s}=gt(),r=s?{id:s.id,name:s.name,avatar:s.image}:Ni,[l,c]=i.useState([]);i.useEffect(()=>{if(!a||!e?.name||!n)return;const p=`${e.name}:${n}`;a.find("sys_comment",{$filter:{threadId:p},$orderby:{createdAt:"asc"}}).then(g=>{g.data?.length&&c(g.data.map(x=>({id:x.id,type:"comment",actor:x.author?.name??"Unknown",actorAvatarUrl:x.author?.avatar,body:x.content,createdAt:x.createdAt,updatedAt:x.updatedAt,parentId:x.parentId,reactions:x.reactions?Object.entries(x.reactions).map(([h,F])=>({emoji:h,count:F.length,reacted:F.includes(r.id)})):void 0})))}).catch(()=>{})},[a,e?.name,n,r.id]);const d=i.useCallback(async p=>{const g={id:crypto.randomUUID(),type:"comment",actor:r.name,actorAvatarUrl:"avatar"in r?r.avatar:void 0,body:p,createdAt:new Date().toISOString()};if(c(x=>[...x,g]),a){const x=`${e.name}:${n}`;a.create("sys_comment",{id:g.id,threadId:x,author:r,content:p,mentions:[],createdAt:g.createdAt}).catch(()=>{})}},[r,a,e?.name,n]),u=i.useCallback(async(p,g)=>{const x={id:crypto.randomUUID(),type:"comment",actor:r.name,actorAvatarUrl:"avatar"in r?r.avatar:void 0,body:g,createdAt:new Date().toISOString(),parentId:p};if(c(h=>[...h,x].map(v=>v.id===p?{...v,replyCount:(v.replyCount??0)+1}:v)),a){const h=`${e.name}:${n}`;a.create("sys_comment",{id:x.id,threadId:h,author:r,content:g,mentions:[],createdAt:x.createdAt,parentId:p}).catch(()=>{})}},[r,a,e?.name,n]),m=i.useCallback((p,g)=>{c(x=>x.map(h=>{if(h.id!==p)return h;const F=[...h.reactions??[]],v=F.findIndex(S=>S.emoji===g);if(v>=0){const S=F[v];S.reacted?S.count<=1?F.splice(v,1):F[v]={...S,count:S.count-1,reacted:!1}:F[v]={...S,count:S.count+1,reacted:!0}}else F.push({emoji:g,count:1,reacted:!0});const b={...h,reactions:F};return a&&a.update("sys_comment",String(p),{$toggleReaction:{emoji:g,userId:r.id}}).catch(()=>{}),b}))},[r.id,a]);return t.jsxs("div",{className:"h-full bg-background overflow-auto p-3 sm:p-4 lg:p-6",children:[t.jsx(Ar,{schema:{type:"detail-view",objectName:e.name,resourceId:n,showBack:!1,showEdit:!0,title:e.label,sections:[{title:"Details",fields:Object.keys(e.fields||{}).map(p=>({name:p,label:e.fields[p].label||p,type:e.fields[p].type||"text"}))}]},dataSource:a,onEdit:()=>o({id:n})}),t.jsx("div",{className:"mt-6 border-t pt-6",children:t.jsx(Tr,{config:{position:"bottom",collapsible:!0,defaultCollapsed:!0,feed:{enableReactions:!0,enableThreading:!0,showCommentInput:!0}},items:l,onAddComment:d,onAddReply:u,onToggleReaction:m})})]})}function Vn({dataSource:e,objects:n,onEdit:a}){const o=Pe(),{objectName:s,viewId:r}=Ge(),[l,c]=ss(),{showDebug:d,toggleDebug:u}=Wo(),{t:m}=me(),{objectLabel:p,objectDescription:g}=la(),[x,h]=i.useState(!1),[F,v]=i.useState("edit"),[b,S]=i.useState(null),E=i.useCallback(_=>{if(S(_),I(H=>H+1),e?.updateViewConfig){const H=s,oe=_.id;H&&oe?e.updateViewConfig(H,oe,_).catch(be=>{console.error("[ViewConfigPanel] Failed to persist view config:",be)}):console.warn("[ViewConfigPanel] Cannot persist view config: missing objectName or viewId.")}else console.warn("[ViewConfigPanel] dataSource.updateViewConfig is not available. View config saved locally only.")},[e,s]),f=i.useCallback(async _=>{try{if(e?.create){const H={objectName:s,..._};await e.create("sys_view",H)}h(!1),v("edit"),I(H=>H+1)}catch(H){console.error("[ViewConfigPanel] Failed to create view:",H)}},[e,s]),[w,j]=i.useState(void 0),{user:y}=gt(),C=y?.role==="admin",{can:V}=ca(),k=n.find(_=>_.name===s);if(!k)return t.jsx("div",{className:"h-full p-4 flex items-center justify-center",children:t.jsxs(mt,{children:[t.jsx("div",{className:"mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:t.jsx(Ft,{className:"h-6 w-6 text-muted-foreground"})}),t.jsx(pt,{children:m("console.objectView.objectNotFound")}),t.jsxs(ht,{children:[m("console.objectView.objectNotFoundDescription",{objectName:s})," ",m("console.objectView.objectNotFoundHint")]})]})});const M=i.useMemo(()=>{const _=k.listViews||k.list_views||{},H=Object.entries(_).map(([oe,be])=>({id:oe,...be,type:be.type||"grid"}));return H.length===0&&H.push({id:"all",label:m("console.objectView.allRecords"),type:"grid",columns:k.fields?Object.keys(k.fields).slice(0,5):[]}),H},[k]),N=r||l.get("view")||M[0]?.id,A=M.find(_=>_.id===N)||M[0],R=b&&b.id===A?.id?{...A,...b}:A,L=i.useCallback((_,H)=>{S(oe=>({...oe||{},id:A?.id,[_]:H}))},[A?.id]),B=_=>{const H=M.find(oe=>oe.id===_);H&&(h(!1),r?o(`../${H.id}`,{relative:"path"}):o(`view/${H.id}`))},P=i.useCallback(()=>{v("create"),h(!0)},[]),$=i.useCallback((_,H)=>{if(_==="settings"){const oe=M.find(be=>be.type===H);oe&&B(oe.id),v("edit"),h(!0)}},[M,B]),[O,I]=i.useState(0),D=vi({objectName:k.name,objectLabel:k.label,dataSource:e,onEdit:a,onRefresh:()=>I(_=>_+1)}),{lastMessage:G}=to({channel:`object:${k.name}`}),W=k.name?`user-${k.name}`:"current-user",{hasConflicts:Q,resolveAllConflicts:se}=ao(W);i.useEffect(()=>{G&&(Q&&se("remote"),I(_=>_+1))},[G,Q,se]),i.useEffect(()=>{e?.find&&k.name&&e.find(k.name,{limit:0}).then(_=>{typeof _?.total=="number"?j(_.total):Array.isArray(_?.data)?j(_.data.length):Array.isArray(_)&&j(_.length)}).catch(()=>{})},[e,k.name,O]);const le=i.useMemo(()=>R?.navigation??k.navigation??{mode:"page"},[R?.navigation,k.navigation]),ce=l.get("recordId"),bt=i.useCallback((_,H)=>{if(H==="new_window"){const oe=window.location.pathname.replace(/\/view\/.*$/,"");window.open(`${oe}/record/${encodeURIComponent(String(_))}`,"_blank");return}(H==="view"||!H||H==="page")&&(r?o(`../../record/${encodeURIComponent(String(_))}`,{relative:"path"}):o(`record/${encodeURIComponent(String(_))}`))},[o,r]),re=Le({navigation:le,objectName:k.name,onNavigate:bt}),nn=()=>{re.close();const _=new URLSearchParams(l);_.delete("recordId"),c(_)};i.useEffect(()=>{ce&&!re.isOpen?re.open({id:ce}):!ce&&re.isOpen&&re.close()},[ce]);const an=i.useCallback(({schema:_,dataSource:H,onEdit:oe,className:be})=>{const on=`${s}-${R.id}-${O}`,T=R;if(T.type==="chart"){const ge=T.chart||{};return t.jsx(Xt,{dataSource:H,schema:{type:"object-chart",objectName:k.name,chartType:ge.chartType,xAxisField:ge.xAxisField,yAxisFields:ge.yAxisFields,aggregation:ge.aggregation,series:ge.series,config:ge.config,filter:ge.filter}},on)}const as={..._,rowHeight:T.rowHeight??_.rowHeight,densityMode:T.densityMode??_.densityMode,inlineEdit:T.inlineEdit??T.editRecordsInline??_.inlineEdit,appearance:T.showDescription!=null?{showDescription:T.showDescription}:_.appearance,showSearch:T.showSearch??_.showSearch,showSort:T.showSort??_.showSort,showFilters:T.showFilters??_.showFilters,showHideFields:T.showHideFields??_.showHideFields,showGroup:T.showGroup??_.showGroup,showColor:T.showColor??_.showColor,showDensity:T.showDensity??_.showDensity,allowExport:T.allowExport??_.allowExport,exportOptions:T.allowExport===!1?void 0:T.exportOptions??_.exportOptions,striped:T.striped??_.striped,bordered:T.bordered??_.bordered,color:T.color??_.color,wrapHeaders:T.wrapHeaders??_.wrapHeaders,clickIntoRecordDetails:T.clickIntoRecordDetails??_.clickIntoRecordDetails,addRecordViaForm:T.addRecordViaForm??_.addRecordViaForm,addDeleteRecordsInline:T.addDeleteRecordsInline??_.addDeleteRecordsInline,collapseAllByDefault:T.collapseAllByDefault??_.collapseAllByDefault,fieldTextColor:T.fieldTextColor??_.fieldTextColor,prefixField:T.prefixField??_.prefixField,showDescription:T.showDescription??_.showDescription,navigation:T.navigation??_.navigation,selection:T.selection??_.selection,pagination:T.pagination??_.pagination,searchableFields:T.searchableFields??_.searchableFields,filterableFields:T.filterableFields??_.filterableFields,resizable:T.resizable??_.resizable,hiddenFields:T.hiddenFields??_.hiddenFields,rowActions:T.rowActions??_.rowActions,bulkActions:T.bulkActions??_.bulkActions,sharing:T.sharing??_.sharing,addRecord:T.addRecord??_.addRecord,conditionalFormatting:T.conditionalFormatting??_.conditionalFormatting,quickFilters:T.quickFilters??_.quickFilters,userFilters:T.userFilters??_.userFilters,showRecordCount:T.showRecordCount??_.showRecordCount,allowPrinting:T.allowPrinting??_.allowPrinting,virtualScroll:T.virtualScroll??_.virtualScroll,emptyState:T.emptyState??_.emptyState,aria:T.aria??_.aria,tabs:_.tabs,...T.filter?.length?{filters:T.filter}:{},...T.sort?.length?{sort:T.sort}:{},options:{kanban:{groupBy:T.kanban?.groupByField||T.kanban?.groupField||"status",groupField:T.kanban?.groupByField||T.kanban?.groupField||"status",titleField:T.kanban?.titleField||k.titleField||"name",cardFields:T.kanban?.columns},calendar:{startDateField:T.calendar?.startDateField||"due_date",endDateField:T.calendar?.endDateField,titleField:T.calendar?.titleField||"name",colorField:T.calendar?.colorField,allDayField:T.calendar?.allDayField,defaultView:T.calendar?.defaultView},timeline:{dateField:T.timeline?.dateField||"due_date",titleField:T.timeline?.titleField||k.titleField||"name",descriptionField:T.timeline?.descriptionField},map:{locationField:T.map?.locationField,titleField:T.map?.titleField||k.titleField||"name",latitudeField:T.map?.latitudeField,longitudeField:T.map?.longitudeField,zoom:T.map?.zoom,center:T.map?.center},gallery:{imageField:T.gallery?.imageField||"image",titleField:T.gallery?.titleField||k.titleField||"name",subtitleField:T.gallery?.subtitleField},gantt:{startDateField:T.gantt?.startDateField||"start_date",endDateField:T.gantt?.endDateField||"end_date",titleField:T.gantt?.titleField||"name",progressField:T.gantt?.progressField,dependenciesField:T.gantt?.dependenciesField,colorField:T.gantt?.colorField},chart:{chartType:T.chart?.chartType,xAxisField:T.chart?.xAxisField,yAxisFields:T.chart?.yAxisFields,aggregation:T.chart?.aggregation,series:T.chart?.series,config:T.chart?.config}}};return t.jsx(Er,{schema:as,className:be,onEdit:oe,onRowClick:ge=>{re.handleClick(ge)},dataSource:H},on)},[R,k,s,O,re]),sn=i.useMemo(()=>M.map(_=>_.id===N&&b&&b.id===_.id?{..._,...b}:_),[M,N,b]),rn=i.useMemo(()=>({type:"object-view",objectName:k.name,layout:"page",showSearch:R?.showSearch!==!1,showFilters:R?.showFilters!==!1,showSort:R?.showSort!==!1,showCreate:!1,showRefresh:!0,allowCreateView:C,viewActions:C?[{type:"settings"},{type:"share"},{type:"duplicate"},{type:"delete"}]:[],onNavigate:(_,H)=>{H==="edit"?a?.({id:_}):H==="view"&&(r?o(`../../record/${encodeURIComponent(String(_))}`,{relative:"path"}):o(`record/${encodeURIComponent(String(_))}`))}}),[k.name,a,R?.showSearch,R?.showFilters,R?.showSort,o,r,C]);return t.jsxs("div",{className:"h-full flex flex-col bg-background min-w-0 overflow-hidden",children:[t.jsxs("div",{className:"flex justify-between items-center py-2.5 sm:py-3 px-3 sm:px-4 border-b shrink-0 bg-background z-10",children:[t.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 min-w-0 flex-1",children:[t.jsx("div",{className:"bg-primary/10 p-1.5 sm:p-2 rounded-md shrink-0",children:t.jsx(Ft,{className:"h-4 w-4 text-primary"})}),t.jsxs("div",{className:"min-w-0",children:[t.jsx("h1",{className:"text-base sm:text-lg font-semibold tracking-tight text-foreground truncate",children:p(k)}),k.description&&t.jsx("p",{className:"text-xs text-muted-foreground truncate hidden sm:block max-w-md",children:g(k)})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 shrink-0",children:[V(k.name,"create")&&t.jsxs(Y,{size:"sm",onClick:D.create,className:"shadow-none gap-1.5 sm:gap-2 h-8 sm:h-9",children:[t.jsx(Fe,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:m("console.objectView.new")})]}),k.actions?.some(_=>_.locations?.includes("list_toolbar"))&&t.jsx(Ws,{schema:{type:"action:bar",location:"list_toolbar",actions:k.actions,size:"sm",variant:"outline"}}),C&&t.jsxs(Ce,{children:[t.jsx(Se,{asChild:!0,children:t.jsx(Y,{size:"sm",variant:"ghost",className:"shadow-none h-8 sm:h-9 px-2",title:m("console.objectView.designTools"),children:t.jsx(br,{className:"h-4 w-4"})})}),t.jsxs(ke,{align:"end",className:"w-48",children:[t.jsxs(ie,{onClick:u,children:[t.jsx(Ho,{open:d,onToggle:u,className:"hidden"}),m("console.objectView.metadataInspector")]}),t.jsx(it,{}),t.jsxs(ie,{onClick:()=>{v("edit"),h(_=>!_)},children:[t.jsx(jr,{className:"h-4 w-4 mr-2"}),m("console.objectView.editView")]}),t.jsxs(ie,{onClick:()=>{v("create"),h(!0)},children:[t.jsx(Fe,{className:"h-4 w-4 mr-2"}),m("console.objectView.addView")]})]})]})]})]}),M.length>1&&t.jsx("div",{className:"border-b px-3 sm:px-4 bg-background overflow-x-auto shrink-0",children:t.jsx(zs,{views:M.map(_=>({id:_.id,label:_.label,type:_.type,hasActiveFilters:Array.isArray(_.filter)&&_.filter.length>0,hasActiveSort:Array.isArray(_.sort)&&_.sort.length>0})),activeViewId:N,onViewChange:B,viewTypeIcons:wi,config:{reorderable:!1}})}),t.jsxs("div",{className:"flex-1 overflow-hidden relative flex flex-row",children:[re.mode==="split"&&re.isOpen?t.jsx(De,{...re,setIsOpen:_=>{_||nn()},title:p(k),mainContent:t.jsxs("div",{className:"flex-1 min-w-0 relative h-full flex flex-col",children:[t.jsx("div",{className:"flex-1 relative overflow-auto p-3 sm:p-4",children:t.jsx(pn,{schema:rn,dataSource:e,views:sn,activeViewId:N,onViewChange:B,onEdit:_=>a?.(_),onRowClick:_=>{re.handleClick(_)},renderListView:an,onCreateView:P,onViewAction:$})}),typeof w=="number"&&t.jsx("div",{"data-testid":"record-count-footer",className:"border-t px-3 sm:px-4 py-1.5 text-xs text-muted-foreground bg-muted/5 shrink-0",children:m("console.objectView.recordCount",{count:w})})]}),children:_=>{const H=_.id||_._id;return t.jsx(Rn,{objectDef:k,recordId:H,dataSource:e,onEdit:a})}}):t.jsx("div",{className:"flex-1 min-w-0 relative h-full flex flex-col",children:t.jsx("div",{className:"flex-1 relative overflow-auto p-3 sm:p-4",children:t.jsx(pn,{schema:rn,dataSource:e,views:sn,activeViewId:N,onViewChange:B,onEdit:_=>a?.(_),onRowClick:_=>{re.handleClick(_)},renderListView:an,onCreateView:P,onViewAction:$})})}),t.jsx(qo,{open:d&&C,sections:[{title:"View Configuration",data:R},{title:"Object Definition",data:k}]}),t.jsx("div",{"data-testid":"view-config-panel-wrapper",className:`transition-[max-width,opacity] duration-300 ease-in-out overflow-hidden ${x&&C?"max-w-[280px] opacity-100":"max-w-0 opacity-0"}`,children:t.jsx(yi,{open:x&&C,onClose:()=>{h(!1),v("edit")},mode:F,activeView:R,objectDef:k,recordCount:w,onSave:E,onViewUpdate:L,onCreate:f})})]}),re.mode!=="split"&&t.jsx(De,{...re,setIsOpen:_=>{_||nn()},title:k.label,className:re.mode==="drawer"?"w-[90vw] sm:max-w-2xl p-0 overflow-hidden":void 0,children:_=>{const H=_.id||_._id;return t.jsx(Rn,{objectDef:k,recordId:H,dataSource:e,onEdit:a})}})]})}function Ci({children:e,authUrl:n}){const[a,o]=i.useState(null),[s,r]=i.useState(void 0),[l,c]=i.useState(!0);return i.useEffect(()=>{let d=!1;async function u(){try{const m=new da({baseUrl:"",autoReconnect:!1});await m.connect();const p=await m.getDiscovery();if(!d)if(p?.mode==="preview")r({autoLogin:p.previewMode?.autoLogin??!0,simulatedRole:p.previewMode?.simulatedRole??"admin",simulatedUserName:p.previewMode?.simulatedUserName??"Preview User",readOnly:p.previewMode?.readOnly??!1,expiresInSeconds:p.previewMode?.expiresInSeconds??0,bannerMessage:p.previewMode?.bannerMessage}),o(!1);else{const g=p?.services?.auth?.enabled??!0;o(g)}}catch(m){d||(console.warn("[ConditionalAuthWrapper] Failed to fetch discovery, defaulting to auth enabled:",m),o(!0))}finally{d||c(!1)}}return u(),()=>{d=!0}},[]),l?t.jsx(de,{}):s?t.jsx(yt,{authUrl:n,previewMode:s,children:e}):a?t.jsx(yt,{authUrl:n,children:e}):t.jsx(yt,{authUrl:n,enabled:!1,children:e})}function Si(){const{t:e}=me(),[n,a]=i.useState(!1),o=i.useMemo(()=>[{title:e("console.shortcuts.groups.general"),shortcuts:[{keys:["⌘","K"],description:e("console.shortcuts.openCommandPalette")},{keys:["?"],description:e("console.shortcuts.showShortcuts")},{keys:["Esc"],description:e("console.shortcuts.closeDialog")}]},{title:e("console.shortcuts.groups.navigation"),shortcuts:[{keys:["B"],description:e("console.shortcuts.toggleSidebar")},{keys:["⌘","/"],description:e("console.shortcuts.focusSearch")}]},{title:e("console.shortcuts.groups.dataViews"),shortcuts:[{keys:["N"],description:e("console.shortcuts.createRecord")},{keys:["R"],description:e("console.shortcuts.refreshData")},{keys:["⌘","E"],description:e("console.shortcuts.editRecord")}]},{title:e("console.shortcuts.groups.preferences"),shortcuts:[{keys:["⌘","D"],description:e("console.shortcuts.toggleDarkMode")}]}],[e]);return i.useEffect(()=>{function s(r){const l=r.target;l.tagName==="INPUT"||l.tagName==="TEXTAREA"||l.isContentEditable||r.key==="?"&&!r.metaKey&&!r.ctrlKey&&!r.altKey&&(r.preventDefault(),a(c=>!c))}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[]),t.jsx(ta,{open:n,onOpenChange:a,children:t.jsxs(na,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[t.jsxs(aa,{children:[t.jsx(sa,{children:e("console.shortcuts.title")}),t.jsx(ra,{children:e("console.shortcuts.description")})]}),t.jsx("div",{className:"space-y-6 pt-2",children:o.map(s=>t.jsxs("div",{children:[t.jsx("h3",{className:"text-sm font-medium text-muted-foreground mb-3",children:s.title}),t.jsx("div",{className:"space-y-2",children:s.shortcuts.map((r,l)=>t.jsxs("div",{className:"flex items-center justify-between py-1.5",children:[t.jsx("span",{className:"text-sm",children:r.description}),t.jsx("div",{className:"flex items-center gap-1",children:r.keys.map((c,d)=>t.jsx("kbd",{className:"inline-flex h-6 min-w-[24px] items-center justify-center rounded border bg-muted px-1.5 text-xs font-medium text-muted-foreground",children:c},d))})]},l))})]},s.title))})]})})}const Mn="objectui-onboarding-dismissed",at=[{icon:ha,title:"Navigate Your Apps",description:"Use the sidebar to browse objects, dashboards, pages, and reports. Switch between apps using the dropdown in the sidebar header."},{icon:We,title:"Quick Search",description:"Press ⌘K (or Ctrl+K) to open the command palette and quickly jump to any object, dashboard, or page."},{icon:ma,title:"Favorites & Recent",description:"Star frequently used items to pin them in the sidebar. Recently visited items also appear for quick access."},{icon:ja,title:"Keyboard Shortcuts",description:"Press ? to view all keyboard shortcuts. Use them to speed up your workflow with CRUD operations and navigation."}];function ki(){const[e,n]=i.useState(!1),[a,o]=i.useState(0);i.useEffect(()=>{try{if(!localStorage.getItem(Mn)){const m=setTimeout(()=>n(!0),800);return()=>clearTimeout(m)}}catch{}},[]);const s=()=>{n(!1);try{localStorage.setItem(Mn,new Date().toISOString())}catch{}},r=()=>{a<at.length-1?o(u=>u+1):s()},l=at[a],c=l.icon,d=a===at.length-1;return t.jsx(ta,{open:e,onOpenChange:u=>{u||s()},children:t.jsxs(na,{className:"sm:max-w-md",children:[t.jsxs(aa,{children:[t.jsxs(sa,{className:"flex items-center gap-2",children:[t.jsx(ja,{className:"h-5 w-5 text-primary"}),"Welcome to ObjectUI"]}),t.jsx(ra,{children:"Let's get you started with a quick tour."})]}),t.jsxs("div",{className:"flex flex-col items-center gap-4 py-6 text-center",children:[t.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded-full bg-primary/10",children:t.jsx(c,{className:"h-8 w-8 text-primary"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h3",{className:"text-lg font-semibold",children:l.title}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:l.description})]})]}),t.jsx("div",{className:"flex items-center justify-center gap-1.5",children:at.map((u,m)=>t.jsx("button",{className:`h-2 w-2 rounded-full transition-colors ${m===a?"bg-primary":"bg-muted-foreground/30"}`,onClick:()=>o(m),"aria-label":`Go to step ${m+1}`},m))}),t.jsxs("div",{className:"flex items-center justify-between pt-2",children:[t.jsx(Y,{variant:"ghost",size:"sm",onClick:s,children:"Skip"}),t.jsxs(Y,{size:"sm",onClick:r,children:[d?"Get Started":"Next",!d&&t.jsx(Sr,{className:"ml-1 h-4 w-4"})]})]})]})})}let Di=0;function On(e="nav"){return`${e}_${Date.now()}_${++Di}`}function Pn(e,n){return[...e,n]}function Et(e,n,a){return e.filter(o=>!(o.type===n&&(n==="page"&&o.pageName===a||n==="dashboard"&&o.dashboardName===a))).map(o=>o.children&&o.children.length>0?{...o,children:Et(o.children,n,a)}:o)}function At(e,n,a,o){return e.map(s=>{let r=s;return n==="page"&&s.type==="page"&&s.pageName===a?r={...s,pageName:o}:n==="dashboard"&&s.type==="dashboard"&&s.dashboardName===a&&(r={...s,dashboardName:o}),r.children&&r.children.length>0?{...r,children:At(r.children,n,a,o)}:r})}function st(e,n){return e.length!==n.length?!1:e===n?!0:JSON.stringify(e)===JSON.stringify(n)}function Fi(){const e=Qe(),{apps:n,refresh:a}=Ze(),o=i.useRef(e);o.current=e;const s=i.useRef(a);s.current=a;const r=i.useCallback(async(f,w)=>{const j=o.current?.getClient();j&&await j.meta.saveItem("app",f,w),await s.current?.()},[]),l=i.useCallback(f=>n.find(w=>w.name===f),[n]),c=i.useCallback(async(f,w,j)=>{const y=l(f);if(!y)return;const C=y.navigation??[],V={id:On("nav_page"),type:"page",label:j||w,pageName:w,icon:"FileText"},k=Pn(C,V),M={...y,navigation:k};try{await r(f,M),K.success(`Navigation updated: added page "${j||w}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...y,navigation:C}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),d=i.useCallback(async(f,w,j)=>{const y=l(f);if(!y)return;const C=y.navigation??[],V={id:On("nav_dash"),type:"dashboard",label:j||w,dashboardName:w,icon:"LayoutDashboard"},k=Pn(C,V),M={...y,navigation:k};try{await r(f,M),K.success(`Navigation updated: added dashboard "${j||w}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...y,navigation:C}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),u=i.useCallback(async(f,w)=>{const j=l(f);if(!j)return;const y=j.navigation??[],C=Et(y,"page",w);if(st(C,y))return;const V={...j,navigation:C};try{await r(f,V),K.success(`Navigation updated: removed page "${w}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...j,navigation:y}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),m=i.useCallback(async(f,w)=>{const j=l(f);if(!j)return;const y=j.navigation??[],C=Et(y,"dashboard",w);if(st(C,y))return;const V={...j,navigation:C};try{await r(f,V),K.success(`Navigation updated: removed dashboard "${w}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...j,navigation:y}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),p=i.useCallback(async(f,w,j)=>{const y=l(f);if(!y)return;const C=y.navigation??[],V=At(C,"page",w,j);if(st(V,C))return;const k={...y,navigation:V};try{await r(f,k),K.success(`Navigation updated: renamed page "${w}" → "${j}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...y,navigation:C}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),g=i.useCallback(async(f,w,j)=>{const y=l(f);if(!y)return;const C=y.navigation??[],V=At(C,"dashboard",w,j);if(st(V,C))return;const k={...y,navigation:V};try{await r(f,k),K.success(`Navigation updated: renamed dashboard "${w}" → "${j}"`,{action:{label:"Undo",onClick:async()=>{try{await r(f,{...y,navigation:C}),K.info("Navigation change undone")}catch{K.error("Failed to undo navigation change")}}}})}catch{K.error("Failed to update navigation")}},[l,r]),x=f=>f&&typeof f=="object"&&"name"in f?f.name:void 0,h=i.useCallback(async(f,w)=>{for(const j of n){const y=x(j);y&&await c(y,f,w)}},[n,c]),F=i.useCallback(async(f,w)=>{for(const j of n){const y=x(j);y&&await d(y,f,w)}},[n,d]),v=i.useCallback(async f=>{for(const w of n){const j=x(w);j&&await u(j,f)}},[n,u]),b=i.useCallback(async f=>{for(const w of n){const j=x(w);j&&await m(j,f)}},[n,m]),S=i.useCallback(async(f,w)=>{for(const j of n){const y=x(j);y&&await p(y,f,w)}},[n,p]),E=i.useCallback(async(f,w)=>{for(const j of n){const y=x(j);y&&await g(y,f,w)}},[n,g]);return{syncPageCreated:c,syncDashboardCreated:d,syncPageDeleted:u,syncDashboardDeleted:m,syncPageRenamed:p,syncDashboardRenamed:g,syncPageCreatedAllApps:h,syncDashboardCreatedAllApps:F,syncPageDeletedAllApps:v,syncDashboardDeletedAllApps:b,syncPageRenamedAllApps:S,syncDashboardRenamedAllApps:E}}function _i(){const{pages:e,dashboards:n,apps:a}=Ze(),o=Qe(),s=i.useRef(o);s.current=o;const{syncPageCreated:r,syncDashboardCreated:l,syncPageDeleted:c,syncDashboardDeleted:d}=Fi(),u=i.useRef(null),m=i.useRef(null),p=i.useRef(0),g=i.useRef(!1),x=h=>h&&typeof h=="object"&&"name"in h?h.name:void 0;return i.useEffect(()=>{if(g.current)return;const h=new Set((e??[]).map(C=>C.name).filter(Boolean)),F=new Set((n??[]).map(C=>C.name).filter(Boolean)),v=u.current,b=m.current;if(v===null||b===null){u.current=h,m.current=F;return}const S=[...h].filter(C=>!v.has(C)),E=[...v].filter(C=>!h.has(C)),f=[...F].filter(C=>!b.has(C)),w=[...b].filter(C=>!F.has(C));if(S.length===0&&E.length===0&&f.length===0&&w.length===0){u.current=h,m.current=F;return}const j=++p.current;g.current=!0;let y=!1;return(async()=>{try{for(const C of a){if(y||p.current!==j)break;const V=x(C);if(V){for(const k of S){if(y)break;await r(V,k)}for(const k of E){if(y)break;await c(V,k)}for(const k of f){if(y)break;await l(V,k)}for(const k of w){if(y)break;await d(V,k)}}}}finally{p.current===j&&(u.current=h,m.current=F,g.current=!1)}})(),()=>{y=!0}},[e,n,a,r,l,c,d]),null}function Ei(e){const{theme:n="system"}=Qt();return t.jsx(Js,{theme:n,className:"toaster group",icons:{success:t.jsx(Jt,{className:"h-4 w-4"}),info:t.jsx(Dr,{className:"h-4 w-4"}),warning:t.jsx(fa,{className:"h-4 w-4"}),error:t.jsx(kr,{className:"h-4 w-4"}),loading:t.jsx(dt,{className:"h-4 w-4 animate-spin"})},toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"}},...e})}const Ai=i.lazy(()=>J(()=>import("./RecordDetailView-ClpxNRz2.js"),__vite__mapDeps([20,1,18,9,10,11,8,3,12,13,4,2,14,15,19,17,7,21,22])).then(e=>({default:e.RecordDetailView}))),Ti=i.lazy(()=>J(()=>import("./DashboardView-jCJCERzJ.js"),__vite__mapDeps([23,1,18,9,10,11,8,3,12,13,4,2,14,15,19,17,7,21,22])).then(e=>({default:e.DashboardView}))),Ri=i.lazy(()=>J(()=>import("./PageView-CFJhE0CN.js"),__vite__mapDeps([24,8,1,9,10,11,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.PageView}))),Vi=i.lazy(()=>J(()=>import("./ReportView-DecAJ58u.js"),__vite__mapDeps([25,1,18,9,10,11,8,3,12,13,4,2,14,15,19,17,7,21,22])).then(e=>({default:e.ReportView}))),Mi=i.lazy(()=>J(()=>import("./SearchResultsPage-CaSb54ho.js"),__vite__mapDeps([26,1,8,9,10,11,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.SearchResultsPage}))),Tt=i.lazy(()=>J(()=>import("./CreateAppPage-DNKskVHK.js"),__vite__mapDeps([27,1,28,9,10,11,8,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.CreateAppPage}))),Oi=i.lazy(()=>J(()=>import("./EditAppPage-UGT9V29B.js"),__vite__mapDeps([29,1,28,9,10,11,8,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.EditAppPage}))),Pi=i.lazy(()=>J(()=>import("./PageDesignPage-DTEQcEuR.js"),__vite__mapDeps([30,1,28,9,10,11,8,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.PageDesignPage}))),Ii=i.lazy(()=>J(()=>import("./DashboardDesignPage-T9tEAHAx.js"),__vite__mapDeps([31,1,28,9,10,11,8,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.DashboardDesignPage}))),Li=i.lazy(()=>J(()=>import("./LoginPage-BR2RpoGG.js"),__vite__mapDeps([32,1,14,4,33])).then(e=>({default:e.LoginPage}))),$i=i.lazy(()=>J(()=>import("./RegisterPage-6IYU4bdp.js"),__vite__mapDeps([34,1,14,4,33])).then(e=>({default:e.RegisterPage}))),zi=i.lazy(()=>J(()=>import("./ForgotPasswordPage-Ca0lLZwY.js"),__vite__mapDeps([35,1,14,4,33])).then(e=>({default:e.ForgotPasswordPage}))),Rt=i.lazy(()=>J(()=>import("./SystemHubPage-PNaxZEht.js"),__vite__mapDeps([36,1,8,9,10,11,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.SystemHubPage}))),Vt=i.lazy(()=>J(()=>import("./AppManagementPage-6bzxYNlP.js"),__vite__mapDeps([37,1,8,9,10,11,3,12,13,4,2,14,15,17,7,18,19,21,22])).then(e=>({default:e.AppManagementPage}))),Mt=i.lazy(()=>J(()=>import("./UserManagementPage-KAZy5fgy.js"),__vite__mapDeps([38,1,14,4,8,9,10,11,3,12,13,2,15,39,17,7,18,19,21,22])).then(e=>({default:e.UserManagementPage}))),Ot=i.lazy(()=>J(()=>import("./OrgManagementPage-DjT2mZ2x.js"),__vite__mapDeps([40,1,14,4,8,9,10,11,3,12,13,2,15,39,17,7,18,19,21,22])).then(e=>({default:e.OrgManagementPage}))),Pt=i.lazy(()=>J(()=>import("./RoleManagementPage-v0ia3MGn.js"),__vite__mapDeps([41,1,14,4,8,9,10,11,3,12,13,2,15,39,17,7,18,19,21,22])).then(e=>({default:e.RoleManagementPage}))),It=i.lazy(()=>J(()=>import("./PermissionManagementPage-C_FPnvGW.js"),__vite__mapDeps([42,1,14,4,8,9,10,11,3,12,13,2,15,39,17,7,18,19,21,22])).then(e=>({default:e.PermissionManagementPage}))),Lt=i.lazy(()=>J(()=>import("./AuditLogPage-qCzdxaNq.js"),__vite__mapDeps([43,1,8,9,10,11,3,12,13,4,2,14,15,39,17,7,18,19,21,22])).then(e=>({default:e.AuditLogPage}))),$t=i.lazy(()=>J(()=>import("./ProfilePage-CQkgvEEi.js"),__vite__mapDeps([44,1,14,4,8,9,10,11,3,12,13,2,15])).then(e=>({default:e.ProfilePage})));function rt({children:e}){return t.jsx(Gr,{children:t.jsx(Ui,{children:e})})}function Ui({children:e}){const n=Qe();return n?t.jsx(Wr,{adapter:n,children:e}):t.jsx(de,{})}function Bi(){const[e,n]=i.useState("disconnected"),{user:a}=gt(),o=Qe(),s=Pe(),r=Kn(),{appName:l}=Ge(),{apps:c,objects:d,loading:u}=Ze(),m=c.filter(P=>P.active!==!1),p=c.find(P=>P.name===l)||m.find(P=>P.isDefault===!0)||m[0],[g,x]=i.useState(!1),[h,F]=i.useState(null),[v,b]=i.useState(0),{addRecentItem:S}=ka(),{execute:E,runner:f}=oa();Gs({dataSource:o??void 0,onUndo:P=>{K.info(`Undo: ${P.description}`,{duration:4e3}),b($=>$+1)},onRedo:P=>{K.info(`Redo: ${P.description}`,{duration:3e3}),b($=>$+1)}}),i.useEffect(()=>{f.registerHandler("crud_success",async P=>(x(!1),b($=>$+1),K.success(P.params?.message??"Record saved successfully"),{success:!0,reload:!0})),f.registerHandler("dialog_cancel",async()=>(x(!1),{success:!0}))},[f]),i.useEffect(()=>{if(!o)return;const P=o.onConnectionStateChange($=>{n($.state),$.error&&console.error("[Console] Connection error:",$.error)});return n(o.getConnectionState()),P},[o]);let y=r.pathname.split("/").filter(P=>P)[2];(y==="view"||y==="record"||y==="page"||y==="dashboard"||y==="design")&&(y="");const C=d.find(P=>P.name===y),V=i.useCallback(()=>{const P=C?.label||"Record";E({type:"crud_success",params:{message:h?`${P} updated successfully`:`${P} created successfully`}})},[E,h,C?.label]),k=i.useCallback(()=>{E({type:"dialog_cancel"})},[E]);i.useEffect(()=>{if(!p)return;const P=r.pathname.split("/").filter(Boolean);let $=P[2];($==="view"||$==="record"||$==="page"||$==="dashboard"||$==="design")&&($="");const O=`/apps/${p.name}`,I=d;if($){const D=I.find(G=>G.name===$);D&&S({id:`object:${D.name}`,label:D.label||D.name,href:`${O}/${D.name}`,type:"object"})}else P[2]==="dashboard"&&P[3]?S({id:`dashboard:${P[3]}`,label:P[3].replace(/[-_]/g," ").replace(/\b\w/g,D=>D.toUpperCase()),href:`${O}/dashboard/${P[3]}`,type:"dashboard"}):P[2]==="report"&&P[3]&&S({id:`report:${P[3]}`,label:P[3].replace(/[-_]/g," ").replace(/\b\w/g,D=>D.toUpperCase()),href:`${O}/report/${P[3]}`,type:"report"})},[r.pathname,S]);const M=P=>{F(P),x(!0)},N=P=>{s(`/apps/${P}`)},A=i.useMemo(()=>new Kt({user:a?{name:a.name,email:a.email,role:a.role??"user"}:{},app:p||{},data:h||{}}),[a,p,h]);if(!o||u)return t.jsx(de,{});const R=r.pathname.endsWith("/create-app"),L=r.pathname.includes("/system");if(!p&&!R&&!L)return t.jsx("div",{className:"h-screen flex items-center justify-center",children:t.jsxs(mt,{children:[t.jsx(pt,{children:"No Apps Configured"}),t.jsx(ht,{children:"No applications have been registered. Create your first app or visit System Settings to configure your environment."}),t.jsxs("div",{className:"mt-4 flex flex-col sm:flex-row items-center gap-3",children:[t.jsx(Y,{onClick:()=>s("/create-app"),"data-testid":"create-first-app-btn",children:"Create Your First App"}),t.jsx(Y,{variant:"outline",onClick:()=>s("/system"),"data-testid":"go-to-settings-btn",children:"System Settings"})]})]})});if(!p&&(R||L))return t.jsx(i.Suspense,{fallback:t.jsx(de,{}),children:t.jsxs(ct,{children:[t.jsx(z,{path:"create-app",element:t.jsx(Tt,{})}),t.jsx(z,{path:"system",element:t.jsx(Rt,{})}),t.jsx(z,{path:"system/apps",element:t.jsx(Vt,{})}),t.jsx(z,{path:"system/users",element:t.jsx(Mt,{})}),t.jsx(z,{path:"system/organizations",element:t.jsx(Ot,{})}),t.jsx(z,{path:"system/roles",element:t.jsx(Pt,{})}),t.jsx(z,{path:"system/permissions",element:t.jsx(It,{})}),t.jsx(z,{path:"system/audit-log",element:t.jsx(Lt,{})}),t.jsx(z,{path:"system/profile",element:t.jsx($t,{})})]})});const B=a?{name:a.name,email:a.email,role:a.role??"user"}:{name:"Anonymous",email:"",role:"guest"};return t.jsxs(Kr,{user:B,app:p,data:{},children:[t.jsx(_i,{}),t.jsxs(Co,{activeAppName:p.name,activeApp:p,onAppChange:N,objects:d,connectionState:e,children:[t.jsx(So,{apps:c,activeApp:p,objects:d,onAppChange:N}),t.jsx(Si,{}),t.jsx(ki,{}),t.jsxs(Ks,{dataSource:o||{},children:[t.jsx(Do,{children:t.jsx(i.Suspense,{fallback:t.jsx(de,{}),children:t.jsxs(ct,{children:[t.jsx(z,{path:"/",element:t.jsx(qe,{to:za(p.navigation||[]),replace:!0})}),t.jsx(z,{path:":objectName",element:t.jsx(Vn,{dataSource:o,objects:d,onEdit:M})}),t.jsx(z,{path:":objectName/view/:viewId",element:t.jsx(Vn,{dataSource:o,objects:d,onEdit:M})}),t.jsx(z,{path:":objectName/record/:recordId",element:t.jsx(Ai,{dataSource:o,objects:d,onEdit:M},v)}),t.jsx(z,{path:"dashboard/:dashboardName",element:t.jsx(Ti,{dataSource:o})}),t.jsx(z,{path:"report/:reportName",element:t.jsx(Vi,{dataSource:o})}),t.jsx(z,{path:"page/:pageName",element:t.jsx(Ri,{})}),t.jsx(z,{path:"design/page/:pageName",element:t.jsx(Pi,{})}),t.jsx(z,{path:"design/dashboard/:dashboardName",element:t.jsx(Ii,{})}),t.jsx(z,{path:"search",element:t.jsx(Mi,{})}),t.jsx(z,{path:"create-app",element:t.jsx(Tt,{})}),t.jsx(z,{path:"edit-app/:editAppName",element:t.jsx(Oi,{})}),t.jsx(z,{path:"system",element:t.jsx(Rt,{})}),t.jsx(z,{path:"system/apps",element:t.jsx(Vt,{})}),t.jsx(z,{path:"system/users",element:t.jsx(Mt,{})}),t.jsx(z,{path:"system/organizations",element:t.jsx(Ot,{})}),t.jsx(z,{path:"system/roles",element:t.jsx(Pt,{})}),t.jsx(z,{path:"system/permissions",element:t.jsx(It,{})}),t.jsx(z,{path:"system/audit-log",element:t.jsx(Lt,{})}),t.jsx(z,{path:"system/profile",element:t.jsx($t,{})})]})})}),C&&t.jsx(Us,{schema:{type:"object-form",formType:"modal",objectName:C.name,mode:h?"edit":"create",recordId:h?.id,title:`${h?"Edit":"Create"} ${C?.label}`,description:h?`Update details for ${C?.label}`:`Add a new ${C?.label} to your database.`,open:g,onOpenChange:x,layout:"vertical",fields:C.fields?Array.isArray(C.fields)?C.fields.filter(P=>typeof P=="string"?!0:ut(P.visible,A)).map(P=>typeof P=="string"?P:P.name):Object.entries(C.fields).filter(([P,$])=>ut($.visible,A)).map(([P])=>P):[],onSuccess:V,onCancel:k,showSubmit:!0,showCancel:!0,submitText:"Save Record",cancelText:"Cancel"},dataSource:o},h?.id||"new")]})]})]})}function za(e){if(!e||e.length===0)return"";for(const n of e){if(n.type==="object")return n.viewName?`${n.objectName}/view/${n.viewName}`:`${n.objectName}`;if(n.type==="page")return n.pageName?`page/${n.pageName}`:"";if(n.type==="dashboard")return n.dashboardName?`dashboard/${n.dashboardName}`:"";if(n.type!=="url"&&n.type==="group"&&n.children){const a=za(n.children);if(a!=="")return a}}return""}function Hi(){const{apps:e,loading:n,error:a}=Ze(),o=Pe(),s=e.filter(l=>l.active!==!1),r=s.find(l=>l.isDefault===!0)||s[0];return n?t.jsx(de,{}):r?t.jsx(qe,{to:`/apps/${r.name}`,replace:!0}):t.jsx("div",{className:"h-screen flex items-center justify-center",children:t.jsxs(mt,{children:[t.jsx(pt,{children:a?"Failed to Load Configuration":"No Apps Configured"}),t.jsx(ht,{children:a?"There was an error loading the configuration. You can still create an app or access System Settings.":"No applications have been registered. Create your first app or configure your system."}),t.jsxs("div",{className:"mt-4 flex flex-col sm:flex-row items-center gap-3",children:[t.jsx(Y,{onClick:()=>o("/create-app"),"data-testid":"create-first-app-btn",children:"Create Your First App"}),t.jsx(Y,{variant:"outline",onClick:()=>o("/system"),"data-testid":"go-to-settings-btn",children:"System Settings"})]})]})})}function qi(){return t.jsx(i.Suspense,{fallback:t.jsx(de,{}),children:t.jsxs(ct,{children:[t.jsx(z,{path:"/",element:t.jsx(Rt,{})}),t.jsx(z,{path:"apps",element:t.jsx(Vt,{})}),t.jsx(z,{path:"users",element:t.jsx(Mt,{})}),t.jsx(z,{path:"organizations",element:t.jsx(Ot,{})}),t.jsx(z,{path:"roles",element:t.jsx(Pt,{})}),t.jsx(z,{path:"permissions",element:t.jsx(It,{})}),t.jsx(z,{path:"audit-log",element:t.jsx(Lt,{})}),t.jsx(z,{path:"profile",element:t.jsx($t,{})})]})})}function Wi(){return t.jsxs(co,{defaultTheme:"system",storageKey:"object-ui-theme",children:[t.jsx(Ei,{position:"bottom-right"}),t.jsxs(Ci,{authUrl:"/api/v1/auth",children:[t.jsx(Zs,{}),t.jsx(rs,{basename:"/console/".replace(/\/$/,"")||"/",children:t.jsx(i.Suspense,{fallback:t.jsx(de,{}),children:t.jsxs(ct,{children:[t.jsx(z,{path:"/login",element:t.jsx(Li,{})}),t.jsx(z,{path:"/register",element:t.jsx($i,{})}),t.jsx(z,{path:"/forgot-password",element:t.jsx(zi,{})}),t.jsx(z,{path:"/system/*",element:t.jsx(vt,{fallback:t.jsx(qe,{to:"/login"}),loadingFallback:t.jsx(de,{}),children:t.jsx(rt,{children:t.jsx(qi,{})})})}),t.jsx(z,{path:"/create-app",element:t.jsx(vt,{fallback:t.jsx(qe,{to:"/login"}),loadingFallback:t.jsx(de,{}),children:t.jsx(rt,{children:t.jsx(i.Suspense,{fallback:t.jsx(de,{}),children:t.jsx(Tt,{})})})})}),t.jsx(z,{path:"/apps/:appName/*",element:t.jsx(vt,{fallback:t.jsx(qe,{to:"/login"}),loadingFallback:t.jsx(de,{}),children:t.jsx(rt,{children:t.jsx(Bi,{})})})}),t.jsx(z,{path:"/",element:t.jsx(rt,{children:t.jsx(Hi,{})})})]})})})]})]})}function In(){const e=typeof window<"u"?window.innerWidth:1024;return e<640?35:e<1024?50:60}function Gi(){const e=typeof window<"u"?window.innerWidth:1024;return e<640?120:e<1024?200:300}function Ki({tasks:e,viewMode:n="month",startDate:a,endDate:o,onTaskClick:s,onTaskUpdate:r,onViewChange:l,onAddClick:c,className:d,inlineEdit:u=!1}){const[m,p]=i.useState(new Date),[g,x]=i.useState(typeof window<"u"&&window.innerWidth<640?32:40),[h,F]=i.useState(In()),[v,b]=i.useState(null),[S,E]=i.useState({});i.useEffect(()=>{const N=()=>{x(window.innerWidth<640?32:40),F(In())};return window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[]);const f=i.useMemo(()=>{let N=a?new Date(a):new Date,A=o?new Date(o):new Date;return!a&&e.length>0&&(N=new Date(Math.min(...e.map(R=>R.start.getTime()))),N.setDate(N.getDate()-7)),!o&&e.length>0&&(A=new Date(Math.max(...e.map(R=>R.end.getTime()))),A.setDate(A.getDate()+14)),N.setHours(0,0,0,0),A.setHours(23,59,59,999),{start:N,end:A}},[a,o,e]),w=i.useMemo(()=>{const N=[],A=new Date(f.start);for(;A<=f.end;)N.push({date:new Date(A),label:A.getDate().toString(),isWeekend:A.getDay()===0||A.getDay()===6}),A.setDate(A.getDate()+1);return N},[f]),j=Gi(),y=i.useRef(null),C=i.useRef(null),V=i.useRef(null),k=N=>{y.current&&(y.current.scrollLeft=N.currentTarget.scrollLeft),C.current&&(C.current.scrollTop=N.currentTarget.scrollTop)},M=N=>{f.end.getTime()-f.start.getTime();const A=h,R=1e3*60*60*24,L=N.start.getTime()-f.start.getTime(),B=N.end.getTime()-N.start.getTime(),P=L/R*A,$=Math.max(B/R*A,A);return{left:P,width:$}};return t.jsxs("div",{className:q("flex flex-col h-full bg-background border rounded-lg overflow-hidden min-w-0",d),children:[t.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between gap-2 p-2 border-b bg-card",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Y,{variant:"outline",size:"sm",onClick:()=>c?.(),"aria-label":"Create new task",children:[t.jsx(Fe,{className:"h-4 w-4 mr-1 sm:mr-2"}),t.jsx("span",{className:"hidden sm:inline",children:"New Task"}),t.jsx("span",{className:"sm:hidden",children:"New"})]}),t.jsx("div",{className:"h-4 w-px bg-border mx-1 sm:mx-2"}),t.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Previous period",children:t.jsx(xa,{className:"h-4 w-4"})}),t.jsx(Y,{variant:"ghost",size:"icon",className:"h-8 w-8","aria-label":"Next period",children:t.jsx(ft,{className:"h-4 w-4"})}),t.jsx("span",{className:"font-semibold text-xs sm:text-sm",children:f.start.toLocaleDateString(void 0,{month:"long",year:"numeric"})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(Zn,{value:n,onValueChange:N=>l?.(N),children:[t.jsx(Qn,{className:"w-[100px] sm:w-[120px] h-8",children:t.jsx(Xn,{})}),t.jsxs(ea,{children:[t.jsx(Ne,{value:"day",children:"Day View"}),t.jsx(Ne,{value:"week",children:"Week View"}),t.jsx(Ne,{value:"month",children:"Month View"}),t.jsx(Ne,{value:"quarter",children:"Quarter View"})]})]}),t.jsxs("div",{className:"flex bg-muted rounded-md p-1",children:[t.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>F(N=>Math.max(15,N-10)),"aria-label":"Zoom out",children:t.jsx(Fr,{className:"h-3 w-3"})}),t.jsx(Y,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>F(N=>Math.min(120,N+10)),"aria-label":"Zoom in",children:t.jsx(_r,{className:"h-3 w-3"})})]})]})]}),t.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden",children:[t.jsxs("div",{className:"flex border-b bg-muted/30 shrink-0 h-10 sm:h-[50px]",children:[t.jsxs("div",{className:"flex items-center font-medium text-xs text-muted-foreground px-2 sm:px-4 border-r bg-card z-20 shadow-sm",style:{width:j,minWidth:j},children:[t.jsx("div",{className:"flex-1",children:"Task Name"}),t.jsx("div",{className:"w-16 sm:w-20 text-right hidden sm:block",children:"Start"}),t.jsx("div",{className:"w-16 sm:w-20 text-right hidden sm:block",children:"End"})]}),t.jsx("div",{className:"flex-1 overflow-hidden",ref:y,children:t.jsx("div",{className:"flex h-full",style:{width:w.length*h},children:w.map((N,A)=>t.jsxs("div",{className:q("flex flex-col items-center justify-center border-r text-xs text-muted-foreground h-full",N.isWeekend&&"bg-muted/50"),style:{width:h,minWidth:h},children:[t.jsx("span",{className:"font-medium text-foreground",children:N.label}),t.jsx("span",{className:"text-[10px] opacity-70",children:N.date.toLocaleDateString(void 0,{weekday:"narrow"})})]},A))})})]}),t.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[t.jsx("div",{className:"overflow-hidden border-r bg-card z-10 shadow-sm",ref:C,style:{width:j,minWidth:j},children:e.map(N=>{const A=u&&v===N.id;return t.jsxs("div",{className:"flex items-center border-b px-2 sm:px-4 hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation",style:{height:g},onClick:()=>!A&&s?.(N),onDoubleClick:()=>{u&&r&&(b(N.id),E({title:N.title,start:N.start.toLocaleDateString("en-CA"),end:N.end.toLocaleDateString("en-CA"),progress:String(N.progress)}))},children:[t.jsxs("div",{className:"flex-1 truncate font-medium text-xs sm:text-sm flex items-center gap-2",children:[t.jsx("div",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:N.color||"#3b82f6"}}),A?t.jsx("input",{className:"border rounded px-1 py-0.5 text-xs w-full bg-background",value:S.title||"",onChange:R=>E(L=>({...L,title:R.target.value})),onKeyDown:R=>{R.key==="Enter"?(r?.(N,{title:S.title,start:new Date(S.start),end:new Date(S.end),progress:Number(S.progress)||0}),b(null)):R.key==="Escape"&&b(null)},onClick:R=>R.stopPropagation(),autoFocus:!0}):t.jsxs("span",{className:"flex flex-col min-w-0",children:[t.jsx("span",{className:"truncate",children:N.title}),t.jsxs("span",{className:"text-[10px] text-muted-foreground sm:hidden",children:[N.start.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})," → ",N.end.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})]})]})]}),t.jsx("div",{className:"w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block",children:A?t.jsx("input",{type:"date",className:"border rounded px-1 py-0.5 text-xs w-full bg-background",value:S.start||"",onChange:R=>E(L=>({...L,start:R.target.value})),onClick:R=>R.stopPropagation()}):N.start.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})}),t.jsx("div",{className:"w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block",children:A?t.jsx("input",{type:"date",className:"border rounded px-1 py-0.5 text-xs w-full bg-background",value:S.end||"",onChange:R=>E(L=>({...L,end:R.target.value})),onClick:R=>R.stopPropagation()}):N.end.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})})]},N.id)})}),t.jsx("div",{className:"flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]",ref:V,onScroll:k,children:t.jsx("div",{style:{width:w.length*h},children:t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-0 flex pointer-events-none z-0",children:w.map((N,A)=>t.jsx("div",{className:q("border-r h-full",N.isWeekend&&"bg-muted/20"),style:{width:h,minWidth:h}},A))}),e.map(N=>{const A=M(N);return t.jsx("div",{className:"relative border-b hover:bg-black/5",style:{height:g},children:t.jsxs("div",{className:"absolute top-1 sm:top-2 h-[calc(100%-8px)] sm:h-[calc(100%-16px)] rounded-sm bg-primary border border-primary-foreground/20 shadow-sm cursor-pointer hover:brightness-110 flex items-center px-2 group",style:{left:A.left,width:A.width,backgroundColor:N.color||"#3b82f6"},onClick:()=>s?.(N),children:[N.progress>0&&t.jsx("div",{className:"absolute left-0 top-0 bottom-0 bg-black/20 rounded-l-sm",style:{width:`${N.progress}%`}}),t.jsxs("span",{className:"text-[10px] text-white font-medium truncate opacity-0 group-hover:opacity-100 transition-opacity",children:[Math.round(N.progress),"%"]})]})},N.id)}),t.jsx("div",{className:"absolute top-0 bottom-0 w-px bg-red-500 z-20 pointer-events-none",style:{left:(new Date().getTime()-f.start.getTime())/(1e3*60*60*24)*h},children:t.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 -ml-[3px]"})})]})})})]})]})]})}function Yi(e){return e.data?e.data:e.staticData?{provider:"value",items:e.staticData}:e.objectName?{provider:"object",object:e.objectName}:null}function Ji(e){if(e){if(typeof e=="string"){const n=e.split(" "),a=n[0],o=n[1]?.toLowerCase()==="desc"?"desc":"asc";return{[a]:o}}if(Array.isArray(e))return e.reduce((n,a)=>(a.field&&a.order&&(n[a.field]=a.order),n),{})}}function Zi(e){let n=null;if(e.startDateField&&e.endDateField)return n={startDateField:e.startDateField,endDateField:e.endDateField,titleField:e.titleField||"name",progressField:e.progressField,dependenciesField:e.dependenciesField||e.dependencyField,colorField:e.colorField},n;if(e.gantt&&(n=e.gantt),n){const a=Ys.safeParse(n);return a.success||console.warn("[ObjectGantt] Invalid gantt configuration:",a.error.format()),n}return null}const Qi=({schema:e,dataSource:n,className:a,onTaskClick:o,onRowClick:s,...r})=>{const[l,c]=i.useState([]),[d,u]=i.useState(!0),[m,p]=i.useState(null),[g,x]=i.useState(null),h=Yi(e),F=i.useMemo(()=>h,[JSON.stringify(h)]),v=Zi(e),b=F?.provider==="value";i.useEffect(()=>{(async()=>{try{if(u(!0),r.data&&Array.isArray(r.data)){c(r.data),u(!1);return}if(b&&F?.provider==="value"){c(F.items),u(!1);return}if(!n||typeof n.find!="function")throw new Error("DataSource required for object/api providers");if(F?.provider==="object"){const w=F.object,j=Ye(g?.fields),y=await n.find(w,{$filter:e.filter,$orderby:Ji(e.sort),...j.length>0?{$expand:j}:{}});let C=Ie(y);c(C)}else F?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectGantt"),c([]));u(!1)}catch(w){p(w),u(!1)}})()},[F,n,b,e.filter,e.sort,g]),i.useEffect(()=>{!b&&n&&(async()=>{try{if(!n)return;const w=F?.provider==="object"?F.object:e.objectName;if(!w)return;const j=await n.getObjectSchema(w);x(j)}catch(w){console.error("Failed to fetch object schema:",w)}})()},[e.objectName,n,b,F]);const S=i.useMemo(()=>{if(!v||!l.length)return[];const{startDateField:f,endDateField:w,titleField:j,progressField:y,dependenciesField:C,colorField:V}=v;return l.map((k,M)=>{const N=k[f],A=k[w],R=k[j]||"Untitled Task",L=y?k[y]:0,B=C?k[C]:[],P=V?k[V]:void 0;return{id:k.id||k._id||`task-${M}`,title:R,start:N?new Date(N):new Date,end:A?new Date(A):new Date,progress:Math.min(100,Math.max(0,L||0)),dependencies:Array.isArray(B)?B:[],color:P,data:k}}).filter(k=>!isNaN(k.start.getTime())&&!isNaN(k.end.getTime()))},[l,v]),E=Le({navigation:e.navigation,objectName:e.objectName,onRowClick:s});return d?t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsx("div",{className:"text-muted-foreground",children:"Loading Gantt chart..."})})}):m?t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsxs("div",{className:"text-destructive",children:["Error: ",m.message]})})}):v?t.jsxs("div",{className:a,children:[t.jsx("div",{className:"h-[calc(100vh-200px)] min-h-[600px]",children:t.jsx(Ki,{tasks:S,onTaskClick:f=>{E.handleClick(f.data),o?.(f.data)},onAddClick:()=>{}})}),E.isOverlay&&t.jsx(De,{...E,title:"Task Details",children:f=>t.jsx("div",{className:"space-y-3",children:Object.entries(f).map(([w,j])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:w.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(j??"—")})]},w))})})]}):t.jsx("div",{className:a,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsx("div",{className:"text-muted-foreground",children:"Gantt configuration required. Please specify startDateField, endDateField, and titleField."})})})},Ua=({schema:e})=>{const{dataSource:n}=Je()||{};return t.jsx(Qi,{schema:e,dataSource:n})};Z.register("object-gantt",Ua,{namespace:"plugin-gantt",label:"Object Gantt",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"gantt",type:"object",label:"Gantt Config",description:"startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField"}]});Z.register("gantt",Ua,{namespace:"view",label:"Gantt View",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"gantt",type:"object",label:"Gantt Config",description:"startDateField, endDateField, titleField, progressField, percentageField, colorField, dependenciesField"}]});const Xi=10080*60*1e3;function el(e){const n=e.flatMap(s=>(s.items||[]).flatMap(r=>[r.startDate,r.endDate])),a=Math.min(...n.map(s=>new Date(s).getTime())),o=Math.max(...n.map(s=>new Date(s).getTime()));return{minDate:new Date(a).toISOString().split("T")[0],maxDate:new Date(o).toISOString().split("T")[0]}}function tl(e,n,a,o){const s=new Date(e).getTime(),r=new Date(n).getTime(),l=new Date(a).getTime(),d=new Date(o).getTime()-l,u=s-l,m=r-s;return{start:u/d*100,width:m/d*100}}function ot(e,n){const a=new Date(e);return n==="short"?a.toLocaleDateString():n==="long"?a.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):a.toISOString().split("T")[0]}const Ba=({schema:e,className:n,...a})=>{const{variant:o="vertical",items:s=[],dateFormat:r="short",onItemClick:l}=e;if(o==="vertical")return t.jsx(Ha,{className:n,...a,children:s.map((c,d)=>t.jsxs(qa,{className:q(c.className,l&&"cursor-pointer"),onClick:()=>l?.(c),children:[t.jsx(zt,{variant:c.variant||"default",children:c.icon&&t.jsx("span",{className:"text-xs",children:c.icon})}),t.jsxs(Wa,{children:[c.time&&t.jsx(Bt,{dateTime:c.time,children:ot(c.time,r)}),c.title&&t.jsx(Ut,{children:c.title}),c.description&&t.jsx(Ht,{className:"line-clamp-2 sm:line-clamp-none",children:c.description}),c.content&&mn(c.content)]})]},d))});if(o==="horizontal")return t.jsx(Ga,{className:q("overflow-x-auto [-webkit-overflow-scrolling:touch]",n),...a,children:s.map((c,d)=>t.jsxs(Ka,{className:q(c.className,l&&"cursor-pointer"),onClick:()=>l?.(c),children:[t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(zt,{variant:c.variant||"default",children:c.icon&&t.jsx("span",{className:"text-xs",children:c.icon})}),t.jsxs("div",{className:"mt-4 text-center",children:[c.time&&t.jsx(Bt,{dateTime:c.time,children:ot(c.time,r)}),c.title&&t.jsx(Ut,{children:c.title}),c.description&&t.jsx(Ht,{className:"text-center line-clamp-2 sm:line-clamp-none",children:c.description}),c.content&&mn(c.content)]})]}),d<s.length-1&&t.jsx("div",{className:"absolute left-full w-16 border-t-2 border-gray-200 top-3"})]},d))});if(o==="gantt"){const c=el(s),d=e.minDate||c.minDate,u=e.maxDate||c.maxDate,m=e.timeScale||"month",g=(()=>{const x=[],h=new Date(d),F=new Date(u);if(m==="month"){const v=new Date(h);for(;v<=F;)x.push(v.toLocaleDateString("en-US",{month:"short",year:"numeric"})),v.setMonth(v.getMonth()+1)}else if(m==="week"){const v=new Date(h);for(;v<=F;)x.push(`Week ${Math.ceil((v.getTime()-h.getTime())/Xi)+1}`),v.setDate(v.getDate()+7)}else if(m==="day"){const v=new Date(h);for(;v<=F;)x.push(v.toLocaleDateString("en-US",{month:"short",day:"numeric"})),v.setDate(v.getDate()+1)}return x})();return t.jsxs(Ya,{className:q("overflow-x-auto [-webkit-overflow-scrolling:touch]",n),...a,children:[t.jsxs(Ja,{children:[t.jsx(qt,{className:"flex items-center px-2 sm:px-4 py-2 sm:py-3",children:t.jsx("span",{className:"font-semibold text-xs sm:text-sm",children:e.rowLabel||"Items"})}),t.jsx(Wt,{children:t.jsx("div",{className:"flex h-full",children:g.map((x,h)=>t.jsx("div",{className:"flex-1 px-1 sm:px-2 py-2 sm:py-3 border-r text-xs font-medium text-center",children:x},h))})})]}),t.jsx("div",{children:t.jsxs("div",{className:"flex",children:[t.jsx(qt,{children:s.map((x,h)=>t.jsx(Gt,{children:t.jsx(Za,{title:x.label,className:"truncate",children:x.label})},h))}),t.jsx(Wt,{className:"relative",children:s.map((x,h)=>t.jsx(Gt,{className:"relative",children:(x.items||[]).map((F,v)=>{const b=tl(F.startDate,F.endDate,d,u);return t.jsx(Qa,{start:b.start,width:b.width,variant:F.variant||"default",onClick:()=>l?.(F,x,h,v),title:`${F.title||""}
|
|
3
|
-
${ot(F.startDate,r)} - ${ot(F.endDate,r)}`,children:t.jsx(Xa,{children:F.title})},v)})},h))})]})})]})}return null};Z.register("timeline",Ba,{namespace:"plugin-timeline",label:"Timeline",category:"data-display",inputs:[{name:"variant",type:"enum",enum:["vertical","horizontal","gantt"],label:"Timeline Variant",defaultValue:"vertical"},{name:"items",type:"array",label:"Timeline Items",description:"For vertical/horizontal: Array of { time, title, description, variant, icon, content }. For gantt: Array of { label, items: [{ title, startDate, endDate, variant }] }"},{name:"dateFormat",type:"enum",enum:["short","long","iso"],label:"Date Format",defaultValue:"short"},{name:"timeScale",type:"enum",enum:["day","week","month"],label:"Time Scale (Gantt only)",defaultValue:"month"},{name:"rowLabel",type:"string",label:"Row Label (Gantt only)",defaultValue:"Items"},{name:"minDate",type:"string",label:"Min Date (Gantt only)",description:"Override auto-calculated min date (YYYY-MM-DD)"},{name:"maxDate",type:"string",label:"Max Date (Gantt only)",description:"Override auto-calculated max date (YYYY-MM-DD)"},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{variant:"vertical",dateFormat:"short",items:[{time:"2024-01-15",title:"Project Started",description:"Kickoff meeting and initial planning",variant:"success",icon:"🚀"},{time:"2024-02-01",title:"First Milestone",description:"Completed initial design phase",variant:"info",icon:"🎨"},{time:"2024-03-15",title:"Beta Release",description:"Released beta version to testers",variant:"warning",icon:"⚡"},{time:"2024-04-01",title:"Launch",description:"Official product launch",variant:"success",icon:"🎉"}]},examples:{vertical:{variant:"vertical",dateFormat:"long",items:[{time:"2024-01-15",title:"Project Started",description:"Kickoff meeting and initial planning",variant:"success"},{time:"2024-02-01",title:"First Milestone",description:"Completed initial design phase",variant:"info"}]},horizontal:{variant:"horizontal",dateFormat:"short",items:[{time:"2024-01-01",title:"Q1",description:"First quarter",variant:"default"},{time:"2024-04-01",title:"Q2",description:"Second quarter",variant:"info"},{time:"2024-07-01",title:"Q3",description:"Third quarter",variant:"warning"},{time:"2024-10-01",title:"Q4",description:"Fourth quarter",variant:"success"}]},gantt:{variant:"gantt",dateFormat:"short",timeScale:"month",rowLabel:"Projects",items:[{label:"Backend Development",items:[{title:"API Design",startDate:"2024-01-01",endDate:"2024-01-31",variant:"success"},{title:"Implementation",startDate:"2024-02-01",endDate:"2024-03-31",variant:"info"}]},{label:"Frontend Development",items:[{title:"UI Design",startDate:"2024-01-15",endDate:"2024-02-15",variant:"warning"},{title:"Component Dev",startDate:"2024-02-15",endDate:"2024-04-15",variant:"default"}]},{label:"Testing",items:[{title:"QA Phase",startDate:"2024-03-01",endDate:"2024-04-30",variant:"danger"}]}]}}});const nl=Zt({title:te().optional(),date:te().optional(),description:te().optional(),variant:te().optional()}),al=Zt({mapping:nl.optional(),objectName:te().optional(),titleField:te().optional(),dateField:te().optional(),startDateField:te().optional(),endDateField:te().optional(),descriptionField:te().optional(),groupByField:te().optional(),colorField:te().optional(),scale:Hr(["hour","day","week","month","quarter","year"]).optional()}),sl=({schema:e,dataSource:n,className:a,onRowClick:o,onItemClick:s,...r})=>{const[l,c]=i.useState([]),[d,u]=i.useState(!1),[m,p]=i.useState(null),[g,x]=i.useState(0),[h,F]=i.useState(null),v=e.timeline;i.useEffect(()=>{const M=al.safeParse(e);M.success||console.warn("[ObjectTimeline] Invalid timeline configuration:",M.error.format())},[e]);const b=Yt(e.bind);i.useEffect(()=>{let M=!0;return(async()=>{if(!(!n||typeof n.getObjectSchema!="function"||!e.objectName))try{const A=await n.getObjectSchema(e.objectName);M&&F(A)}catch(A){console.warn("Failed to fetch object def for ObjectTimeline",A)}})(),()=>{M=!1}},[e.objectName,n]),i.useEffect(()=>{const M=async()=>{if(!(!n||typeof n.find!="function"||!e.objectName)){u(!0);try{const N=Ye(h?.fields),A=await n.find(e.objectName,{options:{$top:100},...N.length>0?{$expand:N}:{}}),R=Ie(A);c(R)}catch(N){console.error(N),p(N)}finally{u(!1)}}};e.objectName&&!b&&!e.items&&!r.data&&M()},[e.objectName,n,b,e.items,r.data,g,h]);const S=r.data||b||l;let E=e.items;if(!E&&S&&Array.isArray(S)){const M=v?.titleField??e.mapping?.title??e.titleField??"name",N=v?.startDateField??e.mapping?.date??e.startDateField??e.dateField??"date",A=v?.endDateField??e.endDateField??N,R=e.mapping?.description??e.descriptionField??"description",L=e.mapping?.variant??"variant",B=v?.groupByField??e.groupByField,P=v?.colorField??e.colorField;E=S.map($=>({title:$[M],time:$[N],startDate:$[N],endDate:$[A],description:$[R],variant:$[L]||"default",...B?{group:$[B]}:{},...P?{color:$[P]}:{},_data:$}))}const f=i.useCallback(async()=>{x(M=>M+1)},[]),{ref:w,isRefreshing:j,pullDistance:y}=ya({onRefresh:f,enabled:!!e.objectName&&!!n}),C=Le({navigation:e.navigation,objectName:e.objectName,onRowClick:o??s}),V=v?.scale??e.scale,k={...e,items:E||[],className:a||e.className,...V?{timeScale:V}:{},onItemClick:M=>{const N=M._data||M;C.handleClick(N),s?.(N)}};return m?t.jsxs("div",{className:"p-4 text-red-500",children:["Error loading timeline: ",m.message]}):t.jsxs("div",{ref:w,className:"relative overflow-auto h-full min-w-0",children:[y>0&&t.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:y},children:j?"Refreshing…":"Pull to refresh"}),t.jsx(Ba,{schema:k}),C.isOverlay&&t.jsx(De,{...C,title:"Timeline Item",children:M=>t.jsx("div",{className:"space-y-3",children:Object.entries(M).map(([N,A])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:N.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(A??"—")})]},N))})})]})},Ha=i.forwardRef(({className:e,...n},a)=>t.jsx("ol",{ref:a,className:q("relative border-l border-gray-200",e),...n}));Ha.displayName="Timeline";const rl=ia("ml-6",{variants:{density:{default:"mb-10",compact:"mb-3",comfortable:"mb-6"}},defaultVariants:{density:"default"}}),qa=i.forwardRef(({className:e,density:n,...a},o)=>t.jsx("li",{ref:o,className:q(rl({density:n}),e),...a}));qa.displayName="TimelineItem";const ol=ia("absolute -left-3 w-6 h-6 rounded-full border-2 flex items-center justify-center",{variants:{variant:{default:"bg-blue-200 border-blue-400",success:"bg-emerald-200 border-emerald-500",warning:"bg-amber-200 border-amber-500",danger:"bg-red-200 border-red-500",info:"bg-purple-200 border-purple-500",todo:"bg-slate-200 border-slate-400","in-progress":"bg-blue-200 border-blue-500",done:"bg-emerald-200 border-emerald-500"}},defaultVariants:{variant:"default"}}),zt=i.forwardRef(({className:e,variant:n="default",...a},o)=>t.jsx("div",{ref:o,className:q(ol({variant:n}),e),...a}));zt.displayName="TimelineMarker";const Wa=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:e,...n}));Wa.displayName="TimelineContent";const Ut=i.forwardRef(({className:e,...n},a)=>t.jsx("h3",{ref:a,className:q("font-semibold text-lg mb-1",e),...n}));Ut.displayName="TimelineTitle";const Bt=i.forwardRef(({className:e,...n},a)=>t.jsx("time",{ref:a,className:q("text-sm font-normal text-gray-500 mb-2 block",e),...n}));Bt.displayName="TimelineTime";const Ht=i.forwardRef(({className:e,...n},a)=>t.jsx("p",{ref:a,className:q("text-base text-gray-700",e),...n}));Ht.displayName="TimelineDescription";const Ga=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("relative flex overflow-x-auto py-8",e),...n}));Ga.displayName="TimelineHorizontal";const Ka=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("flex-shrink-0 w-64 relative",e),...n}));Ka.displayName="TimelineHorizontalItem";const Ya=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("relative w-full border rounded-lg overflow-hidden",e),...n}));Ya.displayName="TimelineGantt";const Ja=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("flex border-b bg-gray-50",e),...n}));Ja.displayName="TimelineGanttHeader";const qt=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("w-48 border-r bg-white",e),...n}));qt.displayName="TimelineGanttRowLabels";const Wt=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("flex-1 overflow-x-auto",e),...n}));Wt.displayName="TimelineGanttGrid";const Gt=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("flex items-center border-b min-h-12",e),...n}));Gt.displayName="TimelineGanttRow";const Za=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("px-4 py-2 font-medium text-sm truncate",e),...n}));Za.displayName="TimelineGanttLabel";const Qa=i.forwardRef(({className:e,start:n=0,width:a=100,variant:o="default",...s},r)=>{const l={default:"bg-blue-500 hover:bg-blue-600",success:"bg-green-500 hover:bg-green-600",warning:"bg-yellow-500 hover:bg-yellow-600",danger:"bg-red-500 hover:bg-red-600",info:"bg-purple-500 hover:bg-purple-600"};return t.jsx("div",{ref:r,className:q("absolute h-8 rounded-md transition-colors cursor-pointer",l[o],e),style:{left:`${n}%`,width:`${a}%`},...s})});Qa.displayName="TimelineGanttBar";const Xa=i.forwardRef(({className:e,...n},a)=>t.jsx("div",{ref:a,className:q("px-2 py-1 text-white text-xs font-medium truncate",e),...n}));Xa.displayName="TimelineGanttBarContent";const es=({schema:e,...n})=>{const{dataSource:a}=Je()||{};return t.jsx(sl,{schema:e,dataSource:a,...n})};Z.register("object-timeline",es,{namespace:"plugin-timeline",label:"Object Timeline",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"variant",type:"enum",enum:["vertical","horizontal","gantt"],defaultValue:"vertical"}]});Z.register("timeline",es,{namespace:"view",label:"Timeline View",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"variant",type:"enum",enum:["vertical","horizontal","gantt"],defaultValue:"vertical"}]});const il=i.createContext(null);function ll(e,n){const a=Array.isArray(e)?e[0]:e?e.x:0,o=Array.isArray(e)?e[1]:e?e.y:0,s=Array.isArray(n)?n[0]:n?n.x:0,r=Array.isArray(n)?n[1]:n?n.y:0;return a===s&&o===r}function he(e,n){if(e===n)return!0;if(!e||!n)return!1;if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let a=0;a<e.length;a++)if(!he(e[a],n[a]))return!1;return!0}else if(Array.isArray(n))return!1;if(typeof e=="object"&&typeof n=="object"){const a=Object.keys(e),o=Object.keys(n);if(a.length!==o.length)return!1;for(const s of a)if(!n.hasOwnProperty(s)||!he(e[s],n[s]))return!1;return!0}return!1}function Ln(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function $n(e,n){const a=n.viewState||n,o={};if("longitude"in a&&"latitude"in a&&(a.longitude!==e.center.lng||a.latitude!==e.center.lat)){const s=e.center.constructor;o.center=new s(a.longitude,a.latitude)}return"zoom"in a&&a.zoom!==e.zoom&&(o.zoom=a.zoom),"bearing"in a&&a.bearing!==e.bearing&&(o.bearing=a.bearing),"pitch"in a&&a.pitch!==e.pitch&&(o.pitch=a.pitch),a.padding&&e.padding&&!he(a.padding,e.padding)&&(o.padding=a.padding),o}const cl=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function zn(e){if(!e)return null;if(typeof e=="string"||("toJS"in e&&(e=e.toJS()),!e.layers))return e;const n={};for(const o of e.layers)n[o.id]=o;const a=e.layers.map(o=>{let s=null;"interactive"in o&&(s=Object.assign({},o),delete s.interactive);const r=n[o.ref];if(r){s=s||Object.assign({},o),delete s.ref;for(const l of cl)l in r&&(s[l]=r[l])}return s||o});return{...e,layers:a}}const Un={version:8,sources:{},layers:[]},Bn={mousedown:"onMouseDown",mouseup:"onMouseUp",mouseover:"onMouseOver",mousemove:"onMouseMove",click:"onClick",dblclick:"onDblClick",mouseenter:"onMouseEnter",mouseleave:"onMouseLeave",mouseout:"onMouseOut",contextmenu:"onContextMenu",touchstart:"onTouchStart",touchend:"onTouchEnd",touchmove:"onTouchMove",touchcancel:"onTouchCancel"},Hn={movestart:"onMoveStart",move:"onMove",moveend:"onMoveEnd",dragstart:"onDragStart",drag:"onDrag",dragend:"onDragEnd",zoomstart:"onZoomStart",zoom:"onZoom",zoomend:"onZoomEnd",rotatestart:"onRotateStart",rotate:"onRotate",rotateend:"onRotateEnd",pitchstart:"onPitchStart",pitch:"onPitch",pitchend:"onPitchEnd"},qn={wheel:"onWheel",boxzoomstart:"onBoxZoomStart",boxzoomend:"onBoxZoomEnd",boxzoomcancel:"onBoxZoomCancel",resize:"onResize",load:"onLoad",render:"onRender",idle:"onIdle",remove:"onRemove",data:"onData",styledata:"onStyleData",sourcedata:"onSourceData",error:"onError"},dl=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],ul=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class Oe{constructor(n,a,o){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=s=>{const r=this.props[qn[s.type]];r?r(s):s.type==="error"&&console.error(s.error)},this._onCameraEvent=s=>{if(this._internalUpdate)return;s.viewState=this._propsedCameraUpdate||Ln(this._map.transform);const r=this.props[Hn[s.type]];r&&r(s)},this._onCameraUpdate=s=>this._internalUpdate?s:(this._propsedCameraUpdate=Ln(s),$n(s,this.props)),this._onPointerEvent=s=>{(s.type==="mousemove"||s.type==="mouseout")&&this._updateHover(s);const r=this.props[Bn[s.type]];r&&(this.props.interactiveLayerIds&&s.type!=="mouseover"&&s.type!=="mouseout"&&(s.features=this._hoveredFeatures||this._queryRenderedFeatures(s.point)),r(s),delete s.features)},this._MapClass=n,this.props=a,this._initialize(o)}get map(){return this._map}setProps(n){const a=this.props;this.props=n;const o=this._updateSettings(n,a),s=this._updateSize(n),r=this._updateViewState(n);this._updateStyle(n,a),this._updateStyleComponents(n),this._updateHandlers(n,a),(o||s||r&&!this._map.isMoving())&&this.redraw()}static reuse(n,a){const o=Oe.savedMaps.pop();if(!o)return null;const s=o.map,r=s.getContainer();for(a.className=r.className;r.childNodes.length>0;)a.appendChild(r.childNodes[0]);s._container=a;const l=s._resizeObserver;l&&(l.disconnect(),l.observe(a)),o.setProps({...n,styleDiffing:!1}),s.resize();const{initialViewState:c}=n;return c&&(c.bounds?s.fitBounds(c.bounds,{...c.fitBoundsOptions,duration:0}):o._updateViewState(c)),s.isStyleLoaded()?s.fire("load"):s.once("style.load",()=>s.fire("load")),s._update(),o}_initialize(n){const{props:a}=this,{mapStyle:o=Un}=a,s={...a,...a.initialViewState,container:n,style:zn(o)},r=s.initialViewState||s.viewState||s;if(Object.assign(s,{center:[r.longitude||0,r.latitude||0],zoom:r.zoom||0,pitch:r.pitch||0,bearing:r.bearing||0}),a.gl){const c=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=c,a.gl)}const l=new this._MapClass(s);r.padding&&l.setPadding(r.padding),a.cursor&&(l.getCanvas().style.cursor=a.cursor),l.transformCameraUpdate=this._onCameraUpdate,l.on("style.load",()=>{this._styleComponents={light:l.getLight(),sky:l.getSky(),projection:l.getProjection?.(),terrain:l.getTerrain()},this._updateStyleComponents(this.props)}),l.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const c in Bn)l.on(c,this._onPointerEvent);for(const c in Hn)l.on(c,this._onCameraEvent);for(const c in qn)l.on(c,this._onEvent);this._map=l}recycle(){this.map.getContainer().querySelector("[mapboxgl-children]")?.remove(),Oe.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const n=this._map;n.style&&(n._frame&&(n._frame.cancel(),n._frame=null),n._render())}_updateSize(n){const{viewState:a}=n;if(a){const o=this._map;if(a.width!==o.transform.width||a.height!==o.transform.height)return o.resize(),!0}return!1}_updateViewState(n){const a=this._map,o=a.transform;if(!a.isMoving()){const r=$n(o,n);if(Object.keys(r).length>0)return this._internalUpdate=!0,a.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(n,a){const o=this._map;let s=!1;for(const r of dl)r in n&&!he(n[r],a[r])&&(s=!0,o[`set${r[0].toUpperCase()}${r.slice(1)}`]?.call(o,n[r]));return s}_updateStyle(n,a){if(n.cursor!==a.cursor&&(this._map.getCanvas().style.cursor=n.cursor||""),n.mapStyle!==a.mapStyle){const{mapStyle:o=Un,styleDiffing:s=!0}=n,r={diff:s};"localIdeographFontFamily"in n&&(r.localIdeographFontFamily=n.localIdeographFontFamily),this._map.setStyle(zn(o),r)}}_updateStyleComponents({light:n,projection:a,sky:o,terrain:s}){const r=this._map,l=this._styleComponents;r.style._loaded&&(n&&!he(n,l.light)&&(l.light=n,r.setLight(n)),a&&!he(a,l.projection)&&a!==l.projection?.type&&(l.projection=typeof a=="string"?{type:a}:a,r.setProjection?.(l.projection)),o&&!he(o,l.sky)&&(l.sky=o,r.setSky(o)),s!==void 0&&!he(s,l.terrain)&&(!s||r.getSource(s.source))&&(l.terrain=s,r.setTerrain(s)))}_updateHandlers(n,a){const o=this._map;for(const s of ul){const r=n[s]??!0,l=a[s]??!0;he(r,l)||(r?o[s].enable(r):o[s].disable())}}_queryRenderedFeatures(n){const a=this._map,{interactiveLayerIds:o=[]}=this.props;try{return a.queryRenderedFeatures(n,{layers:o.filter(a.getLayer.bind(a))})}catch{return[]}}_updateHover(n){const{props:a}=this;if(a.interactiveLayerIds&&(a.onMouseMove||a.onMouseEnter||a.onMouseLeave)){const s=n.type,r=this._hoveredFeatures?.length>0,l=this._queryRenderedFeatures(n.point),c=l.length>0;!c&&r&&(n.type="mouseleave",this._onPointerEvent(n)),this._hoveredFeatures=l,c&&!r&&(n.type="mouseenter",this._onPointerEvent(n)),n.type=s}else this._hoveredFeatures=null}}Oe.savedMaps=[];const ml=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function pl(e){if(!e)return null;const n=e.map,a={getMap:()=>n};for(const o of hl(n))!(o in a)&&!ml.includes(o)&&(a[o]=n[o].bind(n));return a}function hl(e){const n=new Set;let a=e;for(;a;){for(const o of Object.getOwnPropertyNames(a))o[0]!=="_"&&typeof e[o]=="function"&&o!=="fire"&&o!=="setEventedParent"&&n.add(o);a=Object.getPrototypeOf(a)}return Array.from(n)}const gl=typeof document<"u"?i.useLayoutEffect:i.useEffect;function fl(e,n){const{RTLTextPlugin:a,maxParallelImageRequests:o,workerCount:s,workerUrl:r}=n;if(a&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:l,lazy:c=!0}=typeof a=="string"?{pluginUrl:a}:a;e.setRTLTextPlugin(l,d=>{d&&console.error(d)},c)}o!==void 0&&e.setMaxParallelImageRequests(o),s!==void 0&&e.setWorkerCount(s),r!==void 0&&e.setWorkerUrl(r)}const xt=i.createContext(null);function xl(e,n){const a=i.useContext(il),[o,s]=i.useState(null),r=i.useRef(),{current:l}=i.useRef({mapLib:null,map:null});i.useEffect(()=>{const u=e.mapLib;let m=!0,p;return Promise.resolve(u||J(()=>import("./maplibre-gl-CENyyZ0G.js").then(g=>g.m),__vite__mapDeps([45,1]))).then(g=>{if(!m)return;if(!g)throw new Error("Invalid mapLib");const x="Map"in g?g:g.default;if(!x.Map)throw new Error("Invalid mapLib");fl(x,e),e.reuseMaps&&(p=Oe.reuse(e,r.current)),p||(p=new Oe(x.Map,e,r.current)),l.map=pl(p),l.mapLib=x,s(p),a?.onMapMount(l.map,e.id)}).catch(g=>{const{onError:x}=e;x?x({type:"error",target:null,originalEvent:null,error:g}):console.error(g)}),()=>{m=!1,p&&(a?.onMapUnmount(e.id),e.reuseMaps?p.recycle():p.destroy())}},[]),gl(()=>{o&&o.setProps(e)}),i.useImperativeHandle(n,()=>l.map,[o]);const c=i.useMemo(()=>({position:"relative",width:"100%",height:"100%",...e.style}),[e.style]),d={height:"100%"};return i.createElement("div",{id:e.id,ref:r,style:c},o&&i.createElement(xt.Provider,{value:l},i.createElement("div",{"mapboxgl-children":"",style:d},e.children)))}const bl=i.forwardRef(xl),jl=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function xe(e,n){if(!e||!n)return;const a=e.style;for(const o in n){const s=n[o];Number.isFinite(s)&&!jl.test(o)?a[o]=`${s}px`:a[o]=s}}function ts(e,n){if(e===n)return null;const a=Wn(e),o=Wn(n),s=[];for(const r of o)a.has(r)||s.push(r);for(const r of a)o.has(r)||s.push(r);return s.length===0?null:s}function Wn(e){return new Set(e?e.trim().split(/\s+/):[])}const Gn=i.memo(i.forwardRef((e,n)=>{const{map:a,mapLib:o}=i.useContext(xt),s=i.useRef({props:e}),r=i.useMemo(()=>{let b=!1;i.Children.forEach(e.children,f=>{f&&(b=!0)});const S={...e,element:b?document.createElement("div"):void 0},E=new o.Marker(S);return E.setLngLat([e.longitude,e.latitude]),E.getElement().addEventListener("click",f=>{s.current.props.onClick?.({type:"click",target:E,originalEvent:f})}),E.on("dragstart",f=>{const w=f;w.lngLat=r.getLngLat(),s.current.props.onDragStart?.(w)}),E.on("drag",f=>{const w=f;w.lngLat=r.getLngLat(),s.current.props.onDrag?.(w)}),E.on("dragend",f=>{const w=f;w.lngLat=r.getLngLat(),s.current.props.onDragEnd?.(w)}),E},[]);i.useEffect(()=>(r.addTo(a.getMap()),()=>{r.remove()}),[]);const{longitude:l,latitude:c,offset:d,style:u,draggable:m=!1,popup:p=null,rotation:g=0,rotationAlignment:x="auto",pitchAlignment:h="auto"}=e;i.useEffect(()=>{xe(r.getElement(),u)},[u]),i.useImperativeHandle(n,()=>r,[]);const F=s.current.props;(r.getLngLat().lng!==l||r.getLngLat().lat!==c)&&r.setLngLat([l,c]),d&&!ll(r.getOffset(),d)&&r.setOffset(d),r.isDraggable()!==m&&r.setDraggable(m),r.getRotation()!==g&&r.setRotation(g),r.getRotationAlignment()!==x&&r.setRotationAlignment(x),r.getPitchAlignment()!==h&&r.setPitchAlignment(h),r.getPopup()!==p&&r.setPopup(p);const v=ts(F.className,e.className);if(v)for(const b of v)r.toggleClassName(b);return s.current.props=e,Yn.createPortal(e.children,r.getElement())})),yl=i.memo(i.forwardRef((e,n)=>{const{map:a,mapLib:o}=i.useContext(xt),s=i.useMemo(()=>document.createElement("div"),[]),r=i.useRef({props:e}),l=i.useMemo(()=>{const c={...e},d=new o.Popup(c);return d.setLngLat([e.longitude,e.latitude]),d.once("open",u=>{r.current.props.onOpen?.(u)}),d},[]);if(i.useEffect(()=>{const c=d=>{r.current.props.onClose?.(d)};return l.on("close",c),l.setDOMContent(s).addTo(a.getMap()),()=>{l.off("close",c),l.isOpen()&&l.remove()}},[]),i.useEffect(()=>{xe(l.getElement(),e.style)},[e.style]),i.useImperativeHandle(n,()=>l,[]),l.isOpen()){const c=r.current.props;(l.getLngLat().lng!==e.longitude||l.getLngLat().lat!==e.latitude)&&l.setLngLat([e.longitude,e.latitude]),e.offset&&!he(c.offset,e.offset)&&l.setOffset(e.offset),(c.anchor!==e.anchor||c.maxWidth!==e.maxWidth)&&(l.options.anchor=e.anchor,l.setMaxWidth(e.maxWidth));const d=ts(c.className,e.className);if(d)for(const u of d)l.toggleClassName(u);r.current.props=e}return Yn.createPortal(e.children,s)}));function Ee(e,n,a,o){const s=i.useContext(xt),r=i.useMemo(()=>e(s),[]);return i.useEffect(()=>{const l=n,c=null,d=typeof n=="function"?n:null,{map:u}=s;return u.hasControl(r)||(u.addControl(r,l?.position),c&&c(s)),()=>{d&&d(s),u.hasControl(r)&&u.removeControl(r)}},[]),r}function vl(e){const n=Ee(({mapLib:a})=>new a.AttributionControl(e),{position:e.position});return i.useEffect(()=>{xe(n._container,e.style)},[e.style]),null}i.memo(vl);function wl(e){const n=Ee(({mapLib:a})=>new a.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return i.useEffect(()=>{xe(n._controlContainer,e.style)},[e.style]),null}i.memo(wl);function Nl(e,n){const a=i.useRef({props:e}),o=Ee(({mapLib:s})=>{const r=new s.GeolocateControl(e),l=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||l()},r.on("geolocate",c=>{a.current.props.onGeolocate?.(c)}),r.on("error",c=>{a.current.props.onError?.(c)}),r.on("outofmaxbounds",c=>{a.current.props.onOutOfMaxBounds?.(c)}),r.on("trackuserlocationstart",c=>{a.current.props.onTrackUserLocationStart?.(c)}),r.on("trackuserlocationend",c=>{a.current.props.onTrackUserLocationEnd?.(c)}),r},{position:e.position});return a.current.props=e,i.useImperativeHandle(n,()=>o,[]),i.useEffect(()=>{xe(o._container,e.style)},[e.style]),null}i.memo(i.forwardRef(Nl));function Cl(e){const n=Ee(({mapLib:a})=>new a.NavigationControl(e),{position:e.position});return i.useEffect(()=>{xe(n._container,e.style)},[e.style]),null}const Sl=i.memo(Cl);function kl(e){const n=Ee(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),a=i.useRef(e),o=a.current;a.current=e;const{style:s}=e;return e.maxWidth!==void 0&&e.maxWidth!==o.maxWidth&&(n.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==o.unit&&n.setUnit(e.unit),i.useEffect(()=>{xe(n._container,s)},[s]),null}i.memo(kl);function Dl(e){const n=Ee(({mapLib:a})=>new a.TerrainControl(e),{position:e.position});return i.useEffect(()=>{xe(n._container,e.style)},[e.style]),null}i.memo(Dl);function Fl(e){const n=Ee(({mapLib:a})=>new a.LogoControl(e),{position:e.position});return i.useEffect(()=>{xe(n._container,e.style)},[e.style]),null}i.memo(Fl);const _l=Zt({latitudeField:te().optional(),longitudeField:te().optional(),locationField:te().optional(),titleField:te().optional(),descriptionField:te().optional(),zoom:wt().optional(),center:qr([wt(),wt()]).optional()});function El(e){return e.data?e.data:e.staticData?{provider:"value",items:e.staticData}:e.objectName?{provider:"object",object:e.objectName}:null}function Al(e){if(e){if(typeof e=="string"){const n=e.split(" "),a=n[0],o=n[1]?.toLowerCase()==="desc"?"desc":"asc";return{[a]:o}}if(Array.isArray(e))return e.reduce((n,a)=>(a.field&&a.order&&(n[a.field]=a.order),n),{})}}function Tl(e){if(e.locationField||e.latitudeField)return{locationField:e.locationField,latitudeField:e.latitudeField,longitudeField:e.longitudeField,titleField:e.titleField||"name",descriptionField:e.descriptionField,zoom:e.zoom,center:e.center};let n=null;if(e.filter&&typeof e.filter=="object"&&"map"in e.filter?n=e.filter.map:e.map&&(n=e.map),n){const a=_l.safeParse(n);return a.success||console.warn("[ObjectMap] Invalid map configuration:",a.error.format()),n}return{latitudeField:"latitude",longitudeField:"longitude",locationField:"location",titleField:"name",descriptionField:"description",zoom:10,center:[0,0]}}function Rl(e,n){if(n.latitudeField&&n.longitudeField){const a=e[n.latitudeField],o=e[n.longitudeField];if(typeof a=="number"&&typeof o=="number")return[a,o]}if(n.locationField){const a=e[n.locationField];if(typeof a=="object"&&a!==null){const o=a.lat||a.latitude,s=a.lng||a.lon||a.longitude;if(typeof o=="number"&&typeof s=="number")return[o,s]}if(typeof a=="string"){const o=a.split(",").map(s=>parseFloat(s.trim()));if(o.length===2&&!isNaN(o[0])&&!isNaN(o[1]))return[o[0],o[1]]}if(Array.isArray(a)&&a.length===2){const o=parseFloat(a[0]),s=parseFloat(a[1]);if(!isNaN(o)&&!isNaN(s))return[o,s]}}return null}function Vl(e,n,a=50){if(e.length<=1||n>=15)return e.map(l=>({id:l.id,coordinates:l.coordinates,markers:[l],isCluster:!1}));const o=a/Math.pow(2,n),s=new Map;e.forEach(l=>{const c=Math.floor(l.coordinates[0]/o),d=Math.floor(l.coordinates[1]/o),u=`${c}:${d}`;s.has(u)||s.set(u,[]),s.get(u).push(l)});const r=[];return s.forEach((l,c)=>{if(l.length===1)r.push({id:l[0].id,coordinates:l[0].coordinates,markers:l,isCluster:!1});else{const d=l.reduce((m,p)=>m+p.coordinates[0],0)/l.length,u=l.reduce((m,p)=>m+p.coordinates[1],0)/l.length;r.push({id:`cluster-${c}`,coordinates:[d,u],markers:l,isCluster:!0})}}),r}const Ml=({schema:e,dataSource:n,className:a,onMarkerClick:o,onRowClick:s,onEdit:r,onDelete:l,enableClustering:c,clusterRadius:d=50,...u})=>{const[m,p]=i.useState([]),[g,x]=i.useState(!0),[h,F]=i.useState(null),[v,b]=i.useState(null),[S,E]=i.useState(null),[f,w]=i.useState(""),j=El(e),y=i.useMemo(()=>j,[JSON.stringify(j)]),C=Tl(e),V=y?.provider==="value";i.useEffect(()=>{(async()=>{try{if(x(!0),u.data){const I=u.data;if(Array.isArray(I)){p(I),x(!1);return}}if(e.data){const I=e.data;if(Array.isArray(I)){p(I),x(!1);return}}if(V&&y?.provider==="value"){p(y.items),x(!1);return}if(!n||typeof n.find!="function")throw new Error("DataSource required for object/api providers");if(y?.provider==="object"){const I=y.object,D=Ye(v?.fields),G=await n.find(I,{$filter:e.filter,$orderby:Al(e.sort),...D.length>0?{$expand:D}:{}});let W=Ie(G);p(W)}else y?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectMap"),p([]));x(!1)}catch(I){F(I),x(!1)}})()},[y,n,V,e.filter,e.sort,v]),i.useEffect(()=>{!V&&n&&(async()=>{try{if(!n)return;const I=y?.provider==="object"?y.object:e.objectName;if(!I)return;const D=await n.getObjectSchema(I);b(D)}catch(I){console.error("Failed to fetch object schema:",I)}})()},[e.objectName,n,V,y]);const{markers:k,invalidCount:M}=i.useMemo(()=>{let O=0;return{markers:m.map((D,G)=>{const W=Rl(D,C);if(!W)return O++,null;const Q=C.titleField?D[C.titleField]:"Marker",se=C.descriptionField?D[C.descriptionField]:void 0,[le,ce]=W;return!isFinite(le)||!isFinite(ce)||le<-90||le>90||ce<-180||ce>180?(O++,null):{id:D.id||D._id||`marker-${G}`,title:Q,description:se,coordinates:[ce,le],data:D}}).filter(D=>D!==null),invalidCount:O}},[m,C]),N=i.useMemo(()=>k.find(O=>O.id===S),[k,S]),[A,R]=i.useState(C.zoom||3),L=Le({navigation:e.navigation,objectName:e.objectName,onRowClick:s}),B=i.useMemo(()=>{if(!f.trim())return k;const O=f.toLowerCase();return k.filter(I=>I.title?.toLowerCase().includes(O)||I.description?.toLowerCase().includes(O))},[k,f]),P=i.useMemo(()=>c??(e.enableClustering||B.length>100)?Vl(B,A,d):B.map(I=>({id:I.id,coordinates:I.coordinates,markers:[I],isCluster:!1})),[B,A,c,d,e]),$=i.useMemo(()=>{if(!B.length)return{longitude:C.center?.[1]||0,latitude:C.center?.[0]||0,zoom:C.zoom||2};const O=B.map(se=>se.coordinates[0]),I=B.map(se=>se.coordinates[1]),D=Math.min(...O),G=Math.max(...O),W=Math.min(...I),Q=Math.max(...I);return{longitude:(D+G)/2,latitude:(W+Q)/2,zoom:C.zoom||3}},[B,C]);return g?t.jsx("div",{className:q("min-w-0 overflow-hidden",a),children:t.jsx("div",{className:"flex items-center justify-center h-96 bg-muted rounded-lg border",children:t.jsx("div",{className:"text-muted-foreground",children:"Loading map..."})})}):h?t.jsx("div",{className:q("min-w-0 overflow-hidden",a),children:t.jsx("div",{className:"flex items-center justify-center h-96 bg-muted rounded-lg border",children:t.jsxs("div",{className:"text-destructive",children:["Error: ",h.message]})})}):t.jsxs("div",{className:q("min-w-0 overflow-hidden",a),children:[M>0&&t.jsx("div",{className:"mb-2 p-2 text-sm text-yellow-800 bg-yellow-50 border border-yellow-200 rounded",children:`${M} record${M!==1?"s":""} with missing or invalid coordinates excluded from the map.`}),k.length>0&&t.jsx("div",{className:"mb-2",children:t.jsx("input",{type:"text",value:f,onChange:O=>w(O.target.value),placeholder:"Search locations…",className:"w-full px-3 py-2 text-sm border rounded-md bg-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"})}),t.jsx("div",{className:"relative border rounded-lg overflow-hidden bg-muted h-[300px] sm:h-[400px] md:h-[500px] lg:h-[600px] w-full",children:t.jsxs(bl,{initialViewState:$,style:{width:"100%",height:"100%"},mapStyle:"https://demotiles.maplibre.org/style.json",touchZoomRotate:!0,dragRotate:!0,touchPitch:!0,onZoom:O=>R(Math.round(O.viewState.zoom)),children:[t.jsx(Sl,{position:"top-right",showCompass:!0,showZoom:!0}),P.map(O=>O.isCluster?t.jsx(Gn,{longitude:O.coordinates[0],latitude:O.coordinates[1],anchor:"center",children:t.jsx("div",{className:"flex items-center justify-center rounded-full bg-primary text-primary-foreground font-bold text-xs cursor-pointer hover:scale-110 transition-transform shadow-md",style:{width:Math.min(48,24+O.markers.length*2),height:Math.min(48,24+O.markers.length*2)},title:`${O.markers.length} markers`,children:O.markers.length})},O.id):t.jsx(Gn,{longitude:O.coordinates[0],latitude:O.coordinates[1],anchor:"bottom",onClick:I=>{I.originalEvent.stopPropagation();const D=O.markers[0];E(D.id),L.handleClick(D.data),o?.(D.data)},children:t.jsx("div",{className:"text-2xl cursor-pointer hover:scale-110 transition-transform",children:"📍"})},O.id)),N&&t.jsx(yl,{longitude:N.coordinates[0],latitude:N.coordinates[1],anchor:"top",onClose:()=>E(null),closeOnClick:!1,children:t.jsxs("div",{className:"p-2 min-w-[150px] sm:min-w-[200px]",children:[t.jsx("h3",{className:"font-bold text-sm mb-1",children:N.title}),N.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:N.description}),t.jsxs("div",{className:"mt-2 text-xs flex gap-2",children:[r&&t.jsx("button",{className:"text-blue-500 hover:underline",onClick:()=>r(N.data),children:"Edit"}),l&&t.jsx("button",{className:"text-red-500 hover:underline",onClick:()=>l(N.data),children:"Delete"})]})]})})]})}),L.isOverlay&&t.jsx(De,{...L,title:"Location Details",children:O=>t.jsx("div",{className:"space-y-3",children:Object.entries(O).map(([I,D])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:I.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(D??"—")})]},I))})})]})},ns=({schema:e,...n})=>{const{dataSource:a}=Je()||{};return t.jsx(Ml,{schema:e,dataSource:a,...n})};console.log("Registering object-map...");Z.register("object-map",ns,{namespace:"plugin-map",label:"Object Map",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"map",type:"object",label:"Map Config",description:"latitudeField, longitudeField, titleField"}]});Z.register("map",ns,{namespace:"view",label:"Map View",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"map",type:"object",label:"Map Config",description:"latitudeField, longitudeField, titleField"}]});const Ol=ae.lazy(()=>J(()=>import("./MarkdownImpl-eDhoPCJp.js"),__vite__mapDeps([46,1]))),Pl=({schema:e})=>t.jsx(i.Suspense,{fallback:t.jsx(Ke,{className:"w-full h-[200px]"}),children:t.jsx(Ol,{content:e.content||"",className:e.className})});Z.register("markdown",Pl,{namespace:"plugin-markdown",label:"Markdown",category:"plugin",inputs:[{name:"content",type:"string",label:"Markdown Content",required:!0,inputType:"textarea"},{name:"className",type:"string",label:"CSS Class"}],defaultProps:{content:`# Hello World
|
|
4
|
-
|
|
5
|
-
This is a **markdown** component with *formatting* support.
|
|
6
|
-
|
|
7
|
-
- Item 1
|
|
8
|
-
- Item 2
|
|
9
|
-
- Item 3`}});async function Il(e){try{const n=await fetch(`/api/v1/i18n/translations/${e}`);return n.ok?await n.json():(console.warn(`[i18n] Failed to load translations for '${e}': HTTP ${n.status}`),{})}catch(n){return console.warn(`[i18n] Failed to load translations for '${e}':`,n),{}}}async function Ll(){os.createRoot(document.getElementById("root")).render(t.jsx(ae.StrictMode,{children:t.jsx(Rr,{pwa:{enabled:!0,name:"ObjectUI Console",shortName:"Console"},children:t.jsx(Qs,{loadLanguage:Il,children:t.jsx(Wi,{})})})}))}Ll();export{qo as M,io as P,Qe as a,Ze as b,ee as r,Wo as u};
|