@object-ui/console 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +118 -0
  3. package/dist/assets/AdvancedChartImpl-DAS1mU9o.js +7 -0
  4. package/dist/assets/AdvancedChartImpl-DAS1mU9o.js.br +0 -0
  5. package/dist/assets/AdvancedChartImpl-DAS1mU9o.js.gz +0 -0
  6. package/dist/assets/AuditLogPage-BQW_Xbnm.js +1 -0
  7. package/dist/assets/AuditLogPage-BQW_Xbnm.js.br +0 -0
  8. package/dist/assets/AuditLogPage-BQW_Xbnm.js.gz +0 -0
  9. package/dist/assets/ChartImpl-2ivTljUi.js +1 -0
  10. package/dist/assets/ChartImpl-2ivTljUi.js.br +0 -0
  11. package/dist/assets/ChartImpl-2ivTljUi.js.gz +0 -0
  12. package/dist/assets/DashboardView-Dt-4VhH6.js +1 -0
  13. package/dist/assets/DashboardView-Dt-4VhH6.js.br +0 -0
  14. package/dist/assets/DashboardView-Dt-4VhH6.js.gz +0 -0
  15. package/dist/assets/ForgotPasswordPage-zr9S5vrE.js +1 -0
  16. package/dist/assets/KanbanEnhanced-BlGp--J7.js +1 -0
  17. package/dist/assets/KanbanEnhanced-BlGp--J7.js.br +0 -0
  18. package/dist/assets/KanbanEnhanced-BlGp--J7.js.gz +0 -0
  19. package/dist/assets/KanbanImpl-B5wWMXrJ.js +1 -0
  20. package/dist/assets/KanbanImpl-B5wWMXrJ.js.br +0 -0
  21. package/dist/assets/KanbanImpl-B5wWMXrJ.js.gz +0 -0
  22. package/dist/assets/LoginPage-H688gsah.js +1 -0
  23. package/dist/assets/MarkdownImpl-BshtTFK2.js +29 -0
  24. package/dist/assets/MarkdownImpl-BshtTFK2.js.br +0 -0
  25. package/dist/assets/MarkdownImpl-BshtTFK2.js.gz +0 -0
  26. package/dist/assets/OrgManagementPage-x3qIkxHL.js +1 -0
  27. package/dist/assets/OrgManagementPage-x3qIkxHL.js.br +0 -0
  28. package/dist/assets/OrgManagementPage-x3qIkxHL.js.gz +0 -0
  29. package/dist/assets/PageView-BRN1h8QD.js +1 -0
  30. package/dist/assets/PageView-BRN1h8QD.js.br +0 -0
  31. package/dist/assets/PageView-BRN1h8QD.js.gz +0 -0
  32. package/dist/assets/ProfilePage-DjAiGvFb.js +1 -0
  33. package/dist/assets/ProfilePage-DjAiGvFb.js.br +0 -0
  34. package/dist/assets/ProfilePage-DjAiGvFb.js.gz +0 -0
  35. package/dist/assets/RecordDetailView-Bfu7541n.js +1 -0
  36. package/dist/assets/RecordDetailView-Bfu7541n.js.br +0 -0
  37. package/dist/assets/RecordDetailView-Bfu7541n.js.gz +0 -0
  38. package/dist/assets/RegisterPage-CR91Lc7x.js +1 -0
  39. package/dist/assets/ReportView-CwWsv2yl.js +1 -0
  40. package/dist/assets/ReportView-CwWsv2yl.js.br +0 -0
  41. package/dist/assets/ReportView-CwWsv2yl.js.gz +0 -0
  42. package/dist/assets/RoleManagementPage-DnWuzxKJ.js +1 -0
  43. package/dist/assets/RoleManagementPage-DnWuzxKJ.js.br +0 -0
  44. package/dist/assets/RoleManagementPage-DnWuzxKJ.js.gz +0 -0
  45. package/dist/assets/SearchResultsPage-DBpjAlh2.js +1 -0
  46. package/dist/assets/SearchResultsPage-DBpjAlh2.js.br +0 -0
  47. package/dist/assets/SearchResultsPage-DBpjAlh2.js.gz +0 -0
  48. package/dist/assets/UserManagementPage-o0_K0dzR.js +1 -0
  49. package/dist/assets/UserManagementPage-o0_K0dzR.js.br +0 -0
  50. package/dist/assets/UserManagementPage-o0_K0dzR.js.gz +0 -0
  51. package/dist/assets/ViewDesignerPage-BbwrZa9D.js +1 -0
  52. package/dist/assets/ViewDesignerPage-BbwrZa9D.js.br +0 -0
  53. package/dist/assets/ViewDesignerPage-BbwrZa9D.js.gz +0 -0
  54. package/dist/assets/data-adapter-Cn800k4a.js +1 -0
  55. package/dist/assets/data-adapter-Cn800k4a.js.br +0 -0
  56. package/dist/assets/data-adapter-Cn800k4a.js.gz +0 -0
  57. package/dist/assets/framework-mHWN965c.js +10 -0
  58. package/dist/assets/framework-mHWN965c.js.br +0 -0
  59. package/dist/assets/framework-mHWN965c.js.gz +0 -0
  60. package/dist/assets/index-BjEGJcpx.js +56 -0
  61. package/dist/assets/index-BjEGJcpx.js.br +0 -0
  62. package/dist/assets/index-BjEGJcpx.js.gz +0 -0
  63. package/dist/assets/index-CUnVdETN.css +1 -0
  64. package/dist/assets/index-CUnVdETN.css.br +0 -0
  65. package/dist/assets/index-CUnVdETN.css.gz +0 -0
  66. package/dist/assets/infrastructure-aS2LF8OZ.js +1 -0
  67. package/dist/assets/infrastructure-aS2LF8OZ.js.br +0 -0
  68. package/dist/assets/infrastructure-aS2LF8OZ.js.gz +0 -0
  69. package/dist/assets/maplibre-gl-D2AsLM0J.js +811 -0
  70. package/dist/assets/maplibre-gl-D2AsLM0J.js.br +0 -0
  71. package/dist/assets/maplibre-gl-D2AsLM0J.js.gz +0 -0
  72. package/dist/assets/plugins-core-CcBSZCjG.js +4 -0
  73. package/dist/assets/plugins-core-CcBSZCjG.js.br +0 -0
  74. package/dist/assets/plugins-core-CcBSZCjG.js.gz +0 -0
  75. package/dist/assets/plugins-views-DQwkCaaO.js +60 -0
  76. package/dist/assets/plugins-views-DQwkCaaO.js.br +0 -0
  77. package/dist/assets/plugins-views-DQwkCaaO.js.gz +0 -0
  78. package/dist/assets/plugins-views-P3eB-els.css +1 -0
  79. package/dist/assets/plugins-views-P3eB-els.css.br +0 -0
  80. package/dist/assets/plugins-views-P3eB-els.css.gz +0 -0
  81. package/dist/assets/systemObjects-DSpePIIy.js +1 -0
  82. package/dist/assets/systemObjects-DSpePIIy.js.br +2 -0
  83. package/dist/assets/systemObjects-DSpePIIy.js.gz +0 -0
  84. package/dist/assets/ui-components-DVonQS7H.js +31 -0
  85. package/dist/assets/ui-components-DVonQS7H.js.br +0 -0
  86. package/dist/assets/ui-components-DVonQS7H.js.gz +0 -0
  87. package/dist/assets/ui-components-GrNdJOi1.css +1 -0
  88. package/dist/assets/ui-components-GrNdJOi1.css.br +0 -0
  89. package/dist/assets/ui-components-GrNdJOi1.css.gz +0 -0
  90. package/dist/assets/ui-layout-BENIRxAF.js +1 -0
  91. package/dist/assets/ui-layout-BENIRxAF.js.br +0 -0
  92. package/dist/assets/ui-layout-BENIRxAF.js.gz +0 -0
  93. package/dist/assets/vendor-charts-CSvoW-yB.js +65 -0
  94. package/dist/assets/vendor-charts-CSvoW-yB.js.br +0 -0
  95. package/dist/assets/vendor-charts-CSvoW-yB.js.gz +0 -0
  96. package/dist/assets/vendor-dndkit-DRGpK6sP.js +5 -0
  97. package/dist/assets/vendor-dndkit-DRGpK6sP.js.br +0 -0
  98. package/dist/assets/vendor-dndkit-DRGpK6sP.js.gz +0 -0
  99. package/dist/assets/vendor-i18n-D5KbMT7w.js +9 -0
  100. package/dist/assets/vendor-i18n-D5KbMT7w.js.br +0 -0
  101. package/dist/assets/vendor-i18n-D5KbMT7w.js.gz +0 -0
  102. package/dist/assets/vendor-icons-CQ8b-fGy.js +8671 -0
  103. package/dist/assets/vendor-icons-CQ8b-fGy.js.br +0 -0
  104. package/dist/assets/vendor-icons-CQ8b-fGy.js.gz +0 -0
  105. package/dist/assets/vendor-objectstack-DqojdwYW.js +37 -0
  106. package/dist/assets/vendor-objectstack-DqojdwYW.js.br +0 -0
  107. package/dist/assets/vendor-objectstack-DqojdwYW.js.gz +0 -0
  108. package/dist/assets/vendor-radix-BbeYj_o4.js +56 -0
  109. package/dist/assets/vendor-radix-BbeYj_o4.js.br +0 -0
  110. package/dist/assets/vendor-radix-BbeYj_o4.js.gz +0 -0
  111. package/dist/assets/vendor-react-Dy_xkBQQ.js +60 -0
  112. package/dist/assets/vendor-react-Dy_xkBQQ.js.br +0 -0
  113. package/dist/assets/vendor-react-Dy_xkBQQ.js.gz +0 -0
  114. package/dist/assets/vendor-ui-utils-h6yAcIi9.js +1 -0
  115. package/dist/assets/vendor-ui-utils-h6yAcIi9.js.br +0 -0
  116. package/dist/assets/vendor-ui-utils-h6yAcIi9.js.gz +0 -0
  117. package/dist/assets/vendor-zod-Dpl-cylz.js +39 -0
  118. package/dist/assets/vendor-zod-Dpl-cylz.js.br +0 -0
  119. package/dist/assets/vendor-zod-Dpl-cylz.js.gz +0 -0
  120. package/dist/index.html +49 -0
  121. package/dist/index.html.br +0 -0
  122. package/dist/index.html.gz +0 -0
  123. package/dist/manifest.json +19 -0
  124. package/dist/mockServiceWorker.js +349 -0
  125. package/dist/mockServiceWorker.js.br +0 -0
  126. package/dist/mockServiceWorker.js.gz +0 -0
  127. package/dist/stats.html +4949 -0
  128. package/package.json +98 -0
  129. package/plugin.ts +177 -0
@@ -0,0 +1,56 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ChartImpl-2ivTljUi.js","assets/vendor-react-Dy_xkBQQ.js","assets/vendor-charts-CSvoW-yB.js","assets/vendor-ui-utils-h6yAcIi9.js","assets/vendor-i18n-D5KbMT7w.js","assets/AdvancedChartImpl-DAS1mU9o.js","assets/KanbanImpl-B5wWMXrJ.js","assets/vendor-dndkit-DRGpK6sP.js","assets/ui-components-DVonQS7H.js","assets/framework-mHWN965c.js","assets/vendor-icons-CQ8b-fGy.js","assets/vendor-radix-BbeYj_o4.js","assets/ui-components-GrNdJOi1.css","assets/KanbanEnhanced-BlGp--J7.js","assets/plugins-core-CcBSZCjG.js","assets/plugins-views-DQwkCaaO.js","assets/plugins-views-P3eB-els.css","assets/RecordDetailView-Bfu7541n.js","assets/data-adapter-Cn800k4a.js","assets/vendor-objectstack-DqojdwYW.js","assets/vendor-zod-Dpl-cylz.js","assets/infrastructure-aS2LF8OZ.js","assets/ui-layout-BENIRxAF.js","assets/DashboardView-Dt-4VhH6.js","assets/PageView-BRN1h8QD.js","assets/ReportView-CwWsv2yl.js","assets/ViewDesignerPage-BbwrZa9D.js","assets/SearchResultsPage-DBpjAlh2.js","assets/LoginPage-H688gsah.js","assets/RegisterPage-CR91Lc7x.js","assets/ForgotPasswordPage-zr9S5vrE.js","assets/UserManagementPage-o0_K0dzR.js","assets/systemObjects-DSpePIIy.js","assets/OrgManagementPage-x3qIkxHL.js","assets/RoleManagementPage-DnWuzxKJ.js","assets/AuditLogPage-BQW_Xbnm.js","assets/ProfilePage-DjAiGvFb.js","assets/maplibre-gl-D2AsLM0J.js","assets/MarkdownImpl-BshtTFK2.js"])))=>i.map(i=>d[i]);
2
+ import{r as i,j as t,L as oe,u as lt,h as _e,i as ze,R as Z,k as sa,B as nn,l as ra,m as z,N as ct,d as oa,n as sn}from"./vendor-react-Dy_xkBQQ.js";import{ac as ia,ad as rn,ae as on,af as se,ag as je,t as ie,u as le,ah as we,v as ce,ai as kt,w as K,aa as Me,aj as ln,ak as De,al as Je,am as Ce,an as cn,ao as dn,ap as Ft,aq as Tt,ar as Et,as as un,a2 as mn,a3 as pn,a4 as hn,B as $,c as I,W as gn,at as fn,au as bn,av as xn,aw as yn,ax as vn,ay as jn,az as wn,aA as Nn,aB as Dn,aC as Cn,aD as Sn,aE as ae,aF as X,aG as Ge,aH as dt,aI as ut,aJ as la,aK as _n,_ as B,a9 as ke,N as Fe,P as kn,J as Fn,K as Tn,aL as En,x as ca,y as da,z as ua,A as ma,C as re,S as Pn,h as An,D as mt,l as pt,n as ht,o as gt,p as ft,aM as Pt}from"./ui-components-DVonQS7H.js";import{O as Mn,a as On}from"./plugins-core-CcBSZCjG.js";import{E as bt,k as Rn,C as V,g as be,c as xt,f as Te,l as Ln,m as In}from"./framework-mHWN965c.js";import{b as Ye,T as $n}from"./vendor-ui-utils-h6yAcIi9.js";import{O as pa}from"./data-adapter-Cn800k4a.js";import{a as Y,F as f,d as Be,A as yt,G as Vn}from"./vendor-objectstack-DqojdwYW.js";import{u as ha,g as At,a as ga,b as de,A as Mt,c as zn,I as Bn}from"./infrastructure-aS2LF8OZ.js";import{A as Hn}from"./ui-layout-BENIRxAF.js";import{k as Ot,as as he,m as Se,H as fa,ac as Un,at as Wn,au as Gn,av as Kn,r as te,a as He,aw as Qe,ax as Ze,ay as ba,az as qn,aA as Rt,L as Ie,g as vt,C as Xe,S as $e,aB as Jn,aC as Yn,aD as xa,a1 as Qn,aE as ya,T as va,aF as Zn,aG as Xn,b as ja,j as wa,aH as es,d as ts,V as as,aI as Oe,aJ as Lt,Y as ns,aK as ss,J as rs,aL as os,_ as is,$ as ls,aM as cs,R as Na,X as ds,c as us,O as ms,I as ps,aN as hs,aO as gs}from"./vendor-icons-CQ8b-fGy.js";import{u as Da,L as fs,D as bs,M as xs}from"./plugins-views-DQwkCaaO.js";import{o as jt,s as q,t as ys,n as Ke}from"./vendor-zod-Dpl-cylz.js";import"./vendor-radix-BbeYj_o4.js";import"./vendor-i18n-D5KbMT7w.js";import"./vendor-charts-CSvoW-yB.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.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 c of r.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&o(c)}).observe(document,{childList:!0,subtree:!0});function n(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=n(s);fetch(s.href,r)}})();const vs=Y.create({name:"account",label:"Account",icon:"building-2",fields:{name:f.text({label:"Account Name",required:!0,searchable:!0}),industry:f.select(["Technology","Finance","Healthcare","Retail","Manufacturing"],{label:"Industry"}),rating:f.select(["Hot","Warm","Cold"],{label:"Rating"}),type:f.select(["Customer","Partner","Reseller","Vendor"],{label:"Type"}),annual_revenue:f.currency({label:"Annual Revenue"}),website:f.url({label:"Website"}),phone:f.text({label:"Phone"}),employees:f.number({label:"Employees"}),billing_address:f.textarea({label:"Billing Address"}),latitude:f.number({label:"Latitude",scale:6}),longitude:f.number({label:"Longitude",scale:6}),owner:f.lookup("user",{label:"Owner"}),created_at:f.datetime({label:"Created Date"})}}),js=Y.create({name:"contact",label:"Contact",icon:"user",fields:{name:f.text({label:"Name",required:!0,searchable:!0}),company:f.text({label:"Company"}),email:f.email({label:"Email",searchable:!0}),phone:f.text({label:"Phone"}),title:f.text({label:"Title"}),department:f.text({label:"Department"}),account:f.lookup("account",{label:"Account"}),status:f.select(["Active","Lead","Customer"],{label:"Status"}),priority:f.select(["High","Medium","Low"],{label:"Priority",defaultValue:"Medium"}),birthdate:f.date({label:"Birthdate"}),address:f.textarea({label:"Address"}),latitude:f.number({label:"Latitude",scale:6}),longitude:f.number({label:"Longitude",scale:6}),is_active:f.boolean({label:"Active",defaultValue:!0}),notes:f.textarea({label:"Notes"})}}),ws=Y.create({name:"opportunity",label:"Opportunity",icon:"trending-up",fields:{name:f.text({label:"Opportunity Name",required:!0,searchable:!0}),amount:f.currency({label:"Amount"}),stage:f.select(["Prospecting","Qualification","Proposal","Negotiation","Closed Won","Closed Lost"],{label:"Stage"}),close_date:f.date({label:"Close Date"}),account:f.lookup("account",{label:"Account"}),contacts:f.lookup("contact",{label:"Contacts",multiple:!0}),probability:f.percent({label:"Probability"}),type:f.select(["New Business","Existing Business","Upgrade","Renewal"],{label:"Type"}),lead_source:f.select(["Web","Phone","Partner","Referral","Other"],{label:"Lead Source"}),next_step:f.text({label:"Next Step"}),description:f.textarea({label:"Description"})}}),Ns=Y.create({name:"product",label:"Product",icon:"package",fields:{name:f.text({label:"Product Name",required:!0,searchable:!0}),sku:f.text({label:"SKU",required:!0,searchable:!0}),category:f.select(["Electronics","Furniture","Clothing","Services"],{label:"Category"}),price:f.currency({label:"Price"}),stock:f.number({label:"Stock"}),description:f.textarea({label:"Description"}),image:f.url({label:"Image URL"})}}),Ds=Y.create({name:"order",label:"Order",icon:"shopping-cart",fields:{name:f.text({label:"Order Number",required:!0,searchable:!0}),customer:f.lookup("contact",{label:"Customer",required:!0}),amount:f.currency({label:"Total Amount"}),status:f.select(["Draft","Pending","Paid","Shipped","Delivered","Cancelled"],{label:"Status",defaultValue:"Draft"}),order_date:f.date({label:"Order Date",defaultValue:"now"})}}),Cs=Y.create({name:"user",label:"User",icon:"user-check",fields:{name:f.text({label:"Full Name",required:!0,searchable:!0}),email:f.email({label:"Email",required:!0,searchable:!0}),username:f.text({label:"Username",required:!0}),role:f.select(["admin","user","guest"],{label:"Role"}),avatar:f.url({label:"Avatar URL"}),active:f.boolean({label:"Active",defaultValue:!0})}}),Ss=Y.create({name:"project_task",label:"Project Task",icon:"kanban-square",fields:{name:f.text({label:"Task Name",required:!0,searchable:!0}),start_date:f.date({label:"Start Date",required:!0}),end_date:f.date({label:"End Date",required:!0}),progress:f.percent({label:"Progress"}),status:f.select(["Planned","In Progress","Completed","On Hold"],{label:"Status"}),priority:f.select(["High","Medium","Low"],{label:"Priority"}),manager:f.lookup("user",{label:"Manager"}),description:f.textarea({label:"Description"}),color:f.text({label:"Color"}),dependencies:f.text({label:"Dependencies"})}}),_s=Y.create({name:"event",label:"Event",icon:"calendar",fields:{subject:f.text({label:"Subject",required:!0}),start:f.datetime({label:"Start",required:!0}),end:f.datetime({label:"End",required:!0}),location:f.text({label:"Location"}),description:f.textarea({label:"Description"}),participants:f.lookup("contact",{label:"Participants",multiple:!0}),type:f.select(["Meeting","Call","Email","Other"],{label:"Type"})}}),It=Be({objects:[vs,js,ws,Ns,Ds,Cs,Ss,_s],reports:[],pages:[{name:"crm_help",label:"Help & Resources",type:"app",regions:[{name:"main",components:[{type:"container",properties:{className:"prose max-w-3xl mx-auto p-8 text-foreground",children:[{type:"text",properties:{value:"# CRM Help Guide",className:"text-3xl font-bold mb-6 block"}},{type:"text",properties:{value:"Welcome to the CRM application. This guide covers the key features available in your sales workspace.",className:"text-muted-foreground mb-6 block"}},{type:"text",properties:{value:"## Navigation",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:`- **Dashboard** — KPI metrics, revenue trends, pipeline charts
3
+ - **Contacts** — Customer and lead management with map view
4
+ - **Accounts** — Company records with geographic map
5
+ - **Opportunities** — Sales pipeline with Kanban board
6
+ - **Projects** — Task tracking with Gantt and Timeline views
7
+ - **Calendar** — Events and meetings
8
+ - **Orders & Products** — Sales catalog and order processing`,className:"whitespace-pre-line mb-6 block"}},{type:"text",properties:{value:"## View Types",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:`Each object supports multiple view types. Use the view switcher in the toolbar to change between:
9
+ - **Grid** — Tabular data with sorting and filtering
10
+ - **Kanban** — Drag-and-drop board (Opportunities → Pipeline)
11
+ - **Calendar** — Date-based event view (Events → Calendar)
12
+ - **Gantt** — Project timeline (Projects → Gantt View)
13
+ - **Map** — Geographic visualization (Accounts → Map View)
14
+ - **Gallery** — Visual cards (Products → Product Gallery)`,className:"whitespace-pre-line mb-6 block"}},{type:"text",properties:{value:"## Keyboard Shortcuts",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:`- **⌘+K** — Open Command Palette for quick navigation
15
+ - **⌘+N** — Create new record
16
+ - Click any record row to open the detail panel`,className:"whitespace-pre-line block"}}]}}]}]}],apps:[yt.create({name:"crm_app",label:"CRM",icon:"briefcase",description:"Sales pipeline, accounts, and customer management",branding:{primaryColor:"#3B82F6"},navigation:[{id:"nav_dashboard",type:"dashboard",dashboardName:"crm_dashboard",label:"Dashboard",icon:"layout-dashboard"},{id:"nav_contacts",type:"object",objectName:"contact",label:"Contacts",icon:"users"},{id:"nav_accounts",type:"object",objectName:"account",label:"Accounts",icon:"building-2"},{id:"nav_opportunities",type:"object",objectName:"opportunity",label:"Opportunities",icon:"trending-up"},{id:"nav_pipeline",type:"object",objectName:"opportunity",viewName:"pipeline",label:"Pipeline",icon:"kanban-square"},{id:"nav_projects",type:"object",objectName:"project_task",label:"Projects",icon:"kanban-square"},{id:"nav_events",type:"object",objectName:"event",viewName:"calendar",label:"Calendar",icon:"calendar"},{id:"nav_sales",type:"group",label:"Sales",icon:"banknote",children:[{id:"nav_orders",type:"object",objectName:"order",label:"Orders",icon:"shopping-cart"},{id:"nav_products",type:"object",objectName:"product",label:"Products",icon:"package"}]},{id:"nav_help",type:"page",pageName:"crm_help",label:"Help",icon:"help-circle"}]})],dashboards:[{name:"crm_dashboard",label:"CRM Overview",widgets:[{type:"metric",layout:{x:0,y:0,w:1,h:1},options:{label:"Total Revenue",value:"$652,000",trend:{value:12.5,direction:"up",label:"vs last month"},icon:"DollarSign"}},{type:"metric",layout:{x:1,y:0,w:1,h:1},options:{label:"Active Deals",value:"5",trend:{value:2.1,direction:"down",label:"vs last month"},icon:"Briefcase"}},{type:"metric",layout:{x:2,y:0,w:1,h:1},options:{label:"Win Rate",value:"42%",trend:{value:4.3,direction:"up",label:"vs last month"},icon:"Trophy"}},{type:"metric",layout:{x:3,y:0,w:1,h:1},options:{label:"Avg Deal Size",value:"$93,000",trend:{value:1.2,direction:"up",label:"vs last month"},icon:"BarChart3"}},{title:"Revenue Trends",type:"area",layout:{x:0,y:1,w:3,h:2},options:{xField:"month",yField:"revenue"},data:{provider:"value",items:[{month:"Jan",revenue:155e3},{month:"Feb",revenue:87e3},{month:"Mar",revenue:48e3},{month:"Apr",revenue:61e3},{month:"May",revenue:55e3},{month:"Jun",revenue:67e3},{month:"Jul",revenue:72e3}]}},{title:"Lead Source",type:"donut",layout:{x:3,y:1,w:1,h:2},options:{xField:"source",yField:"value"},data:{provider:"value",items:[{source:"Web",value:2},{source:"Referral",value:1},{source:"Partner",value:1},{source:"Existing Business",value:3}]}},{title:"Pipeline by Stage",type:"bar",layout:{x:0,y:3,w:2,h:2},options:{xField:"stage",yField:"amount"},data:{provider:"value",items:[{stage:"Prospecting",amount:25e4},{stage:"Qualification",amount:35e3},{stage:"Proposal",amount:85e3},{stage:"Negotiation",amount:45e3},{stage:"Closed Won",amount:225e3}]}},{title:"Top Products",type:"bar",layout:{x:2,y:3,w:2,h:2},options:{xField:"name",yField:"sales"},data:{provider:"value",items:[{name:"Workstation Pro Laptop",sales:45e3},{name:"Implementation Service",sales:32e3},{name:"Premimum Support",sales:21e3},{name:"Executive Mesh Chair",sales:15e3}]}},{title:"Recent Opportunities",type:"table",layout:{x:0,y:5,w:4,h:2},options:{columns:[{header:"Opportunity Name",accessorKey:"name"},{header:"Amount",accessorKey:"amount"},{header:"Stage",accessorKey:"stage"},{header:"Close Date",accessorKey:"date"}]},data:{provider:"value",items:[{name:"Berlin Automation Project",amount:"$250,000",stage:"Prospecting",date:"2024-09-01"},{name:"ObjectStack Enterprise License",amount:"$150,000",stage:"Closed Won",date:"2024-01-15"},{name:"London Annual Renewal",amount:"$85,000",stage:"Proposal",date:"2024-05-15"},{name:"SF Tower Expansion",amount:"$75,000",stage:"Closed Won",date:"2024-02-28"},{name:"Global Fin Q1 Upsell",amount:"$45,000",stage:"Negotiation",date:"2024-03-30"}]}}]}],manifest:{id:"com.example.crm",version:"1.0.0",type:"app",name:"CRM Example",description:"CRM App Definition",data:[{object:"account",mode:"upsert",records:[{_id:"1",name:"ObjectStack HQ",industry:"Technology",type:"Partner",employees:120,billing_address:"44 Tehama St, San Francisco, CA 94105",latitude:37.7879,longitude:-122.3961,website:"https://objectstack.com",phone:"415-555-0101",owner:"1",created_at:new Date("2023-01-15")},{_id:"2",name:"Salesforce Tower",industry:"Technology",type:"Customer",employees:35e3,billing_address:"415 Mission St, San Francisco, CA 94105",latitude:37.7897,longitude:-122.3972,website:"https://salesforce.com",phone:"415-555-0102",owner:"1",created_at:new Date("2023-02-20")},{_id:"3",name:"Global Financial Services",industry:"Finance",type:"Customer",employees:5e3,billing_address:"100 Wall St, New York, NY 10005",latitude:40.7056,longitude:-74.0084,website:"https://globalfin.example.com",phone:"212-555-0103",owner:"2",created_at:new Date("2023-03-10")},{_id:"4",name:"London Consulting Grp",industry:"Services",type:"Partner",employees:250,billing_address:"10 Downing St, London, UK",latitude:51.5034,longitude:-.1276,website:"https://lcg.example.co.uk",phone:"+44-555-0104",owner:"2",created_at:new Date("2023-04-05")},{_id:"5",name:"Tokyo E-Commerce",industry:"Retail",type:"Vendor",employees:80,billing_address:"Shibuya Crossing, Tokyo, Japan",latitude:35.6595,longitude:139.7004,website:"https://tokyoshop.example.jp",phone:"+81-555-0105",owner:"1",created_at:new Date("2023-05-20")},{_id:"6",name:"Berlin AutoWorks",industry:"Manufacturing",type:"Customer",employees:1200,billing_address:"Berlin, Germany",latitude:52.52,longitude:13.405,website:"https://berlinauto.example.de",phone:"+49-555-0106",owner:"1",created_at:new Date("2023-06-15")},{_id:"7",name:"Paris Fashion House",industry:"Retail",type:"Customer",employees:450,billing_address:"Champs-Élysées, Paris, France",latitude:48.8698,longitude:2.3075,website:"https://mode.example.fr",phone:"+33-555-0107",owner:"2",created_at:new Date("2023-07-01")}]},{object:"contact",mode:"upsert",records:[{_id:"1",name:"Alice Johnson",email:"alice@objectstack.com",phone:"415-555-1001",title:"VP Sales",department:"Sales",account:"1",status:"Active",priority:"High",birthdate:new Date("1985-04-12"),latitude:37.7879,longitude:-122.3961,address:"San Francisco, CA"},{_id:"2",name:"Bob Smith",email:"bob@salesforce.com",phone:"415-555-1002",title:"CTO",department:"Engineering",account:"2",status:"Active",priority:"High",birthdate:new Date("1980-08-23"),latitude:37.7897,longitude:-122.3972,address:"San Francisco, CA"},{_id:"3",name:"Charlie Brown",email:"charlie@globalfin.com",phone:"212-555-1003",title:"Procurement Manager",department:"Purchasing",account:"3",status:"Customer",priority:"Medium",birthdate:new Date("1990-01-15"),latitude:40.7056,longitude:-74.0084,address:"New York, NY"},{_id:"4",name:"Diana Prince",email:"diana@lcg.co.uk",phone:"+44-555-1004",title:"Director",department:"Management",account:"4",status:"Partner",priority:"High",birthdate:new Date("1988-06-05"),latitude:51.5034,longitude:-.1276,address:"London, UK"},{_id:"5",name:"Evan Wright",email:"evan@berlinauto.de",phone:"+49-555-1005",title:"Head of Operations",department:"Operations",account:"6",status:"Lead",priority:"High",birthdate:new Date("1975-11-30"),latitude:52.52,longitude:13.405,address:"Berlin, DE"},{_id:"6",name:"Fiona Gallagher",email:"fiona@mode.fr",phone:"+33-555-1006",title:"Creative Director",department:"Design",account:"7",status:"Customer",priority:"Low",birthdate:new Date("1992-03-18"),latitude:48.8698,longitude:2.3075,address:"Paris, FR"},{_id:"7",name:"George Martin",email:"george@salesforce.com",phone:"415-555-1007",title:"Senior Developer",department:"Engineering",account:"2",status:"Active",priority:"Low",birthdate:new Date("1995-12-12"),latitude:37.7897,longitude:-122.3972,address:"San Francisco, CA"}]},{object:"opportunity",mode:"upsert",records:[{_id:"101",name:"ObjectStack Enterprise License",amount:15e4,stage:"Closed Won",close_date:new Date("2024-01-15"),account_id:"2",contact_ids:["2","7"],probability:100,type:"New Business",lead_source:"Partner",next_step:"Onboarding",description:"Enterprise software license for 500 users. Includes premium support and training."},{_id:"102",name:"Global Fin Q1 Upsell",amount:45e3,stage:"Negotiation",close_date:new Date("2024-03-30"),account_id:"3",contact_ids:["3"],probability:80,type:"Upgrade",lead_source:"Existing Business",next_step:"Review Contract",description:"Adding 50 more seats to the existing contract."},{_id:"103",name:"London Annual Renewal",amount:85e3,stage:"Proposal",close_date:new Date("2024-05-15"),account_id:"4",contact_ids:["4"],probability:60,type:"Renewal",lead_source:"Existing Business",next_step:"Send Quote",description:"Annual renewal for continuous integration services."},{_id:"104",name:"Berlin Automation Project",amount:25e4,stage:"Prospecting",close_date:new Date("2024-09-01"),account_id:"6",contact_ids:["5"],probability:20,type:"New Business",lead_source:"Web",next_step:"Initial Discovery Call",description:"Full factory automation software suite."},{_id:"105",name:"Paris Store POS System",amount:35e3,stage:"Qualification",close_date:new Date("2024-07-20"),account_id:"7",contact_ids:["6"],probability:40,type:"New Business",lead_source:"Referral",next_step:"Demo",description:"POS system for the flagship store on Champs-Élysées."},{_id:"106",name:"Tokyo E-Com Integration",amount:12e3,stage:"Closed Lost",close_date:new Date("2024-02-10"),account_id:"5",contact_ids:[],probability:0,type:"New Business",lead_source:"Web",next_step:"N/A",description:"Client chose a competitor."},{_id:"107",name:"SF Tower Expansion",amount:75e3,stage:"Closed Won",close_date:new Date("2024-02-28"),account_id:"2",contact_ids:["2"],probability:100,type:"Upgrade",lead_source:"Existing Business",next_step:"Implement",description:"Additional storage modules."}]},{object:"user",mode:"upsert",records:[{_id:"1",name:"Martin CEO",email:"martin@example.com",username:"martin",role:"admin",active:!0},{_id:"2",name:"Sarah Sales",email:"sarah@example.com",username:"sarah",role:"user",active:!0}]},{object:"product",mode:"upsert",records:[{_id:"p1",sku:"HW-LAP-001",name:"Workstation Pro Laptop",category:"Electronics",price:2499.99,stock:15,image:"https://images.unsplash.com/photo-1593642702821-c8da6771f0c6?w=600&q=80"},{_id:"p2",sku:"HW-ACC-002",name:"Wireless Ergonomic Mouse",category:"Electronics",price:89.99,stock:120,image:"https://images.unsplash.com/photo-1527864550417-7fd91fc51a46?w=600&q=80"},{_id:"p3",sku:"FUR-CHR-003",name:"Executive Mesh Chair",category:"Furniture",price:549.99,stock:8,image:"https://images.unsplash.com/photo-1505843490538-5133c6c7d0e1?w=600&q=80"},{_id:"p4",sku:"FUR-DSK-004",name:"Adjustable Standing Desk",category:"Furniture",price:799.99,stock:20,image:"https://images.unsplash.com/photo-1595515106969-1ce29566ff1c?w=600&q=80"},{_id:"p5",sku:"HW-AUD-005",name:"Studio Noise Cancelling Headphones",category:"Electronics",price:349.99,stock:45,image:"https://images.unsplash.com/photo-1505740420928-5e560c06d30e?w=600&q=80"},{_id:"p6",sku:"HW-MON-006",name:"4K UltraWide Monitor",category:"Electronics",price:899.99,stock:30,image:"https://images.unsplash.com/photo-1527443224154-c4a3942d3acf?w=600&q=80"},{_id:"p7",sku:"SVC-CNS-007",name:"Implementation Service (Hourly)",category:"Services",price:250,stock:1e3,image:"https://images.unsplash.com/photo-1521791136064-7986c2920216?w=600&q=80"},{_id:"p8",sku:"SVC-SUP-008",name:"Premium Support (Annual)",category:"Services",price:5e3,stock:1e3,image:"https://images.unsplash.com/photo-1486312338219-ce68d2c6f44d?w=600&q=80"}]},{object:"order",mode:"upsert",records:[{_id:"o1",name:"ORD-2024-001",customer:"2",order_date:new Date("2024-01-15"),amount:15459.99,status:"Draft"},{_id:"o2",name:"ORD-2024-002",customer:"3",order_date:new Date("2024-01-18"),amount:289.5,status:"Pending"}]},{object:"project_task",mode:"upsert",records:[{_id:"t1",name:"Requirements Gathering",start_date:new Date("2024-02-01"),end_date:new Date("2024-02-14"),progress:100,status:"Completed",color:"#10b981",priority:"High",manager:"1"},{_id:"t2",name:"Architecture Design",start_date:new Date("2024-02-15"),end_date:new Date("2024-03-01"),progress:100,status:"Completed",color:"#3b82f6",priority:"High",dependencies:"t1",manager:"1"},{_id:"t3",name:"Frontend Development",start_date:new Date("2024-03-02"),end_date:new Date("2024-04-15"),progress:75,status:"In Progress",color:"#8b5cf6",priority:"High",dependencies:"t2",manager:"2"},{_id:"t4",name:"Backend API Integration",start_date:new Date("2024-03-02"),end_date:new Date("2024-04-10"),progress:80,status:"In Progress",color:"#6366f1",priority:"High",dependencies:"t2",manager:"2"},{_id:"t5",name:"QA & Testing",start_date:new Date("2024-04-16"),end_date:new Date("2024-05-01"),progress:0,status:"Planned",color:"#f59e0b",priority:"Medium",dependencies:"t3,t4",manager:"1"},{_id:"t6",name:"UAT",start_date:new Date("2024-05-02"),end_date:new Date("2024-05-15"),progress:0,status:"Planned",color:"#f43f5e",priority:"Medium",dependencies:"t5",manager:"1"},{_id:"t7",name:"Go Live & Launch",start_date:new Date("2024-05-20"),end_date:new Date("2024-05-20"),progress:0,status:"Planned",color:"#ef4444",priority:"Critical",dependencies:"t6",manager:"1"}]},{object:"event",mode:"upsert",records:[{_id:"e1",subject:"Weekly Standup",start:new Date("2024-02-05T09:00:00"),end:new Date("2024-02-05T10:00:00"),location:"Conference Room A",type:"Meeting",description:"Team synchronization regarding Project Alpha"},{_id:"e2",subject:"Client Call - TechCorp",start:new Date("2024-02-06T14:00:00"),end:new Date("2024-02-06T15:00:00"),location:"Zoom",type:"Call",description:"Reviewing Q1 Goals and Roadblocks"},{_id:"e3",subject:"Project Review",start:new Date("2024-02-08T10:00:00"),end:new Date("2024-02-08T11:30:00"),location:"Board Room",type:"Meeting",description:"Milestone review with stakeholders"},{_id:"e4",subject:"Lunch with Partners",start:new Date("2024-02-09T12:00:00"),end:new Date("2024-02-09T13:30:00"),location:"Downtown Cafe",type:"Other",description:"Networking event"},{_id:"e5",subject:"Product Demo - Berlin Auto",start:new Date("2024-03-10T11:00:00"),end:new Date("2024-03-10T12:30:00"),location:"Online",type:"Meeting",description:"Showcasing the new automation suite capabilities"},{_id:"e6",subject:"Internal Training",start:new Date("2024-03-15T09:00:00"),end:new Date("2024-03-15T16:00:00"),location:"Training Center",type:"Other",description:"Security compliance training for all staff"}]}]}}),ks=Y.create({name:"todo_task",label:"Task",icon:"check-circle-2",titleFormat:"{subject}",compactLayout:["subject","status","priority","assignee","due_date"],enable:{apiEnabled:!0,trackHistory:!0,feeds:!0,activities:!0,mru:!0},fields:{subject:f.text({label:"Subject",required:!0,searchable:!0}),status:f.select(["Backlog","Todo","In Progress","Review","Done"],{label:"Status",defaultValue:"Todo"}),priority:f.select(["Critical","High","Medium","Low"],{label:"Priority",defaultValue:"Medium"}),assignee:f.text({label:"Assignee"}),category:f.select(["Bug","Feature","Documentation","Design","Chore"],{label:"Category"}),due_date:f.date({label:"Due Date"}),is_completed:f.boolean({label:"Completed",defaultValue:!1}),estimated_hours:f.number({label:"Est. Hours",scale:1}),description:f.textarea({label:"Description"})}}),J=e=>{const a=new Date;return a.setDate(a.getDate()+e),a},$t=Be({objects:[ks],views:[{listViews:{all:{name:"all",label:"All Tasks",type:"grid",data:{provider:"object",object:"todo_task"},columns:["subject","status","priority","assignee","category","due_date","is_completed"]},board:{name:"board",label:"Board",type:"kanban",data:{provider:"object",object:"todo_task"},columns:["subject","priority","assignee","due_date"],kanban:{groupByField:"status",columns:["priority","assignee","due_date"]}},calendar:{name:"calendar",label:"Calendar",type:"calendar",data:{provider:"object",object:"todo_task"},columns:["subject","status","due_date"],calendar:{startDateField:"due_date",titleField:"subject"}},active:{name:"active",label:"Active",type:"grid",data:{provider:"object",object:"todo_task"},columns:["subject","status","priority","assignee","due_date"],filter:[["status","!=","Done"]],sort:[{field:"priority",order:"asc"}]}}}],apps:[yt.create({name:"todo_app",label:"Task Tracker",icon:"check-square",description:"Manage tasks, track progress, and collaborate with your team",branding:{primaryColor:"#10B981"},navigation:[{id:"nav_task_dashboard",type:"dashboard",dashboardName:"task_dashboard",label:"Dashboard",icon:"layout-dashboard"},{id:"nav_todo_task",type:"object",objectName:"todo_task",label:"All Tasks",icon:"list-todo"},{id:"nav_todo_board",type:"object",objectName:"todo_task",viewName:"board",label:"Task Board",icon:"kanban-square"},{id:"nav_todo_calendar",type:"object",objectName:"todo_task",viewName:"calendar",label:"Calendar",icon:"calendar"},{id:"nav_todo_help",type:"page",pageName:"todo_help",label:"Help",icon:"help-circle"}]})],dashboards:[{name:"task_dashboard",label:"Task Overview",widgets:[{type:"metric",layout:{x:0,y:0,w:1,h:1},options:{label:"Total Tasks",value:"12",icon:"ListTodo"}},{type:"metric",layout:{x:1,y:0,w:1,h:1},options:{label:"In Progress",value:"4",trend:{value:2,direction:"up",label:"this week"},icon:"Clock"}},{type:"metric",layout:{x:2,y:0,w:1,h:1},options:{label:"Completed",value:"3",trend:{value:25,direction:"up",label:"completion rate"},icon:"CheckCircle2"}},{type:"metric",layout:{x:3,y:0,w:1,h:1},options:{label:"Overdue",value:"2",trend:{value:1,direction:"down",label:"vs last week"},icon:"AlertTriangle"}},{title:"Tasks by Status",type:"donut",layout:{x:0,y:1,w:2,h:2},options:{xField:"status",yField:"count"},data:{provider:"value",items:[{status:"Backlog",count:2},{status:"Todo",count:2},{status:"In Progress",count:4},{status:"Review",count:1},{status:"Done",count:3}]}},{title:"Tasks by Category",type:"bar",layout:{x:2,y:1,w:2,h:2},options:{xField:"category",yField:"count"},data:{provider:"value",items:[{category:"Feature",count:4},{category:"Bug",count:3},{category:"Documentation",count:2},{category:"Design",count:1},{category:"Chore",count:2}]}}]}],pages:[{name:"todo_help",label:"Help",type:"app",regions:[{name:"main",components:[{type:"container",properties:{className:"prose max-w-3xl mx-auto p-8 text-foreground",children:[{type:"text",properties:{value:"# Task Tracker Guide",className:"text-3xl font-bold mb-6 block"}},{type:"text",properties:{value:"Your task management workspace for tracking work across your team.",className:"text-muted-foreground mb-6 block"}},{type:"text",properties:{value:"## Views",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:`- **All Tasks** — Grid view with sorting, filtering, and search
17
+ - **Board** — Kanban board grouped by status (drag-and-drop)
18
+ - **Calendar** — Tasks displayed by due date
19
+ - **Active** — Filtered view showing non-completed tasks`,className:"whitespace-pre-line mb-6 block"}},{type:"text",properties:{value:"## Workflow",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:"Tasks flow through stages: **Backlog** → **Todo** → **In Progress** → **Review** → **Done**. Use the Board view to drag tasks between columns.",className:"mb-4 block"}}]}}]}]}],manifest:{id:"com.example.todo",version:"1.0.0",type:"app",name:"Task Tracker",description:"Task management with Kanban boards and calendar views",data:[{object:"todo_task",mode:"upsert",records:[{subject:"Redesign login page",status:"In Progress",priority:"High",assignee:"Alice Chen",category:"Feature",due_date:J(2),is_completed:!1,estimated_hours:8},{subject:"Fix payment gateway timeout",status:"In Progress",priority:"Critical",assignee:"Bob Smith",category:"Bug",due_date:J(1),is_completed:!1,estimated_hours:4},{subject:"Write API documentation",status:"Todo",priority:"Medium",assignee:"Alice Chen",category:"Documentation",due_date:J(5),is_completed:!1,estimated_hours:6},{subject:"Update user onboarding flow",status:"Review",priority:"High",assignee:"Charlie Park",category:"Design",due_date:J(0),is_completed:!1,estimated_hours:12},{subject:"Migrate database to v3",status:"In Progress",priority:"High",assignee:"Bob Smith",category:"Chore",due_date:J(3),is_completed:!1,estimated_hours:16},{subject:"Add dark mode support",status:"Todo",priority:"Medium",assignee:"Alice Chen",category:"Feature",due_date:J(7),is_completed:!1,estimated_hours:10},{subject:"Fix mobile responsive layout",status:"In Progress",priority:"High",assignee:"Charlie Park",category:"Bug",due_date:J(-1),is_completed:!1,estimated_hours:5},{subject:"Create release notes for v2.0",status:"Backlog",priority:"Low",assignee:"Alice Chen",category:"Documentation",due_date:J(14),is_completed:!1,estimated_hours:3},{subject:"Implement search autocomplete",status:"Backlog",priority:"Medium",assignee:"Bob Smith",category:"Feature",due_date:J(10),is_completed:!1,estimated_hours:8},{subject:"Set up CI/CD pipeline",status:"Done",priority:"Medium",assignee:"Bob Smith",category:"Chore",due_date:J(-5),is_completed:!0,estimated_hours:6},{subject:"Design dashboard widgets",status:"Done",priority:"Low",assignee:"Charlie Park",category:"Design",due_date:J(-3),is_completed:!0,estimated_hours:8},{subject:"Optimize image loading",status:"Done",priority:"Medium",assignee:"Alice Chen",category:"Feature",due_date:J(-2),is_completed:!0,estimated_hours:4}]}]}}),Fs=Y.create({name:"kitchen_sink",label:"Kitchen Sink",icon:"utensils",description:"Shows all available field types for testing",fields:{name:f.text({label:"Text (Name)",required:!0,searchable:!0}),description:f.textarea({label:"Text Area"}),code:f.code("json",{label:"Code"}),password:f.password({label:"Password"}),amount:f.number({label:"Number (Int)",scale:0}),price:f.currency({label:"Currency",scale:2}),percent:f.percent({label:"Percentage",scale:2}),rating:f.rating(5,{label:"Rating"}),due_date:f.date({label:"Date"}),event_time:f.datetime({label:"Date Time"}),is_active:f.boolean({label:"Boolean (Switch)",defaultValue:!0}),category:f.select({options:[{label:"Option A",value:"opt_a"},{label:"Option B",value:"opt_b"},{label:"Option C",value:"opt_c"}],label:"Select (Dropdown)"}),tags:f.select({options:[{label:"Red",value:"col_red"},{label:"Green",value:"col_green"},{label:"Blue",value:"col_blue"}],multiple:!0,label:"Multi Select"}),email:f.email({label:"Email"}),url:f.url({label:"URL"}),phone:f.phone({label:"Phone"}),avatar:f.avatar({label:"Avatar"}),color:f.color({label:"Color Picker"}),rich_text:f.richtext({label:"Rich Text"}),image:f.image({label:"Image Upload"}),file:f.file({label:"File Upload"}),signature:f.signature({label:"Signature"}),account:f.lookup("account",{label:"Lookup (Account)"}),location:f.location({label:"Location"}),formula_field:f.formula({expression:"{amount} * {price}",label:"Formula (Amount * Price)"}),auto_number:f.autonumber({label:"Auto Number"})}}),Ts=Y.create({name:"account",label:"Account",fields:{name:f.text({label:"Account Name",required:!0})}}),Es=Y.create({name:"showcase",label:"Feature Showcase",icon:"sparkles",description:"Demonstrates dependsOn, visibleOn, actions with params, and page templates",fields:{title:f.text({label:"Title",required:!0,searchable:!0}),description:f.textarea({label:"Description"}),category:f.select({options:[{label:"Software",value:"software"},{label:"Hardware",value:"hardware"},{label:"Service",value:"service"}],label:"Category"}),sub_category:f.select({options:[{label:"Web App",value:"web_app"},{label:"Mobile App",value:"mobile_app"},{label:"Desktop App",value:"desktop_app"},{label:"Server",value:"server"},{label:"Laptop",value:"laptop"},{label:"Peripheral",value:"peripheral"},{label:"Consulting",value:"consulting"},{label:"Support",value:"support"},{label:"Training",value:"training"}],label:"Sub-Category"}),priority:f.select({options:[{label:"Low",value:"low"},{label:"Medium",value:"medium"},{label:"High",value:"high"},{label:"Critical",value:"critical"}],label:"Priority"}),status:f.select({options:[{label:"Draft",value:"draft"},{label:"Active",value:"active"},{label:"Review",value:"review"},{label:"Completed",value:"completed"},{label:"Archived",value:"archived"}],label:"Status",defaultValue:"draft"}),price:f.currency({label:"Price",scale:2}),discount_percent:f.percent({label:"Discount %",scale:1}),start_date:f.date({label:"Start Date"}),end_date:f.date({label:"End Date"}),owner_email:f.email({label:"Owner Email"}),is_featured:f.boolean({label:"Featured",defaultValue:!1}),tags:f.select({options:[{label:"New",value:"new"},{label:"Popular",value:"popular"},{label:"Sale",value:"sale"},{label:"Premium",value:"premium"}],multiple:!0,label:"Tags"}),notes:f.richtext({label:"Notes"})}}),G=e=>{const a=new Date;return a.setDate(a.getDate()+e),a},Vt=Be({objects:[Fs,Ts,Es],apps:[yt.create({name:"analytics_app",label:"Showcase",icon:"sparkles",description:"All field types, dashboard widgets, and page layouts",branding:{primaryColor:"#8B5CF6"},navigation:[{id:"nav_dash",type:"dashboard",dashboardName:"showcase_dashboard",label:"Dashboard",icon:"layout-dashboard"},{id:"nav_kitchen_sink",type:"object",objectName:"kitchen_sink",label:"All Field Types",icon:"test-tubes"},{id:"nav_showcase",type:"object",objectName:"showcase",label:"Feature Showcase",icon:"sparkles"},{id:"nav_templates",type:"page",pageName:"template_showcase",label:"Page Templates",icon:"layout-template"},{id:"nav_help",type:"page",pageName:"showcase_help",label:"Help & Resources",icon:"help-circle"}]})],dashboards:[{name:"showcase_dashboard",label:"Platform Showcase",description:"Demonstrating all dashboard widget types",widgets:[{type:"metric",layout:{x:0,y:0,w:1,h:1},options:{label:"Total Records",value:"5",icon:"Database"}},{type:"metric",layout:{x:1,y:0,w:1,h:1},options:{label:"Active Items",value:"4",trend:{value:80,direction:"up",label:"active rate"},icon:"Activity"}},{type:"metric",layout:{x:2,y:0,w:1,h:1},options:{label:"Total Value",value:"$22,500",trend:{value:15,direction:"up",label:"this quarter"},icon:"DollarSign"}},{type:"metric",layout:{x:3,y:0,w:1,h:1},options:{label:"Avg Rating",value:"4.2",trend:{value:.3,direction:"up",label:"improvement"},icon:"Star"}},{title:"Records by Category",type:"donut",layout:{x:0,y:1,w:2,h:2},options:{xField:"category",yField:"count"},data:{provider:"value",items:[{category:"Option A",count:2},{category:"Option B",count:2},{category:"Option C",count:1}]}},{title:"Value Distribution",type:"bar",layout:{x:2,y:1,w:2,h:2},options:{xField:"name",yField:"amount"},data:{provider:"value",items:[{name:"Alpha",amount:1500},{name:"Beta",amount:3200},{name:"Gamma",amount:800},{name:"Delta",amount:5e3},{name:"Epsilon",amount:12e3}]}},{title:"Monthly Trend",type:"area",layout:{x:0,y:3,w:4,h:2},options:{xField:"month",yField:"value"},data:{provider:"value",items:[{month:"Jan",value:3200},{month:"Feb",value:4500},{month:"Mar",value:4100},{month:"Apr",value:5800},{month:"May",value:6200},{month:"Jun",value:7500}]}}]}],pages:[{name:"template_showcase",label:"Page Templates",type:"app",template:"header-sidebar-main",regions:[{name:"header",components:[{type:"container",properties:{className:"bg-muted/30 rounded-lg p-6 border",children:[{type:"text",properties:{value:"📐 Page Template Showcase",className:"text-2xl font-bold mb-2 block"}},{type:"text",properties:{value:'This page uses the "header-sidebar-main" template — a full-width header with sidebar + main content below.',className:"text-muted-foreground block"}}]}}]},{name:"sidebar",width:"medium",components:[{type:"container",properties:{className:"bg-card rounded-lg p-4 border space-y-3",children:[{type:"text",properties:{value:"🧭 Available Templates",className:"font-semibold mb-3 block"}},{type:"text",properties:{value:"• **default** — Full-width single column",className:"text-sm block"}},{type:"text",properties:{value:"• **header-sidebar-main** — Header + sidebar/main (this page)",className:"text-sm block"}},{type:"text",properties:{value:"• **three-column** — Sidebar + main + aside",className:"text-sm block"}},{type:"text",properties:{value:"• **dashboard** — 2-column grid layout",className:"text-sm block"}}]}},{type:"container",properties:{className:"bg-card rounded-lg p-4 border space-y-3 mt-4",children:[{type:"text",properties:{value:"🔧 New Features",className:"font-semibold mb-3 block"}},{type:"text",properties:{value:"✅ **dependsOn** — Fields shown when parent has a value",className:"text-sm block"}},{type:"text",properties:{value:"✅ **visibleOn** — Fields shown based on expression",className:"text-sm block"}},{type:"text",properties:{value:"✅ **ActionParams** — Parameter dialog before actions",className:"text-sm block"}},{type:"text",properties:{value:"✅ **Page Templates** — Predefined page layouts",className:"text-sm block"}}]}}]},{name:"main",components:[{type:"container",properties:{className:"space-y-6",children:[{type:"container",properties:{className:"bg-card rounded-lg p-6 border",children:[{type:"text",properties:{value:"## FormField.dependsOn",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:'Fields with `dependsOn` are only shown when the parent field has a value. For example, "Sub-Category" depends on "Category" — it only appears after a category is selected.',className:"text-muted-foreground mb-3 block"}},{type:"text",properties:{value:'```typescript\n{ field: "sub_category", dependsOn: "category" }\n```',className:"font-mono text-sm bg-muted/50 p-3 rounded block"}}]}},{type:"container",properties:{className:"bg-card rounded-lg p-6 border",children:[{type:"text",properties:{value:"## FormField.visibleOn",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:'Fields with `visibleOn` are shown/hidden based on a dynamic expression. For example, pricing fields only appear when status is "active" or "review".',className:"text-muted-foreground mb-3 block"}},{type:"text",properties:{value:'```typescript\n{ field: "price", visibleOn: "${data.status === \'active\'}" }\n```',className:"font-mono text-sm bg-muted/50 p-3 rounded block"}}]}},{type:"container",properties:{className:"bg-card rounded-lg p-6 border",children:[{type:"text",properties:{value:"## ActionParam Collection",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:"Actions can define `params` to collect from the user before execution. A dialog with form fields is shown automatically. Supports text, number, boolean, select, date, and textarea inputs.",className:"text-muted-foreground mb-3 block"}},{type:"text",properties:{value:`\`\`\`typescript
20
+ actions: [{
21
+ name: "assign_owner",
22
+ type: "api",
23
+ params: [
24
+ { name: "owner_email", label: "Email", type: "text", required: true },
25
+ { name: "notify", label: "Notify", type: "boolean", defaultValue: true }
26
+ ]
27
+ }]
28
+ \`\`\``,className:"font-mono text-sm bg-muted/50 p-3 rounded block"}}]}}]}}]}]},{name:"showcase_help",label:"Help & Resources",type:"app",regions:[{name:"main",components:[{type:"container",properties:{className:"prose max-w-3xl mx-auto p-8 text-foreground",children:[{type:"text",properties:{value:"# Platform Showcase",className:"text-3xl font-bold mb-6 block"}},{type:"text",properties:{value:"This app demonstrates the full range of ObjectStack capabilities — all field types, dashboard widgets, page layouts, conditional forms, and action parameters.",className:"text-muted-foreground mb-6 block"}},{type:"text",properties:{value:"## Supported Field Types",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:`- **Text** — Text, Textarea, Code, Password, Rich Text
29
+ - **Number** — Integer, Currency, Percentage, Rating
30
+ - **Date** — Date, DateTime
31
+ - **Selection** — Select (single), Multi-Select
32
+ - **Contact** — Email, URL, Phone
33
+ - **Media** — Image, File, Avatar, Signature
34
+ - **Special** — Boolean, Color, Location, Formula, Auto Number
35
+ - **Relations** — Lookup (references other objects)`,className:"whitespace-pre-line mb-6 block"}},{type:"text",properties:{value:"## Dashboard Widgets",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:`- **Metric** — KPI cards with trends
36
+ - **Bar Chart** — Categorical comparisons
37
+ - **Donut Chart** — Proportional breakdowns
38
+ - **Area Chart** — Time-series trends
39
+ - **Line Chart** — Multi-series trends
40
+ - **Table** — Tabular data summaries`,className:"whitespace-pre-line mb-6 block"}},{type:"text",properties:{value:"## New Features",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:`- **FormField.dependsOn** — Conditional field visibility based on parent field value
41
+ - **FormField.visibleOn** — Expression-based field visibility
42
+ - **ActionParam UI** — Parameter collection dialog before action execution
43
+ - **Page Templates** — Predefined page layout templates (default, header-sidebar-main, three-column, dashboard)`,className:"whitespace-pre-line mb-6 block"}},{type:"text",properties:{value:"## View Types",className:"text-xl font-semibold mb-3 block"}},{type:"text",properties:{value:`- **Grid** — Default tabular view with sort, filter, search
44
+ - **Kanban** — Card board grouped by any select field
45
+ - **Calendar** — Date-based event visualization
46
+ - **Gantt** — Project timeline with dependencies
47
+ - **Timeline** — Chronological activity stream
48
+ - **Map** — Geographic data on interactive map
49
+ - **Gallery** — Visual card grid layout`,className:"whitespace-pre-line block"}}]}}]}]}],manifest:{id:"com.example.kitchen-sink",version:"1.0.0",type:"app",name:"Platform Showcase",description:"Demonstrates all field types, views, dashboard widgets, conditional forms, actions, and page templates",data:[{object:"kitchen_sink",mode:"upsert",records:[{name:"Alpha Configuration",description:"Primary system settings panel for environment management",amount:1500,price:29.99,percent:75.5,rating:4,due_date:G(10),event_time:G(10),is_active:!0,category:"opt_a",tags:["col_red","col_blue"],email:"alpha@example.com",url:"https://alpha.example.com",phone:"+1-555-0101",color:"#3B82F6"},{name:"Beta Dashboard",description:"Real-time monitoring interface with live metrics",amount:3200,price:149.99,percent:42,rating:5,due_date:G(20),event_time:G(20),is_active:!0,category:"opt_b",tags:["col_green"],email:"beta@example.com",url:"https://beta.example.com",phone:"+1-555-0202",color:"#10B981"},{name:"Gamma Report Engine",description:"Automated report generation and distribution system",amount:800,price:49.99,percent:90.25,rating:3,due_date:G(30),is_active:!1,category:"opt_c",tags:["col_red","col_green","col_blue"],email:"gamma@example.com",url:"https://gamma.example.com",phone:"+1-555-0303",color:"#F59E0B"},{name:"Delta API Gateway",description:"Central API routing with rate limiting and auth",amount:5e3,price:299,percent:15.8,rating:5,due_date:G(-5),event_time:G(-5),is_active:!0,category:"opt_a",email:"delta@example.com",url:"https://delta.example.com",phone:"+1-555-0404",color:"#EF4444"},{name:"Epsilon ML Pipeline",description:"Machine learning data processing and model training flow",amount:12e3,price:599.99,percent:60,rating:4,due_date:G(45),is_active:!0,category:"opt_b",tags:["col_blue"],email:"epsilon@example.com",url:"https://epsilon.example.com",phone:"+1-555-0505",color:"#8B5CF6"}]},{object:"showcase",mode:"upsert",records:[{title:"Cloud Infrastructure Setup",description:"Setting up cloud infrastructure for production deployment",category:"software",sub_category:"web_app",priority:"high",status:"active",price:4500,discount_percent:10,start_date:G(-10),end_date:G(30),owner_email:"alice@example.com",is_featured:!0,tags:["new","premium"]},{title:"Server Rack Procurement",description:"Purchasing new server racks for data center expansion",category:"hardware",sub_category:"server",priority:"medium",status:"review",price:12e3,discount_percent:5,start_date:G(-5),end_date:G(60),owner_email:"bob@example.com",is_featured:!1,tags:["popular"]},{title:"Security Consulting",description:"Annual security audit and consulting engagement",category:"service",sub_category:"consulting",priority:"critical",status:"active",price:8e3,start_date:G(0),end_date:G(90),owner_email:"carol@example.com",is_featured:!0,tags:["premium"]},{title:"Mobile App Redesign",description:"Redesigning the mobile application with new UX patterns",category:"software",sub_category:"mobile_app",priority:"high",status:"draft",start_date:G(15),owner_email:"dave@example.com",is_featured:!1,tags:["new"]},{title:"Laptop Refresh Program",description:"Annual laptop replacement for engineering team",category:"hardware",sub_category:"laptop",priority:"low",status:"completed",price:25e3,discount_percent:15,start_date:G(-60),end_date:G(-5),owner_email:"eve@example.com",is_featured:!1,tags:["sale"]},{title:"Team Training Workshop",description:"Advanced TypeScript and React training for the team",category:"service",sub_category:"training",priority:"medium",status:"active",price:3e3,start_date:G(20),end_date:G(22),owner_email:"frank@example.com",is_featured:!0,tags:["popular","new"]}]}]}});let wt=[];try{const e="./hotcrm/packages/",[a,n,o,s,r,c]=await Promise.all([import(e+"crm/src/plugin.ts"),import(e+"finance/src/plugin.ts"),import(e+"marketing/src/plugin.ts"),import(e+"products/src/plugin.ts"),import(e+"support/src/plugin.ts"),import(e+"hr/src/plugin.ts")]);wt=[a.CRMPlugin,n.FinancePlugin,o.MarketingPlugin,s.ProductsPlugin,r.SupportPlugin,c.HRPlugin]}catch{}const Ps=wt.flatMap(e=>Object.values(e.objects||{})),As=wt.flatMap(e=>e.apps||[]);function Ms(e,a){const n=new Set(e.map(s=>s.name)),o=a.filter(s=>!n.has(s.name));return[...e,...o]}const ne=It.default||It,xe=$t.default||$t,ye=Vt.default||Vt,et=ne.apps?JSON.parse(JSON.stringify(ne.apps)):[];if(et.length>0){const e=et[0];if(e&&e.navigation){const a=e.navigation.findIndex(o=>o.id==="nav_dashboard"),n=a!==-1?a+1:0;e.navigation.splice(n,0,{id:"nav_sales_report",type:"url",url:"/apps/crm_app/report/sales_performance_q1",label:"Sales Report",icon:"file-bar-chart"})}}const Os={name:"@object-ui/console",version:"0.1.0",description:"ObjectStack Console",objects:Ms([...ne.objects||[],...xe.objects||[],...ye.objects||[]],Ps),apps:[...et,...xe.apps||[],...ye.apps||[],...As],dashboards:[...ne.dashboards||[],...xe.dashboards||[],...ye.dashboards||[]],reports:[...ne.reports||[],{name:"sales_performance_q1",label:"Q1 Sales Performance",description:"Quarterly analysis of sales revenue by region and product line",objectName:"opportunity",type:"summary",columns:[{field:"name",label:"Deal Name"},{field:"amount",label:"Amount",aggregate:"sum"},{field:"stage",label:"Stage"},{field:"close_date",label:"Close Date"}]}],pages:[...ne.pages||[],...xe.pages||[],...ye.pages||[]],manifest:{id:"com.objectui.console",version:"0.1.0",type:"app",name:"@object-ui/console",data:[...ne.manifest?.data||[],...xe.manifest?.data||[],...ye.manifest?.data||[]]},plugins:[],datasources:[{name:"default",driver:"@objectstack/driver-memory",config:{}}]},Ne=Be(Os),Ca=i.createContext(null);function Rs({children:e,user:a={},app:n={},data:o={}}){const s=i.useMemo(()=>{const r={user:a,app:n,data:o},c=new bt(r);return{user:a,app:n,data:o,evaluator:c}},[a,n,o]);return t.jsx(Ca.Provider,{value:s,children:e})}function Sa(){const e=i.useContext(Ca);if(!e){const a={user:{},app:{},data:{}};return{...a,evaluator:new bt(a)}}return e}function Ve(e,a){if(e==null||e===!0||e==="true")return!0;if(e===!1||e==="false")return!1;if(typeof e=="string"&&e.includes("${"))try{return a.evaluateCondition(e)}catch{return!0}return!0}const _a="objectui-recent-items",Ls=8;function zt(){try{const e=localStorage.getItem(_a);return e?JSON.parse(e):[]}catch{return[]}}function Bt(e){try{localStorage.setItem(_a,JSON.stringify(e))}catch{}}function ka(){const[e,a]=i.useState(zt);i.useEffect(()=>{a(zt())},[]);const n=i.useCallback(s=>{a(r=>{const c=r.filter(d=>d.id!==s.id),l=[{...s,visitedAt:new Date().toISOString()},...c].slice(0,Ls);return Bt(l),l})},[]),o=i.useCallback(()=>{a([]),Bt([])},[]);return{recentItems:e,addRecentItem:n,clearRecentItems:o}}const Fa="objectui-favorites",Ht=20;function Ut(){try{const e=localStorage.getItem(Fa);return e?JSON.parse(e):[]}catch{return[]}}function Ee(e){try{localStorage.setItem(Fa,JSON.stringify(e))}catch{}}function Is(){const[e,a]=i.useState(Ut);i.useEffect(()=>{a(Ut())},[]);const n=i.useCallback(l=>{a(d=>{if(d.some(g=>g.id===l.id))return d;const h=[{...l,favoritedAt:new Date().toISOString()},...d].slice(0,Ht);return Ee(h),h})},[]),o=i.useCallback(l=>{a(d=>{const h=d.filter(g=>g.id!==l);return Ee(h),h})},[]),s=i.useCallback(l=>{a(d=>{const g=d.some(m=>m.id===l.id)?d.filter(m=>m.id!==l.id):[{...l,favoritedAt:new Date().toISOString()},...d].slice(0,Ht);return Ee(g),g})},[]),r=i.useCallback(l=>e.some(d=>d.id===l),[e]),c=i.useCallback(()=>{a([]),Ee([])},[]);return{favorites:e,addFavorite:n,removeFavorite:o,toggleFavorite:s,isFavorite:r,clearFavorites:c}}function qe(e){if(e!=null)return typeof e=="string"?e:e.defaultValue||e.key}function $s(e){const a=`objectui-nav-order-${e}`,[n,o]=i.useState(()=>{try{const l=localStorage.getItem(a);if(!l)return{};const d=JSON.parse(l);if(typeof d!="object"||d===null||Array.isArray(d))return{};const h={};for(const[g,m]of Object.entries(d))Array.isArray(m)&&m.every(y=>typeof y=="string")&&(h[g]=m);return h}catch{return{}}}),s=i.useCallback(l=>{o(l);try{localStorage.setItem(a,JSON.stringify(l))}catch{}},[a]),r=i.useCallback((l,d)=>{const h=n[l];if(!h)return d;const g=new Map(d.map(y=>[y.id,y])),m=[];for(const y of h){const b=g.get(y);b&&(m.push(b),g.delete(y))}return g.forEach(y=>m.push(y)),m},[n]),c=i.useCallback((l,d)=>{s({...n,[l]:d})},[n,s]);return{applyOrder:r,saveOrder:c}}const Ta=i.createContext(null);function Re(e){if(!e)return he;if(te[e])return te[e];const a=e.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("");return te[a]?te[a]:he}function Vs({activeAppName:e,onAppChange:a}){const{isMobile:n}=ia(),{user:o,signOut:s}=ha();i.useEffect(()=>{let S=0;const D=O=>{S=O.touches[0].clientX},M=O=>{const k=O.changedTouches[0].clientX-S;S<30&&k>50&&n&&document.querySelector('[data-sidebar="trigger"]')?.dispatchEvent(new MouseEvent("click",{bubbles:!0}))};return document.addEventListener("touchstart",D,{passive:!0}),document.addEventListener("touchend",M,{passive:!0}),()=>{document.removeEventListener("touchstart",D),document.removeEventListener("touchend",M)}},[n]);const{recentItems:r}=ka(),{favorites:c,removeFavorite:l}=Is(),h=(Ne.apps||[]).filter(u=>u.active!==!1),g=h.find(u=>u.name===e)||h[0],m=g?.branding?.logo,y=g?.branding?.primaryColor,{applyOrder:b,saveOrder:p}=$s(e),[v,N]=i.useState(null),[C,E]=i.useState(null),[A,P]=i.useState(null),j=i.useMemo(()=>({dragItemId:v,dragGroupKey:C,dropTargetId:A,onDragStart:(u,x)=>{E(u),N(x)},onDragOver:(u,x)=>{u.preventDefault(),u.dataTransfer.dropEffect="move",P(x)},onDrop:(u,x,S)=>{if(u.preventDefault(),!v||x!==C)return;const D=S.map(w=>w.id),M=D.indexOf(v),O=D.indexOf(A);if(M===-1||O===-1||M===O)return;const k=[...D];k.splice(M,1),k.splice(O,0,v),p(x,k)},onDragEnd:()=>{N(null),E(null),P(null)}}),[v,C,A,p]);return t.jsxs(Ta.Provider,{value:j,children:[t.jsxs(rn,{collapsible:"icon",children:[t.jsx(on,{children:t.jsx(se,{children:t.jsx(je,{children:t.jsxs(ie,{children:[t.jsx(le,{asChild:!0,children:t.jsxs(we,{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:y?{backgroundColor:y}:void 0,children:m?t.jsx("img",{src:m,alt:qe(g.label),className:"size-6 object-contain"}):i.createElement(Re(g.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:qe(g.label)}),t.jsx("span",{className:"truncate text-xs",children:qe(g.description)||`${h.length} Apps Available`})]}),t.jsx(Ot,{className:"ml-auto"})]})}),t.jsxs(ce,{className:"w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg",align:"start",side:n?"bottom":"right",sideOffset:4,children:[t.jsx(kt,{className:"text-xs text-muted-foreground",children:"Switch Application"}),h.map(u=>t.jsxs(K,{onClick:()=>a(u.name),className:"gap-2 p-2",children:[t.jsx("div",{className:"flex size-6 items-center justify-center rounded-sm border",children:u.icon?i.createElement(Re(u.icon),{className:"size-3"}):t.jsx(he,{className:"size-3"})}),u.label,g.name===u.name&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]},u.name)),t.jsx(Me,{}),t.jsxs(K,{className:"gap-2 p-2",children:[t.jsx("div",{className:"flex size-6 items-center justify-center rounded-md border bg-background",children:t.jsx(Se,{className:"size-4"})}),t.jsx("div",{className:"font-medium text-muted-foreground",children:"Add App"})]})]})]})})})}),t.jsxs(ln,{children:[t.jsx(zs,{items:g.navigation||[],activeAppName:e,applyOrder:b}),c.length>0&&t.jsxs(De,{children:[t.jsxs(Je,{className:"flex items-center gap-1.5",children:[t.jsx(fa,{className:"h-3.5 w-3.5"}),"Favorites"]}),t.jsx(Ce,{children:t.jsx(se,{children:c.slice(0,8).map(u=>t.jsxs(je,{children:[t.jsx(we,{asChild:!0,tooltip:u.label,children:t.jsxs(oe,{to:u.href,children:[t.jsx("span",{className:"text-muted-foreground",children:u.type==="dashboard"?"📊":u.type==="report"?"📈":u.type==="page"?"📄":"📋"}),t.jsx("span",{className:"truncate",children:u.label})]})}),t.jsx(cn,{showOnHover:!0,onClick:x=>{x.stopPropagation(),l(u.id)},"aria-label":`Remove ${u.label} from favorites`,children:t.jsx(Un,{className:"h-3 w-3"})})]},u.id))})})]}),r.length>0&&t.jsxs(De,{children:[t.jsxs(Je,{className:"flex items-center gap-1.5",children:[t.jsx(Wn,{className:"h-3.5 w-3.5"}),"Recent"]}),t.jsx(Ce,{children:t.jsx(se,{children:r.slice(0,5).map(u=>t.jsx(je,{children:t.jsx(we,{asChild:!0,tooltip:u.label,children:t.jsxs(oe,{to:u.href,children:[t.jsx("span",{className:"text-muted-foreground",children:u.type==="dashboard"?"📊":u.type==="report"?"📈":"📄"}),t.jsx("span",{className:"truncate",children:u.label})]})})},u.id))})})]})]}),t.jsx(dn,{children:t.jsx(se,{children:t.jsx(je,{children:t.jsxs(ie,{children:[t.jsx(le,{asChild:!0,children:t.jsxs(we,{size:"lg",className:"data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground",children:[t.jsxs(Ft,{className:"h-8 w-8 rounded-lg",children:[t.jsx(Tt,{src:o?.image??"/avatars/user.jpg",alt:o?.name??"User"}),t.jsx(Et,{className:"rounded-lg bg-primary text-primary-foreground",children:At(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(Ot,{className:"ml-auto size-4"})]})}),t.jsxs(ce,{className:"w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg",side:n?"bottom":"right",align:"end",sideOffset:4,children:[t.jsx(kt,{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(Ft,{className:"h-8 w-8 rounded-lg",children:[t.jsx(Tt,{src:o?.image??"/avatars/user.jpg",alt:o?.name??"User"}),t.jsx(Et,{className:"rounded-lg bg-primary text-primary-foreground",children:At(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(Me,{}),t.jsx(un,{children:t.jsxs(K,{children:[t.jsx(Gn,{className:"mr-2 h-4 w-4"}),"Settings"]})}),t.jsx(Me,{}),t.jsxs(K,{className:"text-destructive focus:text-destructive",onClick:()=>s(),children:[t.jsx(Kn,{className:"mr-2 h-4 w-4"}),"Log out"]})]})]})})})})]}),n&&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:(g.navigation||[]).filter(u=>u.type!=="group").slice(0,5).map(u=>{const x=Re(u.icon),S=`/apps/${e}`;let D="#";return u.type==="object"?D=`${S}/${u.objectName}`:u.type==="dashboard"?D=u.dashboardName?`${S}/dashboard/${u.dashboardName}`:"#":u.type==="page"&&(D=u.pageName?`${S}/page/${u.pageName}`:"#"),t.jsxs(oe,{to:D,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(x,{className:"h-5 w-5"}),t.jsx("span",{className:"text-[10px] truncate max-w-[60px]",children:u.label})]},u.id)})})]})}function zs({items:e,activeAppName:a,applyOrder:n}){if(!e.some(l=>l.type==="group")){const l="__root__",d=n(l,e);return t.jsx(De,{children:t.jsx(Ce,{children:t.jsx(se,{children:d.map(h=>t.jsx(Le,{item:h,activeAppName:a,groupKey:l,groupItems:d,applyOrder:n},h.id))})})})}const s=[];let r=[];const c=l=>{if(r.length===0)return;const d=l,h=n(d,r);s.push(t.jsx(De,{children:t.jsx(Ce,{children:t.jsx(se,{children:h.map(g=>t.jsx(Le,{item:g,activeAppName:a,groupKey:d,groupItems:h,applyOrder:n},g.id))})})},`${l}-group`)),r=[]};return e.forEach((l,d)=>{l.type==="group"?(c(`auto-${d}`),s.push(t.jsx(Le,{item:l,activeAppName:a,groupKey:l.id,groupItems:[],applyOrder:n},l.id))):r.push(l)}),c("auto-end"),t.jsx(t.Fragment,{children:s})}function Le({item:e,activeAppName:a,groupKey:n,groupItems:o,applyOrder:s}){const r=Re(e.icon),c=lt(),[l,d]=i.useState(e.expanded!==!1),{evaluator:h}=Sa(),g=i.useContext(Ta),{can:m}=ga();if(!Ve(e.visible??e.visibleOn,h)||e.requiredPermissions?.length&&!e.requiredPermissions.every(A=>{const P=A.split(":"),[j,u]=P.length>=2?[P[0],P[1]]:[e.objectName||A,"read"];return m(j,u)}))return null;if(e.type==="group"){const E=e.children??[],A=s(n,E);return t.jsx(mn,{open:l,onOpenChange:d,children:t.jsxs(De,{children:[t.jsx(Je,{asChild:!0,children:t.jsxs(pn,{className:"flex w-full items-center justify-between",children:[e.label,t.jsx(He,{className:`ml-auto transition-transform ${l?"rotate-90":""}`})]})}),t.jsx(hn,{children:t.jsx(Ce,{children:t.jsx(se,{children:A.map(P=>t.jsx(Le,{item:P,activeAppName:a,groupKey:n,groupItems:A,applyOrder:s},P.id))})})})]})})}let b="#",p=!1;const v=`/apps/${a}`;if(e.type==="object")b=`${v}/${e.objectName}`,e.viewName&&(b+=`/view/${e.viewName}`);else if(e.type==="page"){if(b=e.pageName?`${v}/page/${e.pageName}`:"#",e.params){const E=new URLSearchParams(e.params);b+=`?${E.toString()}`}}else e.type==="dashboard"?b=e.dashboardName?`${v}/dashboard/${e.dashboardName}`:"#":e.type==="report"?b=e.reportName?`${v}/report/${e.reportName}`:"#":e.type==="url"&&(b=e.url||"#",p=e.target==="_blank");const N=c.pathname.startsWith(b)&&b!=="#",C=g?.dropTargetId===e.id&&g?.dragItemId!==e.id&&g?.dragGroupKey===n;return t.jsx(je,{draggable:!0,onDragStart:E=>{E.dataTransfer.effectAllowed="move",g?.onDragStart(n,e.id)},onDragOver:E=>g?.onDragOver(E,e.id),onDrop:E=>g?.onDrop(E,n,o),onDragEnd:()=>g?.onDragEnd(),className:C?"border-t-2 border-primary":"",children:t.jsx(we,{asChild:!0,isActive:N,tooltip:e.label,children:p?t.jsxs("a",{href:b,target:"_blank",rel:"noopener noreferrer",children:[t.jsx(r,{className:"h-4 w-4"}),t.jsx("span",{children:e.label})]}):t.jsxs(oe,{to:b,className:"py-2.5 sm:py-2",children:[t.jsx(r,{className:"h-4 w-4"}),t.jsx("span",{children:e.label})]})})})}const Bs={theme:"system",setTheme:()=>null},Ea=i.createContext(Bs);function Hs({children:e,defaultTheme:a="system",storageKey:n="vite-ui-theme",...o}){const[s,r]=i.useState(()=>localStorage.getItem(n)||a);i.useEffect(()=>{const l=window.document.documentElement;if(l.classList.remove("light","dark"),s==="system"){const d=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";l.classList.add(d);return}l.classList.add(s)},[s]);const c={theme:s,setTheme:l=>{localStorage.setItem(n,l),r(l)}};return t.jsx(Ea.Provider,{...o,value:c,children:e})}const Nt=()=>{const e=i.useContext(Ea);if(e===void 0)throw new Error("useTheme must be used within a ThemeProvider");return e};function Us(){const{theme:e,setTheme:a}=Nt(),{t:n}=de();return t.jsxs(ie,{children:[t.jsx(le,{asChild:!0,children:t.jsxs($,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[t.jsx(Qe,{className:"h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0"}),t.jsx(Ze,{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:n("console.theme.toggle")})]})}),t.jsxs(ce,{align:"end",children:[t.jsxs(K,{onClick:()=>a("light"),className:"gap-2",children:[t.jsx(Qe,{className:"h-4 w-4"}),n("console.theme.light"),e==="light"&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]}),t.jsxs(K,{onClick:()=>a("dark"),className:"gap-2",children:[t.jsx(Ze,{className:"h-4 w-4"}),n("console.theme.dark"),e==="dark"&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]}),t.jsxs(K,{onClick:()=>a("system"),className:"gap-2",children:[t.jsx(ba,{className:"h-4 w-4"}),n("console.theme.system"),e==="system"&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]})]})]})}const Ws=[{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 Gs(){const{t:e,language:a,changeLanguage:n}=de();return t.jsxs(ie,{children:[t.jsx(le,{asChild:!0,children:t.jsxs($,{variant:"ghost",size:"icon",className:"h-8 w-8",children:[t.jsx(qn,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:e("console.localeSwitcher.label")})]})}),t.jsx(ce,{align:"end",className:"max-h-72 overflow-y-auto",children:Ws.map(o=>t.jsxs(K,{onClick:()=>n(o.code),className:"gap-2",children:[o.label,a===o.code&&t.jsx("span",{className:"ml-auto text-xs",children:"✓"})]},o.code))})]})}const Ks={connected:{label:"Connected",color:"text-green-500",icon:vt},connecting:{label:"Connecting...",color:"text-yellow-500",icon:Ie},reconnecting:{label:"Reconnecting...",color:"text-yellow-500",icon:Ie},disconnected:{label:"Disconnected",color:"text-muted-foreground",icon:Rt},error:{label:"Connection Error",color:"text-destructive",icon:Rt}};function qs({state:e,className:a}){const n=Ks[e],o=n.icon,[s,r]=i.useState(!1);return i.useEffect(()=>{if(e==="connected"){r(!0);const c=setTimeout(()=>r(!1),2e3);return()=>clearTimeout(c)}r(!1)},[e]),e==="connected"&&!s?null:t.jsxs("div",{className:I("flex items-center gap-1.5 text-xs font-medium px-2 py-1 rounded-md transition-opacity duration-300",n.color,e==="connected"&&"bg-green-500/10",e==="error"&&"bg-destructive/10",e==="reconnecting"&&"bg-yellow-500/10",a),title:n.label,children:[t.jsx(o,{className:I("h-3.5 w-3.5",(e==="connecting"||e==="reconnecting")&&"animate-spin")}),t.jsx("span",{className:"hidden sm:inline",children:n.label})]})}function ve(e){return e.replace(/[-_]/g," ").replace(/\b\w/g,a=>a.toUpperCase())}function Js({appName:e,objects:a,connectionState:n}){const o=lt(),s=_e(),{isOnline:r}=Rn(),c=o.pathname.split("/").filter(Boolean),l=s.appName||c[1],d=c[2],h=`/apps/${l}`,g=a.map(y=>({label:y.label||y.name,href:`${h}/${y.name}`})),m=[{label:e,href:h}];if(d==="dashboard")m.push({label:"Dashboards",href:`${m[0].href}`}),c[3]&&m.push({label:ve(c[3])});else if(d==="page")m.push({label:"Pages",href:`${m[0].href}`}),c[3]&&m.push({label:ve(c[3])});else if(d==="report")m.push({label:"Reports",href:`${m[0].href}`}),c[3]&&m.push({label:ve(c[3])});else if(d==="system")m.push({label:"System"}),c[3]&&m.push({label:ve(c[3])});else if(d){const y=a.find(b=>b.name===d);if(y)if(m.push({label:y.label||d,href:`/apps/${l}/${d}`,siblings:g}),c[3]==="record"&&c[4]){const b=c[4].length>12?`${c[4].slice(0,8)}…`:c[4];m.push({label:`#${b}`})}else c[3]==="view"&&c[4]&&m.push({label:ve(c[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(gn,{className:"md:hidden shrink-0"}),t.jsx(fn,{orientation:"vertical",className:"h-4 md:hidden shrink-0"}),t.jsx(bn,{className:"hidden sm:flex min-w-0",children:t.jsx(xn,{children:m.map((y,b)=>t.jsxs(i.Fragment,{children:[b>0&&t.jsx(yn,{}),t.jsx(vn,{children:b===m.length-1||!y.href?y.siblings&&y.siblings.length>1?t.jsxs(ie,{children:[t.jsxs(le,{className:"flex items-center gap-1 text-sm font-medium",children:[y.label,t.jsx(Xe,{className:"h-3 w-3"})]}),t.jsx(ce,{align:"start",className:"max-h-64 overflow-y-auto",children:y.siblings.map(p=>t.jsx(K,{asChild:!0,children:t.jsx(oe,{to:p.href,className:"w-full",children:p.label})},p.href))})]}):t.jsx(jn,{className:"truncate max-w-[200px]",children:y.label}):y.siblings&&y.siblings.length>1?t.jsxs(ie,{children:[t.jsxs(le,{className:"flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors",children:[y.label,t.jsx(Xe,{className:"h-3 w-3"})]}),t.jsx(ce,{align:"start",className:"max-h-64 overflow-y-auto",children:y.siblings.map(p=>t.jsx(K,{asChild:!0,children:t.jsx(oe,{to:p.href,className:"w-full",children:p.label})},p.href))})]}):t.jsx(wn,{asChild:!0,children:t.jsx(oe,{to:y.href,className:"truncate max-w-[150px]",children:y.label})})})]},b))})}),t.jsx("span",{className:"text-sm font-medium sm:hidden truncate min-w-0",children:m[m.length-1]?.label||e})]}),t.jsxs("div",{className:"flex items-center gap-0.5 sm:gap-1 md:gap-2 shrink-0",children:[!r&&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"]}),n&&t.jsx(qs,{state:n}),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($e,{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($,{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($e,{className:"h-4 w-4"})}),t.jsx($,{variant:"ghost",size:"icon",className:"h-8 w-8 hidden sm:flex shrink-0",children:t.jsx(Jn,{className:"h-4 w-4"})}),t.jsx($,{variant:"ghost",size:"icon",className:"h-8 w-8 hidden md:flex shrink-0",children:t.jsx(Yn,{className:"h-4 w-4"})}),t.jsx("div",{className:"shrink-0",children:t.jsx(Us,{})}),t.jsx("div",{className:"shrink-0",children:t.jsx(Gs,{})})]})]})}const Ys=768,Qs=1024;function Zs(){const{setOpen:e,isMobile:a}=ia();i.useEffect(()=>{function n(){const o=window.innerWidth;o>=Ys&&o<Qs&&e(!1)}return n(),window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[e,a])}function Xs({children:e}){return Zs(),t.jsx(t.Fragment,{children:e})}function er({children:e,activeAppName:a,activeApp:n,onAppChange:o,objects:s,connectionState:r}){return t.jsx(Hn,{sidebar:t.jsx(Vs,{activeAppName:a,onAppChange:o}),navbar:t.jsx(Js,{appName:n?.label||a,objects:s,connectionState:r}),className:"p-0 overflow-hidden bg-muted/5",branding:n?.branding?{primaryColor:n.branding.primaryColor,accentColor:n.branding.accentColor,favicon:n.branding.favicon,logo:n.branding.logo,title:n.label?`${n.label} — ObjectStack Console`:void 0}:void 0,children:t.jsx(Xs,{children:e})})}function Wt(e){if(!e)return he;if(te[e])return te[e];const a=e.split("-").map(n=>n.charAt(0).toUpperCase()+n.slice(1)).join("");return te[a]?te[a]:he}function tr({apps:e,activeApp:a,objects:n,onAppChange:o}){const[s,r]=i.useState(!1),c=ze(),{appName:l}=_e(),{setTheme:d}=Nt(),{evaluator:h}=Sa(),{t:g}=de();i.useEffect(()=>{const p=v=>{v.key==="k"&&(v.metaKey||v.ctrlKey)&&(v.preventDefault(),r(N=>!N))};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[]);const m=`/apps/${l||a?.name}`,y=i.useCallback(p=>{r(!1),p()},[]),b=Pa(a?.navigation||[]).filter(p=>Ve(p.visible??p.visibleOn,h));return t.jsxs(Nn,{open:s,onOpenChange:r,children:[t.jsx(Dn,{placeholder:g("console.commandPalette.placeholder")}),t.jsxs(Cn,{children:[t.jsx(Sn,{children:g("console.commandPalette.noResults")}),b.filter(p=>p.type==="object").length>0&&t.jsx(ae,{heading:g("console.commandPalette.objects"),children:b.filter(p=>p.type==="object").map(p=>{const v=Wt(p.icon);return t.jsxs(X,{value:`object ${p.label} ${p.objectName}`,onSelect:()=>y(()=>c(`${m}/${p.objectName}`)),children:[t.jsx(v,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:p.label})]},p.id)})}),b.filter(p=>p.type==="dashboard").length>0&&t.jsx(ae,{heading:g("console.commandPalette.dashboards"),children:b.filter(p=>p.type==="dashboard").map(p=>t.jsxs(X,{value:`dashboard ${p.label} ${p.dashboardName}`,onSelect:()=>y(()=>c(`${m}/dashboard/${p.dashboardName}`)),children:[t.jsx(xa,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:p.label})]},p.id))}),b.filter(p=>p.type==="page").length>0&&t.jsx(ae,{heading:g("console.commandPalette.pages"),children:b.filter(p=>p.type==="page").map(p=>t.jsxs(X,{value:`page ${p.label} ${p.pageName}`,onSelect:()=>y(()=>c(`${m}/page/${p.pageName}`)),children:[t.jsx(Qn,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:p.label})]},p.id))}),b.filter(p=>p.type==="report").length>0&&t.jsx(ae,{heading:g("console.commandPalette.reports"),children:b.filter(p=>p.type==="report").map(p=>t.jsxs(X,{value:`report ${p.label} ${p.reportName}`,onSelect:()=>y(()=>c(`${m}/report/${p.reportName}`)),children:[t.jsx(ya,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:p.label})]},p.id))}),e.filter(p=>p.active!==!1).length>1&&t.jsxs(t.Fragment,{children:[t.jsx(Ge,{}),t.jsx(ae,{heading:g("console.commandPalette.switchApp"),children:e.filter(p=>p.active!==!1).map(p=>{const v=Wt(p.icon);return t.jsxs(X,{value:`app ${p.label} ${p.name}`,onSelect:()=>y(()=>o(p.name)),children:[t.jsx(v,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:p.label}),p.name===a?.name&&t.jsx("span",{className:"ml-auto text-xs text-muted-foreground",children:g("console.commandPalette.current")})]},p.name)})})]}),t.jsx(Ge,{}),t.jsxs(ae,{heading:g("console.commandPalette.preferences"),children:[t.jsxs(X,{value:"theme light",onSelect:()=>y(()=>d("light")),children:[t.jsx(Qe,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:g("console.commandPalette.lightTheme")})]}),t.jsxs(X,{value:"theme dark",onSelect:()=>y(()=>d("dark")),children:[t.jsx(Ze,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:g("console.commandPalette.darkTheme")})]}),t.jsxs(X,{value:"theme system",onSelect:()=>y(()=>d("system")),children:[t.jsx(ba,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:g("console.commandPalette.systemTheme")})]})]}),t.jsx(Ge,{}),t.jsx(ae,{heading:g("console.commandPalette.actions"),children:t.jsxs(X,{value:"search all results full page",onSelect:()=>y(()=>c(`${m}/search`)),children:[t.jsx($e,{className:"mr-2 h-4 w-4"}),t.jsx("span",{children:g("console.commandPalette.openFullSearch")})]})})]})]})}function Pa(e){const a=[];for(const n of e)n.type==="group"&&n.children?a.push(...Pa(n.children)):a.push(n);return a}function ar({error:e,onReset:a}){const{t:n}=de();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(dt,{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(va,{className:"h-6 w-6 text-destructive"})}),t.jsx(ut,{children:n("console.errors.somethingWentWrong")}),t.jsx(la,{className:"mb-4",children:e.message||n("console.errors.unexpectedError")}),t.jsxs("div",{className:"flex items-center justify-center gap-2",children:[t.jsxs($,{variant:"outline",size:"sm",onClick:a,className:"gap-2",children:[t.jsx(Zn,{className:"h-4 w-4"}),n("console.errors.tryAgain")]}),t.jsxs($,{variant:"ghost",size:"sm",onClick:()=>{window.location.href="/"},className:"gap-2",children:[t.jsx(Xn,{className:"h-4 w-4"}),n("console.errors.goHome")]})]})]}),!1]})})}class nr extends i.Component{constructor(a){super(a),this.state={hasError:!1,error:null}}static getDerivedStateFromError(a){return{hasError:!0,error:a}}componentDidCatch(a,n){console.error("[ErrorBoundary] Caught error:",a,n),this.props.onError?.(a,n)}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(ar,{error:this.state.error,onReset:this.resetErrorBoundary}):this.props.children}}function ge({message:e}){const{t:a}=de(),[n,o]=i.useState(0),s=i.useMemo(()=>[a("console.loadingSteps.connecting"),a("console.loadingSteps.loadingConfig"),a("console.loadingSteps.preparingWorkspace")],[a]);return i.useEffect(()=>{if(e)return;const r=setInterval(()=>{o(c=>Math.min(c+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(he,{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:a("console.title")}),t.jsx("p",{className:"text-sm text-muted-foreground",children:a("console.initializing")})]}),e?t.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 bg-muted/50 rounded-full",children:[t.jsx(_n,{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,c)=>t.jsxs("div",{className:"flex items-center gap-2.5 text-sm transition-opacity duration-300",style:{opacity:c<=n?1:.3},children:[c<n?t.jsx(vt,{className:"h-4 w-4 text-primary shrink-0"}):c===n?t.jsx(Ie,{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:c<=n?"text-foreground":"text-muted-foreground",children:r})]},r))})]})})}const sr=Z.lazy(()=>B(()=>import("./ChartImpl-2ivTljUi.js"),__vite__mapDeps([0,1,2,3,4]))),rr=Z.lazy(()=>B(()=>import("./AdvancedChartImpl-DAS1mU9o.js"),__vite__mapDeps([5,1,2,3,4]))),or=({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(sr,{data:e.data,dataKey:e.dataKey,xAxisKey:e.xAxisKey,height:e.height,className:e.className,color:e.color})}),ue=({schema:e})=>{const a=Z.useMemo(()=>{let n=e.series,o=e.xAxisKey,s=e.config;if(o||(e.index?o=e.index:e.category&&(o=e.category)),n||(e.categories?n=e.categories.map(r=>({dataKey:r})):e.value&&(n=[{dataKey:e.value}])),!s&&n){const r=e.colors||["hsl(var(--chart-1))","hsl(var(--chart-2))","hsl(var(--chart-3))"],c={};n.forEach((l,d)=>{c[l.dataKey]={label:l.dataKey,color:r[d%r.length]}}),s=c}return{chartType:e.chartType,data:e.data,config:s,xAxisKey:o,series:n,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(rr,{chartType:a.chartType,data:a.data,config:a.config,xAxisKey:a.xAxisKey,series:a.series,className:a.className})})},Dt=e=>{const{schema:a}=e,n=be(),o=e.dataSource||n.dataSource,s=xt(a.bind),[r,c]=i.useState([]),[l,d]=i.useState(!1);i.useEffect(()=>{let m=!0;const y=async()=>{if(!(!o||!a.objectName)){m&&d(!0);try{const b=await o.find(a.objectName,{$filter:a.filter});let p=[];Array.isArray(b)?p=b:b&&typeof b=="object"&&Array.isArray(b.records)&&(p=b.records),m&&c(p)}catch(b){console.error("[ObjectChart] Fetch error:",b)}finally{m&&d(!1)}}};return a.objectName&&!s&&!a.data&&y(),()=>{m=!1}},[a.objectName,o,s,a.data,a.filter]);const h=s||a.data||r||[],g={...a,data:h};return l&&h.length,t.jsx(ue,{...e,schema:g})};V.register("object-chart",Dt,{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"}]});V.register("bar-chart",or,{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"}});V.register("chart",Dt,{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"}]});V.register("chart",ue,{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"}]}});V.register("chart:bar",ue,{namespace:"plugin-charts",label:"Bar Chart (Alias)",category:"plugin",defaultProps:{chartType:"bar"}});V.register("pie-chart",ue,{namespace:"plugin-charts",label:"Pie Chart",category:"plugin",defaultProps:{chartType:"pie"}});V.register("donut-chart",ue,{namespace:"plugin-charts",label:"Donut Chart",category:"plugin",defaultProps:{chartType:"donut"}});V.register("radar-chart",ue,{namespace:"plugin-charts",label:"Radar Chart",category:"plugin",defaultProps:{chartType:"radar"}});V.register("scatter-chart",ue,{namespace:"plugin-charts",label:"Scatter Chart",category:"plugin",defaultProps:{chartType:"scatter"}});const ir=({schema:e,dataSource:a,className:n,onRowClick:o,onCardClick:s,...r})=>{const[c,l]=i.useState([]),[d,h]=i.useState(null),[g,m]=i.useState(!1),[y,b]=i.useState(null),p=xt(e.bind);i.useEffect(()=>{let j=!0;return(async()=>{if(!(!a||!e.objectName))try{const x=await a.getObjectSchema(e.objectName);j&&h(x)}catch(x){console.warn("Failed to fetch object def",x)}})(),()=>{j=!1}},[e.objectName,a]),i.useEffect(()=>{let j=!0;const u=async()=>{if(!(!a||!e.objectName)){j&&m(!0);try{const x=await a.find(e.objectName,{options:{$top:100},$filter:e.filter});let S=[];Array.isArray(x)?S=x:x&&typeof x=="object"&&(Array.isArray(x.value)?S=x.value:Array.isArray(x.data)&&(S=x.data)),console.log(`[ObjectKanban] Extracted data (length: ${S.length})`),j&&l(S)}catch(x){console.error("[ObjectKanban] Fetch error:",x),j&&b(x)}finally{j&&m(!1)}}};return e.objectName&&!p&&!e.data&&!r.data&&u(),()=>{j=!1}},[e.objectName,a,p,e.data,e.filter,r.data]);const v=r.data||p||e.data||c,N=i.useMemo(()=>{if(!Array.isArray(v))return[];let j=e.cardTitle||e.titleField;if(!j&&d){if(d.titleFormat){const x=/\{(.+?)\}/.exec(d.titleFormat);x&&(j=x[1])}!j&&d.NAME_FIELD_KEY&&(j=d.NAME_FIELD_KEY)}const u=j||"name";return v.map(x=>({...x,id:x.id||x._id,title:x[u]||x.title||"Untitled"}))},[v,e,d]),C=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&&N.length>0){const j=new Set(N.map(u=>u[e.groupBy]));return Array.from(j).map(u=>({id:String(u),title:String(u)}))}return[]},[e.columns,e.groupBy,N,d]),E={...e,data:N,columns:C,className:n||e.className},A=Te({navigation:e.navigation,objectName:e.objectName,onRowClick:o??s});if(y)return t.jsxs("div",{className:"p-4 border border-destructive/50 rounded bg-destructive/10 text-destructive",children:["Error loading kanban data: ",y.message]});const P=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=>{A.handleClick(j),s?.(j)}}}),A.isOverlay&&t.jsx(Fe,{...A,title:P,children:j=>t.jsx("div",{className:"space-y-3",children:Object.entries(j).map(([u,x])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:u.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(x??"—")})]},u))})})]})},lr=Z.lazy(()=>B(()=>import("./KanbanImpl-B5wWMXrJ.js"),__vite__mapDeps([6,1,7,8,9,3,10,11,4,2,12]))),cr=Z.lazy(()=>B(()=>import("./KanbanEnhanced-BlGp--J7.js"),__vite__mapDeps([13,1,14,8,9,3,10,11,4,2,12,15,16,7]))),Aa=({schema:e})=>{const a=Z.useMemo(()=>{const{columns:n=[],data:o,groupBy:s}=e;if(o&&s&&Array.isArray(o)){const r={};n.forEach(l=>{l.id&&(r[String(l.id).toLowerCase()]=l.id),l.title&&(r[String(l.title).toLowerCase()]=l.id)});const c=o.reduce((l,d)=>{const h=String(d[s]??""),g=r[h.toLowerCase()]??h;return l[g]||(l[g]=[]),l[g].push(d),l},{});return n.map(l=>({...l,cards:[...l.cards||[],...c[l.id]||[]]}))}return n},[e]);return t.jsx(i.Suspense,{fallback:t.jsx(ke,{className:"w-full h-[600px]"}),children:t.jsx(lr,{columns:a,onCardMove:e.onCardMove,onCardClick:e.onCardClick,className:e.className})})};V.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"}});V.register("kanban-enhanced",({schema:e})=>{const a=Z.useMemo(()=>{const{columns:n=[],data:o,groupBy:s}=e;if(o&&s&&Array.isArray(o)){const r=o.reduce((c,l)=>{const d=l[s];return c[d]||(c[d]=[]),c[d].push(l),c},{});return n.map(c=>({...c,cards:[...c.cards||[],...r[c.id]||[]]}))}return n},[e]);return t.jsx(i.Suspense,{fallback:t.jsx(ke,{className:"w-full h-[600px]"}),children:t.jsx(cr,{columns:a,onCardMove:e.onCardMove,onColumnToggle:e.onColumnToggle,enableVirtualScrolling:e.enableVirtualScrolling,virtualScrollThreshold:e.virtualScrollThreshold,className:e.className})})},{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 Ma=({schema:e,...a})=>{const{dataSource:n}=be()||{};return t.jsx(ir,{schema:e,dataSource:n,...a})};V.register("object-kanban",Ma,{namespace:"plugin-kanban",label:"Object Kanban",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"}]});V.register("kanban",Ma,{namespace:"view",label:"Kanban Board",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"}]});const Ct="bg-blue-500 text-white";function Oa({events:e=[],view:a="month",currentDate:n=new Date,locale:o="default",onEventClick:s,onDateClick:r,onViewChange:c,onNavigate:l,onAddClick:d,onEventDrop:h,className:g}){const[m,y]=i.useState(a),[b,p]=i.useState(n);i.useEffect(()=>{p(n)},[n]),i.useEffect(()=>{y(a)},[a]);const v=i.useRef(c);v.current=c,i.useEffect(()=>{const D=window.matchMedia("(max-width: 639px)"),M=O=>{O.matches&&(y("day"),v.current?.("day"))};return M(D),D.addEventListener("change",M),()=>D.removeEventListener("change",M)},[]);const N=()=>{const D=new Date(b);m==="month"?D.setMonth(D.getMonth()-1):m==="week"?D.setDate(D.getDate()-7):D.setDate(D.getDate()-1),p(D),l?.(D)},C=()=>{const D=new Date(b);m==="month"?D.setMonth(D.getMonth()+1):m==="week"?D.setDate(D.getDate()+7):D.setDate(D.getDate()+1),p(D),l?.(D)},E=()=>{const D=new Date;p(D),l?.(D)},A=D=>{y(D),c?.(D)},P=()=>{if(m==="month")return b.toLocaleDateString(o,{month:"long",year:"numeric"});if(m==="week"){const D=Ra(b),M=new Date(D);return M.setDate(M.getDate()+6),`${D.toLocaleDateString(o,{month:"short",day:"numeric"})} - ${M.toLocaleDateString(o,{month:"short",day:"numeric",year:"numeric"})}`}else return b.toLocaleDateString(o,{weekday:"long",month:"long",day:"numeric",year:"numeric"})},j=i.useRef(0),u=D=>{j.current=D.touches[0].clientX},x=D=>{const M=j.current-D.changedTouches[0].clientX;if(Math.abs(M)>50){const O=new Date(b);m==="day"?O.setDate(O.getDate()+(M>0?1:-1)):m==="week"?O.setDate(O.getDate()+(M>0?7:-7)):O.setMonth(O.getMonth()+(M>0?1:-1)),p(O),l?.(O)}},S=D=>{D&&(p(D),l?.(D))};return t.jsxs("div",{role:"region","aria-label":"Calendar",className:I("flex flex-col h-full bg-background",g),children:[t.jsxs("div",{className:"flex items-center justify-between p-4 border-b",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($,{variant:"ghost",size:"sm",onClick:E,className:"h-8","aria-label":"Go to today",children:"Today"}),t.jsx("div",{className:"h-4 w-px bg-border mx-1"}),t.jsx($,{variant:"ghost",size:"icon","aria-label":"Previous period",onClick:N,className:"h-8 w-8",children:t.jsx(ja,{className:"h-4 w-4"})}),t.jsx($,{variant:"ghost",size:"icon","aria-label":"Next period",onClick:C,className:"h-8 w-8",children:t.jsx(He,{className:"h-4 w-4"})})]}),t.jsxs(kn,{children:[t.jsx(Fn,{asChild:!0,children:t.jsxs($,{variant:"ghost","aria-label":`Current date: ${P()}`,className:I("text-xl font-semibold h-auto px-3 py-1 hover:bg-muted/50 transition-colors","flex items-center gap-2"),children:[t.jsx(wa,{className:"h-5 w-5 text-muted-foreground"}),t.jsx("span",{children:P()})]})}),t.jsx(Tn,{className:"w-auto p-0",align:"start",children:t.jsx(En,{mode:"single",selected:b,onSelect:S,initialFocus:!0,fromYear:2e3,toYear:2050})})]})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ca,{value:m,onValueChange:A,children:[t.jsx(da,{className:"w-32 bg-background",children:t.jsx(ua,{})}),t.jsxs(ma,{children:[t.jsx(re,{value:"day",children:"Day"}),t.jsx(re,{value:"week",children:"Week"}),t.jsx(re,{value:"month",children:"Month"})]})]}),d&&t.jsxs($,{onClick:d,size:"sm",className:"gap-1",children:[t.jsx(Se,{className:"h-4 w-4"}),"New"]})]})]}),t.jsxs("div",{className:"flex-1 overflow-auto",onTouchStart:u,onTouchEnd:x,children:[m==="month"&&t.jsx(ur,{date:b,events:e,onEventClick:s,onDateClick:r,onEventDrop:h}),m==="week"&&t.jsx(mr,{date:b,events:e,locale:o,onEventClick:s,onDateClick:r}),m==="day"&&t.jsx(pr,{date:b,events:e,onEventClick:s,onDateClick:r})]})]})}function Ra(e){const a=new Date(e),n=a.getDay(),o=a.getDate()-n;return a.setDate(o),a}function dr(e){const a=e.getFullYear(),n=e.getMonth(),o=new Date(a,n,1),s=new Date(a,n+1,0),r=o.getDay(),c=[];for(let d=r-1;d>=0;d--){const h=new Date(o.getTime());h.setDate(h.getDate()-(d+1)),c.push(h)}for(let d=1;d<=s.getDate();d++)c.push(new Date(a,n,d));const l=42-c.length;for(let d=1;d<=l;d++){const h=new Date(s.getTime());h.setDate(h.getDate()+d),c.push(h)}return c}function La(e,a){return e.getFullYear()===a.getFullYear()&&e.getMonth()===a.getMonth()&&e.getDate()===a.getDate()}function St(e,a){return a.filter(n=>{const o=new Date(n.start),s=n.end?new Date(n.end):new Date(o),r=new Date(e);r.setHours(0,0,0,0);const c=new Date(e);c.setHours(23,59,59,999);const l=new Date(o);l.setHours(0,0,0,0);const d=new Date(s);return d.setHours(23,59,59,999),r<=d&&c>=l})}function ur({date:e,events:a,onEventClick:n,onDateClick:o,onEventDrop:s}){const r=dr(e),c=new Date,l=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],[d,h]=i.useState(null),[g,m]=i.useState(null),y=(C,E)=>{h(E.id),C.dataTransfer.effectAllowed="move",C.dataTransfer.setData("text/plain",String(E.id))},b=()=>{h(null),m(null)},p=(C,E)=>{C.preventDefault(),C.dataTransfer.dropEffect="move",m(E)},v=C=>{C.currentTarget.contains(C.relatedTarget)||m(null)},N=(C,E)=>{if(C.preventDefault(),m(null),h(null),!s)return;const A=C.dataTransfer.getData("text/plain"),P=a.find(O=>String(O.id)===A);if(!P)return;const j=new Date(P.start),u=new Date(j);u.setHours(0,0,0,0);const x=new Date(E);x.setHours(0,0,0,0);const S=x.getTime()-u.getTime();if(S===0)return;const D=new Date(j.getTime()+S);let M;P.end&&(M=new Date(new Date(P.end).getTime()+S)),s(P,D,M)};return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx("div",{role:"row",className:"grid grid-cols-7 border-b",children:l.map(C=>t.jsx("div",{role:"columnheader",className:"p-2 text-center text-sm font-medium text-muted-foreground border-r last:border-r-0",children:C},C))}),t.jsx("div",{role:"grid","aria-label":"Calendar grid",className:"grid grid-cols-7 flex-1 auto-rows-fr",children:r.map((C,E)=>{const A=St(C,a),P=C.getMonth()===e.getMonth(),j=La(C,c);return t.jsxs("div",{role:"gridcell","aria-label":`${C.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${A.length>0?`, ${A.length} event${A.length>1?"s":""}`:""}`,className:I("border-b border-r last:border-r-0 p-2 min-h-[100px] cursor-pointer hover:bg-accent/50",!P&&"bg-muted/30 text-muted-foreground",g===E&&"ring-2 ring-primary"),onClick:()=>o?.(C),onDragOver:u=>p(u,E),onDragLeave:v,onDrop:u=>N(u,C),children:[t.jsx("div",{className:I("text-sm font-medium mb-1",j&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-6 w-6"),...j?{"aria-current":"date"}:{},children:C.getDate()}),t.jsxs("div",{className:"space-y-1",children:[A.slice(0,3).map(u=>t.jsx("div",{role:"button","aria-label":u.title,draggable:!!s,onDragStart:x=>y(x,u),onDragEnd:b,className:I("text-xs px-2 py-1 rounded truncate cursor-pointer hover:opacity-80",u.color||Ct,d===u.id&&"opacity-50"),style:u.color&&u.color.startsWith("#")?{backgroundColor:u.color}:void 0,onClick:x=>{x.stopPropagation(),n?.(u)},children:u.title},u.id)),A.length>3&&t.jsxs("div",{className:"text-xs text-muted-foreground px-2",children:["+",A.length-3," more"]})]})]},E)})})]})}function mr({date:e,events:a,locale:n="default",onEventClick:o,onDateClick:s}){const r=i.useRef(null),c=m=>{s&&(r.current=setTimeout(()=>{s(m)},500))},l=()=>{r.current&&(clearTimeout(r.current),r.current=null)},d=Ra(e),h=Array.from({length:7},(m,y)=>{const b=new Date(d);return b.setDate(b.getDate()+y),b}),g=new Date;return t.jsxs("div",{className:"flex flex-col h-full",children:[t.jsx("div",{className:"grid grid-cols-7 border-b",children:h.map(m=>{const y=La(m,g);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:m.toLocaleDateString(n,{weekday:"short"})}),t.jsx("div",{className:I("text-lg font-semibold mt-1",y&&"inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground h-8 w-8"),children:m.getDate()})]},m.toISOString())})}),t.jsx("div",{role:"grid",className:"grid grid-cols-7 flex-1",children:h.map(m=>{const y=St(m,a);return t.jsx("div",{role:"gridcell","aria-label":`${m.toLocaleDateString("default",{weekday:"long",month:"long",day:"numeric",year:"numeric"})}${y.length>0?`, ${y.length} event${y.length>1?"s":""}`:""}`,className:"border-r last:border-r-0 p-2 min-h-[400px] cursor-pointer hover:bg-accent/50",onClick:()=>s?.(m),onTouchStart:()=>c(m),onTouchEnd:l,children:t.jsx("div",{className:"space-y-2",children:y.map(b=>t.jsxs("div",{role:"button","aria-label":b.title,className:I("text-xs sm:text-sm px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",b.color||Ct),style:b.color&&b.color.startsWith("#")?{backgroundColor:b.color}:void 0,onClick:p=>{p.stopPropagation(),o?.(b)},children:[t.jsx("div",{className:"font-medium truncate",children:b.title}),!b.allDay&&t.jsx("div",{className:"text-xs opacity-90 mt-1",children:b.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})})]},b.id))})},m.toISOString())})})]})}function pr({date:e,events:a,onEventClick:n,onDateClick:o}){const s=St(e,a),r=Array.from({length:24},(h,g)=>g),c=i.useRef(null),l=h=>{o&&(c.current=setTimeout(()=>{const g=new Date(e);g.setHours(h,0,0,0),o(g)},500))},d=()=>{c.current&&(clearTimeout(c.current),c.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(h=>{const g=s.filter(m=>m.allDay?h===0:m.start.getHours()===h);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:h===0?"12 AM":h<12?`${h} AM`:h===12?"12 PM":`${h-12} PM`}),t.jsx("div",{className:"flex-1 p-2 space-y-2",onTouchStart:()=>l(h),onTouchEnd:d,children:g.map(m=>t.jsxs("div",{"aria-label":m.title,className:I("px-2 sm:px-3 py-1.5 sm:py-2 rounded cursor-pointer hover:opacity-80",m.color||Ct),style:m.color&&m.color.startsWith("#")?{backgroundColor:m.color}:void 0,onClick:()=>n?.(m),children:[t.jsx("div",{className:"font-medium truncate",children:m.title}),!m.allDay&&t.jsxs("div",{className:"text-xs opacity-90 mt-1",children:[m.start.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"}),m.end&&` - ${m.end.toLocaleTimeString("default",{hour:"numeric",minute:"2-digit"})}`]})]},m.id))})]},h)})})})}function hr(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 gr(e){if(e){if(typeof e=="string"){const a=e.split(" "),n=a[0],o=a[1]?.toLowerCase()==="desc"?"desc":"asc";return{[n]:o}}if(Array.isArray(e))return e.reduce((a,n)=>(n.field&&n.order&&(a[n.field]=n.order),a),{})}}function fr(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 br=({schema:e,dataSource:a,className:n,onEventClick:o,onRowClick:s,onDateClick:r,onNavigate:c,onViewChange:l,...d})=>{const[h,g]=i.useState([]),[m,y]=i.useState(!0),[b,p]=i.useState(null),[v,N]=i.useState(null),[C,E]=i.useState(new Date),[A,P]=i.useState("month"),[j,u]=i.useState(0),x=i.useCallback(async()=>{u(L=>L+1)},[]),{ref:S,isRefreshing:D,pullDistance:M}=Da({onRefresh:x,enabled:!!a&&!!e.objectName}),O=i.useMemo(()=>hr(e),[e.data,e.staticData,e.objectName]),k=i.useMemo(()=>fr(e),[e.filter,e.calendar,e.dateField,e.endField,e.titleField,e.colorField]),w=O?.provider==="value";i.useEffect(()=>{let L=!0;return(async()=>{try{if(!L)return;if(y(!0),w&&O?.provider==="value"){L&&(g(O.items),y(!1));return}if(e.data||d.data){const H=e.data||d.data;if(Array.isArray(H)){g(H),y(!1);return}}if(!a)throw new Error("DataSource required for object/api providers");if(O?.provider==="object"){const H=O.object,U=await a.find(H,{$filter:e.filter,$orderby:gr(e.sort)});let W=[];Array.isArray(U)?W=U:U&&typeof U=="object"&&(Array.isArray(U.data)?W=U.data:Array.isArray(U.value)&&(W=U.value)),L&&g(W)}else O?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectCalendar"),L&&g([]));L&&y(!1)}catch(H){console.error("[ObjectCalendar] Error fetching data:",H),L&&(p(H),y(!1))}})(),()=>{L=!1}},[O,a,w,e.filter,e.sort,j]),i.useEffect(()=>{!w&&a&&(async()=>{try{if(!a)return;const _=O?.provider==="object"?O.object:e.objectName;if(!_)return;const H=await a.getObjectSchema(_);N(H)}catch(_){console.error("Failed to fetch object schema:",_)}})()},[e.objectName,a,w,O]);const F=i.useMemo(()=>{if(!k||!h.length)return[];const{startDateField:L,endDateField:_,titleField:H,colorField:U}=k;return h.map((W,pe)=>{const _t=W[L],We=_?W[_]:null,tn=W[H]||"Untitled",an=U?W[U]:void 0;return{id:W.id||W._id||`event-${pe}`,title:tn,start:_t?new Date(_t):new Date,end:We?new Date(We):void 0,color:an,allDay:!We,data:W}}).filter(W=>!isNaN(W.start.getTime()))},[h,k]),T=i.useCallback(()=>{r?.(new Date)},[r]),R=Te({navigation:e.navigation,objectName:e.objectName,onRowClick:s});return m?t.jsx("div",{className:n,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsx("div",{className:"text-muted-foreground",children:"Loading calendar..."})})}):b?t.jsx("div",{className:n,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsxs("div",{className:"text-destructive",children:["Error: ",b.message]})})}):k?t.jsxs("div",{ref:S,className:n,children:[M>0&&t.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:M},children:D?"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(Oa,{events:F,currentDate:C,view:e.defaultView||"month",onEventClick:L=>{R.handleClick(L.data),o?.(L.data)},onDateClick:r,onNavigate:L=>{E(L),c?.(L)},onViewChange:L=>{P(L),l?.(L)},onAddClick:T})}),R.isOverlay&&t.jsx(Fe,{...R,title:"Event Details",children:L=>t.jsx("div",{className:"space-y-3",children:Object.entries(L).map(([_,H])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:_.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(H??"—")})]},_))})})]}):t.jsx("div",{className:n,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."})})})};V.register("calendar-view",({schema:e,className:a,onAction:n,...o})=>{const s=Z.useMemo(()=>!e.data||!Array.isArray(e.data)?[]:e.data.map((l,d)=>{const h=e.titleField||"title",g=e.startDateField||"start",m=e.endDateField||"end",y=e.colorField||"color",b=e.allDayField||"allDay";return{id:l._id||l.id||d,title:l[h]||"Untitled Event",start:new Date(l[g]),end:l[m]?new Date(l[m]):void 0,allDay:l[b],color:l[y],data:l}}),[e.data,e.titleField,e.startDateField,e.endDateField,e.colorField,e.allDayField]),r=l=>{e.onEventClick&&n?.({type:"event-click",payload:l})},c=()=>{n?.({type:"create",payload:{}})};return t.jsx(Oa,{className:a,events:s,onEventClick:r,onAddClick:c,...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})=>{const{dataSource:a}=be();return t.jsx(br,{schema:e,dataSource:a})};V.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"}]});V.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 xr({open:e,onToggle:a,className:n}){return t.jsxs($,{size:"sm",variant:e?"secondary":"outline",onClick:a,className:`shadow-none gap-2 ${n||""}`,title:"Toggle Metadata Inspector",children:[t.jsx(es,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden lg:inline",children:"Metadata"})]})}function yr({sections:e,open:a}){if(!a)return null;const[n,o]=i.useState(["0"]),[s,r]=i.useState(null),c=async(d,h)=>{try{await navigator.clipboard.writeText(JSON.stringify(d,null,2)),r(h),setTimeout(()=>r(null),2e3)}catch(g){console.error("Failed to copy:",g)}},l=d=>{o(h=>h.includes(d)?h.filter(g=>g!==d):[...h,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,h)=>{const g=String(h),m=n.includes(g),y=s===h;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:()=>l(g),className:"flex-1 flex items-center justify-between text-left",children:[t.jsx("h4",{className:"text-xs font-semibold text-foreground",children:d.title}),m?t.jsx(Xe,{className:"h-3 w-3 text-muted-foreground ml-2"}):t.jsx(He,{className:"h-3 w-3 text-muted-foreground ml-2"})]}),t.jsx("button",{onClick:()=>c(d.data,h),className:"p-1 hover:bg-muted rounded transition-colors ml-2",title:"Copy JSON",children:y?t.jsx(ts,{className:"h-3 w-3 text-green-600"}):t.jsx(as,{className:"h-3 w-3 text-muted-foreground"})})]}),m&&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)})})})]},h)})})]})}function vr(){const[e,a]=i.useState(!1);return{showDebug:e,toggleDebug:()=>a(n=>!n)}}function jr({objectName:e,objectLabel:a,dataSource:n,onEdit:o,onRefresh:s}){const r=ze(),{appName:c}=_e(),l=`/apps/${c}`,{execute:d,loading:h,error:g,runner:m}=Ln({context:{objectName:e,objectLabel:a||e,baseUrl:l}});i.useEffect(()=>{m.registerHandler("create",async()=>(o?.(null),{success:!0})),m.registerHandler("delete",async N=>{const C=N.params?.recordId||N.recordId;if(!C)return{success:!1,error:"No record ID provided"};try{return await n.delete(e,C),s?.(),Ye.success(`${a||e} deleted successfully`),{success:!0,reload:!0}}catch(E){return Ye.error(`Failed to delete ${a||e}`,{description:E.message}),{success:!1,error:E.message}}}),m.registerHandler("navigate",async N=>{const C=N.params?.url||N.url;return C&&r(C.startsWith("/")?C:`${l}/${C}`),{success:!0}}),m.registerHandler("refresh",async()=>(s?.(),{success:!0,reload:!0}))},[m,e,n,o,s,r,l]);const y=i.useCallback(()=>{o?.(null)},[o]),b=i.useCallback(async N=>d({type:"delete",confirmText:"Are you sure you want to delete this record?",params:{recordId:N}}),[d]),p=i.useCallback(N=>{r(`${l}/${e}/view/${N}`)},[r,l,e]),v=i.useCallback(N=>{r(`${l}/${e}/record/${N}`)},[r,l,e]);return{execute:d,create:y,deleteRecord:b,navigateToView:p,navigateToRecord:v,loading:h,error:g}}function wr(e){const{url:a,channel:n,autoReconnect:o=!0,reconnectInterval:s=1e3,maxReconnectAttempts:r=10,authToken:c}=e,[l,d]=i.useState("disconnected"),[h,g]=i.useState(null),[m,y]=i.useState([]),[b,p]=i.useState(null),v=i.useRef(null),N=i.useRef(0),C=i.useRef(null),E=i.useRef(new Map),A=i.useRef([]),P=i.useRef(!0),j=i.useRef(!1),u=i.useCallback(()=>{C.current!==null&&(clearTimeout(C.current),C.current=null)},[]),x=i.useCallback(w=>{for(;A.current.length>0;){const F=A.current.shift(),T={type:F.type,channel:n,data:F.data,timestamp:new Date().toISOString()};w.send(JSON.stringify(T))}},[n]),S=i.useCallback(()=>{if(typeof WebSocket>"u"){p(new Error("WebSocket is not available in this environment")),d("error");return}if(!a){p(new Error("WebSocket URL is required")),d("error");return}try{const T=new URL(a);if(T.protocol!=="ws:"&&T.protocol!=="wss:"){p(new Error("WebSocket URL must use ws: or wss: protocol")),d("error");return}}catch{p(new Error("Invalid WebSocket URL")),d("error");return}v.current&&(j.current=!0,v.current.close(),v.current=null),j.current=!1,d("connecting"),p(null);const w=c?`${a}?token=${encodeURIComponent(c)}&channel=${encodeURIComponent(n)}`:`${a}?channel=${encodeURIComponent(n)}`;let F;try{F=new WebSocket(w)}catch(T){if(!P.current)return;const R=T instanceof Error?T:new Error("Failed to create WebSocket connection");p(R),d("error");return}v.current=F,F.onopen=()=>{P.current&&(d("connected"),p(null),N.current=0,x(F))},F.onmessage=T=>{if(P.current)try{const R=JSON.parse(String(T.data));if(R.channel!==n)return;g(R),y(_=>[..._,R]);const L=E.current.get(R.type);L&&L.forEach(_=>_(R.data))}catch{}},F.onerror=()=>{P.current&&(p(new Error("WebSocket connection error")),d("error"))},F.onclose=()=>{if(P.current){if(v.current=null,j.current){d("disconnected");return}if(o&&N.current<r){d("reconnecting");const T=Math.min(s*Math.pow(2,N.current),3e4);N.current+=1,C.current=setTimeout(()=>{P.current&&S()},T)}else d("disconnected")}}},[a,n,c,o,s,r,x]),D=i.useCallback(()=>{u(),j.current=!0,N.current=0,v.current&&(v.current.close(),v.current=null),d("disconnected")},[u]),M=i.useCallback(()=>{u(),N.current=0,S()},[S,u]),O=i.useCallback((w,F)=>{const T=v.current;if(T&&T.readyState===WebSocket.OPEN){const R={type:w,channel:n,data:F,timestamp:new Date().toISOString()};T.send(JSON.stringify(R))}else A.current.push({type:w,data:F})},[n]),k=i.useCallback((w,F)=>(E.current.has(w)||E.current.set(w,new Set),E.current.get(w).add(F),()=>{const T=E.current.get(w);T&&(T.delete(F),T.size===0&&E.current.delete(w))}),[]);return i.useEffect(()=>(P.current=!0,a&&S(),()=>{P.current=!1,u(),j.current=!0,v.current&&(v.current.close(),v.current=null)}),[a,n,c]),{connectionState:l,isConnected:l==="connected",lastMessage:h,messages:m,send:O,subscribe:k,disconnect:D,reconnect:M,error:b}}const Nr={grid:Oe,kanban:cs,calendar:wa,gallery:ls,timeline:is,gantt:os,map:rs,chart:ya};function Gt({dataSource:e,objects:a,onEdit:n,onRowClick:o}){const s=ze(),{objectName:r,viewId:c}=_e(),[l,d]=sa(),{showDebug:h,toggleDebug:g}=vr(),{t:m}=de(),[y,b]=i.useState(!1),{can:p}=ga(),v=a.find(k=>k.name===r);if(!v)return t.jsx("div",{className:"h-full p-4 flex items-center justify-center",children:t.jsxs(dt,{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(Oe,{className:"h-6 w-6 text-muted-foreground"})}),t.jsx(ut,{children:m("console.objectView.objectNotFound")}),t.jsxs(la,{children:[m("console.objectView.objectNotFoundDescription",{objectName:r})," ",m("console.objectView.objectNotFoundHint")]})]})});const N=i.useMemo(()=>{const k=v.list_views||{},w=Object.entries(k).map(([F,T])=>({id:F,...T,type:T.type||"grid"}));return w.length===0&&w.push({id:"all",label:m("console.objectView.allRecords"),type:"grid",columns:v.fields?Object.keys(v.fields).slice(0,5):[]}),w},[v]),C=c||l.get("view")||N[0]?.id,E=N.find(k=>k.id===C)||N[0],A=k=>{const w=N.find(F=>F.id===k);w&&(c?s(`../${w.id}`,{relative:"path"}):s(`view/${w.id}`))},[P,j]=i.useState(0),u=jr({objectName:v.name,objectLabel:v.label,dataSource:e,onEdit:n,onRefresh:()=>j(k=>k+1)}),{lastMessage:x}=wr({channel:`object:${v.name}`});i.useEffect(()=>{x&&j(k=>k+1)},[x]);const S=l.get("recordId"),D=()=>{const k=new URLSearchParams(l);k.delete("recordId"),d(k)},M=i.useCallback(({schema:k,dataSource:w,onEdit:F,onRowClick:T,className:R})=>{const L=`${r}-${E.id}-${P}`,_=E;if(_.type==="chart")return t.jsx(Dt,{dataSource:w,schema:{type:"object-chart",objectName:v.name,chartType:_.chartType,xAxisField:_.xAxisField,yAxisFields:_.yAxisFields,aggregation:_.aggregation,series:_.series,config:_.config,filter:_.filter}},L);const H={...k,options:{kanban:{groupBy:_.groupBy||_.groupField||"status",groupField:_.groupBy||_.groupField||"status",titleField:_.titleField||v.titleField||"name",cardFields:_.columns||_.cardFields},calendar:{startDateField:_.startDateField||_.dateField||"due_date",endDateField:_.endDateField||_.endField,titleField:_.titleField||_.subjectField||"name",colorField:_.colorField,allDayField:_.allDayField,defaultView:_.defaultView},timeline:{dateField:_.dateField||_.startDateField||"due_date",titleField:_.titleField||v.titleField||"name",descriptionField:_.descriptionField},map:{locationField:_.locationField,titleField:_.titleField||v.titleField||"name",latitudeField:_.latitudeField,longitudeField:_.longitudeField,zoom:_.zoom,center:_.center},gallery:{imageField:_.imageField||"image",titleField:_.titleField||v.titleField||"name",subtitleField:_.subtitleField},gantt:{startDateField:_.startDateField||"start_date",endDateField:_.endDateField||"end_date",titleField:_.titleField||"name",progressField:_.progressField,dependenciesField:_.dependenciesField,colorField:_.colorField},chart:{chartType:_.chartType,xAxisField:_.xAxisField,yAxisFields:_.yAxisFields,aggregation:_.aggregation,series:_.series,config:_.config}}};return t.jsx(fs,{schema:H,className:R,onEdit:F,onRowClick:T||(U=>F?.(U)),dataSource:w},L)},[E,v,r,P]),O=i.useMemo(()=>({type:"object-view",objectName:v.name,layout:"page",showSearch:!0,showFilters:!0,showCreate:!1,showRefresh:!0,onNavigate:(k,w)=>{w==="edit"&&n?.({_id:k,id:k})}}),[v.name,n]);return t.jsxs("div",{className:"h-full flex flex-col bg-background",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(Oe,{className:"h-4 w-4 text-primary"})}),t.jsx("div",{className:"min-w-0",children:t.jsx("h1",{className:"text-base sm:text-lg font-semibold tracking-tight text-foreground truncate",children:v.label})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2 shrink-0",children:[p(v.name,"create")&&t.jsxs($,{size:"sm",onClick:u.create,className:"shadow-none gap-1.5 sm:gap-2 h-8 sm:h-9",children:[t.jsx(Se,{className:"h-4 w-4"}),t.jsx("span",{className:"hidden sm:inline",children:m("console.objectView.new")})]}),v.actions?.filter(k=>k.location==="list_toolbar").map(k=>t.jsx($,{size:"sm",variant:k.variant||"outline",className:"shadow-none h-8 sm:h-9",onClick:()=>u.execute(k),children:k.label||k.name},k.name||k.label)),t.jsxs(ie,{children:[t.jsx(le,{asChild:!0,children:t.jsx($,{size:"sm",variant:y?"secondary":"ghost",className:"shadow-none h-8 sm:h-9 px-2",title:m("console.objectView.designTools"),children:y?t.jsx(Lt,{className:"h-4 w-4"}):t.jsx(ns,{className:"h-4 w-4"})})}),t.jsxs(ce,{align:"end",className:"w-48",children:[t.jsxs(K,{onClick:()=>b(!y),children:[t.jsx(Lt,{className:"h-4 w-4 mr-2"}),m(y?"console.objectView.exitDesignMode":"console.objectView.enterDesignMode")]}),y&&t.jsxs(t.Fragment,{children:[t.jsx(Me,{}),t.jsxs(K,{onClick:g,children:[t.jsx(xr,{open:h,onToggle:g,className:"hidden"}),m("console.objectView.metadataInspector")]}),t.jsxs(K,{onClick:()=>s(c?`../../views/${c}`:`views/${C}`),children:[t.jsx(ss,{className:"h-4 w-4 mr-2"}),m("console.objectView.editView")]}),t.jsxs(K,{onClick:()=>s(c?"../../views/new":"views/new"),children:[t.jsx(Se,{className:"h-4 w-4 mr-2"}),m("console.objectView.addView")]})]})]})]})]})]}),N.length>1&&t.jsx("div",{className:"border-b px-3 sm:px-4 bg-background overflow-x-auto shrink-0",children:t.jsx("div",{className:"flex items-center gap-0.5 -mb-px",children:N.map(k=>{const w=k.id===C,F=Nr[k.type]||Oe;return t.jsxs("button",{onClick:()=>A(k.id),className:I("inline-flex items-center gap-1.5 px-3 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap",w?"border-primary text-primary":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"),children:[t.jsx(F,{className:"h-3.5 w-3.5"}),k.label]},k.id)})})}),t.jsxs("div",{className:"flex-1 overflow-hidden relative flex flex-row",children:[t.jsx("div",{className:"flex-1 relative h-full",children:t.jsx("div",{className:"absolute inset-0 overflow-auto p-3 sm:p-4",children:t.jsx(Mn,{schema:O,dataSource:e,views:N,activeViewId:C,onViewChange:A,onEdit:k=>n?.(k),onRowClick:o||(k=>n?.(k)),renderListView:M},P)})}),t.jsx(yr,{open:h&&y,sections:[{title:"View Configuration",data:E},{title:"Object Definition",data:v}]})]}),t.jsx(Pn,{open:!!S,onOpenChange:k=>!k&&D(),children:t.jsx(An,{side:"right",className:"w-[90vw] sm:w-150 sm:max-w-none p-0 overflow-hidden",children:S&&t.jsx("div",{className:"h-full bg-background overflow-auto p-3 sm:p-4 lg:p-6",children:t.jsx(bs,{schema:{type:"detail-view",objectName:v.name,resourceId:S,showBack:!1,showEdit:!0,title:v.label,sections:[{title:"Details",fields:Object.keys(v.fields||{}).map(k=>({name:k,label:v.fields[k].label||k,type:v.fields[k].type||"text"})),columns:1}]},dataSource:e,onEdit:()=>n({_id:S,id:S})})})})})]})}function Dr({children:e,authUrl:a}){const[n,o]=i.useState(null),[s,r]=i.useState(!0);return i.useEffect(()=>{let c=!1;async function l(){try{const d=new pa({baseUrl:"",autoReconnect:!1});await d.connect();const h=await d.getDiscovery();if(!c){const g=h?.services?.auth?.enabled??!0;o(g)}}catch(d){c||(console.warn("[ConditionalAuthWrapper] Failed to fetch discovery, defaulting to auth enabled:",d),o(!0))}finally{c||r(!1)}}return l(),()=>{c=!0}},[]),s?t.jsx(ge,{}):n?t.jsx(Mt,{authUrl:a,children:e}):t.jsx(Mt,{authUrl:a,enabled:!1,children:e})}function Cr(){const{t:e}=de(),[a,n]=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 c=r.target;c.tagName==="INPUT"||c.tagName==="TEXTAREA"||c.isContentEditable||r.key==="?"&&!r.metaKey&&!r.ctrlKey&&!r.altKey&&(r.preventDefault(),n(l=>!l))}return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[]),t.jsx(mt,{open:a,onOpenChange:n,children:t.jsxs(pt,{className:"sm:max-w-lg max-h-[80vh] overflow-y-auto",children:[t.jsxs(ht,{children:[t.jsx(gt,{children:e("console.shortcuts.title")}),t.jsx(ft,{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,c)=>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((l,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:l},d))})]},c))})]},s.title))})]})})}const Kt="objectui-onboarding-dismissed",Pe=[{icon:xa,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:$e,title:"Quick Search",description:"Press ⌘K (or Ctrl+K) to open the command palette and quickly jump to any object, dashboard, or page."},{icon:fa,title:"Favorites & Recent",description:"Star frequently used items to pin them in the sidebar. Recently visited items also appear for quick access."},{icon:Na,title:"Keyboard Shortcuts",description:"Press ? to view all keyboard shortcuts. Use them to speed up your workflow with CRUD operations and navigation."}];function Sr(){const[e,a]=i.useState(!1),[n,o]=i.useState(0);i.useEffect(()=>{try{if(!localStorage.getItem(Kt)){const g=setTimeout(()=>a(!0),800);return()=>clearTimeout(g)}}catch{}},[]);const s=()=>{a(!1);try{localStorage.setItem(Kt,new Date().toISOString())}catch{}},r=()=>{n<Pe.length-1?o(h=>h+1):s()},c=Pe[n],l=c.icon,d=n===Pe.length-1;return t.jsx(mt,{open:e,onOpenChange:h=>{h||s()},children:t.jsxs(pt,{className:"sm:max-w-md",children:[t.jsxs(ht,{children:[t.jsxs("div",{className:"flex items-center justify-between",children:[t.jsxs(gt,{className:"flex items-center gap-2",children:[t.jsx(Na,{className:"h-5 w-5 text-primary"}),"Welcome to ObjectUI"]}),t.jsxs($,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:s,children:[t.jsx(ds,{className:"h-4 w-4"}),t.jsx("span",{className:"sr-only",children:"Close"})]})]}),t.jsx(ft,{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(l,{className:"h-8 w-8 text-primary"})}),t.jsxs("div",{className:"space-y-2",children:[t.jsx("h3",{className:"text-lg font-semibold",children:c.title}),t.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:c.description})]})]}),t.jsx("div",{className:"flex items-center justify-center gap-1.5",children:Pe.map((h,g)=>t.jsx("button",{className:`h-2 w-2 rounded-full transition-colors ${g===n?"bg-primary":"bg-muted-foreground/30"}`,onClick:()=>o(g),"aria-label":`Go to step ${g+1}`},g))}),t.jsxs("div",{className:"flex items-center justify-between pt-2",children:[t.jsx($,{variant:"ghost",size:"sm",onClick:s,children:"Skip"}),t.jsxs($,{size:"sm",onClick:r,children:[d?"Get Started":"Next",!d&&t.jsx(us,{className:"ml-1 h-4 w-4"})]})]})]})})}function _r(e){const{theme:a="system"}=Nt();return t.jsx($n,{theme:a,className:"toaster group",icons:{success:t.jsx(vt,{className:"h-4 w-4"}),info:t.jsx(ps,{className:"h-4 w-4"}),warning:t.jsx(va,{className:"h-4 w-4"}),error:t.jsx(ms,{className:"h-4 w-4"}),loading:t.jsx(Ie,{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 kr=i.lazy(()=>B(()=>import("./RecordDetailView-Bfu7541n.js"),__vite__mapDeps([17,1,15,9,8,3,10,11,4,2,12,16,14,18,19,20,21,22])).then(e=>({default:e.RecordDetailView}))),Fr=i.lazy(()=>B(()=>import("./DashboardView-Dt-4VhH6.js"),__vite__mapDeps([23,1,15,9,8,3,10,11,4,2,12,16,14,18,19,20,21,22])).then(e=>({default:e.DashboardView}))),Tr=i.lazy(()=>B(()=>import("./PageView-BRN1h8QD.js"),__vite__mapDeps([24,1,9,8,3,10,11,4,2,12,14,15,16,18,19,20,21,22])).then(e=>({default:e.PageView}))),Er=i.lazy(()=>B(()=>import("./ReportView-CwWsv2yl.js"),__vite__mapDeps([25,1,15,9,8,3,10,11,4,2,12,16,14,18,19,20,21,22])).then(e=>({default:e.ReportView}))),qt=i.lazy(()=>B(()=>import("./ViewDesignerPage-BbwrZa9D.js"),__vite__mapDeps([26,1,9,3,10])).then(e=>({default:e.ViewDesignerPage}))),Pr=i.lazy(()=>B(()=>import("./SearchResultsPage-DBpjAlh2.js"),__vite__mapDeps([27,1,8,9,3,10,11,4,2,12,14,15,16,18,19,20,21,22])).then(e=>({default:e.SearchResultsPage}))),Ar=i.lazy(()=>B(()=>import("./LoginPage-H688gsah.js"),__vite__mapDeps([28,1,21,4])).then(e=>({default:e.LoginPage}))),Mr=i.lazy(()=>B(()=>import("./RegisterPage-CR91Lc7x.js"),__vite__mapDeps([29,1,21,4])).then(e=>({default:e.RegisterPage}))),Or=i.lazy(()=>B(()=>import("./ForgotPasswordPage-zr9S5vrE.js"),__vite__mapDeps([30,1,21,4])).then(e=>({default:e.ForgotPasswordPage}))),Rr=i.lazy(()=>B(()=>import("./UserManagementPage-o0_K0dzR.js"),__vite__mapDeps([31,1,21,4,8,9,3,10,11,2,12,32])).then(e=>({default:e.UserManagementPage}))),Lr=i.lazy(()=>B(()=>import("./OrgManagementPage-x3qIkxHL.js"),__vite__mapDeps([33,1,21,4,8,9,3,10,11,2,12,32])).then(e=>({default:e.OrgManagementPage}))),Ir=i.lazy(()=>B(()=>import("./RoleManagementPage-DnWuzxKJ.js"),__vite__mapDeps([34,1,21,4,8,9,3,10,11,2,12,32])).then(e=>({default:e.RoleManagementPage}))),$r=i.lazy(()=>B(()=>import("./AuditLogPage-BQW_Xbnm.js"),__vite__mapDeps([35,1,8,9,3,10,11,4,2,12,32])).then(e=>({default:e.AuditLogPage}))),Vr=i.lazy(()=>B(()=>import("./ProfilePage-DjAiGvFb.js"),__vite__mapDeps([36,1,21,4,8,9,3,10,11,2,12])).then(e=>({default:e.ProfilePage})));function zr(){const[e,a]=i.useState(null),[n,o]=i.useState("disconnected"),{user:s}=ha(),r=ze(),c=lt(),[,l]=sa(),{appName:d}=_e(),h=Ne.apps||[],g=h.filter(w=>w.active!==!1),m=h.find(w=>w.name===d)||g.find(w=>w.isDefault===!0)||g[0],[y,b]=i.useState(!1),[p,v]=i.useState(null),[N,C]=i.useState(0),{addRecentItem:E}=ka();i.useEffect(()=>{let w=!1;async function F(){try{const T=new pa({baseUrl:"",autoReconnect:!0,maxReconnectAttempts:5,reconnectDelay:1e3,cache:{maxSize:50,ttl:3e5}});T.onConnectionStateChange(R=>{w||(o(R.state),R.error&&console.error("[Console] Connection error:",R.error))}),await T.connect(),w||a(T)}catch(T){w||(console.error("[Console] Failed to initialize:",T),o("error"))}}return F(),()=>{w=!0}},[]);const A=Ne.objects||[];let u=c.pathname.split("/").filter(w=>w)[2];(u==="view"||u==="record"||u==="page"||u==="dashboard")&&(u="");const x=A.find(w=>w.name===u);i.useEffect(()=>{if(!m)return;const w=c.pathname.split("/").filter(Boolean);let F=w[2];(F==="view"||F==="record"||F==="page"||F==="dashboard")&&(F="");const T=`/apps/${m.name}`,R=Ne.objects||[];if(F){const L=R.find(_=>_.name===F);L&&E({id:`object:${L.name}`,label:L.label||L.name,href:`${T}/${L.name}`,type:"object"})}else w[2]==="dashboard"&&w[3]?E({id:`dashboard:${w[3]}`,label:w[3].replace(/[-_]/g," ").replace(/\b\w/g,L=>L.toUpperCase()),href:`${T}/dashboard/${w[3]}`,type:"dashboard"}):w[2]==="report"&&w[3]&&E({id:`report:${w[3]}`,label:w[3].replace(/[-_]/g," ").replace(/\b\w/g,L=>L.toUpperCase()),href:`${T}/report/${w[3]}`,type:"report"})},[c.pathname,E]);const S=w=>{v(w),b(!0)},D=w=>{const F=w._id||w.id;F&&l(T=>{const R=new URLSearchParams(T);return R.set("recordId",F),R})},M=w=>{r(`/apps/${w}`)},O=i.useMemo(()=>new bt({user:s?{name:s.name,email:s.email,role:s.role??"user"}:{},app:m||{},data:p||{}}),[s,m,p]);if(!e)return t.jsx(ge,{});if(!m)return t.jsx("div",{className:"h-screen flex items-center justify-center",children:t.jsx(dt,{children:t.jsx(ut,{children:"No Apps Configured"})})});const k=s?{name:s.name,email:s.email,role:s.role??"user"}:{name:"Anonymous",email:"",role:"guest"};return t.jsx(Rs,{user:k,app:m,data:{},children:t.jsxs(er,{activeAppName:m.name,activeApp:m,onAppChange:M,objects:A,connectionState:n,children:[t.jsx(tr,{apps:h,activeApp:m,objects:A,onAppChange:M}),t.jsx(Cr,{}),t.jsx(Sr,{}),t.jsxs(In,{dataSource:e||{},children:[t.jsx(nr,{children:t.jsx(i.Suspense,{fallback:t.jsx(ge,{}),children:t.jsxs(ra,{children:[t.jsx(z,{path:"/",element:t.jsx(ct,{to:$a(m.navigation||[]),replace:!0})}),t.jsx(z,{path:":objectName",element:t.jsx(Gt,{dataSource:e,objects:A,onEdit:S,onRowClick:D})}),t.jsx(z,{path:":objectName/view/:viewId",element:t.jsx(Gt,{dataSource:e,objects:A,onEdit:S,onRowClick:D})}),t.jsx(z,{path:":objectName/record/:recordId",element:t.jsx(kr,{dataSource:e,objects:A,onEdit:S},N)}),t.jsx(z,{path:":objectName/views/new",element:t.jsx(qt,{objects:A})}),t.jsx(z,{path:":objectName/views/:viewId",element:t.jsx(qt,{objects:A})}),t.jsx(z,{path:"dashboard/:dashboardName",element:t.jsx(Fr,{dataSource:e})}),t.jsx(z,{path:"report/:reportName",element:t.jsx(Er,{dataSource:e})}),t.jsx(z,{path:"page/:pageName",element:t.jsx(Tr,{})}),t.jsx(z,{path:"search",element:t.jsx(Pr,{})}),t.jsx(z,{path:"system/users",element:t.jsx(Rr,{})}),t.jsx(z,{path:"system/organizations",element:t.jsx(Lr,{})}),t.jsx(z,{path:"system/roles",element:t.jsx(Ir,{})}),t.jsx(z,{path:"system/audit-log",element:t.jsx($r,{})}),t.jsx(z,{path:"system/profile",element:t.jsx(Vr,{})})]})})}),t.jsx(mt,{open:y,onOpenChange:b,children:t.jsxs(pt,{className:"h-[100dvh] sm:h-auto sm:max-w-xl sm:max-h-[90vh] flex flex-col gap-0 p-0 overflow-hidden w-[100vw] sm:w-full rounded-none sm:rounded-lg",children:[t.jsxs(ht,{className:"p-4 sm:p-6 pb-3 sm:pb-4 border-b",children:[t.jsx("div",{className:"mx-auto w-12 h-1.5 rounded-full bg-muted mb-2 sm:hidden"}),t.jsxs(gt,{className:"text-lg sm:text-xl",children:[p?"Edit":"Create"," ",x?.label]}),t.jsx(ft,{className:"text-sm",children:p?`Update details for ${x?.label}`:`Add a new ${x?.label} to your database.`})]}),t.jsx("div",{className:"flex-1 overflow-y-auto p-4 sm:p-6",children:x&&t.jsx(On,{schema:{type:"object-form",objectName:x.name,mode:p?"edit":"create",recordId:p?.id,layout:"vertical",columns:1,fields:x.fields?Array.isArray(x.fields)?x.fields.filter(w=>typeof w=="string"?!0:Ve(w.visible,O)).map(w=>typeof w=="string"?w:w.name):Object.entries(x.fields).filter(([w,F])=>Ve(F.visible,O)).map(([w])=>w):[],onSuccess:()=>{b(!1),C(w=>w+1),Ye.success(p?`${x?.label} updated successfully`:`${x?.label} created successfully`)},onCancel:()=>b(!1),showSubmit:!0,showCancel:!0,submitText:"Save Record",cancelText:"Cancel"},dataSource:e},p?.id||"new")})]})})]})]})})}function $a(e){if(!e||e.length===0)return"";for(const a of e){if(a.type==="object")return`${a.objectName}`;if(a.type==="page")return a.pageName?`page/${a.pageName}`:"";if(a.type==="dashboard")return a.dashboardName?`dashboard/${a.dashboardName}`:"";if(a.type!=="url"&&a.type==="group"&&a.children){const n=$a(a.children);if(n!=="")return n}}return""}function Br(){const a=(Ne.apps||[]).filter(o=>o.active!==!1),n=a.find(o=>o.isDefault===!0)||a[0];return n?t.jsx(ct,{to:`/apps/${n.name}`,replace:!0}):t.jsx(ge,{})}function Hr(){return t.jsxs(Hs,{defaultTheme:"system",storageKey:"object-ui-theme",children:[t.jsx(_r,{position:"bottom-right"}),t.jsx(Dr,{authUrl:"/api/auth",children:t.jsx(nn,{basename:"/".replace(/\/$/,"")||"/",children:t.jsx(i.Suspense,{fallback:t.jsx(ge,{}),children:t.jsxs(ra,{children:[t.jsx(z,{path:"/login",element:t.jsx(Ar,{})}),t.jsx(z,{path:"/register",element:t.jsx(Mr,{})}),t.jsx(z,{path:"/forgot-password",element:t.jsx(Or,{})}),t.jsx(z,{path:"/apps/:appName/*",element:t.jsx(zn,{fallback:t.jsx(ct,{to:"/login"}),loadingFallback:t.jsx(ge,{}),children:t.jsx(zr,{})})}),t.jsx(z,{path:"/",element:t.jsx(Br,{})})]})})})})]})}function Jt(){const e=typeof window<"u"?window.innerWidth:1024;return e<640?35:e<1024?50:60}function Ur({tasks:e,viewMode:a="month",startDate:n,endDate:o,onTaskClick:s,onViewChange:r,onAddClick:c,className:l}){const[d,h]=i.useState(new Date),[g,m]=i.useState(typeof window<"u"&&window.innerWidth<640?32:40),[y,b]=i.useState(Jt());i.useEffect(()=>{const u=()=>{m(window.innerWidth<640?32:40),b(Jt())};return window.addEventListener("resize",u),()=>window.removeEventListener("resize",u)},[]);const p=i.useMemo(()=>{let u=n?new Date(n):new Date,x=o?new Date(o):new Date;return!n&&e.length>0&&(u=new Date(Math.min(...e.map(S=>S.start.getTime()))),u.setDate(u.getDate()-7)),!o&&e.length>0&&(x=new Date(Math.max(...e.map(S=>S.end.getTime()))),x.setDate(x.getDate()+14)),u.setHours(0,0,0,0),x.setHours(23,59,59,999),{start:u,end:x}},[n,o,e]),v=i.useMemo(()=>{const u=[],x=new Date(p.start);for(;x<=p.end;)u.push({date:new Date(x),label:x.getDate().toString(),isWeekend:x.getDay()===0||x.getDay()===6}),x.setDate(x.getDate()+1);return u},[p]),N=300,C=i.useRef(null),E=i.useRef(null),A=i.useRef(null),P=u=>{C.current&&(C.current.scrollLeft=u.currentTarget.scrollLeft),E.current&&(E.current.scrollTop=u.currentTarget.scrollTop)},j=u=>{p.end.getTime()-p.start.getTime();const x=y,S=1e3*60*60*24,D=u.start.getTime()-p.start.getTime(),M=u.end.getTime()-u.start.getTime(),O=D/S*x,k=Math.max(M/S*x,x);return{left:O,width:k}};return t.jsxs("div",{className:I("flex flex-col h-full bg-background border rounded-lg overflow-hidden",l),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($,{variant:"outline",size:"sm",onClick:()=>c?.(),"aria-label":"Create new task",children:[t.jsx(Se,{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($,{variant:"ghost",size:"icon",className:"h-8 w-8",children:t.jsx(ja,{className:"h-4 w-4"})}),t.jsx($,{variant:"ghost",size:"icon",className:"h-8 w-8",children:t.jsx(He,{className:"h-4 w-4"})}),t.jsx("span",{className:"font-semibold text-xs sm:text-sm",children:p.start.toLocaleDateString(void 0,{month:"long",year:"numeric"})})]}),t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsxs(ca,{value:a,onValueChange:u=>r?.(u),children:[t.jsx(da,{className:"w-[100px] sm:w-[120px] h-8",children:t.jsx(ua,{})}),t.jsxs(ma,{children:[t.jsx(re,{value:"day",children:"Day View"}),t.jsx(re,{value:"week",children:"Week View"}),t.jsx(re,{value:"month",children:"Month View"}),t.jsx(re,{value:"quarter",children:"Quarter View"})]})]}),t.jsxs("div",{className:"flex bg-muted rounded-md p-1",children:[t.jsx($,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>b(u=>Math.max(15,u-10)),children:t.jsx(hs,{className:"h-3 w-3"})}),t.jsx($,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:()=>b(u=>Math.min(120,u+10)),children:t.jsx(gs,{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:N,minWidth:N},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:C,children:t.jsx("div",{className:"flex h-full",style:{width:v.length*y},children:v.map((u,x)=>t.jsxs("div",{className:I("flex flex-col items-center justify-center border-r text-xs text-muted-foreground h-full",u.isWeekend&&"bg-muted/50"),style:{width:y,minWidth:y},children:[t.jsx("span",{className:"font-medium text-foreground",children:u.label}),t.jsx("span",{className:"text-[10px] opacity-70",children:u.date.toLocaleDateString(void 0,{weekday:"narrow"})})]},x))})})]}),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:E,style:{width:N,minWidth:N},children:e.map(u=>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:()=>s?.(u),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:u.color||"#3b82f6"}}),u.title]}),t.jsx("div",{className:"w-16 sm:w-20 text-right text-xs text-muted-foreground hidden sm:block",children:u.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:u.end.toLocaleDateString(void 0,{month:"numeric",day:"numeric"})})]},u.id))}),t.jsx("div",{className:"flex-1 overflow-auto bg-background/50 relative [-webkit-overflow-scrolling:touch]",ref:A,onScroll:P,children:t.jsx("div",{style:{width:v.length*y},children:t.jsxs("div",{className:"relative",children:[t.jsx("div",{className:"absolute inset-0 flex pointer-events-none z-0",children:v.map((u,x)=>t.jsx("div",{className:I("border-r h-full",u.isWeekend&&"bg-muted/20"),style:{width:y,minWidth:y}},x))}),e.map(u=>{const x=j(u);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:x.left,width:x.width,backgroundColor:u.color||"#3b82f6"},onClick:()=>s?.(u),children:[u.progress>0&&t.jsx("div",{className:"absolute left-0 top-0 bottom-0 bg-black/20 rounded-l-sm",style:{width:`${u.progress}%`}}),t.jsxs("span",{className:"text-[10px] text-white font-medium truncate opacity-0 group-hover:opacity-100 transition-opacity",children:[Math.round(u.progress),"%"]})]})},u.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()-p.start.getTime())/(1e3*60*60*24)*y},children:t.jsx("div",{className:"w-2 h-2 rounded-full bg-red-500 -ml-[3px]"})})]})})})]})]})]})}function Wr(e){return e.data?e.data:e.staticData?{provider:"value",items:e.staticData}:e.objectName?{provider:"object",object:e.objectName}:null}function Gr(e){if(e){if(typeof e=="string"){const a=e.split(" "),n=a[0],o=a[1]?.toLowerCase()==="desc"?"desc":"asc";return{[n]:o}}if(Array.isArray(e))return e.reduce((a,n)=>(n.field&&n.order&&(a[n.field]=n.order),a),{})}}function Kr(e){let a=null;if(e.startDateField&&e.endDateField)return a={startDateField:e.startDateField,endDateField:e.endDateField,titleField:e.titleField||"name",progressField:e.progressField,dependenciesField:e.dependenciesField||e.dependencyField,colorField:e.colorField},a;if(e.gantt&&(a=e.gantt),a){const n=Vn.safeParse(a);return n.success||console.warn("[ObjectGantt] Invalid gantt configuration:",n.error.format()),a}return null}const qr=({schema:e,dataSource:a,className:n,onTaskClick:o,onRowClick:s,...r})=>{const[c,l]=i.useState([]),[d,h]=i.useState(!0),[g,m]=i.useState(null),[y,b]=i.useState(null),p=Wr(e),v=i.useMemo(()=>p,[JSON.stringify(p)]),N=Kr(e),C=v?.provider==="value";i.useEffect(()=>{(async()=>{try{if(h(!0),r.data&&Array.isArray(r.data)){l(r.data),h(!1);return}if(C&&v?.provider==="value"){l(v.items),h(!1);return}if(!a)throw new Error("DataSource required for object/api providers");if(v?.provider==="object"){const j=v.object,u=await a.find(j,{$filter:e.filter,$orderby:Gr(e.sort)});let x=[];Array.isArray(u)?x=u:u&&typeof u=="object"&&(Array.isArray(u.data)?x=u.data:Array.isArray(u.records)&&(x=u.records)),l(x)}else v?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectGantt"),l([]));h(!1)}catch(j){m(j),h(!1)}})()},[v,a,C,e.filter,e.sort]),i.useEffect(()=>{!C&&a&&(async()=>{try{if(!a)return;const j=v?.provider==="object"?v.object:e.objectName;if(!j)return;const u=await a.getObjectSchema(j);b(u)}catch(j){console.error("Failed to fetch object schema:",j)}})()},[e.objectName,a,C,v]);const E=i.useMemo(()=>{if(!N||!c.length)return[];const{startDateField:P,endDateField:j,titleField:u,progressField:x,dependenciesField:S,colorField:D}=N;return c.map((M,O)=>{const k=M[P],w=M[j],F=M[u]||"Untitled Task",T=x?M[x]:0,R=S?M[S]:[],L=D?M[D]:void 0;return{id:M.id||M._id||`task-${O}`,title:F,start:k?new Date(k):new Date,end:w?new Date(w):new Date,progress:Math.min(100,Math.max(0,T||0)),dependencies:Array.isArray(R)?R:[],color:L,data:M}}).filter(M=>!isNaN(M.start.getTime())&&!isNaN(M.end.getTime()))},[c,N]),A=Te({navigation:e.navigation,objectName:e.objectName,onRowClick:s});return d?t.jsx("div",{className:n,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsx("div",{className:"text-muted-foreground",children:"Loading Gantt chart..."})})}):g?t.jsx("div",{className:n,children:t.jsx("div",{className:"flex items-center justify-center h-96",children:t.jsxs("div",{className:"text-destructive",children:["Error: ",g.message]})})}):N?t.jsxs("div",{className:n,children:[t.jsx("div",{className:"h-[calc(100vh-200px)] min-h-[600px]",children:t.jsx(Ur,{tasks:E,onTaskClick:P=>{A.handleClick(P.data),o?.(P.data)},onAddClick:()=>{}})}),A.isOverlay&&t.jsx(Fe,{...A,title:"Task Details",children:P=>t.jsx("div",{className:"space-y-3",children:Object.entries(P).map(([j,u])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:j.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(u??"—")})]},j))})})]}):t.jsx("div",{className:n,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."})})})},Va=({schema:e})=>{const{dataSource:a}=be();return t.jsx(qr,{schema:e,dataSource:a})};V.register("object-gantt",Va,{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"}]});V.register("gantt",Va,{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 Jr=10080*60*1e3;function Yr(e){const a=e.flatMap(s=>(s.items||[]).flatMap(r=>[r.startDate,r.endDate])),n=Math.min(...a.map(s=>new Date(s).getTime())),o=Math.max(...a.map(s=>new Date(s).getTime()));return{minDate:new Date(n).toISOString().split("T")[0],maxDate:new Date(o).toISOString().split("T")[0]}}function Qr(e,a,n,o){const s=new Date(e).getTime(),r=new Date(a).getTime(),c=new Date(n).getTime(),d=new Date(o).getTime()-c,h=s-c,g=r-s;return{start:h/d*100,width:g/d*100}}function Ae(e,a){const n=new Date(e);return a==="short"?n.toLocaleDateString():a==="long"?n.toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"}):n.toISOString().split("T")[0]}const za=({schema:e,className:a,...n})=>{const{variant:o="vertical",items:s=[],dateFormat:r="short",onItemClick:c}=e;if(o==="vertical")return t.jsx(Ba,{className:a,...n,children:s.map((l,d)=>t.jsxs(Ha,{className:I(l.className,c&&"cursor-pointer"),onClick:()=>c?.(l),children:[t.jsx(tt,{variant:l.variant||"default",children:l.icon&&t.jsx("span",{className:"text-xs",children:l.icon})}),t.jsxs(Ua,{children:[l.time&&t.jsx(nt,{dateTime:l.time,children:Ae(l.time,r)}),l.title&&t.jsx(at,{children:l.title}),l.description&&t.jsx(st,{className:"line-clamp-2 sm:line-clamp-none",children:l.description}),l.content&&Pt(l.content)]})]},d))});if(o==="horizontal")return t.jsx(Wa,{className:I("overflow-x-auto [-webkit-overflow-scrolling:touch]",a),...n,children:s.map((l,d)=>t.jsxs(Ga,{className:I(l.className,c&&"cursor-pointer"),onClick:()=>c?.(l),children:[t.jsxs("div",{className:"flex flex-col items-center",children:[t.jsx(tt,{variant:l.variant||"default",children:l.icon&&t.jsx("span",{className:"text-xs",children:l.icon})}),t.jsxs("div",{className:"mt-4 text-center",children:[l.time&&t.jsx(nt,{dateTime:l.time,children:Ae(l.time,r)}),l.title&&t.jsx(at,{children:l.title}),l.description&&t.jsx(st,{className:"text-center line-clamp-2 sm:line-clamp-none",children:l.description}),l.content&&Pt(l.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 l=Yr(s),d=e.minDate||l.minDate,h=e.maxDate||l.maxDate,g=e.timeScale||"month",y=(()=>{const b=[],p=new Date(d),v=new Date(h);if(g==="month"){const N=new Date(p);for(;N<=v;)b.push(N.toLocaleDateString("en-US",{month:"short",year:"numeric"})),N.setMonth(N.getMonth()+1)}else if(g==="week"){const N=new Date(p);for(;N<=v;)b.push(`Week ${Math.ceil((N.getTime()-p.getTime())/Jr)+1}`),N.setDate(N.getDate()+7)}else if(g==="day"){const N=new Date(p);for(;N<=v;)b.push(N.toLocaleDateString("en-US",{month:"short",day:"numeric"})),N.setDate(N.getDate()+1)}return b})();return t.jsxs(Ka,{className:I("overflow-x-auto [-webkit-overflow-scrolling:touch]",a),...n,children:[t.jsxs(qa,{children:[t.jsx(rt,{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(ot,{children:t.jsx("div",{className:"flex h-full",children:y.map((b,p)=>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:b},p))})})]}),t.jsx("div",{children:t.jsxs("div",{className:"flex",children:[t.jsx(rt,{children:s.map((b,p)=>t.jsx(it,{children:t.jsx(Ja,{title:b.label,className:"truncate",children:b.label})},p))}),t.jsx(ot,{className:"relative",children:s.map((b,p)=>t.jsx(it,{className:"relative",children:(b.items||[]).map((v,N)=>{const C=Qr(v.startDate,v.endDate,d,h);return t.jsx(Ya,{start:C.start,width:C.width,variant:v.variant||"default",onClick:()=>c?.(v,b,p,N),title:`${v.title||""}
50
+ ${Ae(v.startDate,r)} - ${Ae(v.endDate,r)}`,children:t.jsx(Qa,{children:v.title})},N)})},p))})]})})]})}return null};V.register("timeline",za,{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 Zr=jt({title:q().optional(),date:q().optional(),description:q().optional(),variant:q().optional()}),Xr=jt({mapping:Zr.optional(),objectName:q().optional(),titleField:q().optional(),dateField:q().optional(),descriptionField:q().optional()}),eo=({schema:e,dataSource:a,className:n,onRowClick:o,onItemClick:s,...r})=>{const[c,l]=i.useState([]),[d,h]=i.useState(!1),[g,m]=i.useState(null),[y,b]=i.useState(0);i.useEffect(()=>{const x=Xr.safeParse(e);x.success||console.warn("[ObjectTimeline] Invalid timeline configuration:",x.error.format())},[e]);const p=xt(e.bind);i.useEffect(()=>{const x=async()=>{if(!(!a||!e.objectName)){h(!0);try{const S=await a.find(e.objectName,{options:{$top:100}});let D=S;S.records?D=S.records:S.data&&(D=S.data),Array.isArray(D)&&l(D)}catch(S){console.error(S),m(S)}finally{h(!1)}}};e.objectName&&!p&&!e.items&&!r.data&&x()},[e.objectName,a,p,e.items,r.data,y]);const v=r.data||p||c;let N=e.items;if(!N&&v&&Array.isArray(v)){const x=e.mapping?.title||e.titleField||"name",S=e.mapping?.date||e.dateField||"date",D=e.mapping?.description||e.descriptionField||"description",M=e.mapping?.variant||"variant";N=v.map(O=>({title:O[x],time:O[S],startDate:O[S],endDate:O[S],description:O[D],variant:O[M]||"default",_data:O}))}const C=i.useCallback(async()=>{b(x=>x+1)},[]),{ref:E,isRefreshing:A,pullDistance:P}=Da({onRefresh:C,enabled:!!e.objectName&&!!a}),j=Te({navigation:e.navigation,objectName:e.objectName,onRowClick:o??s}),u={...e,items:N||[],className:n||e.className,onItemClick:x=>{const S=x._data||x;j.handleClick(S),s?.(S)}};return g?t.jsxs("div",{className:"p-4 text-red-500",children:["Error loading timeline: ",g.message]}):t.jsxs("div",{ref:E,className:"relative overflow-auto h-full",children:[P>0&&t.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:P},children:A?"Refreshing…":"Pull to refresh"}),t.jsx(za,{schema:u}),j.isOverlay&&t.jsx(Fe,{...j,title:"Timeline Item",children:x=>t.jsx("div",{className:"space-y-3",children:Object.entries(x).map(([S,D])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:S.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(D??"—")})]},S))})})]})},Ba=i.forwardRef(({className:e,...a},n)=>t.jsx("ol",{ref:n,className:I("relative border-l border-gray-200",e),...a}));Ba.displayName="Timeline";const Ha=i.forwardRef(({className:e,...a},n)=>t.jsx("li",{ref:n,className:I("mb-10 ml-6",e),...a}));Ha.displayName="TimelineItem";const tt=i.forwardRef(({className:e,variant:a="default",...n},o)=>{const s={default:"bg-gray-200 border-gray-300",success:"bg-green-200 border-green-500",warning:"bg-yellow-200 border-yellow-500",danger:"bg-red-200 border-red-500",info:"bg-blue-200 border-blue-500"};return t.jsx("div",{ref:o,className:I("absolute -left-3 w-6 h-6 rounded-full border-2 flex items-center justify-center",s[a],e),...n})});tt.displayName="TimelineMarker";const Ua=i.forwardRef(({className:e,...a},n)=>t.jsx("div",{ref:n,className:e,...a}));Ua.displayName="TimelineContent";const at=i.forwardRef(({className:e,...a},n)=>t.jsx("h3",{ref:n,className:I("font-semibold text-lg mb-1",e),...a}));at.displayName="TimelineTitle";const nt=i.forwardRef(({className:e,...a},n)=>t.jsx("time",{ref:n,className:I("text-sm font-normal text-gray-500 mb-2 block",e),...a}));nt.displayName="TimelineTime";const st=i.forwardRef(({className:e,...a},n)=>t.jsx("p",{ref:n,className:I("text-base text-gray-700",e),...a}));st.displayName="TimelineDescription";const Wa=i.forwardRef(({className:e,...a},n)=>t.jsx("div",{ref:n,className:I("relative flex overflow-x-auto py-8",e),...a}));Wa.displayName="TimelineHorizontal";const Ga=i.forwardRef(({className:e,...a},n)=>t.jsx("div",{ref:n,className:I("flex-shrink-0 w-64 relative",e),...a}));Ga.displayName="TimelineHorizontalItem";const Ka=i.forwardRef(({className:e,...a},n)=>t.jsx("div",{ref:n,className:I("relative w-full border rounded-lg overflow-hidden",e),...a}));Ka.displayName="TimelineGantt";const qa=i.forwardRef(({className:e,...a},n)=>t.jsx("div",{ref:n,className:I("flex border-b bg-gray-50",e),...a}));qa.displayName="TimelineGanttHeader";const rt=i.forwardRef(({className:e,...a},n)=>t.jsx("div",{ref:n,className:I("w-48 border-r bg-white",e),...a}));rt.displayName="TimelineGanttRowLabels";const ot=i.forwardRef(({className:e,...a},n)=>t.jsx("div",{ref:n,className:I("flex-1 overflow-x-auto",e),...a}));ot.displayName="TimelineGanttGrid";const it=i.forwardRef(({className:e,...a},n)=>t.jsx("div",{ref:n,className:I("flex items-center border-b min-h-12",e),...a}));it.displayName="TimelineGanttRow";const Ja=i.forwardRef(({className:e,...a},n)=>t.jsx("div",{ref:n,className:I("px-4 py-2 font-medium text-sm truncate",e),...a}));Ja.displayName="TimelineGanttLabel";const Ya=i.forwardRef(({className:e,start:a=0,width:n=100,variant:o="default",...s},r)=>{const c={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:I("absolute h-8 rounded-md transition-colors cursor-pointer",c[o],e),style:{left:`${a}%`,width:`${n}%`},...s})});Ya.displayName="TimelineGanttBar";const Qa=i.forwardRef(({className:e,...a},n)=>t.jsx("div",{ref:n,className:I("px-2 py-1 text-white text-xs font-medium truncate",e),...a}));Qa.displayName="TimelineGanttBarContent";const Za=({schema:e,...a})=>{const{dataSource:n}=be();return t.jsx(eo,{schema:e,dataSource:n,...a})};V.register("object-timeline",Za,{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"}]});V.register("timeline",Za,{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 to=i.createContext(null);function ao(e,a){const n=Array.isArray(e)?e[0]:e?e.x:0,o=Array.isArray(e)?e[1]:e?e.y:0,s=Array.isArray(a)?a[0]:a?a.x:0,r=Array.isArray(a)?a[1]:a?a.y:0;return n===s&&o===r}function Q(e,a){if(e===a)return!0;if(!e||!a)return!1;if(Array.isArray(e)){if(!Array.isArray(a)||e.length!==a.length)return!1;for(let n=0;n<e.length;n++)if(!Q(e[n],a[n]))return!1;return!0}else if(Array.isArray(a))return!1;if(typeof e=="object"&&typeof a=="object"){const n=Object.keys(e),o=Object.keys(a);if(n.length!==o.length)return!1;for(const s of n)if(!a.hasOwnProperty(s)||!Q(e[s],a[s]))return!1;return!0}return!1}function Yt(e){return{longitude:e.center.lng,latitude:e.center.lat,zoom:e.zoom,pitch:e.pitch,bearing:e.bearing,padding:e.padding}}function Qt(e,a){const n=a.viewState||a,o={};if("longitude"in n&&"latitude"in n&&(n.longitude!==e.center.lng||n.latitude!==e.center.lat)){const s=e.center.constructor;o.center=new s(n.longitude,n.latitude)}return"zoom"in n&&n.zoom!==e.zoom&&(o.zoom=n.zoom),"bearing"in n&&n.bearing!==e.bearing&&(o.bearing=n.bearing),"pitch"in n&&n.pitch!==e.pitch&&(o.pitch=n.pitch),n.padding&&e.padding&&!Q(n.padding,e.padding)&&(o.padding=n.padding),o}const no=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function Zt(e){if(!e)return null;if(typeof e=="string"||("toJS"in e&&(e=e.toJS()),!e.layers))return e;const a={};for(const o of e.layers)a[o.id]=o;const n=e.layers.map(o=>{let s=null;"interactive"in o&&(s=Object.assign({},o),delete s.interactive);const r=a[o.ref];if(r){s=s||Object.assign({},o),delete s.ref;for(const c of no)c in r&&(s[c]=r[c])}return s||o});return{...e,layers:n}}const Xt={version:8,sources:{},layers:[]},ea={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"},ta={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"},aa={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"},so=["minZoom","maxZoom","minPitch","maxPitch","maxBounds","projection","renderWorldCopies"],ro=["scrollZoom","boxZoom","dragRotate","dragPan","keyboard","doubleClickZoom","touchZoomRotate","touchPitch"];class fe{constructor(a,n,o){this._map=null,this._internalUpdate=!1,this._hoveredFeatures=null,this._propsedCameraUpdate=null,this._styleComponents={},this._onEvent=s=>{const r=this.props[aa[s.type]];r?r(s):s.type==="error"&&console.error(s.error)},this._onCameraEvent=s=>{if(this._internalUpdate)return;s.viewState=this._propsedCameraUpdate||Yt(this._map.transform);const r=this.props[ta[s.type]];r&&r(s)},this._onCameraUpdate=s=>this._internalUpdate?s:(this._propsedCameraUpdate=Yt(s),Qt(s,this.props)),this._onPointerEvent=s=>{(s.type==="mousemove"||s.type==="mouseout")&&this._updateHover(s);const r=this.props[ea[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=a,this.props=n,this._initialize(o)}get map(){return this._map}setProps(a){const n=this.props;this.props=a;const o=this._updateSettings(a,n),s=this._updateSize(a),r=this._updateViewState(a);this._updateStyle(a,n),this._updateStyleComponents(a),this._updateHandlers(a,n),(o||s||r&&!this._map.isMoving())&&this.redraw()}static reuse(a,n){const o=fe.savedMaps.pop();if(!o)return null;const s=o.map,r=s.getContainer();for(n.className=r.className;r.childNodes.length>0;)n.appendChild(r.childNodes[0]);s._container=n;const c=s._resizeObserver;c&&(c.disconnect(),c.observe(n)),o.setProps({...a,styleDiffing:!1}),s.resize();const{initialViewState:l}=a;return l&&(l.bounds?s.fitBounds(l.bounds,{...l.fitBoundsOptions,duration:0}):o._updateViewState(l)),s.isStyleLoaded()?s.fire("load"):s.once("style.load",()=>s.fire("load")),s._update(),o}_initialize(a){const{props:n}=this,{mapStyle:o=Xt}=n,s={...n,...n.initialViewState,container:a,style:Zt(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}),n.gl){const l=HTMLCanvasElement.prototype.getContext;HTMLCanvasElement.prototype.getContext=()=>(HTMLCanvasElement.prototype.getContext=l,n.gl)}const c=new this._MapClass(s);r.padding&&c.setPadding(r.padding),n.cursor&&(c.getCanvas().style.cursor=n.cursor),c.transformCameraUpdate=this._onCameraUpdate,c.on("style.load",()=>{this._styleComponents={light:c.getLight(),sky:c.getSky(),projection:c.getProjection?.(),terrain:c.getTerrain()},this._updateStyleComponents(this.props)}),c.on("sourcedata",()=>{this._updateStyleComponents(this.props)});for(const l in ea)c.on(l,this._onPointerEvent);for(const l in ta)c.on(l,this._onCameraEvent);for(const l in aa)c.on(l,this._onEvent);this._map=c}recycle(){this.map.getContainer().querySelector("[mapboxgl-children]")?.remove(),fe.savedMaps.push(this)}destroy(){this._map.remove()}redraw(){const a=this._map;a.style&&(a._frame&&(a._frame.cancel(),a._frame=null),a._render())}_updateSize(a){const{viewState:n}=a;if(n){const o=this._map;if(n.width!==o.transform.width||n.height!==o.transform.height)return o.resize(),!0}return!1}_updateViewState(a){const n=this._map,o=n.transform;if(!n.isMoving()){const r=Qt(o,a);if(Object.keys(r).length>0)return this._internalUpdate=!0,n.jumpTo(r),this._internalUpdate=!1,!0}return!1}_updateSettings(a,n){const o=this._map;let s=!1;for(const r of so)r in a&&!Q(a[r],n[r])&&(s=!0,o[`set${r[0].toUpperCase()}${r.slice(1)}`]?.call(o,a[r]));return s}_updateStyle(a,n){if(a.cursor!==n.cursor&&(this._map.getCanvas().style.cursor=a.cursor||""),a.mapStyle!==n.mapStyle){const{mapStyle:o=Xt,styleDiffing:s=!0}=a,r={diff:s};"localIdeographFontFamily"in a&&(r.localIdeographFontFamily=a.localIdeographFontFamily),this._map.setStyle(Zt(o),r)}}_updateStyleComponents({light:a,projection:n,sky:o,terrain:s}){const r=this._map,c=this._styleComponents;r.style._loaded&&(a&&!Q(a,c.light)&&(c.light=a,r.setLight(a)),n&&!Q(n,c.projection)&&n!==c.projection?.type&&(c.projection=typeof n=="string"?{type:n}:n,r.setProjection?.(c.projection)),o&&!Q(o,c.sky)&&(c.sky=o,r.setSky(o)),s!==void 0&&!Q(s,c.terrain)&&(!s||r.getSource(s.source))&&(c.terrain=s,r.setTerrain(s)))}_updateHandlers(a,n){const o=this._map;for(const s of ro){const r=a[s]??!0,c=n[s]??!0;Q(r,c)||(r?o[s].enable(r):o[s].disable())}}_queryRenderedFeatures(a){const n=this._map,{interactiveLayerIds:o=[]}=this.props;try{return n.queryRenderedFeatures(a,{layers:o.filter(n.getLayer.bind(n))})}catch{return[]}}_updateHover(a){const{props:n}=this;if(n.interactiveLayerIds&&(n.onMouseMove||n.onMouseEnter||n.onMouseLeave)){const s=a.type,r=this._hoveredFeatures?.length>0,c=this._queryRenderedFeatures(a.point),l=c.length>0;!l&&r&&(a.type="mouseleave",this._onPointerEvent(a)),this._hoveredFeatures=c,l&&!r&&(a.type="mouseenter",this._onPointerEvent(a)),a.type=s}else this._hoveredFeatures=null}}fe.savedMaps=[];const oo=["setMaxBounds","setMinZoom","setMaxZoom","setMinPitch","setMaxPitch","setRenderWorldCopies","setProjection","setStyle","addSource","removeSource","addLayer","removeLayer","setLayerZoomRange","setFilter","setPaintProperty","setLayoutProperty","setLight","setTerrain","setFog","remove"];function io(e){if(!e)return null;const a=e.map,n={getMap:()=>a};for(const o of lo(a))!(o in n)&&!oo.includes(o)&&(n[o]=a[o].bind(a));return n}function lo(e){const a=new Set;let n=e;for(;n;){for(const o of Object.getOwnPropertyNames(n))o[0]!=="_"&&typeof e[o]=="function"&&o!=="fire"&&o!=="setEventedParent"&&a.add(o);n=Object.getPrototypeOf(n)}return Array.from(a)}const co=typeof document<"u"?i.useLayoutEffect:i.useEffect;function uo(e,a){const{RTLTextPlugin:n,maxParallelImageRequests:o,workerCount:s,workerUrl:r}=a;if(n&&e.getRTLTextPluginStatus&&e.getRTLTextPluginStatus()==="unavailable"){const{pluginUrl:c,lazy:l=!0}=typeof n=="string"?{pluginUrl:n}:n;e.setRTLTextPlugin(c,d=>{d&&console.error(d)},l)}o!==void 0&&e.setMaxParallelImageRequests(o),s!==void 0&&e.setWorkerCount(s),r!==void 0&&e.setWorkerUrl(r)}const Ue=i.createContext(null);function mo(e,a){const n=i.useContext(to),[o,s]=i.useState(null),r=i.useRef(),{current:c}=i.useRef({mapLib:null,map:null});i.useEffect(()=>{const h=e.mapLib;let g=!0,m;return Promise.resolve(h||B(()=>import("./maplibre-gl-D2AsLM0J.js").then(y=>y.m),__vite__mapDeps([37,1]))).then(y=>{if(!g)return;if(!y)throw new Error("Invalid mapLib");const b="Map"in y?y:y.default;if(!b.Map)throw new Error("Invalid mapLib");uo(b,e),e.reuseMaps&&(m=fe.reuse(e,r.current)),m||(m=new fe(b.Map,e,r.current)),c.map=io(m),c.mapLib=b,s(m),n?.onMapMount(c.map,e.id)}).catch(y=>{const{onError:b}=e;b?b({type:"error",target:null,originalEvent:null,error:y}):console.error(y)}),()=>{g=!1,m&&(n?.onMapUnmount(e.id),e.reuseMaps?m.recycle():m.destroy())}},[]),co(()=>{o&&o.setProps(e)}),i.useImperativeHandle(a,()=>c.map,[o]);const l=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:l},o&&i.createElement(Ue.Provider,{value:c},i.createElement("div",{"mapboxgl-children":"",style:d},e.children)))}const po=i.forwardRef(mo),ho=/box|flex|grid|column|lineHeight|fontWeight|opacity|order|tabSize|zIndex/;function ee(e,a){if(!e||!a)return;const n=e.style;for(const o in a){const s=a[o];Number.isFinite(s)&&!ho.test(o)?n[o]=`${s}px`:n[o]=s}}function Xa(e,a){if(e===a)return null;const n=na(e),o=na(a),s=[];for(const r of o)n.has(r)||s.push(r);for(const r of n)o.has(r)||s.push(r);return s.length===0?null:s}function na(e){return new Set(e?e.trim().split(/\s+/):[])}const go=i.memo(i.forwardRef((e,a)=>{const{map:n,mapLib:o}=i.useContext(Ue),s=i.useRef({props:e}),r=i.useMemo(()=>{let C=!1;i.Children.forEach(e.children,P=>{P&&(C=!0)});const E={...e,element:C?document.createElement("div"):void 0},A=new o.Marker(E);return A.setLngLat([e.longitude,e.latitude]),A.getElement().addEventListener("click",P=>{s.current.props.onClick?.({type:"click",target:A,originalEvent:P})}),A.on("dragstart",P=>{const j=P;j.lngLat=r.getLngLat(),s.current.props.onDragStart?.(j)}),A.on("drag",P=>{const j=P;j.lngLat=r.getLngLat(),s.current.props.onDrag?.(j)}),A.on("dragend",P=>{const j=P;j.lngLat=r.getLngLat(),s.current.props.onDragEnd?.(j)}),A},[]);i.useEffect(()=>(r.addTo(n.getMap()),()=>{r.remove()}),[]);const{longitude:c,latitude:l,offset:d,style:h,draggable:g=!1,popup:m=null,rotation:y=0,rotationAlignment:b="auto",pitchAlignment:p="auto"}=e;i.useEffect(()=>{ee(r.getElement(),h)},[h]),i.useImperativeHandle(a,()=>r,[]);const v=s.current.props;(r.getLngLat().lng!==c||r.getLngLat().lat!==l)&&r.setLngLat([c,l]),d&&!ao(r.getOffset(),d)&&r.setOffset(d),r.isDraggable()!==g&&r.setDraggable(g),r.getRotation()!==y&&r.setRotation(y),r.getRotationAlignment()!==b&&r.setRotationAlignment(b),r.getPitchAlignment()!==p&&r.setPitchAlignment(p),r.getPopup()!==m&&r.setPopup(m);const N=Xa(v.className,e.className);if(N)for(const C of N)r.toggleClassName(C);return s.current.props=e,oa.createPortal(e.children,r.getElement())})),fo=i.memo(i.forwardRef((e,a)=>{const{map:n,mapLib:o}=i.useContext(Ue),s=i.useMemo(()=>document.createElement("div"),[]),r=i.useRef({props:e}),c=i.useMemo(()=>{const l={...e},d=new o.Popup(l);return d.setLngLat([e.longitude,e.latitude]),d.once("open",h=>{r.current.props.onOpen?.(h)}),d},[]);if(i.useEffect(()=>{const l=d=>{r.current.props.onClose?.(d)};return c.on("close",l),c.setDOMContent(s).addTo(n.getMap()),()=>{c.off("close",l),c.isOpen()&&c.remove()}},[]),i.useEffect(()=>{ee(c.getElement(),e.style)},[e.style]),i.useImperativeHandle(a,()=>c,[]),c.isOpen()){const l=r.current.props;(c.getLngLat().lng!==e.longitude||c.getLngLat().lat!==e.latitude)&&c.setLngLat([e.longitude,e.latitude]),e.offset&&!Q(l.offset,e.offset)&&c.setOffset(e.offset),(l.anchor!==e.anchor||l.maxWidth!==e.maxWidth)&&(c.options.anchor=e.anchor,c.setMaxWidth(e.maxWidth));const d=Xa(l.className,e.className);if(d)for(const h of d)c.toggleClassName(h);r.current.props=e}return oa.createPortal(e.children,s)}));function me(e,a,n,o){const s=i.useContext(Ue),r=i.useMemo(()=>e(s),[]);return i.useEffect(()=>{const c=a,l=null,d=typeof a=="function"?a:null,{map:h}=s;return h.hasControl(r)||(h.addControl(r,c?.position),l&&l(s)),()=>{d&&d(s),h.hasControl(r)&&h.removeControl(r)}},[]),r}function bo(e){const a=me(({mapLib:n})=>new n.AttributionControl(e),{position:e.position});return i.useEffect(()=>{ee(a._container,e.style)},[e.style]),null}i.memo(bo);function xo(e){const a=me(({mapLib:n})=>new n.FullscreenControl({container:e.containerId&&document.getElementById(e.containerId)}),{position:e.position});return i.useEffect(()=>{ee(a._controlContainer,e.style)},[e.style]),null}i.memo(xo);function yo(e,a){const n=i.useRef({props:e}),o=me(({mapLib:s})=>{const r=new s.GeolocateControl(e),c=r._setupUI;return r._setupUI=()=>{r._container.hasChildNodes()||c()},r.on("geolocate",l=>{n.current.props.onGeolocate?.(l)}),r.on("error",l=>{n.current.props.onError?.(l)}),r.on("outofmaxbounds",l=>{n.current.props.onOutOfMaxBounds?.(l)}),r.on("trackuserlocationstart",l=>{n.current.props.onTrackUserLocationStart?.(l)}),r.on("trackuserlocationend",l=>{n.current.props.onTrackUserLocationEnd?.(l)}),r},{position:e.position});return n.current.props=e,i.useImperativeHandle(a,()=>o,[]),i.useEffect(()=>{ee(o._container,e.style)},[e.style]),null}i.memo(i.forwardRef(yo));function vo(e){const a=me(({mapLib:n})=>new n.NavigationControl(e),{position:e.position});return i.useEffect(()=>{ee(a._container,e.style)},[e.style]),null}const jo=i.memo(vo);function wo(e){const a=me(({mapLib:r})=>new r.ScaleControl(e),{position:e.position}),n=i.useRef(e),o=n.current;n.current=e;const{style:s}=e;return e.maxWidth!==void 0&&e.maxWidth!==o.maxWidth&&(a.options.maxWidth=e.maxWidth),e.unit!==void 0&&e.unit!==o.unit&&a.setUnit(e.unit),i.useEffect(()=>{ee(a._container,s)},[s]),null}i.memo(wo);function No(e){const a=me(({mapLib:n})=>new n.TerrainControl(e),{position:e.position});return i.useEffect(()=>{ee(a._container,e.style)},[e.style]),null}i.memo(No);function Do(e){const a=me(({mapLib:n})=>new n.LogoControl(e),{position:e.position});return i.useEffect(()=>{ee(a._container,e.style)},[e.style]),null}i.memo(Do);const Co=jt({latitudeField:q().optional(),longitudeField:q().optional(),locationField:q().optional(),titleField:q().optional(),descriptionField:q().optional(),zoom:Ke().optional(),center:ys([Ke(),Ke()]).optional()});function So(e){return e.data?e.data:e.staticData?{provider:"value",items:e.staticData}:e.objectName?{provider:"object",object:e.objectName}:null}function _o(e){if(e){if(typeof e=="string"){const a=e.split(" "),n=a[0],o=a[1]?.toLowerCase()==="desc"?"desc":"asc";return{[n]:o}}if(Array.isArray(e))return e.reduce((a,n)=>(n.field&&n.order&&(a[n.field]=n.order),a),{})}}function ko(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 a=null;if(e.filter&&typeof e.filter=="object"&&"map"in e.filter?a=e.filter.map:e.map&&(a=e.map),a){const n=Co.safeParse(a);return n.success||console.warn("[ObjectMap] Invalid map configuration:",n.error.format()),a}return{latitudeField:"latitude",longitudeField:"longitude",locationField:"location",titleField:"name",descriptionField:"description",zoom:10,center:[0,0]}}function Fo(e,a){if(a.latitudeField&&a.longitudeField){const n=e[a.latitudeField],o=e[a.longitudeField];if(typeof n=="number"&&typeof o=="number")return[n,o]}if(a.locationField){const n=e[a.locationField];if(typeof n=="object"&&n!==null){const o=n.lat||n.latitude,s=n.lng||n.lon||n.longitude;if(typeof o=="number"&&typeof s=="number")return[o,s]}if(typeof n=="string"){const o=n.split(",").map(s=>parseFloat(s.trim()));if(o.length===2&&!isNaN(o[0])&&!isNaN(o[1]))return[o[0],o[1]]}if(Array.isArray(n)&&n.length===2){const o=parseFloat(n[0]),s=parseFloat(n[1]);if(!isNaN(o)&&!isNaN(s))return[o,s]}}return null}const To=({schema:e,dataSource:a,className:n,onMarkerClick:o,onRowClick:s,onEdit:r,onDelete:c,...l})=>{const[d,h]=i.useState([]),[g,m]=i.useState(!0),[y,b]=i.useState(null),[p,v]=i.useState(null),[N,C]=i.useState(null),[E,A]=i.useState(""),P=So(e),j=i.useMemo(()=>P,[JSON.stringify(P)]),u=ko(e),x=j?.provider==="value";i.useEffect(()=>{(async()=>{try{if(m(!0),l.data){const T=l.data;if(Array.isArray(T)){h(T),m(!1);return}}if(e.data){const T=e.data;if(Array.isArray(T)){h(T),m(!1);return}}if(x&&j?.provider==="value"){h(j.items),m(!1);return}if(!a)throw new Error("DataSource required for object/api providers");if(j?.provider==="object"){const T=j.object,R=await a.find(T,{$filter:e.filter,$orderby:_o(e.sort)});let L=[];Array.isArray(R)?L=R:R&&typeof R=="object"&&(Array.isArray(R.data)?L=R.data:Array.isArray(R.records)&&(L=R.records)),h(L)}else j?.provider==="api"&&(console.warn("API provider not yet implemented for ObjectMap"),h([]));m(!1)}catch(T){b(T),m(!1)}})()},[j,a,x,e.filter,e.sort]),i.useEffect(()=>{!x&&a&&(async()=>{try{if(!a)return;const T=j?.provider==="object"?j.object:e.objectName;if(!T)return;const R=await a.getObjectSchema(T);v(R)}catch(T){console.error("Failed to fetch object schema:",T)}})()},[e.objectName,a,x,j]);const{markers:S,invalidCount:D}=i.useMemo(()=>{let F=0;return{markers:d.map((R,L)=>{const _=Fo(R,u);if(!_)return F++,null;const H=u.titleField?R[u.titleField]:"Marker",U=u.descriptionField?R[u.descriptionField]:void 0,[W,pe]=_;return!isFinite(W)||!isFinite(pe)||W<-90||W>90||pe<-180||pe>180?(F++,null):{id:R.id||R._id||`marker-${L}`,title:H,description:U,coordinates:[pe,W],data:R}}).filter(R=>R!==null),invalidCount:F}},[d,u]),M=i.useMemo(()=>S.find(F=>F.id===N),[S,N]),O=Te({navigation:e.navigation,objectName:e.objectName,onRowClick:s}),k=i.useMemo(()=>{if(!E.trim())return S;const F=E.toLowerCase();return S.filter(T=>T.title?.toLowerCase().includes(F)||T.description?.toLowerCase().includes(F))},[S,E]),w=i.useMemo(()=>{if(!k.length)return{longitude:u.center?.[1]||0,latitude:u.center?.[0]||0,zoom:u.zoom||2};const F=k.map(U=>U.coordinates[0]),T=k.map(U=>U.coordinates[1]),R=Math.min(...F),L=Math.max(...F),_=Math.min(...T),H=Math.max(...T);return{longitude:(R+L)/2,latitude:(_+H)/2,zoom:u.zoom||3}},[k,u]);return g?t.jsx("div",{className:n,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..."})})}):y?t.jsx("div",{className:n,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: ",y.message]})})}):t.jsxs("div",{className:n,children:[D>0&&t.jsx("div",{className:"mb-2 p-2 text-sm text-yellow-800 bg-yellow-50 border border-yellow-200 rounded",children:`${D} record${D!==1?"s":""} with missing or invalid coordinates excluded from the map.`}),S.length>0&&t.jsx("div",{className:"mb-2",children:t.jsx("input",{type:"text",value:E,onChange:F=>A(F.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(po,{initialViewState:w,style:{width:"100%",height:"100%"},mapStyle:"https://demotiles.maplibre.org/style.json",touchZoomRotate:!0,dragRotate:!0,touchPitch:!0,children:[t.jsx(jo,{position:"top-right",showCompass:!0,showZoom:!0}),k.map(F=>t.jsx(go,{longitude:F.coordinates[0],latitude:F.coordinates[1],anchor:"bottom",onClick:T=>{T.originalEvent.stopPropagation(),C(F.id),O.handleClick(F.data),o?.(F.data)},children:t.jsx("div",{className:"text-2xl cursor-pointer hover:scale-110 transition-transform",children:"📍"})},F.id)),M&&t.jsx(fo,{longitude:M.coordinates[0],latitude:M.coordinates[1],anchor:"top",onClose:()=>C(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:M.title}),M.description&&t.jsx("p",{className:"text-xs text-muted-foreground",children:M.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(M.data),children:"Edit"}),c&&t.jsx("button",{className:"text-red-500 hover:underline",onClick:()=>c(M.data),children:"Delete"})]})]})})]})}),O.isOverlay&&t.jsx(Fe,{...O,title:"Location Details",children:F=>t.jsx("div",{className:"space-y-3",children:Object.entries(F).map(([T,R])=>t.jsxs("div",{className:"flex flex-col",children:[t.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:T.replace(/_/g," ")}),t.jsx("span",{className:"text-sm",children:String(R??"—")})]},T))})})]})},en=({schema:e,...a})=>{const{dataSource:n}=be();return t.jsx(To,{schema:e,dataSource:n,...a})};console.log("Registering object-map...");V.register("object-map",en,{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"}]});V.register("map",en,{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 Eo=Z.lazy(()=>B(()=>import("./MarkdownImpl-BshtTFK2.js"),__vite__mapDeps([38,1]))),Po=({schema:e})=>t.jsx(i.Suspense,{fallback:t.jsx(ke,{className:"w-full h-[200px]"}),children:t.jsx(Eo,{content:e.content||"",className:e.className})});V.register("markdown",Po,{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
51
+
52
+ This is a **markdown** component with *formatting* support.
53
+
54
+ - Item 1
55
+ - Item 2
56
+ - Item 3`}});async function Ao(){sn.createRoot(document.getElementById("root")).render(t.jsx(Z.StrictMode,{children:t.jsx(xs,{pwa:{enabled:!0,name:"ObjectUI Console",shortName:"Console"},children:t.jsx(Bn,{children:t.jsx(Hr,{})})})}))}Ao();export{xr as M,yr as a,Ne as b,qe as r,vr as u};
Binary file
Binary file