@objectstack/console 9.7.0 → 9.9.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.
- package/dist/assets/{AdapterProvider-o2n9dY2j.js → AdapterProvider-DJb3ZVmJ.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-DGAL-HJ9.js → AiPendingActionsPage-BI-QQNee.js} +1 -1
- package/dist/assets/ApiConsolePage-CPV6vWpt.js +1 -0
- package/dist/assets/AppDocsIndex-D4Y3i2rM.js +1 -0
- package/dist/assets/AppManagementPage-CLiHbNPr.js +1 -0
- package/dist/assets/ApprovalsInboxPage-CAyznoRP.js +1 -0
- package/dist/assets/{AuditLogPage-B_gxba-u.js → AuditLogPage-BeEqEy4g.js} +1 -1
- package/dist/assets/ComponentNavView-DmALsugj.js +1 -0
- package/dist/assets/ConsoleFloatingChatbot-CXwRB3yg.js +1 -0
- package/dist/assets/DashboardView-BF0o0wgx.js +1 -0
- package/dist/assets/{DashboardWidgetInspector-CNmycNmj.js → DashboardWidgetInspector-DIMge0qc.js} +1 -1
- package/dist/assets/{DeveloperHubPage-YvUkG7Lt.js → DeveloperHubPage-DbQwi1EV.js} +1 -1
- package/dist/assets/{ExpressionProvider-Cuv0RaiR.js → ExpressionProvider-DKFCgLsJ.js} +1 -1
- package/dist/assets/FlowRunsPage-CJDL4g0k.js +1 -0
- package/dist/assets/{IntegrationsPage-C8k36Ie_.js → IntegrationsPage-DU_wvj4-.js} +2 -2
- package/dist/assets/{InterfaceListPage-DTHEyaKG.js → InterfaceListPage-DZpFSsQf.js} +1 -1
- package/dist/assets/{ManagedByBadge-B60ZX6y9.js → ManagedByBadge-Difq_L_A.js} +1 -1
- package/dist/assets/MarketplaceAccessDenied-CXUE33gy.js +1 -0
- package/dist/assets/MarketplaceInstalledPage-CBfcARvX.js +1 -0
- package/dist/assets/MarketplacePackagePage-BWCVUz3e.js +4 -0
- package/dist/assets/MarketplacePage-BT-WkhAG.js +1 -0
- package/dist/assets/{MetadataInspector-zJtxyFau.js → MetadataInspector-BRICMLXW.js} +1 -1
- package/dist/assets/{MetadataProvider-BagIop6q.js → MetadataProvider-CEw2X-qL.js} +1 -1
- package/dist/assets/PageView-CP-3dRzz.js +1 -0
- package/dist/assets/{ProfilePage-0yyBZHjT.js → ProfilePage-BAtKSxuK.js} +1 -1
- package/dist/assets/PublicFormsPage-D7D2WWL7.js +1 -0
- package/dist/assets/RecordDetailView-BdQK61l2.js +1 -0
- package/dist/assets/{RecordFormPage-DqFdHPz8.js → RecordFormPage-lFVOsTl0.js} +1 -1
- package/dist/assets/ReportDefaultInspector-GD1EQSTh.js +1 -0
- package/dist/assets/{ReportView-Cx-qFxJZ.js → ReportView-BHtzV5eK.js} +1 -1
- package/dist/assets/{RuntimeDraftBar-Be6SQ4g6.js → RuntimeDraftBar-DXwH4Hvd.js} +1 -1
- package/dist/assets/{SearchResultsPage-DkQMPMlE.js → SearchResultsPage-CE_LTSSU.js} +1 -1
- package/dist/assets/{SettingsHub-el09ZPJP.js → SettingsHub-BLEC_8Ao.js} +1 -1
- package/dist/assets/{SettingsView-BiYeb1nb.js → SettingsView-BEjR60F6.js} +1 -1
- package/dist/assets/SystemHubPage-DjNBraYu.js +1 -0
- package/dist/assets/componentRegistry-ByxoJqMW.js +1 -0
- package/dist/assets/{data-adapter-BtpuYbBh.js → data-adapter-CCidkDs3.js} +1 -1
- package/dist/assets/framework-BLEk-ou3.js +34 -0
- package/dist/assets/{highlighted-body-OFNGDK62-DfdyR_41.js → highlighted-body-OFNGDK62-DiT7C6XW.js} +1 -1
- package/dist/assets/index-CJe1zUD0.css +2 -0
- package/dist/assets/index-DdQV1cqi.js +4 -0
- package/dist/assets/marketplaceApi-CucX7DD9.js +1 -0
- package/dist/assets/{mergeServerFields-DPrTk8u4.js → mergeServerFields-djmY7AgR.js} +4 -4
- package/dist/assets/mermaid-GHXKKRXX-CK-9EMhD.js +1 -0
- package/dist/assets/metadata-admin-BbJpmVQm.js +19 -0
- package/dist/assets/{plugin-calendar-CwYuZf8c.js → plugin-calendar-DQC9zdKq.js} +1 -1
- package/dist/assets/{plugin-charts-DhlEvpuy.js → plugin-charts-AMObsZz3.js} +2 -2
- package/dist/assets/plugin-chatbot-Ch8YIyYL.js +120 -0
- package/dist/assets/plugin-dashboard-C7fxXXeO.js +5 -0
- package/dist/assets/plugin-form-gQDKenio.js +1 -0
- package/dist/assets/{plugin-gantt-C5hIQDHF.js → plugin-gantt-BHmpu6VX.js} +3 -3
- package/dist/assets/plugin-grid-boi_rkH3.js +6 -0
- package/dist/assets/plugin-kanban-DOsTOpJz.js +1 -0
- package/dist/assets/{plugin-map-Cz9tJHoZ.js → plugin-map-Bid9UXOR.js} +1 -1
- package/dist/assets/{plugin-markdown-_H-xFg2t.js → plugin-markdown-BUQOG31j.js} +15 -2
- package/dist/assets/plugin-report-FxG9jOvy.js +59 -0
- package/dist/assets/plugin-timeline-DDrFKEb8.js +1 -0
- package/dist/assets/plugin-view-DhNkNfUe.js +1 -0
- package/dist/assets/plugins-views-DUKPQNs8.js +4 -0
- package/dist/assets/resolveActionParams-C_x4GXvS.js +9 -0
- package/dist/assets/{skeletons-BRDBm95C.js → skeletons-B_SNEnMn.js} +1 -1
- package/dist/assets/src-Bzm5L_v8.js +2 -0
- package/dist/assets/{src-B5JRlZgC.js → src-DbxuLwqh.js} +1 -1
- package/dist/assets/{types-fX7qb4I3.js → types-CosU35As.js} +1 -1
- package/dist/assets/ui-components-CrPYFyEM.js +42 -0
- package/dist/assets/{ui-layout-CswtJjnW.js → ui-layout-DAWxaQvy.js} +1 -1
- package/dist/assets/{useActionModal-d8GNl1HP.js → useActionModal-DDu3wUOI.js} +1 -1
- package/dist/assets/useReconcileOnError-Agbi2njU.js +1 -0
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/ApiConsolePage-DNuInlzy.js +0 -1
- package/dist/assets/AppDocsIndex-DtACBq8P.js +0 -1
- package/dist/assets/AppManagementPage-BSgP2T9T.js +0 -1
- package/dist/assets/ApprovalsInboxPage-jrTqrLxX.js +0 -1
- package/dist/assets/ComponentNavView-BSV-rPCq.js +0 -1
- package/dist/assets/ConsoleFloatingChatbot-B1xDv7X-.js +0 -1
- package/dist/assets/DashboardView-BNUhTJ8Y.js +0 -1
- package/dist/assets/FlowRunsPage-DdjGSDw1.js +0 -1
- package/dist/assets/MarketplaceInstalledPage-DJN3P4aw.js +0 -1
- package/dist/assets/MarketplacePackagePage-BUrsYfA7.js +0 -4
- package/dist/assets/MarketplacePage-q23E8dYU.js +0 -1
- package/dist/assets/PageView-M09zUJqv.js +0 -1
- package/dist/assets/PublicFormsPage-BPEDFiNo.js +0 -1
- package/dist/assets/RecordDetailView-cj45YVH-.js +0 -1
- package/dist/assets/ReportDefaultInspector-D5dIioUJ.js +0 -1
- package/dist/assets/SystemHubPage-QSk3FL5a.js +0 -1
- package/dist/assets/framework-ZJouI0cJ.js +0 -34
- package/dist/assets/index-B99f8h8i.js +0 -4
- package/dist/assets/index-BXu9hpEZ.css +0 -2
- package/dist/assets/marketplaceApi-DCvJ2C6u.js +0 -1
- package/dist/assets/mermaid-GHXKKRXX-BF-AoOMn.js +0 -1
- package/dist/assets/metadata-admin-DT8BohcC.js +0 -19
- package/dist/assets/plugin-chatbot-CJsfoGAD.js +0 -120
- package/dist/assets/plugin-dashboard-CGRjBe2V.js +0 -5
- package/dist/assets/plugin-form-C5yl9byI.js +0 -1
- package/dist/assets/plugin-grid-2QHjCxCx.js +0 -6
- package/dist/assets/plugin-kanban-LtqKit9T.js +0 -1
- package/dist/assets/plugin-report-DA6bVPuW.js +0 -59
- package/dist/assets/plugin-timeline-DjngAdR-.js +0 -1
- package/dist/assets/plugin-view-BUsWmCh-.js +0 -1
- package/dist/assets/plugins-views-yfd0iHKg.js +0 -4
- package/dist/assets/resolveActionParams-ergReBd1.js +0 -9
- package/dist/assets/runtime-config-BeHVOPm3.js +0 -1
- package/dist/assets/ui-components-Bs-DxYrW.js +0 -42
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./vendor-react-DR370ovB.js";import{Mt as t}from"./ui-components-
|
|
1
|
+
import{t as e}from"./vendor-react-DR370ovB.js";import{Mt as t}from"./ui-components-CrPYFyEM.js";var n=e();function r({cards:e=6}){return(0,n.jsxs)(`div`,{className:`w-full space-y-6 p-4 sm:p-6`,children:[(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-7 w-56`}),(0,n.jsx)(t,{className:`h-4 w-80`})]}),(0,n.jsx)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4`,children:Array.from({length:4}).map((e,r)=>(0,n.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-2`,children:[(0,n.jsx)(t,{className:`h-4 w-20`}),(0,n.jsx)(t,{className:`h-8 w-24`}),(0,n.jsx)(t,{className:`h-3 w-16`})]},`stat-${r}`))}),(0,n.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4`,children:Array.from({length:e}).map((e,r)=>(0,n.jsxs)(`div`,{className:`rounded-lg border p-4 space-y-3`,children:[(0,n.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,n.jsx)(t,{className:`h-5 w-32`}),(0,n.jsx)(t,{className:`h-5 w-5 rounded-full`})]}),(0,n.jsx)(t,{className:`h-40 w-full`}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(t,{className:`h-3 w-16`}),(0,n.jsx)(t,{className:`h-3 w-12`})]})]},`widget-${r}`))})]})}function i({fields:e=8,columns:r=2}){return(0,n.jsxs)(`div`,{className:`w-full space-y-6 p-4 sm:p-6`,children:[(0,n.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,n.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,n.jsx)(t,{className:`h-8 w-8 rounded`}),(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-6 w-48`}),(0,n.jsx)(t,{className:`h-4 w-32`})]})]}),(0,n.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,n.jsx)(t,{className:`h-9 w-20`}),(0,n.jsx)(t,{className:`h-9 w-20`})]})]}),(0,n.jsx)(t,{className:`h-5 w-24`}),(0,n.jsx)(`div`,{className:`grid grid-cols-1 ${r===2?`md:grid-cols-2`:``} gap-4`,children:Array.from({length:e}).map((e,r)=>(0,n.jsxs)(`div`,{className:`space-y-2`,children:[(0,n.jsx)(t,{className:`h-4 w-24`}),(0,n.jsx)(t,{className:`h-9 w-full`})]},`field-${r}`))}),(0,n.jsxs)(`div`,{className:`space-y-3 pt-4 border-t`,children:[(0,n.jsx)(t,{className:`h-5 w-32`}),(0,n.jsx)(`div`,{className:`space-y-2`,children:Array.from({length:3}).map((e,r)=>(0,n.jsxs)(`div`,{className:`flex items-center gap-3 py-2`,children:[(0,n.jsx)(t,{className:`h-8 w-8 rounded-full`}),(0,n.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,n.jsx)(t,{className:`h-4 w-40`}),(0,n.jsx)(t,{className:`h-3 w-24`})]})]},`related-${r}`))})]})]})}export{r as n,i as t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ui-components-BL3SEdAz.css","./plugin-dashboard-DnNKJB60.css","./index-CJe1zUD0.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,a as n,c as r,d as i,f as a,i as o,l as s,m as c,o as l,p as u,r as d,s as f,t as p,u as m}from"./vendor-react-DR370ovB.js";import{d as h,f as g,n as _,o as v}from"./infrastructure-CJNwTVno.js";import{A as y,B as b,F as x,I as S,N as C,O as w,T,U as E,a as D,b as O,ct as ee,ht as k,j as A,o as j,r as M,w as N}from"./framework-BLEk-ou3.js";import{$a as P,$n as te,$r as ne,$t as re,Aa as ie,Ai as ae,An as oe,Bn as se,Bt as F,Co as I,Ct as L,Da as ce,Ds as le,Dt as R,Ea as ue,F as de,Fi as fe,Fn as pe,Fo as me,Fr as he,Fs as z,Ft as B,Gt as V,H,Ha as U,Hn as ge,Ht as _e,I as ve,In as ye,Io as be,It as xe,Ja as Se,Jn as Ce,Js as we,Ks as Te,Ln as Ee,Lo as W,Ls as De,Lt as Oe,Ma as G,Mn as K,Mr as ke,Nn as Ae,Oa as je,Oo as Me,Os as Ne,Pn as q,Po as Pe,Pr as Fe,Pt as Ie,R as Le,Rn as Re,Rr as ze,Rt as J,Sa as Be,Si as Ve,Sr as He,St as Ue,Tr as We,Ts as Ge,Tt as Ke,Ui as qe,Ut as Je,Va as Ye,Vn as Xe,Vr as Ze,Vt as Qe,Wo as $e,Ws as et,Wt as tt,Xa as nt,Xi as rt,Xs as it,Yo as at,Zr as ot,_a as st,_i as ct,_t as lt,aa as ut,at as dt,b as ft,bo as pt,bt as mt,cc as ht,ci as gt,cn as _t,co as vt,cr as yt,da as bt,dn as xt,dr as St,ds as Ct,ei as wt,en as Tt,er as Et,es as Dt,fc as Ot,fn as kt,fr as At,ga as jt,gc as Mt,gi as Nt,gn as Pt,gs as Ft,gt as It,hr as Y,ht as Lt,ia as Rt,it as zt,ja as Bt,ji as Vt,jn as Ht,jr as Ut,js as Wt,ko as Gt,li as Kt,ln as qt,lr as Jt,mt as Yt,ni as Xt,nn as Zt,nr as Qt,ns as $t,nt as en,oa as tn,oi as nn,on as rn,oo as an,or as on,pc as X,pr as sn,qn as cn,rc as ln,ri as un,rs as dn,rt as fn,sc as pn,si as mn,sn as hn,sr as gn,tn as _n,tr as vn,ts as yn,un as bn,ur as xn,vi as Sn,vt as Cn,w as wn,wt as Tn,ys as En,yt as Dn,z as On,za as kn,zn as An,zt as jn}from"./ui-components-CrPYFyEM.js";import{n as Mn,r as Z}from"./vendor-ui-utils-rQOI1gAo.js";import{r as Nn}from"./data-adapter-CCidkDs3.js";import{t as Pn}from"./AdapterProvider-DJb3ZVmJ.js";import{n as Fn}from"./plugin-form-gQDKenio.js";import{a as In,c as Ln,l as Rn,s as zn,t as Bn,u as Vn}from"./MetadataProvider-CEw2X-qL.js";import{n as Hn,r as Un,t as Wn}from"./ExpressionProvider-DKFCgLsJ.js";import{a as Gn,c as Kn,d as qn,f as Jn,i as Yn,n as Xn,o as Zn,r as Qn,s as $n,t as er,u as tr}from"./useReconcileOnError-Agbi2njU.js";import{n as nr,o as rr,r as ir,t as ar}from"./RecentItemsProvider-B76qldBH.js";import{i as or,r as sr}from"./useActionModal-DDu3wUOI.js";import{a as cr,c as lr,i as ur,l as dr,o as fr,r as pr,s as mr,t as hr}from"./RecordDetailView-BdQK61l2.js";import{n as gr,r as _r,t as vr}from"./ui-layout-DAWxaQvy.js";import{a as yr,d as br,f as xr,i as Sr,m as Cr,p as wr,t as Tr,u as Er}from"./plugin-chatbot-Ch8YIyYL.js";import{C as Dr,r as Or}from"./mergeServerFields-djmY7AgR.js";import{n as kr,t as Ar}from"./appRoute-D5vwtoc_.js";import{a as jr,c as Mr,i as Nr,l as Pr,n as Fr,o as Ir,r as Lr,s as Rr}from"./metadata-admin-BbJpmVQm.js";import{a as zr,n as Br,o as Vr,r as Hr,s as Ur,t as Wr}from"./utils-bipVuqQL.js";import{n as Gr,r as Kr,t as qr}from"./MetadataInspector-BRICMLXW.js";import{b as Jr,n as Yr,v as Xr}from"./marketplaceApi-CucX7DD9.js";import{n as Zr,r as Qr}from"./InterfaceListPage-DZpFSsQf.js";import{c as $r}from"./plugins-views-DUKPQNs8.js";import{a as ei,c as ti,i as ni,l as ri,n as ii,o as ai,r as oi,s as si,t as ci,u as li}from"./plugin-view-DhNkNfUe.js";import{n as ui,r as di,t as fi}from"./RuntimeDraftBar-DXwH4Hvd.js";import{t as pi}from"./ManagedByBadge-Difq_L_A.js";import"./resolveActionParams-C_x4GXvS.js";import{n as mi}from"./PageView-CP-3dRzz.js";import"./RecordFormPage-lFVOsTl0.js";import"./DashboardView-BF0o0wgx.js";import"./ReportView-BHtzV5eK.js";import"./SearchResultsPage-CE_LTSSU.js";import"./MarketplacePage-BT-WkhAG.js";import"./MarketplacePackagePage-BWCVUz3e.js";import"./MarketplaceInstalledPage-CBfcARvX.js";import{n as hi}from"./componentRegistry-ByxoJqMW.js";var Q=p(),$=e(t(),1),gi=(0,$.createContext)({theme:`system`,setTheme:()=>null});function _i({children:e,defaultTheme:t=`system`,storageKey:n=`vite-ui-theme`,...r}){let[i,a]=(0,$.useState)(()=>localStorage.getItem(n)||t);(0,$.useEffect)(()=>{let e=window.document.documentElement;if(e.classList.remove(`light`,`dark`),i===`system`){let t=window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`;e.classList.add(t);return}e.classList.add(i)},[i]);let o={theme:i,setTheme:e=>{localStorage.setItem(n,e),a(e)}};return(0,Q.jsx)(gi.Provider,{...r,value:o,children:e})}var vi=()=>{let e=(0,$.useContext)(gi);if(e===void 0)throw Error(`useTheme must be used within a ThemeProvider`);return e};function yi(){return(0,Q.jsx)(`div`,{className:`h-screen flex items-center justify-center text-sm text-muted-foreground`,children:`Loading…`})}function bi({children:e}){return(0,Q.jsx)(_i,{defaultTheme:`system`,storageKey:`object-ui-theme`,children:(0,Q.jsx)(lr,{children:(0,Q.jsx)(ir,{children:(0,Q.jsx)(sr,{children:(0,Q.jsx)(ar,{children:(0,Q.jsx)($.Suspense,{fallback:(0,Q.jsx)(yi,{}),children:e})})})})})})}function xi({children:e}){return(0,Q.jsx)(Pn,{children:(0,Q.jsx)(Ln,{children:(0,Q.jsx)(Si,{children:e})})})}function Si({children:e}){let t=N(),{language:n}=M(),r=(0,$.useRef)(null);return t&&r.current!==null&&r.current!==n&&t.clearCache?.(),t&&(r.current=n),t?(0,Q.jsx)(E,{dataSource:t,children:(0,Q.jsxs)(Bn,{adapter:t,children:[(0,Q.jsx)(Ci,{}),e]},n)}):(0,Q.jsx)(yi,{})}function Ci(){let{user:e}=g(),t=N(),n=rr();return(0,$.useEffect)(()=>{if(!e?.id||!t){n(`favorites`,null),n(`recent`,null);return}let r=Nn({dataSource:t,userId:e.id,key:`ui.favorites`}),i=Nn({dataSource:t,userId:e.id,key:`ui.recent`});return n(`favorites`,r),n(`recent`,i),()=>{n(`favorites`,null),n(`recent`,null)}},[e?.id,t,n]),null}function wi({children:e}){let{activeOrganization:t,organizations:r,isOrganizationsLoading:i}=g();return i?(0,Q.jsx)(yi,{}):((r??[]).length>0||t)&&!t?(0,Q.jsx)(n,{to:`/organizations`,replace:!0}):(0,Q.jsx)(Q.Fragment,{children:e})}function Ti(){let e=s(),t=e.pathname.replace(/^\/system/,``);return(0,Q.jsx)(n,{to:`${t?`/apps/setup/system${t}`:`/apps/setup`}${e.search}${e.hash}`,replace:!0})}var Ei=(0,$.lazy)(()=>c(()=>import(`./ConsoleFloatingChatbot-CXwRB3yg.js`),__vite__mapDeps([0]),import.meta.url)),Di=()=>{c(()=>import(`./ConsoleFloatingChatbot-CXwRB3yg.js`),__vite__mapDeps([0]),import.meta.url)};function Oi(e){let[t,n]=(0,$.useState)(!1),{t:r}=M(),{openSeq:i}=In(),a=(0,$.useRef)(i);return(0,$.useEffect)(()=>{i!==a.current&&(a.current=i,n(!0))},[i]),t?(0,Q.jsx)($.Suspense,{fallback:null,children:(0,Q.jsx)(Ei,{...e,defaultOpen:!0})}):(0,Q.jsx)(`button`,{type:`button`,"aria-label":r(`topbar.openAssistant`,{defaultValue:`Open {{name}} assistant`,name:e.appLabel}),onClick:()=>n(!0),onMouseEnter:Di,onFocus:Di,className:`fixed bottom-20 right-6 z-50 flex h-14 w-14 items-center justify-center rounded-full bg-primary text-primary-foreground shadow-lg ring-1 ring-primary/20 transition-transform hover:scale-105 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 sm:bottom-6`,"data-testid":`console-chatbot-fab`,children:(0,Q.jsxs)(`svg`,{width:`22`,height:`22`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,Q.jsx)(`path`,{d:`M12 3v3`}),(0,Q.jsx)(`path`,{d:`M12 18v3`}),(0,Q.jsx)(`path`,{d:`M5.6 5.6l2.1 2.1`}),(0,Q.jsx)(`path`,{d:`M16.3 16.3l2.1 2.1`}),(0,Q.jsx)(`path`,{d:`M3 12h3`}),(0,Q.jsx)(`path`,{d:`M18 12h3`}),(0,Q.jsx)(`path`,{d:`M5.6 18.4l2.1-2.1`}),(0,Q.jsx)(`path`,{d:`M16.3 7.7l2.1-2.1`}),(0,Q.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})})}function ki(e){let t=Dr(),[n,r]=(0,$.useState)(!1);return{publishAll:(0,$.useCallback)(async()=>{r(!0);try{let n=(await t.listDrafts?.({})||[]).filter(e=>e&&typeof e.type==`string`&&typeof e.name==`string`).map(e=>({type:e.type,name:e.name,packageId:typeof e.packageId==`string`&&e.packageId?e.packageId:null}));if(n.length===0)return Z.info(e(`home.pendingDrafts.nothing`,{defaultValue:`Nothing to publish.`})),{ok:!0,attempted:0};let r=[...new Set(n.map(e=>e.packageId).filter(e=>e!==null))],i=n.filter(e=>e.packageId===null),a=[],o=[],s=0,c=e=>{if(e){e.seedError&&a.push(e.seedError),typeof e.seededRows==`number`&&(s+=e.seededRows);for(let t of e.issues??[])t.severity===`error`&&o.push(t.message)}};for(let e of r){let t=await fetch(`/api/v1/packages/${encodeURIComponent(e)}/publish-drafts`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:`{}`}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error?.message||`HTTP ${t.status}`);c(yr(n))}let l=[...i.filter(e=>e.type!==`seed`),...i.filter(e=>e.type===`seed`)];for(let e of l){let n=(await t.publishDraft(e.type,e.name))?.seedApplied;n&&n.success===!1&&a.push(n.error??`${e.name}: sample data failed to load`)}return o.length>0?Z.warning(e(`home.pendingDrafts.probeWarn`,{defaultValue:`Published, but verification found problems.`}),{description:o[0]}):a.length>0?Z.warning(e(`home.pendingDrafts.seedWarn`,{defaultValue:`Published, but some sample data failed to load.`}),{description:a[0]}):Z.success(s>0?e(`home.pendingDrafts.publishedVerified`,{count:s,defaultValue:`Published & verified — {{count}} sample row(s) live.`}):e(`home.pendingDrafts.published`,{defaultValue:`Published! Your changes are live.`})),{ok:!0,attempted:n.length}}catch(t){return Z.error(`${e(`home.pendingDrafts.publishFailed`,{defaultValue:`Publish failed`})}: ${t.message}`),{ok:!1,attempted:0}}finally{r(!1)}},[t,e]),publishing:n}}async function Ai(){let e=await fetch(`/api/v1/meta/_drafts`,{credentials:`include`,headers:{Accept:`application/json`},cache:`no-store`});if(!e.ok)throw Error(`_drafts HTTP ${e.status}`);let t=await e.json();return(Array.isArray(t)?t:t?.drafts??[]).filter(e=>typeof e?.type==`string`&&typeof e?.name==`string`).map(e=>({type:e.type,name:e.name,packageId:typeof e.packageId==`string`&&e.packageId?e.packageId:null}))}async function ji(e){let t=await fetch(`/api/v1/meta/${encodeURIComponent(e)}`,{credentials:`include`,headers:{Accept:`application/json`},cache:`no-store`});if(!t.ok)throw Error(`published list HTTP ${t.status}`);let n=await t.json(),r=Array.isArray(n)?n:n?.items??[];return new Set(r.map(e=>typeof e?.name==`string`?e.name:null).filter(e=>e!==null))}function Mi({open:e,onOpenChange:t}){let{t:n}=M(),[r,i]=(0,$.useState)(null),[a,o]=(0,$.useState)(null),s=(0,$.useCallback)(async()=>{i(null),o(null);try{let e=await Ai();i(e);let t=[...new Set(e.map(e=>e.type))];await Promise.all(t.map(async e=>{let t=null;try{t=await ji(e)}catch{return}i(n=>n&&n.map(n=>n.type===e?{...n,kind:t.has(n.name)?`update`:`new`}:n))}))}catch(e){o(e.message)}},[]);(0,$.useEffect)(()=>{e&&s()},[e,s]);let c=new Map;for(let e of r??[]){let t=c.get(e.type)??[];t.push(e),c.set(e.type,t)}return(0,Q.jsx)(Ie,{open:e,onOpenChange:t,children:(0,Q.jsxs)(B,{side:`right`,className:`w-[420px] sm:max-w-[420px]`,"data-testid":`draft-changes-panel`,children:[(0,Q.jsxs)(Oe,{children:[(0,Q.jsx)(J,{children:n(`preview.changes.title`,{defaultValue:`Pending changes`})}),(0,Q.jsx)(xe,{children:n(`preview.changes.description`,{defaultValue:`What publishing will change. New items are added; updates overwrite the live version.`})})]}),(0,Q.jsx)(`div`,{className:`mt-4 flex flex-col gap-4 overflow-y-auto px-4 pb-6`,children:a?(0,Q.jsxs)(`p`,{className:`text-sm text-destructive`,children:[n(`preview.changes.loadFailed`,{defaultValue:`Could not load pending changes:`}),` `,a]}):r===null?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(G,{className:`h-4 w-4 animate-spin`}),n(`preview.changes.loading`,{defaultValue:`Loading pending changes…`})]}):r.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n(`preview.changes.empty`,{defaultValue:`Nothing pending — every draft has been published.`})}):[...c.entries()].map(([e,t])=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`h4`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:[e,` · `,t.length]}),(0,Q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:t.map(e=>(0,Q.jsxs)(`li`,{className:`flex items-center gap-2 rounded-md border px-2.5 py-1.5 text-sm`,children:[e.kind===`new`?(0,Q.jsx)(Me,{className:`h-3.5 w-3.5 shrink-0 text-emerald-600`}):e.kind===`update`?(0,Q.jsx)(Gt,{className:`h-3.5 w-3.5 shrink-0 text-amber-600`}):(0,Q.jsx)(G,{className:`h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs`,children:e.name}),e.kind?(0,Q.jsx)(te,{variant:`outline`,className:e.kind===`new`?`border-emerald-200 bg-emerald-50 text-emerald-700`:`border-amber-200 bg-amber-50 text-amber-700`,children:e.kind===`new`?n(`preview.changes.kindNew`,{defaultValue:`New`}):n(`preview.changes.kindUpdate`,{defaultValue:`Update`})}):null]},`${e.type}:${e.name}`))})]},e))})]})})}function Ni(){let e=Vn(),t=s(),n=m(),{t:r}=M(),{publishAll:i,publishing:a}=ki(r),[o,c]=(0,$.useState)(!1),[l,u]=(0,$.useState)(null);if((0,$.useEffect)(()=>{if(!e)return;let t=!1;return fetch(`/api/v1/meta/_drafts`,{credentials:`include`,headers:{Accept:`application/json`},cache:`no-store`}).then(e=>e.ok?e.json():null).then(e=>{if(t||!e)return;let n=Array.isArray(e)?e:e?.drafts??[];u(Array.isArray(n)?n.length:null)}).catch(()=>{}),()=>{t=!0}},[e,t.pathname]),!e)return null;let d=()=>{Rn();let e=new URLSearchParams(t.search);e.delete(zn);let r=e.toString();n(`${t.pathname}${r?`?${r}`:``}${t.hash}`,{replace:!0})};return(0,Q.jsxs)(`div`,{className:`sticky top-0 z-40 flex items-center gap-3 border-b border-amber-300/70 bg-amber-50 px-4 py-2 text-sm text-amber-900 dark:border-amber-700/60 dark:bg-amber-950/40 dark:text-amber-200`,"data-testid":`draft-preview-bar`,children:[(0,Q.jsx)(Pe,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate`,children:r(`preview.draftBar.message`,{defaultValue:`Draft preview — you are seeing unpublished changes. Nothing here is live until you publish.`})}),(0,Q.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>c(!0),"data-testid":`draft-preview-changes`,children:[(0,Q.jsx)(vt,{className:`mr-1 h-3.5 w-3.5`}),r(`preview.draftBar.changes`,{defaultValue:`Changes`}),typeof l==`number`?` (${l})`:``]}),(0,Q.jsxs)(Y,{size:`sm`,onClick:async()=>{(await i()).ok&&(d(),setTimeout(()=>{try{window.location.reload()}catch{}},300))},disabled:a,"data-testid":`draft-preview-publish`,children:[(0,Q.jsx)(Vt,{className:`mr-1 h-3.5 w-3.5`}),a?r(`preview.draftBar.publishing`,{defaultValue:`Publishing…`}):r(`preview.draftBar.publish`,{defaultValue:`Publish`})]}),(0,Q.jsx)(Mi,{open:o,onOpenChange:c}),(0,Q.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:d,"data-testid":`draft-preview-exit`,children:[(0,Q.jsx)(He,{className:`mr-1 h-3.5 w-3.5`}),r(`preview.draftBar.exit`,{defaultValue:`Exit preview`})]})]})}function Pi(){let e=Vn(),{appName:t}=a(),n=s(),{apps:r,refresh:i}=T(),{t:o}=M(),[c,l]=(0,$.useState)(!1);if(e)return null;let u=t??n.pathname.match(/\/apps\/([^/?#]+)/)?.[1];if(!u)return null;let d=kr(r??[],u);return!d||d.hidden!==!0?null:(0,Q.jsxs)(`div`,{className:`sticky top-0 z-40 flex items-center gap-3 border-b border-amber-300/70 bg-amber-50 px-4 py-2 text-sm text-amber-900 dark:border-amber-700/60 dark:bg-amber-950/40 dark:text-amber-200`,"data-testid":`unpublished-app-bar`,children:[(0,Q.jsx)(me,{className:`h-4 w-4 shrink-0`}),(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate`,children:o(`preview.unpublishedBar.message`,{defaultValue:`Unpublished app — fully functional, but only builders can see it. Publish to make it visible to your users.`})}),(0,Q.jsxs)(Y,{size:`sm`,onClick:async()=>{l(!0);try{let e=await fetch(`/api/v1/meta/app/${encodeURIComponent(u)}`,{method:`PUT`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:JSON.stringify({...d,hidden:!1})});if(!e.ok){let t=await e.json().catch(()=>null);throw Error(t?.error?.message??t?.error??`HTTP ${e.status}`)}Z.success(o(`preview.unpublishedBar.published`,{defaultValue:`Published! The app is now visible to your users.`})),i?.()}catch(e){Z.error(`${o(`preview.unpublishedBar.publishFailed`,{defaultValue:`Publish failed`})}: ${e.message}`)}finally{l(!1)}},disabled:c,"data-testid":`unpublished-app-publish`,children:[(0,Q.jsx)(Vt,{className:`mr-1 h-3.5 w-3.5`}),c?o(`preview.unpublishedBar.publishing`,{defaultValue:`Publishing…`}):o(`preview.unpublishedBar.publish`,{defaultValue:`Publish`})]})]})}var Fi=`__all__`;function Ii(e,t){if(t)return t.split(`.`).reduce((e,t)=>e==null?e:e[t],e)}function Li(e){if(Array.isArray(e))return e;let t=e?.data??e;return Array.isArray(t)?t:Array.isArray(t?.packages)?t.packages:Array.isArray(t?.items)?t.items:Array.isArray(e?.items)?e.items:[]}function Ri(e,t){if(!t||t.length===0)return!0;for(let n of t){let t=Ii(e,n.key),r=n.op??`eq`,i=Array.isArray(n.value)?n.value:[n.value];switch(r){case`eq`:if(t!==n.value)return!1;break;case`ne`:if(t===n.value)return!1;break;case`in`:if(!i.includes(t))return!1;break;case`nin`:if(i.includes(t))return!1;break}}return!0}function zi(e){let[t,n]=$.useState([]),r=e.optionsSource.endpoint,i=e.optionsSource.valueKey||`id`,a=e.optionsSource.labelKey||`name`,o=e.optionsSource.filter,s=JSON.stringify(o??[]);return $.useEffect(()=>{let e=!1;return(async()=>{try{let t=await fetch(r,{credentials:`include`,headers:{Accept:`application/json`}});if(!t.ok)return;let s=await t.json();if(e)return;let c=Li(s),l=[],u=new Set;for(let e of c){if(!Ri(e,o))continue;let t=Ii(e,i);if(t==null||typeof t!=`string`||u.has(t))continue;u.add(t);let n=Ii(e,a);l.push({value:t,label:typeof n==`string`&&n?n:t})}l.sort((e,t)=>e.label.localeCompare(t.label)),n(l)}catch{}})(),()=>{e=!0}},[r,i,a,s]),t}function Bi(e,t,n){let r=Array.isArray(t)?t:[],i=m(),a=s(),o=new URLSearchParams(a.search);$.useEffect(()=>{let t=new URLSearchParams(a.search),n=!1;for(let i of r)if(i.persist!==`none`&&!t.get(`package`))try{let r=sessionStorage.getItem(`objectui-ctx-${e}-${i.id}`);r&&(t.set(`package`,r),n=!0)}catch{}n&&i({pathname:a.pathname,search:t.toString()},{replace:!0})},[e,r,a.pathname,a.search,i]);let c=$.useCallback((t,n)=>{let r=n===Fi?t.allValue??``:n;try{let n=`objectui-ctx-${e}-${t.id}`;r?sessionStorage.setItem(n,r):sessionStorage.removeItem(n)}catch{}let o=new URLSearchParams(a.search);r?o.set(`package`,r):o.delete(`package`),i({pathname:a.pathname,search:o.toString()},{replace:!0})},[e,a.pathname,a.search,i]),l={};for(let t of r){let n=``;try{n=sessionStorage.getItem(`objectui-ctx-${e}-${t.id}`)??``}catch{}l[t.id]=(o.get(`package`)??n)||(t.allValue??``)}return{contextValues:l,element:r.length===0?null:(0,Q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(e=>(0,Q.jsx)(Vi,{def:e,value:l[e.id],onChange:t=>c(e,t),t:n},e.id))})}}function Vi({def:e,value:t,onChange:n,t:r}){let i=zi(e),a=Pr(e.icon),o=Hr(e.label,r)||e.id,s=o===`Package`?r?.(`common.package`,{defaultValue:o})??o:o,c=r?.(`actionDialog.selectPlaceholder`,{label:s,defaultValue:`Select ${s}…`})??`Select ${s}…`,l=!!t&&t!==(e.allValue??``);return $.useEffect(()=>{l||i.length>0&&n(i[0].value)},[l,n,i]),(0,Q.jsxs)(F,{value:l?t:``,onValueChange:n,children:[(0,Q.jsx)(Je,{"aria-label":s,className:`h-9 w-full gap-2 rounded-md border-sidebar-border/70 bg-sidebar/80 px-2 text-xs font-medium text-sidebar-foreground shadow-none transition-colors hover:bg-sidebar-accent focus:ring-1 focus:ring-sidebar-ring data-[state=open]:bg-sidebar-accent [&>svg]:h-3.5 [&>svg]:w-3.5 [&>svg]:shrink-0`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2 overflow-hidden`,children:[(0,Q.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded border border-sidebar-border/70 bg-sidebar-accent text-sidebar-foreground/70`,children:(0,Q.jsx)(a,{className:`h-3 w-3`})}),(0,Q.jsx)(tt,{placeholder:c,className:`truncate`})]})}),(0,Q.jsx)(Qe,{className:`w-[var(--radix-select-trigger-width)]`,children:i.map(e=>(0,Q.jsx)(_e,{value:e.value,children:e.label},e.value))})]})}var Hi=$.forwardRef(({className:e,onClick:t,"aria-label":n,title:r,...i},a)=>{let{toggleSidebar:o}=R(),{t:s}=M(),c=String(n||r||s(`common.toggleSidebar`,{defaultValue:`Toggle sidebar`}));return(0,Q.jsxs)(Y,{ref:a,"data-sidebar":`trigger`,variant:`ghost`,size:`icon`,className:X(`h-7 w-7`,e),"aria-label":c,title:c,onClick:e=>{t?.(e),o()},...i,children:[(0,Q.jsx)(Rt,{}),(0,Q.jsx)(`span`,{className:`sr-only`,children:c})]})});Hi.displayName=`LocalizedSidebarTrigger`;function Ui(e){let t=`objectui-nav-order-${e}`,[n,r]=$.useState(()=>{try{let e=localStorage.getItem(t);if(!e)return{};let n=JSON.parse(e);if(typeof n!=`object`||!n||Array.isArray(n))return{};let r={};for(let[e,t]of Object.entries(n))Array.isArray(t)&&t.every(e=>typeof e==`string`)&&(r[e]=t);return r}catch{return{}}}),i=$.useCallback(e=>{r(e);try{localStorage.setItem(t,JSON.stringify(e))}catch{}},[t]);return{applyOrder:$.useCallback(e=>{let t=n.__root__;if(!t)return e;let r=new Map(e.map(e=>[e.id,e])),i=[];for(let e of t){let t=r.get(e);t&&(i.push(t),r.delete(e))}return r.forEach(e=>i.push(e)),i},[n]),handleReorder:$.useCallback(e=>{let t=e.map(e=>e.id);i({...n,__root__:t})},[n,i])}}function Wi(e){return e.componentRef===`metadata:directory`}function Gi(e){return e.componentRef===`developer:packages`}function Ki(e){if(e.type!==`group`)return!1;let t=String(e.id??``).toLowerCase(),n=typeof e.label==`string`?e.label.toLowerCase():``;return t===`overview`||n===`overview`}function qi({activeAppName:e}){let{isMobile:t,setOpenMobile:n}=R(),r=s(),{t:i}=M(),{objectLabel:a,dashboardLabel:o,navGroupLabel:c,viewLabel:l}=Mt(),{context:u,currentAppName:f}=dr(),{user:p}=g(),m=h();$.useEffect(()=>{let e=0,n=t=>{e=t.touches[0].clientX},r=n=>{let r=n.changedTouches[0].clientX-e;e<30&&r>50&&t&&document.querySelector(`[data-sidebar="trigger"]`)?.dispatchEvent(new MouseEvent(`click`,{bubbles:!0}))};return document.addEventListener(`touchstart`,n,{passive:!0}),document.addEventListener(`touchend`,r,{passive:!0}),()=>{document.removeEventListener(`touchstart`,n),document.removeEventListener(`touchend`,r)}},[t]);let{recentItems:v}=nr(),{favorites:y,removeFavorite:b}=or(),{apps:x,objects:S}=T(),C=x||[],w=C.filter(e=>e.active!==!1&&e.hidden!==!0),E=kr(C.filter(e=>e.active!==!1),e||f)||w[0],{applyOrder:D,handleReorder:O}=Ui(E?.name||`home`),{togglePin:ee,applyPins:k}=qn(),A=E?.areas||[],[j,N]=$.useState(()=>A.length>0?A[0].id:null);$.useEffect(()=>{A.length>0?N(e=>A.some(t=>t.id===e)?e:A[0].id):N(null)},[E?.name,A.length]);let te=A.find(e=>e.id===j)?.navigation||E?.navigation||[],{contextValues:ne,element:re}=Bi(E?.name||`home`,E?.contextSelectors,i),ie=$.useMemo(()=>{let e=[{id:`home-dashboard`,label:i(`home.nav`,{defaultValue:`Home`}),type:`url`,url:`/home`,icon:`home`},{id:`docs`,label:i(`layout.systemNav.documentation`,{defaultValue:`Documentation`}),type:`url`,url:`/docs`,icon:`book-open`}];if(m){let t=[{id:`sys-settings`,label:i(`layout.systemNav.systemSettings`,{defaultValue:`System Settings`}),type:`url`,url:`/apps/setup`,icon:`settings`},{id:`sys-apps`,label:i(`layout.systemNav.applications`,{defaultValue:`Applications`}),type:`url`,url:`/apps/setup/system/apps`,icon:`layout-grid`},{id:`sys-marketplace`,label:i(`layout.systemNav.appMarketplace`,{defaultValue:`App Marketplace`}),type:`url`,url:`/apps/setup/system/marketplace`,icon:`store`},{id:`sys-objects`,label:i(`layout.systemNav.objectManager`,{defaultValue:`Object Manager`}),type:`url`,url:`/apps/setup/system/metadata/object`,icon:`database`},{id:`sys-users`,label:i(`layout.systemNav.users`,{defaultValue:`Users`}),type:`url`,url:`/apps/setup/system/users`,icon:`users`},{id:`sys-orgs`,label:i(`layout.systemNav.organizations`,{defaultValue:`Organizations`}),type:`url`,url:`/apps/setup/system/organizations`,icon:`building-2`},{id:`sys-roles`,label:i(`layout.systemNav.roles`,{defaultValue:`Roles`}),type:`url`,url:`/apps/setup/system/roles`,icon:`shield`},{id:`sys-config`,label:i(`layout.systemNav.configuration`,{defaultValue:`Configuration`}),type:`url`,url:`/apps/setup/system/settings`,icon:`sliders-horizontal`}];e.push({id:`sys-administration`,label:i(`layout.systemNav.administration`,{defaultValue:`Administration`}),type:`group`,icon:`shield`,children:t})}return e},[i,m]),ae=u===`home`?ie:te,oe=u===`app`&&E?`/apps/${Ar(E)}`:``,se=u===`app`&&E?.name===`studio`,F=$.useMemo(()=>{if(!se)return``;let e=new URLSearchParams(r.search).get(`package`)||ne.active_package;return e?`?package=${encodeURIComponent(e)}`:``},[ne.active_package,se,r.search]),I=$.useMemo(()=>{if(u!==`app`||E?.name!==`studio`)return ae;let e=i(`sidebar.packageManagement`,{defaultValue:`Package management`}),t=n=>n.flatMap(n=>{if(Wi(n))return[];let r=n.children?.length?t(n.children):n.children;return n.type===`group`&&r?.length===0?[]:Gi(n)?[{...n,type:`url`,label:e,url:`${oe}/component/developer/packages${F}`,children:r}]:r===n.children?[n]:[{...n,children:r}]});return t(ae).flatMap(e=>Ki(e)?e.children??[]:[e])},[E?.name,oe,u,ae,F,i]),ce=$.useMemo(()=>k(D(I)),[I,D,k]),[le,ue]=$.useState(!1),{evaluator:de}=Un(),fe=$.useCallback(e=>Hn(e,de),[de]),{can:pe}=_(),me=$.useCallback(e=>e.every(e=>{let t=e.split(`:`),[n,r]=t.length>=2?[t[0],t[1]]:[e,`read`];return pe(n,r)}),[pe]),he=$.useMemo(()=>new Set((S||[]).map(e=>e?.name).filter(Boolean)),[S]),z=$.useCallback((e,t)=>e===`object`?he.size===0?!0:he.has(t):!0,[he]),B=se&&r.pathname.replace(/\/+$/,``)===oe;return(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsxs)(Yt,{collapsible:`icon`,className:`!top-14 !h-[calc(100svh-3.5rem)]`,children:[t&&u===`app`&&(0,Q.jsx)(mt,{className:`border-b p-1.5`,children:(0,Q.jsx)(Ue,{children:(0,Q.jsx)(Ke,{children:(0,Q.jsx)(Tn,{asChild:!0,className:`h-9 text-sm font-medium`,children:(0,Q.jsxs)(d,{to:`/home`,onClick:()=>n(!1),"data-testid":`mobile-sidebar-home`,children:[(0,Q.jsx)(P,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:i(`home.nav`,{defaultValue:`Home`})})]})})})})}),(0,Q.jsx)(Lt,{className:`pt-2`,children:(0,Q.jsx)(`div`,{className:`transition-opacity duration-200 ease-in-out`,children:u===`app`&&E?(0,Q.jsxs)(Q.Fragment,{children:[re&&(0,Q.jsx)(lt,{className:`group-data-[state=collapsed]:hidden px-2 pb-1`,children:(0,Q.jsx)(`div`,{className:`rounded-lg border border-sidebar-border/70 bg-sidebar-accent/25 p-1.5 shadow-xs`,children:(0,Q.jsx)(Cn,{children:re})})}),se&&(0,Q.jsx)(lt,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Ue,{children:(0,Q.jsx)(Ke,{children:(0,Q.jsx)(Tn,{asChild:!0,isActive:B,tooltip:i(`home.nav`,{defaultValue:`Home`}),children:(0,Q.jsxs)(d,{to:{pathname:oe,search:F},children:[(0,Q.jsx)(P,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:i(`home.nav`,{defaultValue:`Home`})})]})})})})})}),A.length>1&&(0,Q.jsxs)(lt,{children:[(0,Q.jsxs)(Dn,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Ye,{className:`h-3.5 w-3.5`}),i(`sidebar.area`,{defaultValue:`Area`})]}),(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Ue,{children:A.map(e=>{let t=Pr(e.icon);return(0,Q.jsx)(Ke,{children:(0,Q.jsxs)(Tn,{isActive:e.id===j,tooltip:e.label,onClick:()=>N(e.id),children:[(0,Q.jsx)(t,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:e.label})]})},e.id)})})})]}),(0,Q.jsx)(vr,{items:ce,basePath:oe,evaluateVisibility:fe,checkPermission:me,checkCapability:z,enablePinning:!t,onPinToggle:ee,enableReorder:!t,onReorder:O,resolveObjectLabel:(e,t)=>a({name:e,label:t}),resolveDashboardLabel:(e,t)=>o({name:e,label:t}),resolveGroupLabel:E?(e,t)=>c(E.name,e,t):void 0,resolveItemLabel:E?(e,t)=>E.name===`studio`&&t===i(`sidebar.packageManagement`,{defaultValue:`Package management`})?t:c(E.name,e,t):void 0,resolveViewLabel:(e,t,n)=>l(e,t,n),t:i,templateContext:{currentUserId:p?.id??null,contextValues:ne}}),v.length>0&&(0,Q.jsxs)(lt,{children:[(0,Q.jsxs)(Dn,{className:`flex items-center gap-1.5 cursor-pointer select-none`,onClick:()=>ue(e=>!e),children:[(0,Q.jsx)(Ge,{className:`h-3 w-3 transition-transform duration-150 ${le?`rotate-90`:``}`}),(0,Q.jsx)(dn,{className:`h-3.5 w-3.5`}),i(`sidebar.recent`,{defaultValue:`Recent`})]}),le&&(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Ue,{children:v.slice(0,5).map(e=>(0,Q.jsx)(Ke,{children:(0,Q.jsx)(Tn,{asChild:!0,tooltip:e.label,children:(0,Q.jsxs)(d,{to:e.href,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.type===`dashboard`?`📊`:e.type===`report`?`📈`:`📄`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]})})},e.id))})})]}),y.some(e=>e.type!==`nav`)&&(0,Q.jsxs)(lt,{children:[(0,Q.jsxs)(Dn,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Xt,{className:`h-3.5 w-3.5`}),i(`sidebar.favorites`,{defaultValue:`Favorites`})]}),(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Ue,{children:y.filter(e=>e.type!==`nav`).slice(0,8).map(e=>(0,Q.jsxs)(Ke,{children:[(0,Q.jsx)(Tn,{asChild:!0,tooltip:e.label,children:(0,Q.jsxs)(d,{to:e.href,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.type===`dashboard`?`📊`:e.type===`report`?`📈`:e.type===`page`?`📄`:`📋`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]})}),(0,Q.jsx)(L,{showOnHover:!0,onClick:t=>{t.stopPropagation(),b(e.id)},"aria-label":i(`sidebar.removeFromFavorites`,{defaultValue:`Remove {{name}} from favorites`,name:e.label}),children:(0,Q.jsx)(un,{className:`h-3 w-3`})})]},e.id))})})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(lt,{children:(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Ue,{children:ie.map(e=>{let t=Pr(e.icon),n=r.pathname===e.url;return(0,Q.jsx)(Ke,{children:(0,Q.jsx)(Tn,{asChild:!0,tooltip:e.label,isActive:n,children:(0,Q.jsxs)(d,{to:e.url||`/home`,children:[(0,Q.jsx)(t,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{children:e.label})]})})},e.id)})})})}),y.filter(e=>e.type===`object`||e.type===`dashboard`||e.type===`page`).length>0&&(0,Q.jsxs)(lt,{children:[(0,Q.jsxs)(Dn,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(Xt,{className:`h-3.5 w-3.5`}),i(`sidebar.starred`,{defaultValue:`Starred`})]}),(0,Q.jsx)(Cn,{children:(0,Q.jsx)(Ue,{children:y.filter(e=>e.type===`object`||e.type===`dashboard`||e.type===`page`).slice(0,8).map(e=>(0,Q.jsxs)(Ke,{children:[(0,Q.jsx)(Tn,{asChild:!0,tooltip:e.label,children:(0,Q.jsxs)(d,{to:e.href,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.type===`dashboard`?`📊`:e.type===`page`?`📄`:`📋`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]})}),(0,Q.jsx)(L,{showOnHover:!0,onClick:t=>{t.stopPropagation(),b(e.id)},"aria-label":i(`sidebar.removeFromFavorites`,{defaultValue:`Remove {{name}} from favorites`,name:e.label}),children:(0,Q.jsx)(un,{className:`h-3 w-3`})})]},e.id))})})]})]})})}),(0,Q.jsx)(It,{className:`border-t p-1`,children:(0,Q.jsx)(Hi,{className:`w-full justify-start pl-2 group-data-[state=collapsed]:justify-center group-data-[state=collapsed]:pl-0`})})]})})}function Ji(){let{theme:e,setTheme:t}=vi(),{t:n}=M();return(0,Q.jsxs)(hn,{children:[(0,Q.jsx)(Pt,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:[(0,Q.jsx)(ne,{className:`h-4 w-4 rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0`}),(0,Q.jsx)(jt,{className:`absolute h-4 w-4 rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:n(`console.theme.toggle`)})]})}),(0,Q.jsxs)(_t,{align:`end`,children:[(0,Q.jsxs)(bn,{onClick:()=>t(`light`),className:`gap-2`,children:[(0,Q.jsx)(ne,{className:`h-4 w-4`}),n(`console.theme.light`),e===`light`&&(0,Q.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]}),(0,Q.jsxs)(bn,{onClick:()=>t(`dark`),className:`gap-2`,children:[(0,Q.jsx)(jt,{className:`h-4 w-4`}),n(`console.theme.dark`),e===`dark`&&(0,Q.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]}),(0,Q.jsxs)(bn,{onClick:()=>t(`system`),className:`gap-2`,children:[(0,Q.jsx)(st,{className:`h-4 w-4`}),n(`console.theme.system`),e===`system`&&(0,Q.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]})]})]})}var Yi=[{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 Xi(){let{t:e,language:t,changeLanguage:n}=M();return(0,Q.jsxs)(hn,{children:[(0,Q.jsx)(Pt,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,children:[(0,Q.jsx)(an,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`sr-only`,children:e(`console.localeSwitcher.label`)})]})}),(0,Q.jsx)(_t,{align:`end`,className:`max-h-72 overflow-y-auto`,children:Yi.map(e=>(0,Q.jsxs)(bn,{onClick:()=>n(e.code),className:`gap-2`,children:[e.label,t===e.code&&(0,Q.jsx)(`span`,{className:`ml-auto text-xs`,children:`✓`})]},e.code))})]})}var Zi={connected:{labelKey:`topbar.connection.connected`,defaultValue:`Connected`,color:`text-green-500`,icon:Ft},connecting:{labelKey:`topbar.connection.connecting`,defaultValue:`Connecting...`,color:`text-yellow-500`,icon:G},reconnecting:{labelKey:`topbar.connection.reconnecting`,defaultValue:`Reconnecting...`,color:`text-yellow-500`,icon:G},disconnected:{labelKey:`topbar.connection.disconnected`,defaultValue:`Disconnected`,color:`text-muted-foreground`,icon:We},error:{labelKey:`topbar.connection.error`,defaultValue:`Connection Error`,color:`text-destructive`,icon:We}};function Qi({state:e,className:t}){let n=Zi[e],{t:r}=M(),i=r(n.labelKey,{defaultValue:n.defaultValue}),a=n.icon,[o,s]=(0,$.useState)(!1);return(0,$.useEffect)(()=>{if(e===`connected`){s(!0);let e=setTimeout(()=>s(!1),2e3);return()=>clearTimeout(e)}s(!1)},[e]),e===`connected`&&!o?null:(0,Q.jsxs)(`div`,{className:X(`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`,t),title:i,children:[(0,Q.jsx)(a,{className:X(`h-3.5 w-3.5`,(e===`connecting`||e===`reconnecting`)&&`animate-spin`)}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:i})]})}function $i(e){if(!e)return``;let t=new Date(e).getTime();if(Number.isNaN(t))return``;let n=(Date.now()-t)/1e3;return n<60?`${Math.max(1,Math.floor(n))}s`:n<3600?`${Math.floor(n/60)}m`:n<86400?`${Math.floor(n/3600)}h`:`${Math.floor(n/86400)}d`}function ea({notifications:e,unreadCount:t,pendingApprovalsCount:n,activities:r,onMarkAllRead:i,onMarkRead:o}){let{t:s}=M(),c=m(),l=a(),{currentAppName:u}=dr(),[d,f]=(0,$.useState)(!1),[p,h]=(0,$.useState)(`notifications`),[g,_]=(0,$.useState)(`unread`),v=t+n,y=s(`sidebar.inboxAriaLabel`,{defaultValue:`Open inbox`}),b=(0,$.useRef)(null),[x,S]=(0,$.useState)(!1);(0,$.useEffect)(()=>{let e=b.current;if(e!==null&&v>e){S(!0);let e=window.setTimeout(()=>S(!1),1200);return()=>window.clearTimeout(e)}b.current=v},[v]),(0,$.useEffect)(()=>{x||(b.current=v)},[x,v]);let C=()=>{f(!1);let e=u??l.appName;c(e?`/apps/${e}/system/approvals`:`/apps/setup/system/approvals`)},w=()=>{f(!1),c(`/apps/setup/sys_inbox_message?view=mine`)},T=()=>{f(!1),c(`/apps/setup/sys_activity`)},E=e=>{o(e.id);let t=u??l.appName;if(e.action_url){f(!1);let n=e.action_url;if(/^https?:\/\//i.test(n)){window.open(n,`_blank`,`noopener,noreferrer`);return}if(n.startsWith(`/apps/`)){c(n);return}let r=n.startsWith(`/`)?n:`/${n}`;c(t?`/apps/${t}${r}`:r);return}e.source_object&&e.source_id&&(f(!1),c(t?`/apps/${t}/${e.source_object}/${e.source_id}`:`/objects/${e.source_object}/${e.source_id}`))};return(0,Q.jsxs)(re,{open:d,onOpenChange:f,children:[(0,Q.jsx)(_n,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8 relative shrink-0 ${x?`motion-safe:animate-bounce`:``}`,"aria-label":y,title:s(`sidebar.inbox`,{defaultValue:`Inbox`}),children:[(0,Q.jsx)(it,{className:`h-4 w-4`}),v>0&&(0,Q.jsx)(`span`,{className:`absolute -top-0.5 -right-0.5 h-4 min-w-[16px] rounded-full bg-red-500 text-[10px] leading-4 text-white text-center px-1 motion-safe:animate-in motion-safe:zoom-in-50 motion-safe:fade-in-0 motion-safe:duration-200`,children:v>9?`9+`:v},v)]})}),(0,Q.jsxs)(Tt,{align:`end`,sideOffset:8,className:`w-96 p-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-3 pt-3 pb-1`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-semibold`,children:s(`sidebar.inbox`,{defaultValue:`Inbox`})}),p===`notifications`&&t>0&&(0,Q.jsx)(`button`,{type:`button`,onClick:i,className:`text-xs text-muted-foreground hover:text-foreground`,children:s(`notifications.markAllRead`,{defaultValue:`Mark all read`})})]}),(0,Q.jsxs)(en,{value:p,onValueChange:e=>h(e),className:`w-full`,children:[(0,Q.jsxs)(zt,{className:`w-full justify-start rounded-none border-b bg-transparent px-1 h-9`,children:[(0,Q.jsxs)(dt,{value:`notifications`,className:`text-xs gap-1.5 data-[state=active]:bg-transparent`,children:[(0,Q.jsx)(it,{className:`h-3.5 w-3.5`}),s(`sidebar.notifications`,{defaultValue:`Notifications`}),t>0&&(0,Q.jsx)(`span`,{className:`ml-0.5 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-red-500 px-1 text-[10px] text-white motion-safe:animate-in motion-safe:zoom-in-75 motion-safe:duration-200`,children:t>9?`9+`:t},`notif-${t}`)]}),(0,Q.jsxs)(dt,{value:`approvals`,className:`text-xs gap-1.5 data-[state=active]:bg-transparent`,children:[(0,Q.jsx)(mn,{className:`h-3.5 w-3.5`}),s(`sidebar.approvals`,{defaultValue:`Approvals`}),n>0&&(0,Q.jsx)(`span`,{className:`ml-0.5 inline-flex h-4 min-w-[16px] items-center justify-center rounded-full bg-amber-500 px-1 text-[10px] text-white motion-safe:animate-in motion-safe:zoom-in-75 motion-safe:duration-200`,children:n>9?`9+`:n},`appr-${n}`)]}),(0,Q.jsxs)(dt,{value:`activity`,className:`text-xs gap-1.5 data-[state=active]:bg-transparent`,children:[(0,Q.jsx)(Ot,{className:`h-3.5 w-3.5`}),s(`sidebar.activityFeed`,{defaultValue:`Activity`})]})]}),(0,Q.jsxs)(fn,{value:`notifications`,className:`m-0 max-h-80 overflow-auto`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1 border-b px-2 py-1.5`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>_(`unread`),className:`text-xs px-2 py-1 rounded-md transition-colors ${g===`unread`?`bg-accent text-foreground font-medium`:`text-muted-foreground hover:text-foreground`}`,children:[s(`notifications.filterUnread`,{defaultValue:`Unread`}),t>0&&(0,Q.jsx)(`span`,{className:`ml-1 text-[10px] opacity-70`,children:t})]}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>_(`all`),className:`text-xs px-2 py-1 rounded-md transition-colors ${g===`all`?`bg-accent text-foreground font-medium`:`text-muted-foreground hover:text-foreground`}`,children:s(`notifications.filterAll`,{defaultValue:`All`})})]}),(()=>{let t=g===`unread`?e.filter(e=>!e.is_read):e;return t.length===0?(0,Q.jsx)(`div`,{className:`px-3 py-8 text-sm text-muted-foreground text-center motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-300`,children:g===`unread`?s(`notifications.emptyUnread`,{defaultValue:`You're all caught up`}):s(`notifications.empty`,{defaultValue:`No notifications`})}):(0,Q.jsx)(`ul`,{className:`divide-y`,children:t.map((e,t)=>(0,Q.jsx)(`li`,{className:`motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-1 motion-safe:duration-200`,style:{animationDelay:`${Math.min(t,6)*20}ms`},children:(0,Q.jsx)(`button`,{type:`button`,onClick:()=>E(e),className:`w-full text-left px-3 py-2.5 hover:bg-accent transition-colors duration-150 ${e.is_read?``:`bg-accent/40`}`,children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full bg-primary transition-opacity duration-200 ${e.is_read?`opacity-0`:`opacity-100`}`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`text-sm font-medium leading-tight truncate`,children:e.title}),e.body&&(0,Q.jsx)(`div`,{className:`text-xs text-muted-foreground line-clamp-2 mt-0.5`,children:e.body}),(0,Q.jsx)(`div`,{className:`text-[10px] text-muted-foreground mt-1`,children:$i(e.created_at)})]})]})})},e.id))})})(),(0,Q.jsx)(`div`,{className:`border-t px-3 py-2 text-center`,children:(0,Q.jsx)(`button`,{type:`button`,onClick:w,className:`text-xs text-primary hover:underline`,children:s(`notifications.viewAll`,{defaultValue:`View all notifications`})})})]}),(0,Q.jsx)(fn,{value:`approvals`,className:`m-0 max-h-80 overflow-auto`,children:(0,Q.jsx)(`div`,{className:`px-3 py-6 text-center motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-300`,children:n>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(mn,{className:`mx-auto h-6 w-6 text-amber-500 motion-safe:animate-in motion-safe:zoom-in-50 motion-safe:duration-300`}),(0,Q.jsx)(`div`,{className:`mt-2 text-sm font-medium`,children:s(`notifications.approvalsPending`,{defaultValue:`{{count}} pending approvals`,count:n})}),(0,Q.jsx)(Y,{size:`sm`,className:`mt-3`,onClick:C,children:s(`notifications.viewApprovals`,{defaultValue:`View approvals`})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:s(`notifications.noPendingApprovals`,{defaultValue:`No pending approvals`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:C,className:`mt-2 text-xs text-primary hover:underline`,children:s(`notifications.openApprovalsInbox`,{defaultValue:`Open Approvals Inbox`})})]})})}),(0,Q.jsxs)(fn,{value:`activity`,className:`m-0 max-h-80 overflow-auto`,children:[r.length===0?(0,Q.jsx)(`div`,{className:`px-3 py-8 text-sm text-muted-foreground text-center motion-safe:animate-in motion-safe:fade-in-0 motion-safe:duration-300`,children:s(`layout.activityFeed.empty`,{defaultValue:`No recent activity`})}):(0,Q.jsx)(`ul`,{className:`divide-y`,children:r.slice(0,20).map((e,t)=>(0,Q.jsxs)(`li`,{className:`px-3 py-2.5 motion-safe:animate-in motion-safe:fade-in-0 motion-safe:slide-in-from-top-1 motion-safe:duration-200`,style:{animationDelay:`${Math.min(t,6)*20}ms`},children:[(0,Q.jsxs)(`div`,{className:`text-sm leading-tight truncate`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:e.user}),` `,(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:e.description})]}),(0,Q.jsxs)(`div`,{className:`text-[10px] text-muted-foreground mt-0.5`,children:[$i(e.timestamp),` · `,e.objectName]})]},e.id))}),(0,Q.jsx)(`div`,{className:`border-t px-3 py-2 text-center`,children:(0,Q.jsx)(`button`,{type:`button`,onClick:T,className:`text-xs text-primary hover:underline`,children:s(`layout.activityFeed.viewAll`,{defaultValue:`View all activity`})})})]})]})]})]})}function ta({activeAppName:e,onAppChange:t}){let{apps:n}=T(),{t:r}=M(),{appLabel:i}=Mt(),a=n||[],o=a.filter(e=>e.active!==!1&&e.hidden!==!0),s=kr(o,e)||kr(a.filter(e=>e.active!==!1),e)||o[0];return s?(0,Q.jsxs)(hn,{children:[(0,Q.jsx)(Pt,{asChild:!0,children:(0,Q.jsxs)(`button`,{className:`flex items-center gap-1 rounded-md px-1.5 py-1 text-sm font-medium text-foreground/80 hover:bg-accent hover:text-foreground transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring max-w-[40vw] sm:max-w-none`,children:[(0,Q.jsx)(`span`,{className:`truncate whitespace-nowrap`,children:i({name:s.name,label:Hr(s.label,r)})}),(0,Q.jsx)(le,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`})]})}),(0,Q.jsxs)(_t,{align:`start`,sideOffset:8,className:`w-60`,children:[(0,Q.jsx)(xt,{className:`text-xs text-muted-foreground font-normal`,children:r(`layout.appSwitcher.switchApplication`,{defaultValue:`Switch Application`})}),(0,Q.jsx)(kt,{}),o.map(e=>{let n=Pr(e.icon),a=i({name:e.name,label:Hr(e.label,r)}),o=s.name===e.name;return(0,Q.jsxs)(bn,{onClick:()=>t(Ar(e)??e.name),className:`flex items-center gap-2.5 py-2`,children:[(0,Q.jsx)(`div`,{className:`flex size-5 shrink-0 items-center justify-center rounded border bg-muted text-muted-foreground`,children:(0,Q.jsx)(n,{className:`size-3`})}),(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:a}),o&&(0,Q.jsx)(Ne,{className:`size-3.5 text-primary shrink-0`})]},e.name)})]})]}):null}var na=(0,$.createContext)(null);function ra({children:e}){let[t,n]=(0,$.useState)(null),r=(0,$.useMemo)(()=>({value:t,setValue:n}),[t]);return(0,Q.jsx)(na.Provider,{value:r,children:e})}function ia(){return(0,$.useContext)(na)?.value??null}function aa(e){let t=(0,$.useContext)(na),n=(0,$.useRef)(null);(0,$.useEffect)(()=>{if(!t)return;let r=e??null;return t.setValue(r),n.current=r,()=>{t.setValue(null)}},[t,e])}function oa(e){let{views:t,activeViewId:n,onChange:r,triggerLabel:i,enabled:a=!0}=e,o=(0,$.useRef)(r);o.current=r;let s=(0,$.useCallback)(e=>o.current(e),[]);aa((0,$.useMemo)(()=>a?{views:t,activeViewId:n,onChange:s,triggerLabel:i}:null,[a,t,n,s,i]))}function sa(e){return e.replace(/[-_]/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function ca(){return(0,Q.jsx)(`span`,{className:`select-none text-muted-foreground/40 mx-1.5 text-base font-light`,"aria-hidden":!0,children:`/`})}var la=[];function ua({variant:e,appName:t,objects:n,connectionState:r,presenceUsers:i,activities:o,activeAppName:c,onAppChange:l}){let u=e??(t?`app`:`home`),f=u===`app`,p=s(),h=a(),_=m(),{isOnline:y}=A(),{user:b,signOut:x,isAuthEnabled:S,organizations:C,activeOrganization:w,isOrganizationsLoading:E}=g(),D=N(),{t:O}=M(),{objectLabel:ee,dashboardLabel:k,pageLabel:j,reportLabel:P,viewLabel:te,appLabel:ne}=Mt(),{apps:re,dashboards:ae,pages:oe,reports:se}=T(),{currentAppName:F,recordTitle:I}=dr(),L=ia(),[ce,R]=(0,$.useState)(null),ue=(0,$.useCallback)(async()=>{if(ce===null)try{let e=D?.getClient?.();if(!e?.meta?.getItems){R([]);return}let t=await e.meta.getItems(`doc`);R((Array.isArray(t)?t:Array.isArray(t?.items)?t.items:Array.isArray(t?.value)?t.value:[]).map(e=>({name:e?.name,label:e?.label,_packageId:e?._packageId})).filter(e=>e.name))}catch{R([])}},[ce,D]),[de,fe]=(0,$.useState)(null),[pe,me]=(0,$.useState)([]),he=(0,$.useRef)(!1),z=(0,$.useRef)(!1),B=(0,$.useRef)(!0);(0,$.useEffect)(()=>(B.current=!0,()=>{B.current=!1}),[]);let V=(0,$.useRef)(!1),H=(0,$.useRef)(!1),U=(0,$.useRef)(!1),[ge,_e]=(0,$.useState)(0),ve=(0,$.useRef)(!1),ye=(0,$.useCallback)(async()=>{if(!D||!f)return;let e=e=>e?.httpStatus===404||e?.status===404||e?.code===`object_not_found`;if(!he.current&&!U.current){U.current=!0;try{let t=await D.find(`sys_activity`,{$orderby:{timestamp:`desc`},$top:20}).catch(t=>(e(t)&&(he.current=!0),{data:[]}));if(t.data?.length){let e=t.data.filter(e=>typeof e.type==`string`);e.length&&fe(e)}}catch{}finally{U.current=!1}}},[D,f]);(0,$.useEffect)(()=>{ye()},[ye]),(0,$.useEffect)(()=>{if(!D||!f||!b?.id||z.current)return;let e=!1,t=null,n=1e4,r=n,i=e=>e?.httpStatus===404||e?.status===404||e?.code===`object_not_found`,a=new Set([`read`,`clicked`,`dismissed`]),o=async()=>{if(!V.current){V.current=!0;try{let[e,t]=await Promise.all([D.find(`sys_inbox_message`,{$filter:{user_id:b.id},$orderby:{created_at:`desc`},$top:20}),D.find(`sys_notification_receipt`,{$filter:{user_id:b.id,channel:`inbox`},$top:200}).catch(()=>({data:[]}))]);if(!B.current)return;let i=Array.isArray(e?.data)?e.data:[],o=Array.isArray(t?.data)?t.data:[],s=new Map;for(let e of o){let t=e?.notification_id==null?``:String(e.notification_id);if(!t)continue;let n=s.get(t);(!n||!a.has(n.state)&&a.has(e.state))&&s.set(t,{id:String(e.id),state:String(e.state)})}me(i.map(e=>{let t=e?.notification_id==null?null:String(e.notification_id),n=t?s.get(t):void 0;return{id:String(e.id),notification_id:t,receipt_id:n?.id??null,type:e.topic??`notification`,title:e.title??``,body:e.body_md??null,action_url:e.action_url??null,is_read:n?a.has(n.state):!1,created_at:e.created_at}})),r=n}catch(e){if(i(e)){z.current=!0;return}r=Math.min(r*2,12e4)}finally{V.current=!1}}},s=()=>{if(e||z.current)return;let n=typeof document<`u`&&document.hidden?6e4:r;t=setTimeout(async()=>{await o(),s()},n)},c=()=>{e||typeof document>`u`||document.hidden||(t&&=(clearTimeout(t),null),r=n,o().finally(s))};return o().finally(s),typeof document<`u`&&document.addEventListener(`visibilitychange`,c),()=>{e=!0,t&&clearTimeout(t),typeof document<`u`&&document.removeEventListener(`visibilitychange`,c)}},[D,f,b?.id]),(0,$.useEffect)(()=>{if(!f||!b?.id||ve.current)return;let e=`${``.replace(/\/$/,``)}/api/v1/approvals/requests`,t=[];b.id&&t.push(b.id),b.email&&t.push(b.email);for(let e of b.roles||[])e&&t.push(`role:${e}`);let n=!1,r=null,i=async()=>{if(t.length!==0&&!H.current){H.current=!0;try{let n=new URLSearchParams({status:`pending`,approverId:t.join(`,`)}),r=await fetch(`${e}?${n}`,{credentials:`include`});if(r.status===404){ve.current=!0;return}if(!r.ok)return;let i=await r.json().catch(()=>null),a=new Set;for(let e of i?.data||[])a.add(e.id);B.current&&_e(a.size)}catch{}finally{H.current=!1}}},a=()=>{n||ve.current||(r=setTimeout(async()=>{await i(),a()},3e4))};return i().finally(a),()=>{n=!0,r&&clearTimeout(r)}},[f,b?.id]);let xe=pe.reduce((e,t)=>e+ +!t.is_read,0),Se=(0,$.useCallback)(async(e,t)=>{!D||!e.notification_id||(e.receipt_id?await D.update(`sys_notification_receipt`,e.receipt_id,{state:`read`,at:t}):await D.create(`sys_notification_receipt`,{notification_id:e.notification_id,user_id:b?.id,channel:`inbox`,state:`read`,at:t,created_at:t}))},[D,b?.id]),Ce=(0,$.useCallback)(async e=>{let t=pe.find(t=>t.id===e);if(me(t=>t.map(t=>t.id===e?{...t,is_read:!0}:t)),t)try{await Se(t,new Date().toISOString())}catch{}},[pe,Se]),Ee=(0,$.useCallback)(async()=>{let e=pe.filter(e=>!e.is_read);if(!e.length)return;me(e=>e.map(e=>({...e,is_read:!0})));let t=new Date().toISOString();await Promise.all(e.map(e=>Se(e,t).catch(()=>{})))},[pe,Se]),W=ur(),De=i??(W.length>0?W:la),Oe=o??de??[],G=E||(C??[]).length>0||!!w,K=p.pathname.split(`/`).filter(Boolean),ke=h.appName||K[1],Ae=K[2],je=`/apps/${ke}`,Me=n??[],q=kr(re||[],c||F||ke),Pe=new Set,Fe=e=>{for(let t of e||[])t.type===`object`&&t.objectName&&Pe.add(t.objectName),t.children&&Fe(t.children)};Fe(q?.navigation||[]);for(let e of q?.areas||[])Fe(e.navigation||[]);let Ie=Pe.size>0?Me.filter(e=>Pe.has(e.name)):Me.filter(e=>!e.name.startsWith(`sys_`)&&!e.name.startsWith(`auth_`)),Le=q?._packageId,Re=Le?(ce??[]).filter(e=>e._packageId===Le):[],ze=Ie.map(e=>({label:ee(e),href:`${je}/${e.name}`})),J=[];if(f){if(Ae===`dashboard`){if(J.push({label:O(`console.breadcrumb.dashboards`),href:je}),K[3]){let e=K[3],t=Kr(ae,e,q?._packageId)?.label||sa(e);J.push({label:k({name:e,label:t})})}}else if(Ae===`page`){if(J.push({label:O(`console.breadcrumb.pages`),href:je}),K[3]){let e=K[3],t=Kr(oe,e,q?._packageId)?.label||sa(e);J.push({label:j({name:e,label:t})})}}else if(Ae===`report`){if(J.push({label:O(`console.breadcrumb.reports`),href:je}),K[3]){let e=K[3],t=Kr(se,e,q?._packageId)?.label||sa(e);J.push({label:P({name:e,label:t})})}}else if(Ae===`system`)J.push({label:O(`console.breadcrumb.system`)}),K[3]&&J.push({label:sa(K[3])});else if(Ae){let e=Me.find(e=>e.name===Ae);if(e){if(J.push({label:ee(e),href:`${je}/${Ae}`,siblings:ze}),K[3]===`record`&&K[4]){let e=K[4].length>12?`${K[4].slice(0,8)}…`:K[4],t=I?.trim(),n=t&&t.length>48?`${t.slice(0,45)}…`:t;J.push({label:n||`#${e}`})}else if(K[3]===`view`&&K[4]){let t=K[4],n=(e.listViews||e.list_views||{})[t],r=n&&(n.label||n.title)||sa(t),i=te(e.name,t,r);J.push({label:i})}}}}let Be=J[J.length-1]?.label||t||``;return(0,Q.jsxs)(`div`,{className:`flex items-center justify-between w-full h-full`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center min-w-0 flex-1`,children:[(0,Q.jsx)(d,{to:`/home`,className:X(`flex items-center justify-center h-7 w-7 shrink-0 rounded-md bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,f&&`hidden sm:flex`),title:Xr(),children:(0,Q.jsx)(Ye,{className:`h-4 w-4`})}),u===`home`&&(0,Q.jsx)(`span`,{className:`hidden sm:inline ml-2 text-sm font-semibold tracking-tight`,children:Xr()}),u===`orgs`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ca,{}),(0,Q.jsx)(`span`,{className:`text-sm font-medium text-foreground/80 px-1.5`,children:O(`organizations.title`,{defaultValue:`Organizations`})})]}),f&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Hi,{className:`lg:hidden shrink-0 ml-1`,"aria-label":O(`common.toggleSidebar`,{defaultValue:`Toggle sidebar`})}),c&&l?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`hidden sm:flex items-center`,children:(0,Q.jsx)(ca,{})}),(0,Q.jsx)(`div`,{className:`hidden sm:flex items-center`,children:(0,Q.jsx)(ta,{activeAppName:c,onAppChange:l})})]}):t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`hidden sm:flex items-center`,children:(0,Q.jsx)(ca,{})}),(0,Q.jsx)(`span`,{className:`hidden sm:inline text-sm font-medium text-foreground/80 px-1.5`,children:t})]}):null,J.map((e,t)=>{let n=t===J.length-1;return(0,Q.jsxs)(`span`,{className:`hidden sm:flex items-center min-w-0`,children:[(0,Q.jsx)(ca,{}),e.siblings&&e.siblings.length>1?(0,Q.jsxs)(hn,{children:[(0,Q.jsxs)(Pt,{className:`flex items-center gap-1 rounded-md px-1.5 py-1 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring hover:bg-accent hover:text-foreground ${n?`text-foreground/80`:`text-foreground/60`}`,children:[e.label,(0,Q.jsx)(le,{className:`h-3.5 w-3.5 text-muted-foreground`})]}),(0,Q.jsxs)(_t,{align:`start`,sideOffset:8,className:`w-56 max-h-72 overflow-y-auto`,children:[(0,Q.jsx)(xt,{className:`text-xs text-muted-foreground font-normal`,children:`Switch Object`}),(0,Q.jsx)(kt,{}),e.siblings.map(e=>(0,Q.jsx)(bn,{asChild:!0,children:(0,Q.jsx)(d,{to:e.href,className:`w-full`,children:e.label})},e.href))]})]}):e.href?(0,Q.jsx)(d,{to:e.href,className:`rounded-md px-1.5 py-1 text-sm font-medium transition-colors hover:bg-accent hover:text-foreground truncate max-w-[160px] ${n?`text-foreground/80`:`text-foreground/60`}`,children:e.label}):(0,Q.jsx)(`span`,{className:`px-1.5 py-1 text-sm font-medium truncate max-w-[160px] ${n?`text-foreground/80`:`text-foreground/60`}`,children:e.label})]},t)}),L&&L.views.length>0?L.views.length>1?(0,Q.jsxs)(hn,{children:[(0,Q.jsx)(Pt,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:`sm:hidden flex items-center gap-0.5 min-w-0 ml-1 rounded-md px-1.5 py-1 text-sm font-medium hover:bg-accent active:bg-accent/80 transition-colors`,"aria-label":O(`topbar.switchView`,{defaultValue:`Switch view`}),children:[(0,Q.jsx)(`span`,{className:`truncate max-w-[180px]`,children:L.triggerLabel??L.views.find(e=>e.id===L.activeViewId)?.label??Be}),(0,Q.jsx)(le,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(_t,{align:`start`,className:`min-w-[220px] max-w-[280px]`,children:L.views.map(e=>{let t=e.id===L.activeViewId;return(0,Q.jsxs)(bn,{onSelect:()=>{t||L.onChange(e.id)},className:`gap-2`,children:[e.icon?(0,Q.jsx)(`span`,{className:`shrink-0 text-muted-foreground [&>svg]:h-4 [&>svg]:w-4`,children:e.icon}):null,(0,Q.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),e.locked?(0,Q.jsx)(Bt,{className:`h-3 w-3 shrink-0 text-muted-foreground`,"aria-hidden":!0}):null,t?(0,Q.jsx)(Ne,{className:`h-4 w-4 shrink-0 text-foreground`,"aria-hidden":!0}):null]},e.id)})})]}):(0,Q.jsx)(`span`,{className:`text-sm font-medium sm:hidden truncate min-w-0 ml-1`,children:L.triggerLabel??L.views[0].label}):(0,Q.jsx)(`span`,{className:`text-sm font-medium sm:hidden truncate min-w-0 ml-1`,children:Be})]})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5 sm:gap-1 shrink-0 [&>*+*[data-topbar-group]]:ml-1 [&>[data-topbar-group]+[data-topbar-group]]:border-l [&>[data-topbar-group]+[data-topbar-group]]:border-border/60 [&>[data-topbar-group]+[data-topbar-group]]:pl-1 sm:[&>[data-topbar-group]+[data-topbar-group]]:pl-2 sm:[&>[data-topbar-group]+[data-topbar-group]]:ml-2`,children:[!y&&(0,Q.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:[(0,Q.jsx)(`span`,{className:`h-2 w-2 rounded-full bg-yellow-500 animate-pulse`}),O(`topbar.offline`,{defaultValue:`Offline`})]}),f&&r&&(0,Q.jsx)(Qi,{state:r}),f&&De.length>0&&(0,Q.jsx)(`div`,{className:`hidden md:flex items-center shrink-0`,title:O(`topbar.usersOnline`,{defaultValue:`Users currently online`}),children:(0,Q.jsx)(cr,{users:De,size:`sm`,maxVisible:3,showStatus:!0})}),(0,Q.jsxs)(`div`,{"data-topbar-group":!0,className:`flex items-center gap-0.5 sm:gap-1 shrink-0`,children:[(0,Q.jsxs)(`button`,{onClick:()=>document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0})),className:`hidden lg:flex relative items-center gap-2 w-48 xl:w-64 h-8 px-3 text-sm rounded-md border bg-muted/50 text-muted-foreground hover:bg-muted transition-colors`,children:[(0,Q.jsx)(Ve,{className:`h-3.5 w-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`flex-1 text-left text-xs`,children:O(`console.search`,{defaultValue:`Search…`})}),(0,Q.jsxs)(`kbd`,{className:`pointer-events-none inline-flex h-5 items-center gap-0.5 rounded border bg-background px-1.5 text-[10px] font-medium text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:`text-xs`,children:`⌘`}),`K`]})]}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`lg:hidden h-8 w-8 shrink-0`,onClick:()=>document.dispatchEvent(new KeyboardEvent(`keydown`,{key:`k`,metaKey:!0})),"aria-label":O(`console.search`,{defaultValue:`Search…`}),children:(0,Q.jsx)(Ve,{className:`h-4 w-4`})})]}),(0,Q.jsxs)(`div`,{"data-topbar-group":!0,className:`flex items-center gap-0.5 shrink-0`,children:[(0,Q.jsx)(ea,{notifications:pe,unreadCount:xe,pendingApprovalsCount:ge,activities:Oe,onMarkAllRead:Ee,onMarkRead:Ce}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0`,asChild:!0,"aria-label":O(`topbar.aiAssistant`,{defaultValue:`AI Assistant`}),children:(0,Q.jsx)(d,{to:`/ai`,children:(0,Q.jsx)(Te,{className:`h-4 w-4`})})}),(0,Q.jsxs)(hn,{onOpenChange:e=>{e&&ue()},children:[(0,Q.jsx)(Pt,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8 hidden md:flex shrink-0`,"aria-label":O(`sidebar.helpTooltip`,{defaultValue:`Help & Documentation`}),children:(0,Q.jsx)(Ct,{className:`h-4 w-4`})})}),(0,Q.jsxs)(_t,{align:`end`,className:`min-w-56 rounded-lg`,sideOffset:4,children:[Re.length>0&&Le?(0,Q.jsxs)(bn,{className:`cursor-pointer`,onClick:()=>_(Re.length===1?`/apps/${Le}/docs/${Re[0].name}`:`/apps/${Le}/docs`),children:[(0,Q.jsx)(we,{className:`mr-2 h-4 w-4`}),O(`help.appDocs`,{defaultValue:`This app's docs`})]}):null,(0,Q.jsxs)(bn,{className:`cursor-pointer`,onClick:()=>_(`/docs`),children:[(0,Q.jsx)(Ye,{className:`mr-2 h-4 w-4`}),O(`help.allDocs`,{defaultValue:`All documentation`})]}),(0,Q.jsx)(kt,{}),(0,Q.jsx)(bn,{asChild:!0,className:`cursor-pointer`,children:(0,Q.jsxs)(`a`,{href:`https://docs.objectstack.ai`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,Q.jsx)(be,{className:`mr-2 h-4 w-4`}),O(`help.onlineDocs`,{defaultValue:`Online documentation`})]})})]})]})]}),(0,Q.jsxs)(`div`,{"data-topbar-group":!0,className:`flex items-center gap-0.5 shrink-0`,children:[` `,(0,Q.jsxs)(hn,{children:[(0,Q.jsx)(Pt,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0 rounded-full`,children:(0,Q.jsxs)(Et,{className:`h-7 w-7 rounded-full`,children:[(0,Q.jsx)(Qt,{src:b?.image,alt:b?.name??`User`}),(0,Q.jsx)(vn,{className:`rounded-full bg-primary text-primary-foreground text-xs`,children:v(b)})]})})}),(0,Q.jsxs)(_t,{align:`end`,className:`min-w-64 rounded-lg`,sideOffset:4,children:[(0,Q.jsx)(xt,{className:`p-0 font-normal`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-2`,children:[(0,Q.jsxs)(Et,{className:`h-8 w-8 rounded-lg`,children:[(0,Q.jsx)(Qt,{src:b?.image,alt:b?.name??`User`}),(0,Q.jsx)(vn,{className:`rounded-lg bg-primary text-primary-foreground`,children:v(b)})]}),(0,Q.jsxs)(`div`,{className:`grid flex-1 text-left text-sm leading-tight`,children:[(0,Q.jsx)(`span`,{className:`truncate font-semibold`,children:b?.name??`User`}),(0,Q.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:b?.email??``})]})]})}),(0,Q.jsx)(kt,{}),(0,Q.jsxs)(qt,{children:[(0,Q.jsxs)(bn,{onClick:()=>_(`/apps/account/component/account/profile_card`),className:`cursor-pointer`,children:[(0,Q.jsx)(Ut,{className:`mr-2 h-4 w-4`}),O(`user.profile`,{defaultValue:`Profile`})]}),G&&(0,Q.jsxs)(bn,{onClick:()=>_(`/organizations`),className:`cursor-pointer`,children:[(0,Q.jsx)(et,{className:`mr-2 h-4 w-4`}),O(`organizations.mine`,{defaultValue:`My Organizations`})]}),(re||[]).filter(e=>e.active!==!1&&e.hidden===!0&&e.name!==`account`).map(e=>{let t=Pr(e.icon),n=ne({name:e.name,label:Hr(e.label,O)});return(0,Q.jsxs)(bn,{onClick:()=>_(`/apps/${Ar(e)??e.name}`),className:`cursor-pointer`,children:[(0,Q.jsx)(t,{className:`mr-2 h-4 w-4`}),n]},`hidden_app_${e.name}`)})]}),(0,Q.jsx)(kt,{}),(0,Q.jsx)(xt,{className:`text-[11px] font-normal text-muted-foreground uppercase tracking-wide px-2`,children:O(`user.preferences`,{defaultValue:`Preferences`})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-foreground/80`,children:O(`user.theme`,{defaultValue:`Theme`})}),(0,Q.jsx)(Ji,{})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1.5 text-sm`,children:[(0,Q.jsx)(`span`,{className:`text-foreground/80`,children:O(`user.language`,{defaultValue:`Language`})}),(0,Q.jsx)(Xi,{})]}),S&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(kt,{}),(0,Q.jsxs)(bn,{className:`text-destructive focus:text-destructive`,onClick:()=>x(),children:[(0,Q.jsx)(ie,{className:`mr-2 h-4 w-4`}),O(`user.logout`,{defaultValue:`Log out`})]})]})]})]})]})]})]})}function da({children:e}){return tr(),(0,Q.jsx)(Q.Fragment,{children:e})}function fa({children:e,activeAppName:t,activeApp:n,onAppChange:r,objects:i,connectionState:a,userId:o}){let s=Hr(n?.label)||t,{isAiEnabled:c}=C(),l=c||!1,u=Jr().features.aiStudio===!1&&n?.defaultAgent===`metadata_assistant`?void 0:n?.defaultAgent,{setContext:d,setCurrentAppName:f}=dr();return(0,$.useEffect)(()=>{d(`app`),f(t)},[d,f,t]),(0,Q.jsx)(ra,{children:(0,Q.jsxs)(_r,{sidebar:(0,Q.jsx)(qi,{activeAppName:t,onAppChange:r}),navbar:(0,Q.jsx)(ua,{variant:`app`,appName:s,objects:i,connectionState:a,activeAppName:t,onAppChange:r}),className:`!p-0 overflow-y-auto overflow-x-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?`${Hr(n.label)} — ${Xr()}`:void 0}:void 0,children:[(0,Q.jsxs)(da,{children:[(0,Q.jsx)(Ni,{}),(0,Q.jsx)(Pi,{}),e]}),l&&(0,Q.jsx)(Oi,{appLabel:s,appName:t,defaultAgent:u,objects:i,userId:o})]})})}function pa({title:e,description:t,icon:n,actions:r,accentColor:i,sticky:a=!1,className:o,"data-testid":s}){return(0,Q.jsxs)(`div`,{style:{"--page-header-accent":i||`hsl(var(--primary))`},className:X(`relative shrink-0 border-b bg-background z-10`,a&&`sticky top-0 bg-background/85 backdrop-blur supports-[backdrop-filter]:bg-background/75`,o),"data-testid":s??`page-header`,children:[(0,Q.jsx)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 top-0 h-[2px] opacity-80`,style:{background:`linear-gradient(90deg, transparent, var(--page-header-accent), transparent)`}}),(0,Q.jsxs)(`div`,{className:`flex justify-between items-center gap-3 py-2.5 sm:py-3 px-4 sm:px-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[n&&(0,Q.jsx)(`div`,{className:X(`shrink-0 inline-flex items-center justify-center rounded-lg`,`h-9 w-9 sm:h-10 sm:w-10`,`[&_svg]:h-[18px] [&_svg]:w-[18px] sm:[&_svg]:h-5 sm:[&_svg]:w-5`),style:{color:`var(--page-header-accent)`,background:`linear-gradient(135deg, color-mix(in srgb, var(--page-header-accent) 18%, transparent), color-mix(in srgb, var(--page-header-accent) 6%, transparent))`,boxShadow:`inset 0 0 0 1px color-mix(in srgb, var(--page-header-accent) 22%, transparent)`},children:n}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h1`,{className:`text-base sm:text-lg lg:text-xl font-semibold tracking-tight text-foreground truncate leading-tight`,children:e}),t&&(0,Q.jsx)(`p`,{className:`text-xs sm:text-sm text-muted-foreground truncate hidden sm:block max-w-xl mt-0.5`,children:t})]})]}),r&&(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5 sm:gap-2 shrink-0`,children:r})]})]})}function ma({apps:e,activeApp:t,objects:n,onAppChange:r,dataSource:i}){let[o,s]=(0,$.useState)(!1),[c,l]=(0,$.useState)(``),u=m(),{appName:d}=a(),{setTheme:f}=vi(),{evaluator:p}=Un(),{t:h}=M();(0,$.useEffect)(()=>{let e=e=>{e.key===`k`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),s(e=>!e))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),(0,$.useEffect)(()=>{o||l(``)},[o]);let _=`/apps/${d||Ar(t)}`,{user:v}=g(),y=(0,$.useMemo)(()=>({currentUserId:v?.id??null}),[v?.id]),b=(0,$.useCallback)(e=>{s(!1),e()},[]),x=ha(t?.navigation||[]).filter(e=>Hn(e.visible??e.visibleOn,p)),{results:S,isSearching:C}=O({query:c,objects:n,dataSource:i,objectNames:(0,$.useMemo)(()=>x.filter(e=>e.type===`object`&&typeof e.objectName==`string`).map(e=>e.objectName),[t?.name,x.map(e=>e.objectName||``).join(`|`)]),enabled:o&&!!i,getDisplayName:Br}),{recentItems:w}=nr(),T=(0,$.useMemo)(()=>w.filter(e=>e.type===`record`).slice(0,5),[w]),E=o&&c.trim().length===0&&T.length>0;return(0,Q.jsxs)(oe,{open:o,onOpenChange:s,children:[(0,Q.jsx)(Ae,{placeholder:h(`console.commandPalette.placeholder`),value:c,onValueChange:l}),(0,Q.jsxs)(pe,{children:[(0,Q.jsx)(Ht,{children:C?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-2 text-muted-foreground`,children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-1.5 w-1.5 rounded-full bg-primary motion-safe:animate-pulse`}),h(`console.commandPalette.searching`,{defaultValue:`Searching…`})]}):h(`console.commandPalette.noResults`)}),E&&(0,Q.jsx)(K,{heading:h(`console.commandPalette.recentRecords`,{defaultValue:`Recently viewed`}),children:T.map(e=>(0,Q.jsxs)(q,{value:`recent ${e.label} ${e.id}`,onSelect:()=>b(()=>u(e.href)),children:[(0,Q.jsx)(Ve,{className:`mr-2 h-4 w-4`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]},`recent:${e.id}`))}),S.length>0&&(0,Q.jsx)(K,{heading:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[h(`console.commandPalette.records`,{defaultValue:`Records`}),C&&(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`inline-block h-1.5 w-1.5 rounded-full bg-primary motion-safe:animate-pulse`})]}),children:S.map(e=>{let t=Pr(e.icon);return(0,Q.jsxs)(q,{value:`record ${c} ${e.display} ${e.objectLabel} ${e.objectName} ${e.recordId}`,onSelect:()=>b(()=>u(`${_}/${e.objectName}/record/${e.recordId}`)),children:[(0,Q.jsx)(t,{className:`mr-2 h-4 w-4`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.display}),(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:e.objectLabel})]},`${e.objectName}:${e.recordId}`)})}),x.filter(e=>e.type===`object`).length>0&&(0,Q.jsx)(K,{heading:h(`console.commandPalette.objects`),children:x.filter(e=>e.type===`object`).map(e=>{let t=Pr(e.icon);return(0,Q.jsxs)(q,{value:`object ${Hr(e.label,h)} ${e.objectName}`,onSelect:()=>b(()=>u(gr(e,_,y).href)),children:[(0,Q.jsx)(t,{className:`mr-2 h-4 w-4`}),(0,Q.jsx)(`span`,{children:Hr(e.label,h)})]},e.id)})}),x.filter(e=>e.type===`dashboard`).length>0&&(0,Q.jsx)(K,{heading:h(`console.commandPalette.dashboards`),children:x.filter(e=>e.type===`dashboard`).map(e=>(0,Q.jsxs)(q,{value:`dashboard ${Hr(e.label,h)} ${e.dashboardName}`,onSelect:()=>b(()=>u(gr(e,_,y).href)),children:[(0,Q.jsx)(U,{className:`mr-2 h-4 w-4`}),(0,Q.jsx)(`span`,{children:Hr(e.label,h)})]},e.id))}),x.filter(e=>e.type===`page`).length>0&&(0,Q.jsx)(K,{heading:h(`console.commandPalette.pages`),children:x.filter(e=>e.type===`page`).map(e=>(0,Q.jsxs)(q,{value:`page ${Hr(e.label,h)} ${e.pageName}`,onSelect:()=>b(()=>u(gr(e,_,y).href)),children:[(0,Q.jsx)(I,{className:`mr-2 h-4 w-4`}),(0,Q.jsx)(`span`,{children:Hr(e.label,h)})]},e.id))}),x.filter(e=>e.type===`report`).length>0&&(0,Q.jsx)(K,{heading:h(`console.commandPalette.reports`),children:x.filter(e=>e.type===`report`).map(e=>(0,Q.jsxs)(q,{value:`report ${Hr(e.label,h)} ${e.reportName}`,onSelect:()=>b(()=>u(gr(e,_,y).href)),children:[(0,Q.jsx)(z,{className:`mr-2 h-4 w-4`}),(0,Q.jsx)(`span`,{children:Hr(e.label,h)})]},e.id))}),e.filter(e=>e.active!==!1).length>1&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ye,{}),(0,Q.jsx)(K,{heading:h(`console.commandPalette.switchApp`),children:e.filter(e=>e.active!==!1).map(e=>{let n=Pr(e.icon);return(0,Q.jsxs)(q,{value:`app ${Hr(e.label,h)} ${e.name}`,onSelect:()=>b(()=>r(Ar(e)??e.name)),children:[(0,Q.jsx)(n,{className:`mr-2 h-4 w-4`}),(0,Q.jsx)(`span`,{children:Hr(e.label,h)}),e.name===t?.name&&(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-muted-foreground`,children:h(`console.commandPalette.current`)})]},e.name)})})]}),(0,Q.jsx)(ye,{}),(0,Q.jsxs)(K,{heading:h(`console.commandPalette.preferences`),children:[(0,Q.jsxs)(q,{value:`theme light`,onSelect:()=>b(()=>f(`light`)),children:[(0,Q.jsx)(ne,{className:`mr-2 h-4 w-4`}),(0,Q.jsx)(`span`,{children:h(`console.commandPalette.lightTheme`)})]}),(0,Q.jsxs)(q,{value:`theme dark`,onSelect:()=>b(()=>f(`dark`)),children:[(0,Q.jsx)(jt,{className:`mr-2 h-4 w-4`}),(0,Q.jsx)(`span`,{children:h(`console.commandPalette.darkTheme`)})]}),(0,Q.jsxs)(q,{value:`theme system`,onSelect:()=>b(()=>f(`system`)),children:[(0,Q.jsx)(st,{className:`mr-2 h-4 w-4`}),(0,Q.jsx)(`span`,{children:h(`console.commandPalette.systemTheme`)})]})]}),(0,Q.jsx)(ye,{}),(0,Q.jsx)(K,{heading:h(`console.commandPalette.actions`),children:(0,Q.jsxs)(q,{value:`search all results full page`,onSelect:()=>b(()=>u(`${_}/search`)),children:[(0,Q.jsx)(Ve,{className:`mr-2 h-4 w-4`}),(0,Q.jsx)(`span`,{children:h(`console.commandPalette.openFullSearch`)})]})})]})]})}function ha(e){let t=[];for(let n of e)n.type===`group`&&n.children?t.push(...ha(n.children)):t.push(n);return t}function ga(){let{t:e}=M(),[t,n]=(0,$.useState)(!1),r=(0,$.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.aiChat`,{defaultValue:`AI assistant`}),shortcuts:[{keys:[`⌘`,`⇧`,`O`],description:e(`console.shortcuts.newChat`,{defaultValue:`New chat`})},{keys:[`⌘`,`⇧`,`S`],description:e(`console.shortcuts.toggleChatsList`,{defaultValue:`Toggle conversations list`})}]},{title:e(`console.shortcuts.groups.preferences`),shortcuts:[{keys:[`⌘`,`D`],description:e(`console.shortcuts.toggleDarkMode`)}]}],[e]);return(0,$.useEffect)(()=>{function e(e){let t=e.target;t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable||e.key===`?`&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(e.preventDefault(),n(e=>!e))}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[]),(0,Q.jsx)(Ee,{open:t,onOpenChange:n,children:(0,Q.jsxs)(Re,{className:`sm:max-w-lg max-h-[80vh] overflow-y-auto`,children:[(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(ge,{children:e(`console.shortcuts.title`)}),(0,Q.jsx)(An,{children:e(`console.shortcuts.description`)})]}),(0,Q.jsx)(`div`,{className:`space-y-6 pt-2`,children:r.map(e=>(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground mb-3`,children:e.title}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:e.shortcuts.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between py-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm`,children:e.description}),(0,Q.jsx)(`div`,{className:`flex items-center gap-1`,children:e.keys.map((e,t)=>(0,Q.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:e},t))})]},t))})]},e.title))})]})})}function _a(){return null}function va(){return typeof document<`u`&&document.documentElement.lang?.startsWith(`zh`)||typeof navigator<`u`&&navigator.language?.startsWith(`zh`)?D.console:j.console}function ya({message:e,error:t,onRetry:n,retrying:r}){let[i,a]=(0,$.useState)(0),o=va(),s=(0,$.useMemo)(()=>[o.loadingSteps.connecting,o.loadingSteps.loadingConfig,o.loadingSteps.preparingWorkspace],[o]);return(0,$.useEffect)(()=>{if(e||t)return;let n=setInterval(()=>{a(e=>Math.min(e+1,s.length-1))},1200);return()=>clearInterval(n)},[e,t,s.length]),(0,Q.jsx)(`div`,{className:`flex flex-col items-center justify-center h-screen bg-background`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-6`,children:[(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(`div`,{className:`absolute inset-0 bg-primary/20 rounded-2xl blur-xl animate-pulse`}),(0,Q.jsx)(`div`,{className:`relative bg-linear-to-br from-primary to-primary/80 p-4 rounded-2xl shadow-lg`,children:(0,Q.jsx)($e,{className:`h-10 w-10 text-primary-foreground`})})]}),(0,Q.jsxs)(`div`,{className:`text-center space-y-2`,children:[(0,Q.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:Xr()}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o.initializing})]}),t?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-4 max-w-md w-full px-6`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 p-5 rounded-lg border border-destructive/30 bg-destructive/5 w-full`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-destructive`,children:[(0,Q.jsx)(En,{className:`h-5 w-5 shrink-0`}),(0,Q.jsx)(`span`,{className:`text-sm font-semibold`,children:o.error.connectionFailed})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground text-center break-words`,children:t}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground text-center`,children:o.error.checkServer})]}),n&&(0,Q.jsx)(Y,{onClick:n,disabled:r,variant:`default`,size:`sm`,className:`gap-2`,children:r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(G,{className:`h-4 w-4 animate-spin`}),o.actions.retrying]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fe,{className:`h-4 w-4`}),o.actions.retry]})})]}):e?(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 px-4 py-2 bg-muted/50 rounded-full`,children:[(0,Q.jsx)(de,{className:`h-4 w-4 text-primary`}),(0,Q.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e})]}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2 w-64`,children:s.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2.5 text-sm transition-opacity duration-300`,style:{opacity:t<=i?1:.3},children:[t<i?(0,Q.jsx)(Ft,{className:`h-4 w-4 text-primary shrink-0`}):t===i?(0,Q.jsx)(G,{className:`h-4 w-4 text-primary shrink-0 animate-spin`}):(0,Q.jsx)(`div`,{className:`h-4 w-4 rounded-full border border-muted-foreground/30 shrink-0`}),(0,Q.jsx)(`span`,{className:t<=i?`text-foreground`:`text-muted-foreground`,children:e})]},e))})]})})}function ba(e){let{theme:t=`system`}=vi(),{t:n}=M();return(0,Q.jsx)(Mn,{theme:t,className:`toaster group`,position:`top-right`,closeButton:!0,richColors:!0,expand:!0,visibleToasts:4,containerAriaLabel:n(`notifications.regionLabel`,{defaultValue:`Notifications`}),icons:{success:(0,Q.jsx)(Ft,{className:`h-4 w-4`}),info:(0,Q.jsx)(Se,{className:`h-4 w-4`}),warning:(0,Q.jsx)(ze,{className:`h-4 w-4`}),error:(0,Q.jsx)(bt,{className:`h-4 w-4`}),loading:(0,Q.jsx)(G,{className:`h-4 w-4 animate-spin`})},toastOptions:{duration:4e3,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})}var xa=[`motion-safe:animate-in`,`motion-safe:fade-in-0`,`motion-safe:duration-150`];function Sa({children:e,className:t}){let n=s(),r=$.useRef(null),i=$.useRef(n.pathname);return $.useLayoutEffect(()=>{if(i.current===n.pathname)return;i.current=n.pathname;let e=r.current;e&&(e.classList.remove(...xa),e.offsetWidth,e.classList.add(...xa))},[n.pathname]),(0,Q.jsx)(`div`,{ref:r,className:[...xa,t??``].filter(Boolean).join(` `),children:e})}var Ca=null,wa=null;function Ta(){return wa||(wa=(async()=>{let e={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},t=e.VITE_SENTRY_DSN;if(!t)return!1;try{let n=await c(()=>import(`./vendor-sentry-BIOhD5Kg.js`).then(e=>e.t),[],import.meta.url),r=Number(e.VITE_SENTRY_TRACES_SAMPLE_RATE??`0.1`);return n.init({dsn:t,environment:e.VITE_SENTRY_ENVIRONMENT||e.MODE||`production`,release:e.VITE_SENTRY_RELEASE||e.VITE_APP_VERSION||`unknown`,tracesSampleRate:Number.isFinite(r)?r:.1,sendDefaultPii:e.VITE_SENTRY_SEND_DEFAULT_PII!==`false`,replaysSessionSampleRate:0,replaysOnErrorSampleRate:e.VITE_SENTRY_REPLAY===`true`?.1:0,integrations:[n.browserTracingIntegration()],beforeBreadcrumb(e){return(e.category===`fetch`||e.category===`xhr`)&&e.data?.url&&typeof e.data.url==`string`&&(e.data.url=Da(e.data.url)),e}}),Ca=n,!0}catch(e){return console.warn(`[sentry] init failed; continuing without observability:`,e),!1}})(),wa)}function Ea(e,t){if(Ca)try{Ca.captureException(e,t?{extra:t}:void 0)}catch{}}function Da(e){try{let t=new URL(e,`http://localhost`);for(let e of[`token`,`access_token`,`id_token`,`apiKey`,`api_key`,`password`])t.searchParams.has(e)&&t.searchParams.set(e,`[redacted]`);return t.pathname+(t.searchParams.toString()?`?`+t.searchParams.toString():``)}catch{return e}}function Oa({error:e,onReset:t}){let{t:n}=M();return(0,Q.jsx)(`div`,{className:`flex h-full items-center justify-center p-8`,children:(0,Q.jsxs)(`div`,{className:`max-w-md text-center`,children:[(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-destructive/10`,children:(0,Q.jsx)(ze,{className:`h-6 w-6 text-destructive`})}),(0,Q.jsx)(H,{children:n(`console.errors.somethingWentWrong`)}),(0,Q.jsx)(On,{className:`mb-4`,children:e.message||n(`console.errors.unexpectedError`)}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-2`,children:[(0,Q.jsxs)(Y,{variant:`outline`,size:`sm`,onClick:t,className:`gap-2`,children:[(0,Q.jsx)(ae,{className:`h-4 w-4`}),n(`console.errors.tryAgain`)]}),(0,Q.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:()=>{window.location.href=`/`},className:`gap-2`,children:[(0,Q.jsx)(P,{className:`h-4 w-4`}),n(`console.errors.goHome`)]})]})]}),!1]})})}var ka=class extends $.Component{constructor(e){super(e),this.state={hasError:!1,error:null}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`[ErrorBoundary] Caught error:`,e,t),Ea(e,{componentStack:t.componentStack}),this.props.onError?.(e,t)}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:(0,Q.jsx)(Oa,{error:this.state.error,onReset:this.resetErrorBoundary}):this.props.children}},Aa=new Set([`form`,`detail`]);function ja(e){return typeof e==`string`&&Aa.has(e)}function Ma(e,t){let n=e.type||`grid`,r=ja(n)?`form`:`list`,i=e.label,a=e.data&&typeof e.data==`object`?e.data:void 0;return{name:e.id,object:t,viewKind:r,label:i,config:{...e,type:n,label:i,columns:Array.isArray(e.columns)?e.columns:[],data:{...a,object:t}}}}function Na(e){let t=e.config??{},n={...t};return delete n.data,{...n,id:e.name,label:e.label??t.label}}function Pa(e){let t=e.fields;return!t||typeof t!=`object`?[]:Object.entries(t).map(([e,t])=>{let n=t??{};return{name:e,label:typeof n.label==`string`&&n.label?n.label:e,type:typeof n.type==`string`?n.type:`text`,hidden:n.hidden===!0}})}function Fa({open:e,onClose:t,mode:n=`edit`,activeView:r,objectDef:i,onViewUpdate:a,onSave:o,onCreate:s,metadataClient:c,onAfterChange:l}){let{t:u}=M(),d=(0,$.useRef)(null),f=(0,$.useMemo)(()=>Or(),[]),[p]=(0,$.useState)(()=>`view_${Date.now()}`),m=(0,$.useMemo)(()=>({id:p,label:u(`console.objectView.newView`),type:`grid`,columns:[],filter:[],sort:[]}),[]),h=(0,$.useMemo)(()=>Ma(n===`create`?m:r,i.name),[n===`create`?`create`:r.id,i.name]),[g,_]=(0,$.useState)(h),[v,y]=(0,$.useState)(!1),[b,x]=(0,$.useState)(0),S=(0,$.useRef)(g),C=(0,$.useRef)(h);C.current!==h&&(C.current=h,S.current=h,_(h),y(!1)),(0,$.useEffect)(()=>{S.current=g},[g]),(0,$.useEffect)(()=>{e&&d.current&&d.current.focus()},[e]);let w=(0,$.useMemo)(()=>Pa(i),[i.fields]),T=Mr(g.viewKind)?`form`:`list`,E=(0,$.useCallback)(e=>{let t={...S.current,...e};if(S.current=t,_(t),y(!0),a){let e=Na(t);for(let[t,n]of Object.entries(e))t!==`id`&&a(t,n)}},[a]),D=(0,$.useCallback)(()=>{let e=Na(g);n===`create`?s?.(e):(o?.(e),x(e=>e+1)),y(!1)},[g,o,s,n]),O=(0,$.useCallback)(()=>{if(n===`create`){t();return}_(h),y(!1)},[h,n,t]),ee=(0,$.useCallback)(e=>{let t=Ma(e,i.name);S.current=t,_(t),y(!1)},[i.name]),k=u(n===`create`?`console.objectView.createView`:`console.objectView.configureView`);return e?(0,Q.jsxs)(`div`,{ref:d,tabIndex:-1,role:`complementary`,"aria-label":k,"data-testid":`view-config-panel`,className:`flex h-full flex-col`,children:[(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,Q.jsx)(Rr,{type:`view`,name:g.name,draft:g,variantKey:`config`,familyKey:T,isHome:!0,readOnly:!1,locale:f,objectFieldsOverride:w,onPatch:E})}),(0,Q.jsxs)(`div`,{"data-testid":`view-config-footer`,className:`flex items-center justify-end gap-2 border-t px-4 py-2.5`,children:[n===`edit`&&(0,Q.jsx)(fi,{type:`view`,name:r.id,metadataClient:c,dirty:v,onResume:ee,savedSignal:b,onAfterChange:l}),(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:O,"data-testid":`view-config-discard`,children:u(`console.objectView.discard`)}),(0,Q.jsx)(Y,{size:`sm`,onClick:D,disabled:n===`edit`&&!v,"data-testid":`view-config-save`,children:u(`console.objectView.save`)})]})]}):(0,Q.jsx)(`div`,{ref:d,tabIndex:-1,"data-testid":`view-config-panel`,"aria-hidden":!0})}function Ia(e){return[{type:`grid`,icon:kn,label:e(`console.objectView.viewTypeGrid`),description:e(`console.objectView.viewTypeGridDesc`)},{type:`kanban`,icon:nn,label:e(`console.objectView.viewTypeKanban`),description:e(`console.objectView.viewTypeKanbanDesc`)},{type:`calendar`,icon:De,label:e(`console.objectView.viewTypeCalendar`),description:e(`console.objectView.viewTypeCalendarDesc`)},{type:`gallery`,icon:nt,label:e(`console.objectView.viewTypeGallery`),description:e(`console.objectView.viewTypeGalleryDesc`)},{type:`timeline`,icon:dn,label:e(`console.objectView.viewTypeTimeline`),description:e(`console.objectView.viewTypeTimelineDesc`)},{type:`gantt`,icon:gt,label:e(`console.objectView.viewTypeGantt`),description:e(`console.objectView.viewTypeGanttDesc`)},{type:`map`,icon:ue,label:e(`console.objectView.viewTypeMap`),description:e(`console.objectView.viewTypeMapDesc`)},{type:`chart`,icon:z,label:e(`console.objectView.viewTypeChart`),description:e(`console.objectView.viewTypeChartDesc`)}]}function La(e,t){for(let n=1;n<1e3;n++){let r=`${e} ${n}`;if(!t.has(r))return r}return e}var Ra={kanban:[{key:`groupByField`,i18nKey:`console.objectView.groupByField`,helpI18nKey:`console.objectView.groupByFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`,preferred:ii}],calendar:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.startDateFieldHelp`,filter:e=>e.type===`date`,preferred:oi},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],timeline:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.timelineDateFieldHelp`,filter:e=>e.type===`date`,preferred:oi},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gantt:[{key:`startDateField`,i18nKey:`console.objectView.startDateField`,helpI18nKey:`console.objectView.ganttStartDateFieldHelp`,filter:e=>e.type===`date`,preferred:oi},{key:`endDateField`,i18nKey:`console.objectView.endDateField`,helpI18nKey:`console.objectView.ganttEndDateFieldHelp`,filter:e=>e.type===`date`,preferred:ci},{key:`titleField`,i18nKey:`console.objectView.titleField`,helpI18nKey:`console.objectView.titleFieldHelp`,filter:e=>e.type===`text`}],gallery:[{key:`coverField`,i18nKey:`console.objectView.imageField`,helpI18nKey:`console.objectView.imageFieldHelp`,filter:e=>ai(e)}],map:[{key:`latitudeField`,i18nKey:`console.objectView.latitudeField`,helpI18nKey:`console.objectView.latitudeFieldHelp`,filter:e=>e.type===`number`&&ei(e,`latitude`)},{key:`longitudeField`,i18nKey:`console.objectView.longitudeField`,helpI18nKey:`console.objectView.longitudeFieldHelp`,filter:e=>e.type===`number`&&ei(e,`longitude`)}],chart:[{key:`chartType`,i18nKey:`console.objectView.chartType`,helpI18nKey:`console.objectView.chartTypeHelp`,kind:`enum`,enumOptions:[{value:`bar`,i18nKey:`console.objectView.chartTypeBar`},{value:`line`,i18nKey:`console.objectView.chartTypeLine`},{value:`pie`,i18nKey:`console.objectView.chartTypePie`},{value:`area`,i18nKey:`console.objectView.chartTypeArea`},{value:`scatter`,i18nKey:`console.objectView.chartTypeScatter`}],defaultValue:`bar`},{key:`xAxisField`,i18nKey:`console.objectView.xAxisField`,helpI18nKey:`console.objectView.xAxisFieldHelp`,filter:e=>e.type===`select`||e.type===`boolean`||e.type===`date`||e.type===`text`,preferred:ii},{key:`yAxisFields`,i18nKey:`console.objectView.yAxisField`,helpI18nKey:`console.objectView.yAxisFieldHelp`,filter:e=>e.type===`number`}]};function za({open:e,onOpenChange:t,onCreate:n,existingLabels:r,availableTypes:i,objectDef:a}){let{t:o}=M(),s=(0,$.useMemo)(()=>Ia(o),[o]),c=(0,$.useMemo)(()=>i&&i.length>0?s.filter(e=>i.includes(e.type)):s,[s,i]),l=(0,$.useMemo)(()=>new Set(r??[]),[(r??[]).join(`\0`)]),u=(0,$.useMemo)(()=>a?ni(a):[],[a]),[d,f]=(0,$.useState)(c[0]?.type??`grid`),[p,m]=(0,$.useState)(``),[h,g]=(0,$.useState)(!1),[_,v]=(0,$.useState)({});(0,$.useEffect)(()=>{e&&(f(c[0]?.type??`grid`),g(!1),v({}))},[e,c]),(0,$.useEffect)(()=>{h||m(La(c.find(e=>e.type===d)?.label??`View`,l))},[d,h,c,l]);let y=Ra[d]??[],b=e=>e.kind===`enum`?(e.enumOptions?.length??0)>0:a?(e.filter?u.filter(e.filter):u).length>0:!0,x=(0,$.useMemo)(()=>{let e={};return c.forEach(t=>{let n=(Ra[t.type]??[]).find(e=>!b(e));e[t.type]=n??null}),e},[c,u,a]),S=e=>_[`${d}.${e}`]??``,C=(e,t)=>v(n=>({...n,[`${d}.${e}`]:t})),w=p.trim(),T=w.length>0&&l.has(w),E=y.every(e=>S(e.key).length>0),D=w.length>0&&!T&&E;(0,$.useEffect)(()=>{y.length!==0&&y.forEach(e=>{if(S(e.key).length>0)return;if(e.kind===`enum`){e.defaultValue&&C(e.key,e.defaultValue);return}let t=e.filter?u.filter(e.filter):u;if(t.length===0)return;if(t.length===1){C(e.key,t[0].value);return}let n=si(t,e.preferred??[]);n&&C(e.key,n)})},[d,u]);let O=()=>{if(!D)return;let e={};y.forEach(t=>{let n=S(t.key);n&&(e[t.key]=t.key===`yAxisFields`?[n]:n)});let r={type:d,label:w};Object.keys(e).length>0&&(r[d]=e),n(r),t(!1)};return(0,Q.jsx)(Ee,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Re,{className:`sm:max-w-[560px]`,"data-testid":`create-view-dialog`,children:[(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(ge,{children:o(`console.objectView.createView`)}),(0,Q.jsx)(An,{children:o(`console.objectView.createViewDesc`)})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-4 gap-2 py-2`,"data-testid":`create-view-type-grid`,children:c.map(({type:e,label:t,description:n,icon:r})=>{let i=e===d,a=x[e],s=!!a,c=s?o(`console.objectView.viewTypeUnavailable`,{field:o(a.i18nKey)}):void 0;return(0,Q.jsxs)(`button`,{type:`button`,"data-testid":`create-view-type-${e}`,"aria-pressed":i,"aria-disabled":s,disabled:s,title:c,onClick:()=>{s||f(e)},className:X(`group flex flex-col items-start gap-1 rounded-lg border bg-background p-3 text-left transition-colors`,!s&&`hover:border-primary/60 hover:bg-accent/40`,i&&!s?`border-primary ring-2 ring-primary/30 bg-accent/40`:`border-border`,s&&`opacity-50 cursor-not-allowed`),children:[(0,Q.jsx)(r,{className:X(`h-5 w-5`,i&&!s?`text-primary`:`text-muted-foreground group-hover:text-foreground`)}),(0,Q.jsx)(`div`,{className:`text-xs font-medium leading-tight`,children:t}),(0,Q.jsx)(`div`,{className:`text-[10px] leading-tight text-muted-foreground line-clamp-2`,children:s?o(`console.objectView.viewTypeUnavailableShort`):n})]},e)})}),y.length>0&&(0,Q.jsx)(`div`,{className:`space-y-3 rounded-md border border-dashed bg-muted/30 p-3`,"data-testid":`create-view-required-fields`,children:y.map(e=>{let t=S(e.key),n=e.kind===`enum`,r=n?[]:e.filter?u.filter(e.filter):u,i=!n&&u.length>0&&r.length===0;return(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`label`,{htmlFor:`create-view-required-${e.key}`,className:`text-xs font-medium`,children:[o(e.i18nKey),(0,Q.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,Q.jsxs)(`select`,{id:`create-view-required-${e.key}`,"data-testid":`create-view-required-${e.key}`,value:t,onChange:t=>C(e.key,t.target.value),disabled:i,className:X(`h-9 w-full rounded-md border bg-background px-2 text-xs`,`border-input`),children:[(0,Q.jsx)(`option`,{value:``,children:o(n?`console.objectView.selectOption`:`console.objectView.selectField`)}),n?e.enumOptions.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:o(e.i18nKey)},e.value)):r.map(e=>(0,Q.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),e.helpI18nKey&&!i&&(0,Q.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:o(e.helpI18nKey)}),i&&(0,Q.jsxs)(`p`,{className:`flex items-center gap-1 text-[11px] text-destructive`,"data-testid":`create-view-error-no-field-${e.key}`,children:[(0,Q.jsx)(En,{className:`h-3 w-3`}),o(`console.objectView.noEligibleFieldForType`)]})]},e.key)})}),(0,Q.jsxs)(`div`,{className:`space-y-1`,children:[(0,Q.jsxs)(`label`,{htmlFor:`create-view-name-input`,className:`text-xs font-medium`,children:[o(`console.objectView.title`),(0,Q.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),(0,Q.jsx)(Zt,{id:`create-view-name-input`,"data-testid":`create-view-name-input`,autoFocus:!0,value:p,onChange:e=>{m(e.target.value),g(!0)},onKeyDown:e=>{e.key===`Enter`&&D&&O()},placeholder:o(`console.objectView.newView`),className:`h-9`}),T&&(0,Q.jsx)(`p`,{className:`text-[11px] text-destructive`,"data-testid":`create-view-error-duplicate`,children:o(`console.objectView.duplicateViewName`)})]}),(0,Q.jsxs)(se,{className:`mt-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>t(!1),"data-testid":`create-view-cancel`,children:o(`console.objectView.cancel`)}),(0,Q.jsx)(Y,{type:`button`,disabled:!D,onClick:O,"data-testid":`create-view-submit`,children:o(`console.objectView.create`)})]})]})})}function Ba(e,t){switch(e){case`system`:return{icon:`Lock`,title:t(`list.managedBy.system.title`,{defaultValue:`Nothing here yet`}),message:t(`list.managedBy.system.message`,{defaultValue:`Entries appear automatically when their source action runs (e.g. Submit for Approval, Share, Invite). Trigger one of those on a source record to create a row.`})};case`append-only`:return{icon:`Archive`,title:t(`list.managedBy.appendOnly.title`,{defaultValue:`No events recorded`}),message:t(`list.managedBy.appendOnly.message`,{defaultValue:`This is an immutable audit log. Rows are written by the platform when events occur — you can export the history but cannot create entries from here.`})};case`better-auth`:return{icon:`ShieldAlert`,title:t(`list.managedBy.betterAuth.title`,{defaultValue:`No identity records`}),message:t(`list.managedBy.betterAuth.message`,{defaultValue:`Identity rows are managed by the authentication provider. Use the dedicated identity workflows (Invite User, Reset Password, …) to create new entries.`})};default:return}}var Va=(0,$.lazy)(()=>c(()=>import(`./plugin-charts-AMObsZz3.js`).then(e=>e.t).then(e=>({default:e.ObjectChart})),__vite__mapDeps([0]),import.meta.url)),Ha=(0,$.lazy)(()=>c(()=>import(`./plugin-grid-boi_rkH3.js`).then(e=>e.t).then(e=>({default:e.ImportWizard})),__vite__mapDeps([0]),import.meta.url)),Ua={grid:ot,kanban:nn,calendar:De,gallery:kn,timeline:Ot,gantt:Wt,map:ce,chart:z},Wa={id:`current-user`,name:`Demo User`};function Ga(e,t){if(!Array.isArray(e))return e;let n=e=>{if(typeof e==`string`)return e===`{current_user_id}`?t??e:e;if(Array.isArray(e))return e.map(n);if(e&&typeof e==`object`){let t={};for(let r of Object.keys(e))t[r]=n(e[r]);return t}return e};return e.map(n)}function Ka({dataSource:e,objects:t,onEdit:n,externalRefreshKey:r}){let{objectName:i}=a(),{t:o}=M();return t.find(e=>e.name===i)?(0,Q.jsx)(qa,{dataSource:e,objects:t,onEdit:n,externalRefreshKey:r}):(0,Q.jsx)(`div`,{className:`h-full p-4 flex items-center justify-center`,children:(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(`div`,{className:`mx-auto mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,Q.jsx)(ot,{className:`h-6 w-6 text-muted-foreground`})}),(0,Q.jsx)(H,{children:o(`console.objectView.objectNotFound`)}),(0,Q.jsxs)(On,{children:[o(`console.objectView.objectNotFoundDescription`,{objectName:i}),` `,o(`console.objectView.objectNotFoundHint`)]})]})})}function qa({dataSource:e,objects:t,onEdit:n,externalRefreshKey:r}){let i=m(),{appName:o,objectName:c,viewId:l}=a(),[d,f]=u(),p=s(),{showDebug:h}=Gr(),{t:v}=M(),{objectLabel:y,objectDescription:S,viewLabel:C,viewEmptyState:T,actionLabel:E,actionConfirm:D,actionSuccess:O,actionParamText:ee,fieldLabel:k,fieldOptionLabel:A}=Mt(),{isFavorite:j,toggleFavorite:N}=or(),P=Dr(),[te,ne]=(0,$.useState)(!1),[re,ie]=(0,$.useState)(`edit`),[ae,oe]=(0,$.useState)(!1),[se,F]=(0,$.useState)(!1),[I,L]=(0,$.useState)(null),ce=(0,$.useRef)({}),le=(0,$.useRef)({}),R=(0,$.useCallback)((t,n,r)=>{if(!e?.updateViewConfig||!c||!t)return;let i=le.current[t]||{};le.current[t]={...i,...r};let a=ce.current[t];a&&clearTimeout(a),ce.current[t]=setTimeout(()=>{let r=le.current[t]||{};delete le.current[t],delete ce.current[t],Promise.resolve(e.updateViewConfig(c,t,{...n,...r})).catch(e=>{console.error(`[ObjectView] Failed to persist view config:`,e)})},300)},[e,c]),ue=(0,$.useCallback)(e=>{L(e),U(e=>e+1);let t=e.id;P&&t?di(`view`,t,e,{metadataClient:P}).catch(e=>{console.error(`[ViewConfigPanel] Failed to persist view config:`,e)}):console.warn(`[ViewConfigPanel] Cannot persist view config: missing metadataClient or viewId.`)},[P]),de=(0,$.useCallback)(async e=>{try{let n;if(P){let r=t?.find?.(e=>e.name===c),i=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]),a=[];Array.isArray(r?.compactLayout)&&r.compactLayout.length>0?a=r.compactLayout.filter(e=>r.fields?.[e]):r?.fields&&(a=Object.entries(r.fields).filter(([e,t])=>t&&!t.hidden&&!i.has(e)).map(([e])=>e).slice(0,5));let o=Array.isArray(e.columns)&&e.columns.length>0?e.columns:a,s={...e,columns:o};if(e.type===`kanban`)s.kanban={...s.kanban||{},columns:o};else if(e.type===`gallery`){let e=s.gallery||{};(!Array.isArray(e.visibleFields)||e.visibleFields.length===0)&&(s.gallery={...e,visibleFields:o})}n=await ui(`view`,String(e?.name??e?.id??s?.id??``),s,{metadataClient:P})}ne(!1),ie(`edit`),U(e=>e+1),n&&(l?i(`../${n}`,{relative:`path`}):i(`view/${n}`))}catch(e){console.error(`[ViewConfigPanel] Failed to create view:`,e)}},[e,c,t,i,l,P]),[fe,pe]=(0,$.useState)(void 0),{user:me,activeOrganization:he}=g(),z=me?.role===`admin`,{can:B}=_(),V=t.find(e=>e.name===c),[H,U]=(0,$.useState)(0),ge=mi({dataSource:e,objects:t,objectName:V.name,onRefresh:()=>U(e=>e+1)}),{confirmHandler:_e,toastHandler:ye}=ge,be=(0,$.useMemo)(()=>pr(V),[V]);(0,$.useEffect)(()=>{r===void 0||r===0||U(e=>e+1)},[r]);let[xe,Se]=(0,$.useState)(!1),[Ce,we]=(0,$.useState)([]);(0,$.useEffect)(()=>{let t=!1;if(!c){we([]);return}return typeof e?.listViews==`function`?(e.listViews(c).then(e=>{t||we((e||[]).map(e=>({...e,id:e.name||e.id,objectName:e.objectName||e.object||c})))}).catch(e=>{console.error(`[ObjectView] Failed to load overlay views:`,e),t||we([])}),()=>{t=!0}):(we([]),()=>{t=!0})},[e,c,H]);let[Te,Ee]=(0,$.useState)({});(0,$.useEffect)(()=>{let t=!1;if(!e||!c){Ee({});return}let n=V.listViews||V.list_views||{},r=Object.keys(n),i=V.list;if(i&&typeof i==`object`){let e=i.name||`list`;r.includes(e)||r.unshift(e)}if(r.length===0){Ee({});return}return(async()=>{if(typeof e.listViewOverrides==`function`)try{let t=await e.listViewOverrides(c);if(t&&typeof t==`object`){let e={};for(let n of r)t[n]&&(e[n]=t[n]);return e}}catch{}if(typeof e.getView!=`function`)return{};let t=await Promise.all(r.map(async t=>{try{return[t,await e.getView(c,t)]}catch{return[t,null]}})),n={};for(let[e,r]of t)r&&typeof r==`object`&&(n[e]=r);return n})().then(e=>{t||Ee(e)}),()=>{t=!0}},[e,c,V.listViews,V.list_views,V.list,H]);let W=(0,$.useMemo)(()=>{let e=new Set([`id`,`created_at`,`createdAt`,`updated_at`,`updatedAt`,`deleted_at`,`deletedAt`,`created_by`,`createdBy`,`updated_by`,`updatedBy`,`_version`,`_rev`]),t=()=>Array.isArray(V.compactLayout)&&V.compactLayout.length>0?V.compactLayout.filter(e=>V.fields?.[e]):V.fields?Object.entries(V.fields).filter(([t,n])=>!(!n||n.hidden||e.has(t))).map(([e])=>e).slice(0,5):[],n=V.listViews||V.list_views||{},r=Object.entries(n).map(([e,t])=>{let n=Te[e];return{id:e,...t,...n||{},type:n?.type||t.type||`grid`}}),i=V.list;if(i&&typeof i==`object`){let e=i.name||`list`,t=r.findIndex(t=>t.id===e);if(t>=0){let[e]=r.splice(t,1);r.unshift({...e,isDefault:!0})}else{let t=Te[e];r.unshift({id:e,...i,...t||{},type:t?.type||i.type||`grid`,isDefault:!0})}}r.length===0&&r.push({id:`all`,label:v(`console.objectView.allRecords`),type:`grid`,columns:t()});let a=new Set(r.map(e=>e.id));for(let e of Ce){let t=e.id||e._id;if(!t)continue;let n={label:e.label||e.name||t,type:e.type||`grid`,columns:e.columns,filter:e.filter,sort:e.sort,showSearch:e.showSearch,showFilters:e.showFilters,showSort:e.showSort,isPinned:e.isPinned,isDefault:e.isDefault,visibility:e.visibility,sortOrder:e.sortOrder,...e,id:t},i={};for(let[e,t]of Object.entries(n))t!==void 0&&(i[e]=t);if(a.has(t)){let e=r.findIndex(e=>e.id===t);r[e]={...r[e],...i}}else r.push(i)}let o=new Set([`grid`,`list`,`table`]);for(let e of r)o.has(e.type)&&(!Array.isArray(e.columns)||e.columns.length===0)&&(e.columns=t());let s=new Map(r.map((e,t)=>[e.id,t])),c=[];try{let e=typeof window<`u`?window.localStorage?.getItem(`viewOrder:${V.name}`):null;e&&(c=JSON.parse(e))}catch{}let l=new Map(c.map((e,t)=>[e,t]));return r.sort((e,t)=>{let n=l.get(e.id),r=l.get(t.id);if(n!==void 0&&r!==void 0)return n-r;if(n!==void 0)return-1;if(r!==void 0)return 1;let i=Ce.find(t=>(t.id||t._id)===e.id),a=Ce.find(e=>(e.id||e._id)===t.id),o=i&&typeof i.sortOrder==`number`,c=a&&typeof a.sortOrder==`number`;return o&&c?i.sortOrder===a.sortOrder?(i.created_at||``).localeCompare(a.created_at||``):i.sortOrder-a.sortOrder:o?-1:c?1:(s.get(e.id)??0)-(s.get(t.id)??0)}),r},[V,Ce,Te,v]),De=(0,$.useMemo)(()=>W.find(e=>e.isDefault)?.id,[W]),Oe=l||d.get(`view`)||De||W[0]?.id,G=W.find(e=>e.id===Oe)||W[0],K=I&&I.id===G?.id?{...G,...I}:G,ke=(0,$.useCallback)((e,t)=>{L(n=>({...n||{},id:G?.id,[e]:t}))},[G?.id]),Ae=e=>{let t=W.find(t=>t.id===e);t&&(t.id!==Oe&&ne(!1),l?i(`../${t.id}`,{relative:`path`}):i(`view/${t.id}`))},je=(0,$.useMemo)(()=>(W||[]).map(e=>{let t=Ua[e.type];return{id:e.id,label:C(V.name,e.name||e.id,e.label||e.name||e.id),icon:t?(0,Q.jsx)(t,{className:`h-4 w-4`}):void 0}}),[W,V.name,C]);oa({views:je,activeViewId:Oe??``,onChange:Ae,enabled:je.length>0&&!!Oe});let Me=(0,$.useCallback)(()=>{oe(!0)},[]),Ne=(0,$.useCallback)((e,t)=>{if(e===`settings`){let e=W.find(e=>e.type===t);e&&Ae(e.id),ie(`edit`),ne(!0)}},[W,Ae]),q=(0,$.useCallback)(e=>Ce.some(t=>(t.id||t._id)===e),[Ce]),Pe=(0,$.useCallback)(async(t,n)=>{if(!q(t)){Z.error(v(`console.objectView.cannotEditMetaView`)||`Built-in views cannot be renamed.`);return}try{typeof e?.updateView==`function`&&await e.updateView(c,t,{label:n}),U(e=>e+1)}catch(e){console.error(`[ViewTabBar] Failed to rename view:`,e),Z.error(v(`objectViewActions.renameFailed`))}},[e,c,q,v]),Ie=(0,$.useCallback)(async t=>{if(!e)return;if(!q(t)){Z.error(v(`console.objectView.cannotDeleteMetaView`)||`Built-in views cannot be deleted.`);return}let n=W.find(e=>e.id===t)?.label||t;if(await _e(v(`console.objectView.deleteViewConfirm`,{name:n})||`Are you sure you want to delete the view "${n}"? This cannot be undone.`,{title:v(`console.objectView.deleteViewTitle`)||`Delete view`,confirmText:v(`console.objectView.delete`)||`Delete`,cancelText:v(`console.objectView.cancel`)||`Cancel`}))try{if(typeof e?.deleteView==`function`&&await e.deleteView(c,t),t===Oe){let e=W.find(e=>e.id!==t);e&&i(l?`../${e.id}`:`view/${e.id}`,l?{relative:`path`}:void 0)}U(e=>e+1)}catch(e){console.error(`[ViewTabBar] Failed to delete view:`,e),Z.error(v(`objectViewActions.deleteFailed`))}},[e,q,Oe,W,l,i,v,_e]),Le=(0,$.useCallback)(async(t,n)=>{if(e){if(!q(t)){Z.error(v(`console.objectView.cannotEditMetaView`)||`Built-in views cannot be pinned.`);return}try{typeof e?.updateView==`function`&&await e.updateView(c,t,{isPinned:n}),U(e=>e+1)}catch(e){console.error(`[ViewTabBar] Failed to pin view:`,e)}}},[e,c,q,v]),Re=(0,$.useCallback)(async t=>{if(e){if(!q(t)){Z.error(v(`console.objectView.cannotEditMetaView`)||`System view — it cannot be set as a default.`);return}try{if(typeof e?.updateView!=`function`)return;let n=e.updateView,r=Ce.filter(e=>(e.id||e._id)!==t&&e.isDefault).map(e=>n(c,e.id||e._id,{isDefault:!1}));r.push(n(c,t,{isDefault:!0})),await Promise.all(r),U(e=>e+1)}catch(e){console.error(`[ViewTabBar] Failed to set default view:`,e),Z.error(`Failed to set default view`)}}},[e,c,Ce,q,v]),ze=(0,$.useCallback)(async t=>{try{typeof window<`u`&&window.localStorage?.setItem(`viewOrder:${c}`,JSON.stringify(t))}catch{}if(typeof e?.updateView==`function`){let n=e.updateView,r=new Set(Ce.map(e=>e.id||e._id)),i=t.filter(e=>r.has(e)).map((e,t)=>n(c,e,{sortOrder:t}));try{await Promise.all(i)}catch(e){console.error(`[ViewTabBar] Failed to reorder views:`,e)}}U(e=>e+1)},[e,Ce,c]),J=(0,$.useCallback)(e=>{if(!q(e)){Z.error(v(`console.objectView.cannotEditMetaView`)||`System view — it cannot be edited.`);return}e!==Oe&&Ae(e),ie(`edit`),ne(!0)},[Oe,Ae,q,v]),Be=(0,$.useCallback)(()=>{oe(!0)},[]),Ve=me?{id:me.id,name:me.name,avatar:me.image}:Wa,He=Jn({objectName:V.name,objectLabel:V.label,dataSource:e,onEdit:n,onRefresh:()=>U(e=>e+1),onConfirm:_e,onToast:ye}),{lastMessage:Ue}=mr({channel:`object:${V.name}`}),{hasConflicts:We,resolveAllConflicts:Ge}=fr(V.name?`user-${V.name}`:`current-user`);(0,$.useEffect)(()=>{Ue&&(We&&Ge(`remote`),U(e=>e+1))},[Ue,We,Ge]),(0,$.useEffect)(()=>{e?.find&&V.name&&e.find(V.name,{limit:0}).then(e=>{typeof e?.total==`number`?pe(e.total):Array.isArray(e?.data)?pe(e.data.length):Array.isArray(e)&&pe(e.length)}).catch(()=>{})},[e,V.name,H]);let Ke=(0,$.useMemo)(()=>K?.navigation??V.navigation??{mode:`drawer`,width:`min(92vw, 1280px)`},[K?.navigation,V.navigation]),Je=d.get(`recordId`),Ye=Array.from(d.entries()).filter(([e])=>e.startsWith(`filter[`)).map(([e,t])=>`${e}=${t}`).join(`&`),Xe=(0,$.useMemo)(()=>{let e=[];return new URLSearchParams(Ye).forEach((t,n)=>{let r=/^filter\[(.+)\]$/.exec(n);r&&r[1]&&t!==``&&e.push([r[1],`=`,t])}),e},[Ye]),[Ze]=(0,$.useState)(()=>Qr(new URLSearchParams(window.location.search))),Qe=(0,$.useCallback)(e=>{f(t=>Zr(t,e),{replace:!0})},[f]),$e=(0,$.useCallback)((e,t)=>{if(t===`new_window`){let t=window.location.pathname.replace(/\/view\/.*$/,``);window.open(`${t}/record/${encodeURIComponent(String(e))}`,`_blank`);return}let n={from:{pathname:p.pathname+(p.search||``),label:C(V.name,K?.name??``,K?.label??``)||y(V)}};l?i(`../../record/${encodeURIComponent(String(e))}`,{relative:`path`,state:n}):i(`record/${encodeURIComponent(String(e))}`,{state:n})},[i,l,p.pathname,p.search,V,K?.name,K?.label,C,y]),et=x({navigation:Ke,objectName:V.name,onNavigate:$e}),tt=()=>{et.close();let e=new URLSearchParams(d);e.delete(`recordId`),f(e)},nt=(0,$.useCallback)((e,t)=>{if(t&&(t.metaKey||t.ctrlKey||t.button===1)){et.handleClick(e,t);return}if(et.mode===`drawer`){let t=e?.id??e?._id;if(t!=null){let e=new URLSearchParams(d);e.set(`recordId`,String(t)),f(e);return}}et.handleClick(e,t)},[et,d,f]),rt=(0,$.useCallback)(()=>{let e=et.selectedRecord,t=e&&(e.id??e._id);t!=null&&(tt(),$e(t))},[et.selectedRecord,$e]);(0,$.useEffect)(()=>{Je&&!et.isOpen?et.open({id:Je}):!Je&&et.isOpen&&et.close()},[Je]);let it=(0,$.useCallback)(({schema:e,dataSource:t,onEdit:n,className:r,refreshKey:i})=>{let a=H+(i||0),o=`${c}-${K.id}-${a}`,s=K;if(s.type===`chart`){let e=s.chart||{};if(e.dataset){let n=Array.isArray(e.dimensions)?e.dimensions:[],r=Array.isArray(e.values)?e.values:[];return(0,Q.jsx)($.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading chart…`}),children:(0,Q.jsx)(Va,{dataSource:t,schema:{type:`object-chart`,dataset:e.dataset,dimensions:n,values:r,chartType:e.chartType||`bar`,xAxisKey:n[0],series:r.map(e=>({dataKey:e,label:e})),config:e.config,className:`h-[400px] w-full`}})},o)}let n=e.xAxisField||`name`,r=Array.isArray(e.yAxisFields)&&e.yAxisFields[0]||`value`,i=e.aggregation||`count`,a=e.series&&e.series.length>0?e.series:[{dataKey:r,label:r}];return(0,Q.jsx)($.Suspense,{fallback:(0,Q.jsx)(`div`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading chart…`}),children:(0,Q.jsx)(Va,{dataSource:t,schema:{type:`object-chart`,objectName:V.name,chartType:e.chartType||`bar`,aggregate:{field:r,function:i,groupBy:n},xAxisKey:n,series:a,config:e.config,filter:e.filter,className:`h-[400px] w-full`}})},o)}return(0,Q.jsx)($r,{schema:{...e,rowHeight:s.rowHeight??e.rowHeight,densityMode:s.densityMode??e.densityMode,sort:s.sort??e.sort,filter:(()=>{let t=Ga(s.filter??e.filter,Ve.id);return Xe.length?[...Array.isArray(t)?t:[],...Xe]:t})(),hiddenFields:s.hiddenFields??e.hiddenFields,columnState:s.columnState??e.columnState,onDensityChange:e=>{R(s.id,s,{densityMode:e})},onSortChange:e=>{R(s.id,s,{sort:e})},onFilterChange:e=>{R(s.id,s,{filter:e})},onHiddenFieldsChange:e=>{R(s.id,s,{hiddenFields:e})},onColumnStateChange:e=>{R(s.id,s,{columnState:e})},inlineEdit:s.inlineEdit??s.editRecordsInline??e.inlineEdit,appearance:s.appearance?s.showDescription==null?s.appearance:{...s.appearance,showDescription:s.showDescription}:s.showDescription==null?e.appearance:{showDescription:s.showDescription},showViewSwitcher:((s.appearance??e.appearance)?.allowedVisualizations?.length??0)>1,showSearch:s.showSearch??e.showSearch,showSort:s.showSort??e.showSort,showFilters:s.showFilters??e.showFilters,showHideFields:s.showHideFields??e.showHideFields,showGroup:s.showGroup??e.showGroup,showColor:s.showColor??e.showColor,showDensity:s.showDensity??e.showDensity,allowExport:s.allowExport??e.allowExport,exportOptions:s.allowExport===!1?void 0:s.exportOptions??e.exportOptions,striped:s.striped??e.striped,bordered:s.bordered??e.bordered,color:s.color??e.color,wrapHeaders:s.wrapHeaders??e.wrapHeaders,clickIntoRecordDetails:s.clickIntoRecordDetails??e.clickIntoRecordDetails,addRecordViaForm:s.addRecordViaForm??e.addRecordViaForm,addDeleteRecordsInline:s.addDeleteRecordsInline??e.addDeleteRecordsInline,collapseAllByDefault:s.collapseAllByDefault??e.collapseAllByDefault,fieldTextColor:s.fieldTextColor??e.fieldTextColor,prefixField:s.prefixField??e.prefixField,showDescription:s.showDescription??e.showDescription,navigation:s.navigation??e.navigation,selection:s.selection??e.selection,pagination:s.pagination??e.pagination,searchableFields:s.searchableFields??e.searchableFields,filterableFields:s.filterableFields??e.filterableFields,resizable:s.resizable??e.resizable,rowActions:s.rowActions??e.rowActions,rowActionDefs:Array.isArray(V?.actions)?V.actions.filter(e=>Array.isArray(e?.locations)&&e.locations.includes(`list_item`)).map(e=>({...e,label:E(V.name,e.name,e.label||e.name),...e.confirmText!==void 0&&{confirmText:D(V.name,e.name,e.confirmText)},...e.successMessage!==void 0&&{successMessage:O(V.name,e.name,e.successMessage)}})):[],bulkActions:s.bulkActions??e.bulkActions,bulkActionDefs:s.bulkActionDefs??e.bulkActionDefs,sharing:s.sharing??e.sharing,addRecord:s.addRecord??e.addRecord,conditionalFormatting:s.conditionalFormatting??e.conditionalFormatting,quickFilters:s.quickFilters??e.quickFilters,userFilters:s.userFilters??e.userFilters,showRecordCount:s.showRecordCount??e.showRecordCount,allowPrinting:s.allowPrinting??e.allowPrinting,virtualScroll:s.virtualScroll??e.virtualScroll,emptyState:T(V.name,s.name||s.id||``,s.emptyState??e.emptyState??Ba(V?.managedBy,v)),aria:s.aria??e.aria,tabs:s.tabs??e.tabs,...(()=>{let e=Ga([...Array.isArray(s.filter)?s.filter:[],...Xe],Ve.id);return Array.isArray(e)&&e.length?{filters:e}:{}})(),...s.sort?.length?{sort:s.sort}:{},options:{kanban:{groupBy:s.kanban?.groupByField||s.kanban?.groupField||`status`,groupField:s.kanban?.groupByField||s.kanban?.groupField||`status`,titleField:s.kanban?.titleField||V.titleField||`name`,cardFields:s.kanban?.columns},calendar:{startDateField:s.calendar?.startDateField||`due_date`,endDateField:s.calendar?.endDateField,titleField:s.calendar?.titleField||`name`,colorField:s.calendar?.colorField,allDayField:s.calendar?.allDayField,defaultView:s.calendar?.defaultView},timeline:{dateField:s.timeline?.dateField||`due_date`,titleField:s.timeline?.titleField||V.titleField||`name`,descriptionField:s.timeline?.descriptionField},map:{locationField:s.map?.locationField,titleField:s.map?.titleField||V.titleField||`name`,latitudeField:s.map?.latitudeField,longitudeField:s.map?.longitudeField,zoom:s.map?.zoom,center:s.map?.center},gallery:{...s.gallery||{},imageField:s.gallery?.imageField||s.gallery?.coverField||`image`,coverField:s.gallery?.coverField||s.gallery?.imageField,titleField:s.gallery?.titleField||V.titleField||`name`,subtitleField:s.gallery?.subtitleField},gantt:{startDateField:s.gantt?.startDateField||`start_date`,endDateField:s.gantt?.endDateField||`end_date`,titleField:s.gantt?.titleField||`name`,progressField:s.gantt?.progressField,dependenciesField:s.gantt?.dependenciesField,colorField:s.gantt?.colorField},chart:{chartType:s.chart?.chartType,xAxisField:s.chart?.xAxisField,yAxisFields:s.chart?.yAxisFields,aggregation:s.chart?.aggregation,series:s.chart?.series,config:s.chart?.config}}},className:r,onEdit:n,onDelete:e=>{e?.id!=null&&He.deleteRecord(String(e.id))},onBulkDelete:e=>{let t=e.filter(e=>e?.id!=null);t.length!==0&&He.execute({type:`delete`,confirmText:v(`console.objectView.bulkDeleteConfirm`,{count:t.length,defaultValue:`Delete ${t.length} selected records? This cannot be undone.`}),params:{records:t}})},onRowClick:(e,t)=>{nt(e,t)},onSortChange:e=>{R(s.id,s,{sort:e})},onFilterChange:e=>{R(s.id,s,{filter:e})},onHiddenFieldsChange:e=>{R(s.id,s,{hiddenFields:e})},onColumnStateChange:e=>{R(s.id,s,{columnState:e})},userFilterSelections:Ze,onUserFilterSelectionsChange:Qe,dataSource:t},o)},[K,V,c,H,et,He,R,Xe,Ze,Qe]),at=(0,$.useMemo)(()=>W.map(e=>e.id===Oe&&I&&I.id===e.id?{...e,...I}:e),[W,Oe,I]),ot=(0,$.useMemo)(()=>({type:`object-view`,objectName:V.name,layout:`page`,showSearch:K?.showSearch!==!1,showFilters:K?.showFilters!==!1,showSort:K?.showSort!==!1,showCreate:!1,showRefresh:!0,allowCreateView:z,viewActions:z?[{type:`settings`},{type:`share`},{type:`delete`}]:[],onNavigate:(e,t)=>{if(t===`edit`)n?.({id:e});else if(t===`view`){let t={from:{pathname:p.pathname+(p.search||``),label:C(V.name,K?.name??``,K?.label??``)||y(V)}};l?i(`../../record/${encodeURIComponent(String(e))}`,{relative:`path`,state:t}):i(`record/${encodeURIComponent(String(e))}`,{state:t})}}}),[V,n,K?.showSearch,K?.showFilters,K?.showSort,K?.name,K?.label,i,l,z,p.pathname,p.search,C,y]);return(0,Q.jsxs)(w,{...ge.actionProviderProps,children:[(0,Q.jsxs)(`div`,{className:`h-full flex flex-col bg-background min-w-0 overflow-hidden`,children:[(0,Q.jsx)(`div`,{className:`hidden sm:block`,children:(0,Q.jsx)(pa,{title:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:y(V)}),(0,Q.jsx)(pi,{managedBy:V?.managedBy})]}),description:V.description?S(V):void 0,icon:(0,Q.jsx)(Pr(V?.icon),{className:`h-4 w-4`}),actions:(0,Q.jsxs)(Q.Fragment,{children:[c&&(0,Q.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:()=>N({id:`object:${c}`,label:y(V),href:`/apps/${o}/${c}`,type:`object`}),className:`h-8 sm:h-9 px-2`,"aria-pressed":j(`object:${c}`),"aria-label":j(`object:${c}`)?v(`common.removeFromFavorites`,{defaultValue:`Remove from favorites`}):v(`common.addToFavorites`,{defaultValue:`Add to favorites`}),"data-testid":`object-favorite-btn-${c}`,children:j(`object:${c}`)?(0,Q.jsx)(Xt,{className:`h-4 w-4 fill-amber-400 text-amber-400`}):(0,Q.jsx)(un,{className:`h-4 w-4`})}),be.create&&B(V.name,`create`)&&(0,Q.jsxs)(Y,{size:`sm`,onClick:He.create,className:`shadow-none gap-1.5 sm:gap-2 h-8 sm:h-9`,children:[(0,Q.jsx)(qe,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`console.objectView.new`)})]}),be.import&&B(V.name,`create`)&&(0,Q.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:()=>Se(!0),className:`hidden sm:inline-flex shadow-none gap-1.5 sm:gap-2 h-8 sm:h-9`,title:v(`console.objectView.importTitle`),"data-testid":`object-view-import-button`,children:[(0,Q.jsx)(Fe,{className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:v(`console.objectView.import`)})]}),V.actions?.some(e=>e.locations?.includes(`list_toolbar`))&&(0,Q.jsx)(b,{schema:{type:`action:bar`,location:`list_toolbar`,actions:(V.actions||[]).map(e=>({...e,label:E(V.name,e.name,e.label||e.name),...e.confirmText!==void 0&&{confirmText:D(V.name,e.name,e.confirmText)},...e.successMessage!==void 0&&{successMessage:O(V.name,e.name,e.successMessage)}})),size:`sm`,variant:`outline`,mobileMaxVisible:0}})]})})}),be.create&&B(V.name,`create`)&&(0,Q.jsx)(`button`,{type:`button`,onClick:He.create,className:`sm:hidden fixed right-4 bottom-36 z-40 h-12 w-12 rounded-full bg-primary text-primary-foreground shadow-lg active:scale-95 transition-transform inline-flex items-center justify-center`,"aria-label":v(`console.objectView.new`),"data-testid":`mobile-fab-create`,children:(0,Q.jsx)(qe,{className:`h-5 w-5`})}),xe&&(0,Q.jsx)($.Suspense,{fallback:null,children:(0,Q.jsx)(Ha,{open:xe,onOpenChange:Se,objectName:V.name,objectLabel:y(V),fields:Object.entries(V.fields||{}).map(([e,t])=>({name:e,label:t?.label||e,type:t?.type||`text`,required:!!t?.required})),dataSource:e,onComplete:e=>{U(e=>e+1);let t=e.importedRows,n=e.skippedRows;n>0?Z.warning(v(`console.objectView.importedWithSkipped`,{ok:t,skipped:n})):t>0&&Z.success(v(`console.objectView.importedToast`,{count:t}))}})}),W.length>=1&&(()=>{let e=W.map(e=>{let t=Ce.find(t=>(t.id||t._id)===e.id),n=!t;return{id:e.id,label:C(V.name,e.name||e.id,e.label||e.name||e.id),type:e.type,hasActiveFilters:Array.isArray(e.filter)&&e.filter.length>0,hasActiveSort:Array.isArray(e.sort)&&e.sort.length>0,isDefault:!!(t?.isDefault??e.isDefault),isPinned:!!(t?.isPinned??e.isPinned),visibility:t?.visibility??e.visibility,readonly:n,readonlyReason:n?v(`console.objectView.systemViewReadonly`)||`System view defined in code — read-only.`:void 0}});return(0,Q.jsx)(Q.Fragment,{children:(0,Q.jsxs)(`div`,{className:`hidden sm:block border-b px-3 sm:px-4 bg-background overflow-x-auto shrink-0`,children:[(0,Q.jsx)(ri,{views:e,activeViewId:Oe,onViewChange:Ae,viewTypeIcons:Ua,config:{reorderable:!1,showAddButton:z,showPinnedSection:!0,showVisibilityGroups:!0},onAddView:z?Be:void 0,onRenameView:z?Pe:void 0,onDeleteView:z?Ie:void 0,onPinView:z?Le:void 0,onSetDefaultView:z?Re:void 0,onConfigView:z?J:void 0,onManageViews:z?()=>F(!0):void 0}),z&&(0,Q.jsx)(ti,{open:se,onOpenChange:F,views:e,activeViewId:Oe,viewTypeIcons:Ua,onRename:Pe,onDelete:Ie,onSetDefault:Re,onSetPinned:Le,onReorder:ze,onAddView:Be,onConfigView:J})]})})})(),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-hidden relative flex flex-row`,children:[et.mode===`split`&&et.isOpen?(0,Q.jsx)(ve,{...et,setIsOpen:e=>{e||tt()},title:y(V),onExpand:rt,expandLabel:v(`console.objectView.expandToPage`,{defaultValue:`Open as full page`}),storageKey:`drawer-width:${V.name}`,mainContent:(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0 relative h-full flex flex-col`,children:[(0,Q.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,Q.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,Q.jsx)(li,{schema:ot,dataSource:e,views:at,activeViewId:Oe,onViewChange:Ae,onEdit:e=>n?.(e),onRowClick:(e,t)=>{nt(e,t)},renderListView:it,onCreateView:Me,onViewAction:Ne})})}),typeof fe==`number`&&(0,Q.jsx)(`div`,{"data-testid":`record-count-footer`,className:`border-t px-3 sm:px-4 py-1.5 text-xs text-muted-foreground bg-muted/5 shrink-0`,children:v(`console.objectView.recordCount`,{count:fe})})]}),children:r=>{let i=r.id||r._id;return(0,Q.jsx)(hr,{dataSource:e,objects:t,onEdit:n,objectNameOverride:V.name,recordIdOverride:i,embedded:!0})}}):(0,Q.jsx)(`div`,{className:`flex-1 min-w-0 relative h-full flex flex-col`,children:(0,Q.jsx)(`div`,{className:`flex-1 relative overflow-hidden`,children:(0,Q.jsx)(`div`,{className:`h-full overflow-auto`,children:(0,Q.jsx)(li,{schema:ot,dataSource:e,views:at,activeViewId:Oe,onViewChange:Ae,onEdit:e=>n?.(e),onRowClick:(e,t)=>{nt(e,t)},renderListView:it,onCreateView:Me,onViewAction:Ne})})})}),(0,Q.jsx)(qr,{open:h&&z,sections:[{title:`View Configuration`,data:K},{title:`Object Definition`,data:V}]}),(0,Q.jsx)(`div`,{"data-testid":`view-config-panel-wrapper`,className:`transition-[max-width,opacity] duration-300 ease-in-out overflow-hidden ${te&&z?`max-w-[280px] opacity-100`:`max-w-0 opacity-0`}`,children:(0,Q.jsx)(Fa,{open:te&&z,onClose:()=>{ne(!1),ie(`edit`)},mode:re,activeView:K,objectDef:V,recordCount:fe,onSave:ue,onViewUpdate:ke,onCreate:de,metadataClient:P,onAfterChange:()=>U(e=>e+1)})}),(0,Q.jsx)(za,{open:ae&&z,onOpenChange:oe,existingLabels:W.map(e=>e.label).filter(Boolean),objectDef:V,onCreate:e=>de(e)})]}),et.mode!==`split`&&(0,Q.jsx)(ve,{...et,setIsOpen:e=>{e||tt()},title:y(V),onExpand:rt,expandLabel:v(`console.objectView.expandToPage`,{defaultValue:`Open as full page`}),storageKey:`drawer-width:${V.name}`,children:r=>{let i=r.id||r._id;return(0,Q.jsx)(hr,{dataSource:e,objects:t,onEdit:n,objectNameOverride:V.name,recordIdOverride:i,embedded:!0})}})]}),ge.dialogs]})}function Ja({appName:e,error:t,onRetry:n}){let{t:r}=M(),i=!!t;return(0,Q.jsx)(`div`,{className:`flex h-screen items-center justify-center`,"data-testid":`preview-draft-empty-state`,children:(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(`div`,{className:`mb-2 flex justify-center text-muted-foreground`,"aria-hidden":`true`,children:i?(0,Q.jsx)(ze,{className:`h-8 w-8`}):(0,Q.jsx)(Pe,{className:`h-8 w-8`})}),(0,Q.jsx)(H,{children:i?r(`preview.empty.loadFailedTitle`,{defaultValue:`Draft preview failed to load`}):e?r(`preview.empty.notReadyTitle`,{app:e,defaultValue:`“{{app}}” isn’t in the draft yet`}):r(`preview.empty.nothingTitle`,{defaultValue:`Nothing to preview yet`})}),(0,Q.jsx)(On,{children:i?r(`preview.empty.loadFailedDescription`,{defaultValue:`The draft overlay could not be read. Retry, or check your connection.`}):r(`preview.empty.notReadyDescription`,{defaultValue:`The build may still be running, or it may have failed before this app was staged. Check the conversation for the build status — this pane refreshes as drafts land.`})}),(0,Q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Q.jsxs)(Y,{variant:`outline`,onClick:n,"data-testid":`preview-draft-retry`,children:[(0,Q.jsx)(fe,{className:`mr-1.5 h-3.5 w-3.5`}),r(`preview.empty.retry`,{defaultValue:`Retry`})]})})]})})}var Ya=(0,$.lazy)(()=>c(()=>import(`./RecordDetailView-BdQK61l2.js`).then(e=>e.n).then(e=>({default:e.RecordDetailView})),__vite__mapDeps([0]),import.meta.url)),Xa=(0,$.lazy)(()=>c(()=>import(`./DashboardView-BF0o0wgx.js`).then(e=>e.t).then(e=>({default:e.DashboardView})),__vite__mapDeps([0,1]),import.meta.url)),Za=(0,$.lazy)(()=>c(()=>import(`./PageView-CP-3dRzz.js`).then(e=>e.t).then(e=>({default:e.PageView})),__vite__mapDeps([0]),import.meta.url)),Qa=(0,$.lazy)(()=>c(()=>import(`./ReportView-BHtzV5eK.js`).then(e=>e.t).then(e=>({default:e.ReportView})),__vite__mapDeps([0]),import.meta.url)),$a=(0,$.lazy)(()=>c(()=>import(`./SearchResultsPage-CE_LTSSU.js`).then(e=>e.t).then(e=>({default:e.SearchResultsPage})),__vite__mapDeps([0]),import.meta.url)),eo=(0,$.lazy)(()=>c(()=>import(`./RecordFormPage-lFVOsTl0.js`).then(e=>e.t).then(e=>({default:e.RecordFormPage})),__vite__mapDeps([0]),import.meta.url)),to=(0,$.lazy)(()=>c(()=>import(`./ComponentNavView-DmALsugj.js`).then(e=>({default:e.ComponentNavView})),__vite__mapDeps([0]),import.meta.url)),no=(0,$.lazy)(()=>c(()=>import(`./metadata-admin-BbJpmVQm.js`).then(e=>e.t).then(e=>({default:e.MetadataDirectoryPage})),__vite__mapDeps([0]),import.meta.url)),ro=(0,$.lazy)(()=>c(()=>import(`./metadata-admin-BbJpmVQm.js`).then(e=>e.t).then(e=>({default:e.StudioHomePage})),__vite__mapDeps([0]),import.meta.url)),io=(0,$.lazy)(()=>c(()=>import(`./metadata-admin-BbJpmVQm.js`).then(e=>e.t).then(e=>({default:e.MetadataResourceListPage})),__vite__mapDeps([0]),import.meta.url)),ao=(0,$.lazy)(()=>c(()=>import(`./metadata-admin-BbJpmVQm.js`).then(e=>e.t).then(e=>({default:e.MetadataResourceEditPage})),__vite__mapDeps([0]),import.meta.url)),oo=(0,$.lazy)(()=>c(()=>import(`./metadata-admin-BbJpmVQm.js`).then(e=>e.t).then(e=>({default:e.MetadataResourceHistoryPage})),__vite__mapDeps([0]),import.meta.url)),so=(0,$.lazy)(()=>c(()=>import(`./metadata-admin-BbJpmVQm.js`).then(e=>e.t).then(e=>({default:e.MetadataDiagnosticsPage})),__vite__mapDeps([0]),import.meta.url)),co=(0,$.lazy)(()=>c(()=>import(`./index-DdQV1cqi.js`).then(e=>e.t).then(e=>({default:e.CreateAppPage})),__vite__mapDeps([0,2]),import.meta.url)),lo=(0,$.lazy)(()=>c(()=>import(`./index-DdQV1cqi.js`).then(e=>e.t).then(e=>({default:e.EditAppPage})),__vite__mapDeps([0,2]),import.meta.url)),uo=(0,$.lazy)(()=>c(()=>import(`./index-DdQV1cqi.js`).then(e=>e.t).then(e=>({default:e.DashboardDesignPage})),__vite__mapDeps([0,2]),import.meta.url)),fo=(0,$.lazy)(()=>c(()=>import(`./MarketplacePage-BT-WkhAG.js`).then(e=>e.t).then(e=>({default:e.MarketplacePage})),__vite__mapDeps([0]),import.meta.url)),po=(0,$.lazy)(()=>c(()=>import(`./MarketplacePackagePage-BWCVUz3e.js`).then(e=>e.t).then(e=>({default:e.MarketplacePackagePage})),__vite__mapDeps([0]),import.meta.url)),mo=(0,$.lazy)(()=>c(()=>import(`./MarketplaceInstalledPage-CBfcARvX.js`).then(e=>e.t).then(e=>({default:e.MarketplaceInstalledPage})),__vite__mapDeps([0]),import.meta.url));function ho({appName:e}){let{reviewSeq:t,reviewTarget:n}=In(),r=m(),i=(0,$.useRef)(t);return(0,$.useEffect)(()=>{if(t===i.current||!n||!e)return;i.current=t;let{type:a,name:o}=n;r(`/apps/${e}/metadata/${encodeURIComponent(a)}/${encodeURIComponent(o)}?review=1`)},[t,n,e,r]),null}function go({extraRoutes:e,extraRoutesNoApp:t}={}){let[i,o]=(0,$.useState)(`disconnected`),{user:c,getAuthConfig:l}=g(),u=N(),[d,p]=(0,$.useState)({});(0,$.useEffect)(()=>{let e=!1;return l().then(t=>{e||p(t?.features??{})}).catch(()=>{}),()=>{e=!0}},[l]);let h=m(),_=s(),{appName:v}=a(),{apps:b,objects:x,loading:C,ensureType:w,error:E,refresh:D}=T(),O=Vn(),{t:k}=M(),{objectLabel:A}=Mt(),[j,P]=(0,$.useState)(!w);(0,$.useEffect)(()=>{if(!w){P(!0);return}let e=!1;return Promise.all([w(`object`),w(`dashboard`),w(`report`),w(`page`)]).finally(()=>{e||P(!0)}),()=>{e=!0}},[w]);let te=b.filter(e=>e.active!==!1).filter(e=>e.hidden!==!0),ne=_.pathname.endsWith(`/create-app`),re=_.pathname.includes(`/system`),ie=_.pathname.includes(`/metadata`),ae=_.pathname===`/apps/setup`||_.pathname.startsWith(`/apps/setup/`),oe=ne||re||ie||ae,se=kr(b,v),F=se||(!v||oe?te.find(e=>e.isDefault===!0)||te[0]:void 0),I=!!v&&!se&&!oe,[L,ce]=(0,$.useState)(`idle`);(0,$.useEffect)(()=>{if(!I){L!==`idle`&&ce(`idle`);return}L===`idle`&&!C&&!O&&(ce(`checking`),Promise.resolve(D()).finally(()=>ce(`done`)))},[I,C,O,L,D]),(0,$.useEffect)(()=>{if(!F?.name)return;let e=v??F.name,t=`/apps/${e}/metadata/package`;(_.pathname===t||_.pathname.startsWith(`${t}/`))&&h(`/apps/${e}/component/developer/packages`,{replace:!0})},[F?.name,v,_.pathname,h]);let[le,R]=(0,$.useState)(!1),[ue,de]=(0,$.useState)(null),[fe,pe]=(0,$.useState)(0),{execute:me,runner:he}=S();y({dataSource:u??void 0,onUndo:e=>{Z.info(`Undo: ${e.description}`,{duration:4e3}),pe(e=>e+1)},onRedo:e=>{Z.info(`Redo: ${e.description}`,{duration:3e3}),pe(e=>e+1)}}),(0,$.useEffect)(()=>{he.registerHandler(`crud_success`,async e=>(R(!1),pe(e=>e+1),Z.success(e.params?.message??`Record saved successfully`),{success:!0,reload:!0})),he.registerHandler(`dialog_cancel`,async()=>(R(!1),{success:!0})),he.registerHandler(`navigate_create`,async e=>{let t=zr({action:e,context:he.getContext?.()??{},defaultBaseUrl:`/apps/${v??``}`});return t.success?(h(t.url),{success:!0}):t}),he.registerHandler(`navigate_edit`,async e=>{let t=Vr({action:e,context:he.getContext?.()??{},defaultBaseUrl:`/apps/${v??``}`});return t.success?(h(t.url),{success:!0}):t})},[he,h,v]),(0,$.useEffect)(()=>{if(!u)return;let e=u.onConnectionStateChange(e=>{o(e.state),e.error&&console.error(`[Console] Connection error:`,e.error)});return o(u.getConnectionState()),e},[u]);let z=_.pathname.split(`/`).filter(Boolean)[2];(z===`view`||z===`record`||z===`page`||z===`dashboard`||z===`design`)&&(z=``);let B=x.find(e=>e.name===z),V=(0,$.useCallback)(()=>{let e=B?A(B):k(`common.record`,{defaultValue:`Record`});me({type:`crud_success`,params:{message:ue?k(`form.updateSuccess`,{object:e,defaultValue:`${e} updated successfully`}):k(`form.createSuccess`,{object:e,defaultValue:`${e} created successfully`})}})},[me,ue,B,A,k]),U=(0,$.useCallback)(()=>{me({type:`dialog_cancel`})},[me]);$n({pathname:_.pathname,appName:F?.name,objects:x});let ge=e=>{let t=Ur({objectDef:B,baseUrl:v?`/apps/${v}`:F?.name?`/apps/${F.name}`:``,record:e});if(t.kind===`page`){h(t.url);return}de(e),R(!0)},_e=e=>{h(`/apps/${e}`)},ve=(0,$.useMemo)(()=>new ee({user:c?{name:c.name,email:c.email,role:c.role??`user`}:{},app:F||{},data:ue||{}}),[c,F,ue]);return!u||C||!j?(0,Q.jsx)(ya,{}):O&&(I||!F)?(0,Q.jsx)(Ja,{appName:v,error:E,onRetry:()=>void D()}):I?L===`done`?(0,Q.jsx)(`div`,{className:`h-screen flex items-center justify-center`,children:(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(H,{children:k(`empty.appNotAvailable`,{defaultValue:`App not available`})}),(0,Q.jsx)(On,{children:k(`empty.appNotAvailableDescription`,{defaultValue:`This app is not available yet — it may still be publishing. Try again in a moment.`})}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(Y,{onClick:()=>ce(`idle`),"data-testid":`app-not-available-retry`,children:k(`common.retry`,{defaultValue:`Retry`})})})]})}):(0,Q.jsx)(ya,{}):!F&&!ne&&!re&&!ie?(0,Q.jsx)(`div`,{className:`h-screen flex items-center justify-center`,children:(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(H,{children:k(`empty.noAppsConfigured`)}),(0,Q.jsx)(On,{children:k(`empty.noAppsConfiguredDescription`)}),(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-col sm:flex-row items-center gap-3`,children:[(0,Q.jsx)(Y,{onClick:()=>h(`/create-app`),"data-testid":`create-first-app-btn`,children:k(`empty.createFirstApp`)}),(0,Q.jsx)(Y,{variant:`outline`,onClick:()=>h(`/apps/setup`),"data-testid":`go-to-settings-btn`,children:k(`empty.systemSettings`)})]})]})}):!F&&(ne||re||ie)?(0,Q.jsx)($.Suspense,{fallback:(0,Q.jsx)(ya,{}),children:(0,Q.jsxs)(r,{children:[(0,Q.jsx)(f,{path:`create-app`,element:(0,Q.jsx)(co,{})}),(0,Q.jsx)(f,{path:`system/marketplace`,element:(0,Q.jsx)(fo,{})}),(0,Q.jsx)(f,{path:`system/marketplace/installed`,element:(0,Q.jsx)(mo,{})}),(0,Q.jsx)(f,{path:`system/marketplace/:packageId`,element:(0,Q.jsx)(po,{})}),(0,Q.jsx)(f,{path:`metadata`,element:(0,Q.jsx)(no,{})}),(0,Q.jsx)(f,{path:`metadata/_diagnostics`,element:(0,Q.jsx)(so,{})}),(0,Q.jsx)(f,{path:`metadata/:type`,element:(0,Q.jsx)(io,{})}),(0,Q.jsx)(f,{path:`metadata/:type/new`,element:(0,Q.jsx)(ao,{createMode:!0})}),(0,Q.jsx)(f,{path:`metadata/:type/:name`,element:(0,Q.jsx)(ao,{})}),(0,Q.jsx)(f,{path:`metadata/:type/:name/history`,element:(0,Q.jsx)(oo,{})}),t]})}):(0,Q.jsxs)(Wn,{user:c?{name:c.name,email:c.email,role:c.role??`user`}:{name:`Anonymous`,email:``,role:`guest`},app:F,data:{},features:d,children:[(0,Q.jsx)(Kn,{}),(0,Q.jsxs)(fa,{activeAppName:F.name,activeApp:F,onAppChange:_e,objects:x,connectionState:i,userId:c?.id,children:[(0,Q.jsx)(ma,{apps:b,activeApp:F,objects:x,onAppChange:_e,dataSource:u}),(0,Q.jsx)(ga,{}),(0,Q.jsx)(_a,{}),(0,Q.jsx)(ho,{appName:v}),(0,Q.jsx)(ka,{children:(0,Q.jsx)($.Suspense,{fallback:(0,Q.jsx)(ya,{}),children:(0,Q.jsx)(Sa,{className:`h-full`,children:(0,Q.jsxs)(r,{children:[(0,Q.jsx)(f,{path:`/`,element:(()=>{let e=bo(F,{currentUserId:c?.id??null});return e?(0,Q.jsx)(n,{to:e,replace:!0}):(0,Q.jsx)(ro,{})})()}),(0,Q.jsx)(f,{path:`metadata/package/*`,element:(0,Q.jsx)(n,{to:`/apps/${v??F.name}/component/developer/packages`,replace:!0})}),(0,Q.jsxs)(f,{path:`metadata`,children:[(0,Q.jsx)(f,{index:!0,element:(0,Q.jsx)(no,{})}),(0,Q.jsx)(f,{path:`_diagnostics`,element:(0,Q.jsx)(so,{})}),(0,Q.jsx)(f,{path:`:type`,element:(0,Q.jsx)(io,{})}),(0,Q.jsx)(f,{path:`:type/new`,element:(0,Q.jsx)(ao,{createMode:!0})}),(0,Q.jsx)(f,{path:`:type/:name`,element:(0,Q.jsx)(ao,{})}),(0,Q.jsx)(f,{path:`:type/:name/history`,element:(0,Q.jsx)(oo,{})})]}),(0,Q.jsx)(f,{path:`:objectName`,element:(0,Q.jsx)(Ka,{dataSource:u,objects:x,onEdit:ge,externalRefreshKey:fe})}),(0,Q.jsx)(f,{path:`:objectName/new`,element:(0,Q.jsx)(eo,{mode:`create`})}),(0,Q.jsx)(f,{path:`:objectName/view/:viewId`,element:(0,Q.jsx)(Ka,{dataSource:u,objects:x,onEdit:ge,externalRefreshKey:fe})}),(0,Q.jsx)(f,{path:`:objectName/record/:recordId`,element:(0,Q.jsx)(Ya,{dataSource:u,objects:x,onEdit:ge},fe)}),(0,Q.jsx)(f,{path:`:objectName/record/:recordId/edit`,element:(0,Q.jsx)(eo,{mode:`edit`})}),(0,Q.jsx)(f,{path:`dashboard/:dashboardName`,element:(0,Q.jsx)(Xa,{dataSource:u})}),(0,Q.jsx)(f,{path:`report/:reportName`,element:(0,Q.jsx)(Qa,{dataSource:u})}),(0,Q.jsx)(f,{path:`page/:pageName`,element:(0,Q.jsx)(Za,{})}),(0,Q.jsx)(f,{path:`component/:ns/:name/*`,element:(0,Q.jsx)(to,{})}),(0,Q.jsx)(f,{path:`component/metadata/directory`,element:(0,Q.jsx)(Co,{mode:`directory`})}),(0,Q.jsx)(f,{path:`component/metadata/resource/*`,element:(0,Q.jsx)(Co,{mode:`resource`})}),(0,Q.jsx)(f,{path:`design/dashboard/:dashboardName`,element:(0,Q.jsx)(uo,{})}),(0,Q.jsx)(f,{path:`search`,element:(0,Q.jsx)($a,{})}),(0,Q.jsx)(f,{path:`create-app`,element:(0,Q.jsx)(co,{})}),(0,Q.jsx)(f,{path:`edit-app/:editAppName`,element:(0,Q.jsx)(lo,{})}),(0,Q.jsx)(f,{path:`system/marketplace`,element:(0,Q.jsx)(fo,{})}),(0,Q.jsx)(f,{path:`system/marketplace/installed`,element:(0,Q.jsx)(mo,{})}),(0,Q.jsx)(f,{path:`system/marketplace/:packageId`,element:(0,Q.jsx)(po,{})}),e,(0,Q.jsx)(f,{path:`:objectName/:maybeRecordId`,element:(0,Q.jsx)(wo,{})}),(0,Q.jsx)(f,{path:`*`,element:(0,Q.jsx)(To,{})})]})})})}),B&&(0,Q.jsx)(Fn,{schema:{type:`object-form`,formType:`modal`,objectName:B.name,mode:ue?`edit`:`create`,recordId:ue?.id,subforms:B.form?.subforms??B.formViews?.default?.subforms,...(()=>{let e=B.form??B.formViews?.default;return e?.type===`tabbed`&&Array.isArray(e?.sections)?{contentLayout:`tabbed`,sections:e.sections}:{}})(),title:k(ue?`form.editTitle`:`form.createTitle`,{object:A(B)}),description:k(ue?`form.editDescription`:`form.createDescription`,{object:A(B)}),open:le,onOpenChange:R,layout:`vertical`,fields:B.fields?Array.isArray(B.fields)?B.fields.filter(e=>typeof e==`string`?!0:Hn(e.visible,ve)).map(e=>typeof e==`string`?e:e.name):Object.entries(B.fields).filter(([e,t])=>Hn(t.visible,ve)).map(([e])=>e):[],onSuccess:V,onCancel:U,showSubmit:!0,showCancel:!0,submitText:ue?k(`form.update`,{defaultValue:k(`common.save`,{defaultValue:`Save`})}):k(`form.create`,{defaultValue:k(`common.create`,{defaultValue:`Create`})}),cancelText:k(`common.cancel`)},dataSource:u},ue?.id||`new`)]})]})}function _o(e,t){if(!e||e.length===0)return``;for(let n of e){if(n.type===`object`||n.type===`page`||n.type===`dashboard`||n.type===`report`){let e=vo(n,t);if(e)return e;continue}if(n.type!==`url`&&n.type===`group`&&n.children){let e=_o(n.children,t);if(e!==``)return e}}return``}function vo(e,t){if(!e||e.type===`url`||e.type===`action`||e.type===`separator`||e.type===`group`)return``;let{href:n,external:r}=gr(e,``,t);return r||!n||n===`#`?``:n.replace(/^\//,``)}function yo(e,t){if(e)for(let n of e){if(n.id===t)return n;if(n.type===`group`&&n.children){let e=yo(n.children,t);if(e)return e}}}function bo(e,t){let n=e?.homePageId,r=e?.navigation||[];if(n){let e=vo(yo(r,n),t);if(e)return e}return _o(r,t)}var xo=new Set([`new`,`view`,`record`,`edit`,`dashboard`,`report`,`page`,`design`,`search`,`create-app`,`edit-app`,`metadata`]);function So(e){return!e||xo.has(e)||!/^[A-Za-z0-9_-]+$/.test(e)?!1:e.length>=6}function Co({mode:e}){let t=s(),r=t.pathname.replace(/\/component\/metadata\/.*$/,``);if(e===`directory`)return(0,Q.jsx)(n,{to:`${r}/metadata${t.search}${t.hash}`,replace:!0});let i=new URLSearchParams(t.search).get(`type`)??``,a=t.pathname.match(/\/component\/metadata\/resource(\/.*)?$/)?.[1]??``;return(0,Q.jsx)(n,{to:i?`${r}/metadata/${encodeURIComponent(i)}${a}${t.hash}`:`${r}/metadata${t.hash}`,replace:!0})}function wo(){let{objectName:e,maybeRecordId:t}=a(),r=s();return e&&So(t)?(0,Q.jsx)(n,{to:`${r.pathname.replace(/\/$/,``).replace(`/${t}`,`/record/${t}`)}${r.search}${r.hash}`,replace:!0}):(0,Q.jsx)(To,{})}function To(){let e=m(),{t}=M();return(0,Q.jsx)(`div`,{className:`flex h-full w-full items-center justify-center p-8`,children:(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(H,{children:t(`console.notFound.title`,{defaultValue:`Page not found`})}),(0,Q.jsx)(On,{children:t(`console.notFound.description`,{defaultValue:`The URL you followed does not match any view in this app.`})}),(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsx)(Y,{variant:`outline`,onClick:()=>e(-1),children:t(`console.notFound.back`,{defaultValue:`Go back`})})})]})})}function Eo({children:e,userId:t}){let{setContext:n}=dr(),{isAiEnabled:r}=C(),{t:i}=M(),a=r||!1;return(0,$.useEffect)(()=>{n(`home`)},[n]),(0,Q.jsxs)(`div`,{className:`flex min-h-svh w-full flex-col bg-background`,"data-testid":`home-layout`,children:[(0,Q.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:(0,Q.jsx)(ua,{variant:`home`})}),(0,Q.jsx)(`main`,{className:`flex-1 min-w-0 overflow-auto pb-20 sm:pb-0`,children:e}),a&&(0,Q.jsx)(Oi,{appLabel:i(`workspace.default`,{defaultValue:`Workspace`}),objects:[],userId:t})]})}var Do=[{from:`from-blue-500/15`,to:`to-indigo-500/10`,text:`text-blue-600 dark:text-blue-400`,ring:`group-hover:border-blue-500/40`,solid:`bg-blue-500`},{from:`from-emerald-500/15`,to:`to-teal-500/10`,text:`text-emerald-600 dark:text-emerald-400`,ring:`group-hover:border-emerald-500/40`,solid:`bg-emerald-500`},{from:`from-fuchsia-500/15`,to:`to-pink-500/10`,text:`text-fuchsia-600 dark:text-fuchsia-400`,ring:`group-hover:border-fuchsia-500/40`,solid:`bg-fuchsia-500`},{from:`from-amber-500/15`,to:`to-orange-500/10`,text:`text-amber-600 dark:text-amber-400`,ring:`group-hover:border-amber-500/40`,solid:`bg-amber-500`},{from:`from-sky-500/15`,to:`to-cyan-500/10`,text:`text-sky-600 dark:text-sky-400`,ring:`group-hover:border-sky-500/40`,solid:`bg-sky-500`},{from:`from-violet-500/15`,to:`to-purple-500/10`,text:`text-violet-600 dark:text-violet-400`,ring:`group-hover:border-violet-500/40`,solid:`bg-violet-500`},{from:`from-rose-500/15`,to:`to-red-500/10`,text:`text-rose-600 dark:text-rose-400`,ring:`group-hover:border-rose-500/40`,solid:`bg-rose-500`}];function Oo(e){let t=0;for(let n=0;n<e.length;n++)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)}function ko({app:e,onClick:t,isFavorite:n,index:r=0}){let{t:i}=M(),{appLabel:a,appDescription:o}=Mt(),{toggleFavorite:s}=or(),c=Pr(e.icon),l=a({name:e.name,label:Hr(e.label,i)}),u=o({name:e.name,description:Hr(e.description,i)}),d=Do[(Oo(e.name)+r)%Do.length];return(0,Q.jsxs)(cn,{className:X(`group relative overflow-hidden border border-border/70 bg-card/80 backdrop-blur-sm`,`transition-[transform,box-shadow,border-color] duration-200 hover:-translate-y-0.5 hover:shadow-lg`,`motion-reduce:transition-none motion-reduce:hover:transform-none`,d.ring),"data-testid":`app-card-${e.name}`,children:[(0,Q.jsx)(`button`,{type:`button`,"aria-label":l,className:`absolute inset-0 z-10 rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,onClick:t,"data-testid":`app-card-open-${e.name}`}),(0,Q.jsx)(`div`,{"aria-hidden":!0,className:X(`absolute inset-x-0 top-0 h-1`,d.solid)}),(0,Q.jsx)(`div`,{"aria-hidden":!0,className:X(`absolute inset-0 bg-gradient-to-br opacity-0 transition-opacity duration-300 group-hover:opacity-100`,d.from,d.to)}),(0,Q.jsxs)(Ce,{className:`relative p-5`,children:[(0,Q.jsx)(Y,{variant:`ghost`,size:`sm`,className:`absolute top-2 right-2 z-20 h-8 w-8 p-0 opacity-0 transition-opacity group-hover:opacity-100 focus-visible:opacity-100`,onClick:t=>{t.stopPropagation(),s({id:`app:${e.name}`,label:l,href:`/apps/${Ar(e)??e.name}`,type:`object`})},"aria-label":n?i(`common.removeFromFavorites`,{defaultValue:`Remove from favorites`})+` — ${l}`:i(`common.addToFavorites`,{defaultValue:`Add to favorites`})+` — ${l}`,"aria-pressed":n,"data-testid":`favorite-btn-${e.name}`,children:n?(0,Q.jsx)(Xt,{className:`h-4 w-4 fill-amber-400 text-amber-400`}):(0,Q.jsx)(un,{className:`h-4 w-4`})}),(0,Q.jsx)(`div`,{className:X(`inline-flex h-14 w-14 items-center justify-center rounded-xl mb-4 ring-1 ring-inset`,`bg-gradient-to-br ring-border/40`,d.from,d.to),children:(0,Q.jsx)(c,{className:X(`h-7 w-7`,d.text)})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`font-semibold text-base sm:text-lg leading-tight truncate`,children:l}),e.isDefault&&(0,Q.jsx)(te,{variant:`secondary`,className:`shrink-0 text-[10px] px-1.5 py-0`,children:i(`home.appCard.default`,{defaultValue:`Default`})})]}),(0,Q.jsx)(`p`,{className:X(`text-sm text-muted-foreground mt-1.5 line-clamp-2 min-h-[2.5rem]`,!u&&`italic`),children:u||i(`home.appCard.noDescription`,{defaultValue:`No description`})})]}),(0,Q.jsx)(`div`,{className:`mt-4 flex items-center justify-between text-xs font-medium`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground transition-colors group-hover:text-foreground`,children:[i(`home.open`,{defaultValue:`Open`}),(0,Q.jsx)(ln,{className:`h-3.5 w-3.5 transition-transform duration-200 group-hover:translate-x-0.5 group-hover:-translate-y-0.5`})]})})]})]})}var Ao={object:`bg-blue-500/10 text-blue-600 dark:text-blue-400 ring-blue-500/20`,dashboard:`bg-violet-500/10 text-violet-600 dark:text-violet-400 ring-violet-500/20`,page:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-emerald-500/20`,record:`bg-amber-500/10 text-amber-600 dark:text-amber-400 ring-amber-500/20`},jo={object:$e,record:I,dashboard:U,page:pt};function Mo({items:e}){let t=m(),{t:n}=M();return e.length===0?null:(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-5`,children:[(0,Q.jsx)(`span`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-lg bg-sky-500/10 ring-1 ring-sky-500/20 text-sky-600 dark:text-sky-400`,children:(0,Q.jsx)(dn,{className:`h-4 w-4`})}),(0,Q.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight`,children:n(`home.recentApps.title`,{defaultValue:`Recently Accessed`})})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>{let r=jo[e.type]||$e,i=n(`home.recentApps.itemType.${e.type}`,{defaultValue:Wr(e.type)}),a=Ao[e.type]||Ao.object;return(0,Q.jsx)(cn,{className:`group cursor-pointer border border-border/70 bg-card/80 backdrop-blur-sm transition-[transform,box-shadow,border-color] duration-200 hover:-translate-y-0.5 hover:shadow-md hover:border-foreground/20 motion-reduce:transition-none motion-reduce:hover:transform-none`,onClick:()=>t(e.href),"data-testid":`recent-item-${e.id}`,role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.href))},children:(0,Q.jsx)(Ce,{className:`p-3.5`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:X(`inline-flex h-10 w-10 items-center justify-center rounded-lg ring-1 shrink-0`,a),children:(0,Q.jsx)(r,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-sm truncate`,children:e.label}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i})]}),(0,Q.jsx)(ln,{className:`h-4 w-4 text-muted-foreground opacity-0 -translate-x-1 transition-[opacity,transform] duration-200 group-hover:opacity-100 group-hover:translate-x-0`})]})})},e.id)})})]})}var No={object:`bg-blue-500/10 text-blue-600 dark:text-blue-400 ring-blue-500/20`,dashboard:`bg-violet-500/10 text-violet-600 dark:text-violet-400 ring-violet-500/20`,page:`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400 ring-emerald-500/20`,record:`bg-amber-500/10 text-amber-600 dark:text-amber-400 ring-amber-500/20`},Po={object:$e,record:I,dashboard:U,page:pt};function Fo({items:e}){let t=m(),{t:n}=M();return e.length===0?null:(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-5`,children:[(0,Q.jsx)(`span`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-lg bg-amber-500/10 ring-1 ring-amber-500/20 text-amber-600 dark:text-amber-400`,children:(0,Q.jsx)(Xt,{className:`h-4 w-4 fill-current`})}),(0,Q.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight`,children:n(`home.starredApps.title`,{defaultValue:`Starred`})})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>{let r=Po[e.type]||$e,i=No[e.type]||No.object,a=n(`home.recentApps.itemType.${e.type}`,{defaultValue:Wr(e.type)});return(0,Q.jsx)(cn,{className:`group cursor-pointer border border-border/70 bg-card/80 backdrop-blur-sm transition-[transform,box-shadow,border-color] duration-200 hover:-translate-y-0.5 hover:shadow-md hover:border-foreground/20 motion-reduce:transition-none motion-reduce:hover:transform-none`,onClick:()=>t(e.href),"data-testid":`starred-item-${e.id}`,role:`link`,tabIndex:0,onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e.href))},children:(0,Q.jsx)(Ce,{className:`p-3.5`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`div`,{className:X(`inline-flex h-10 w-10 items-center justify-center rounded-lg ring-1 shrink-0`,i),children:(0,Q.jsx)(r,{className:`h-5 w-5`})}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`h3`,{className:`font-medium text-sm truncate`,children:e.label}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a})]}),(0,Q.jsx)(ln,{className:`h-4 w-4 text-muted-foreground opacity-0 -translate-x-1 transition-[opacity,transform] duration-200 group-hover:opacity-100 group-hover:translate-x-0`})]})})},e.id)})})]})}function Io(e){return e<5?`home.greetingNight`:e<12?`home.greetingMorning`:e<18?`home.greetingAfternoon`:e<23?`home.greetingEvening`:`home.greetingNight`}function Lo({t:e}){return(0,Q.jsx)(`section`,{"data-testid":`home-getting-started`,className:`rounded-2xl border border-border bg-card p-6 sm:p-8 shadow-sm`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col sm:flex-row sm:items-center gap-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,Q.jsx)(`span`,{className:`inline-flex h-10 w-10 items-center justify-center rounded-lg bg-amber-500/10 ring-1 ring-amber-500/20 text-amber-600 dark:text-amber-400`,children:(0,Q.jsx)(Xt,{className:`h-5 w-5`})}),(0,Q.jsx)(`span`,{className:`inline-flex h-10 w-10 items-center justify-center rounded-lg bg-emerald-500/10 ring-1 ring-emerald-500/20 text-emerald-600 dark:text-emerald-400`,children:(0,Q.jsx)(dn,{className:`h-5 w-5`})})]}),(0,Q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold tracking-tight`,children:e(`home.gettingStarted.title`,{defaultValue:`Make this home yours`})}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1 max-w-xl`,children:e(`home.gettingStarted.description`,{defaultValue:`Star an app to pin it here for one-click access. Anything you open will show up under Recently Accessed automatically.`})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:e(`home.gettingStarted.cta`,{defaultValue:`Browse all applications`})}),(0,Q.jsx)(ht,{className:`h-3.5 w-3.5`})]})]})})}function Ro({icon:e,value:t,label:n,tone:r}){return(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-2 rounded-full border border-border bg-card px-3 py-1.5 text-sm shadow-sm`,children:[(0,Q.jsx)(e,{className:`h-4 w-4 ${r}`}),(0,Q.jsx)(`span`,{className:`font-semibold tabular-nums`,children:t}),(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:n})]})}function zo({t:e}){let t=Dr(),[n,r]=(0,$.useState)([]),{publishAll:i,publishing:a}=ki(e),o=n.length;return(0,$.useEffect)(()=>{let e=!1;return Promise.resolve(t.listDrafts?.({})).then(t=>{e||!Array.isArray(t)||r(t.filter(e=>e&&typeof e.type==`string`&&typeof e.name==`string`).map(e=>({type:e.type,name:e.name})))}).catch(()=>{}),()=>{e=!0}},[t]),o<=0?null:(0,Q.jsx)(`div`,{className:`px-4 sm:px-6 lg:px-8 pt-4`,children:(0,Q.jsx)(`div`,{className:`max-w-7xl mx-auto`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-indigo-300/60 dark:border-indigo-700/50 bg-indigo-50 dark:bg-indigo-950/30 px-4 py-3`,children:[(0,Q.jsx)(yn,{className:`h-5 w-5 shrink-0 text-indigo-600 dark:text-indigo-400`}),(0,Q.jsx)(`p`,{className:`flex-1 min-w-0 text-sm text-indigo-900 dark:text-indigo-200`,children:e(`home.pendingDrafts.message`,{count:o,defaultValue:`You have {{count}} unpublished change(s) — publish to make them live.`})}),(0,Q.jsx)(Y,{size:`sm`,onClick:async()=>{(await i()).ok&&(r([]),setTimeout(()=>{try{window.location.reload()}catch{}},700))},disabled:a,"data-testid":`pending-drafts-publish`,children:a?e(`home.pendingDrafts.publishing`,{defaultValue:`Publishing…`}):e(`home.pendingDrafts.cta`,{defaultValue:`Publish`})})]})})})}function Bo({t:e}){let t=m(),{hasLocalPassword:n}=g(),[r,i]=(0,$.useState)(!1);return(0,$.useEffect)(()=>{if(typeof localStorage<`u`&&localStorage.getItem(`os:recovery-pw-dismissed`)===`1`)return;let e=!1;return Promise.resolve(n?.()).then(t=>{!e&&t===!1&&i(!0)}).catch(()=>{}),()=>{e=!0}},[n]),r?(0,Q.jsx)(`div`,{className:`px-4 sm:px-6 lg:px-8 pt-4`,children:(0,Q.jsx)(`div`,{className:`max-w-7xl mx-auto`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-amber-300/60 dark:border-amber-700/50 bg-amber-50 dark:bg-amber-950/30 px-4 py-3`,children:[(0,Q.jsx)(ct,{className:`h-5 w-5 shrink-0 text-amber-600 dark:text-amber-400`}),(0,Q.jsx)(`p`,{className:`flex-1 min-w-0 text-sm text-amber-900 dark:text-amber-200`,children:e(`home.recoveryReminder.message`,{defaultValue:`Set a recovery password so you can still sign in if single sign-on is ever unavailable.`})}),(0,Q.jsx)(Y,{size:`sm`,variant:`outline`,onClick:()=>t(`/set-password`),"data-testid":`recovery-pw-set`,children:e(`home.recoveryReminder.cta`,{defaultValue:`Set password`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>{try{localStorage.setItem(`os:recovery-pw-dismissed`,`1`)}catch{}i(!1)},"aria-label":e(`home.recoveryReminder.dismiss`,{defaultValue:`Dismiss`}),className:`shrink-0 rounded-md p-1 text-amber-700/70 hover:text-amber-900 dark:text-amber-300/70 dark:hover:text-amber-100`,children:(0,Q.jsx)(He,{className:`h-4 w-4`})})]})})}):null}function Vo(){let e=m(),{t}=M(),{apps:n,loading:r}=T(),{recentItems:i}=nr(),{favorites:a}=or(),{user:o}=g(),s=h(),c=n.filter(e=>e.active!==!1&&e.hidden!==!0),l=i.filter(e=>e.type===`object`||e.type===`dashboard`||e.type===`page`||e.type===`record`).slice(0,6),u=a.filter(e=>e.type===`object`||e.type===`dashboard`||e.type===`page`||e.type===`record`).slice(0,8),d=(0,$.useMemo)(()=>t(Io(new Date().getHours()),{defaultValue:`Welcome`}),[t]),f=(o?.name?.trim()||o?.email?.split(`@`)[0]||``).trim();return r?(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-20`,children:(0,Q.jsx)(`div`,{className:`text-muted-foreground`,children:t(`home.loading`,{defaultValue:`Loading workspace…`})})}):c.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col flex-1`,children:[(0,Q.jsx)(zo,{t}),(0,Q.jsx)(Bo,{t}),(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6`,children:s?(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(H,{children:t(`home.welcome`,{defaultValue:`Welcome to ObjectUI`})}),(0,Q.jsx)(On,{children:t(`home.welcomeAdminDescription`,{defaultValue:`Describe your business in one sentence — AI generates the objects, screens, APIs and agent tools. Or set things up yourself from the Administration menu on the left.`})}),(0,Q.jsx)(`div`,{className:`mt-6 flex flex-col sm:flex-row items-center gap-3`,children:(0,Q.jsxs)(Y,{onClick:()=>e(`/ai?agent=metadata_assistant`),"data-testid":`build-with-ai-btn`,children:[(0,Q.jsx)(Kt,{className:`mr-2 h-4 w-4`}),t(`home.buildWithAI`,{defaultValue:`Build with AI`})]})})]}):(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(H,{children:t(`home.noAppsTitle`,{defaultValue:`No applications yet`})}),(0,Q.jsx)(On,{children:t(`home.noAppsDescription`,{defaultValue:`There are no applications available to you yet. Please contact your workspace administrator.`})})]})})]}):(0,Q.jsxs)(`div`,{className:`relative min-h-full bg-background`,children:[(0,Q.jsx)(zo,{t}),(0,Q.jsx)(Bo,{t}),(0,Q.jsx)(`section`,{className:`px-4 sm:px-6 lg:px-8 pt-10 pb-6`,children:(0,Q.jsxs)(`div`,{className:`max-w-7xl mx-auto`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-muted-foreground mb-3`,children:[(0,Q.jsx)(Kt,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{className:`uppercase tracking-wider`,children:t(`home.title`,{defaultValue:`Home`})})]}),(0,Q.jsxs)(`h1`,{className:`text-3xl sm:text-4xl lg:text-5xl font-bold tracking-tight text-pretty`,children:[(0,Q.jsxs)(`span`,{className:`text-foreground`,children:[d,f?`, `:``]}),f&&(0,Q.jsx)(`span`,{className:`bg-gradient-to-r from-indigo-600 via-violet-600 to-fuchsia-600 bg-clip-text text-transparent dark:from-indigo-400 dark:via-violet-400 dark:to-fuchsia-400`,children:f}),(0,Q.jsx)(`span`,{className:`text-foreground/40`,children:`.`})]}),(0,Q.jsx)(`p`,{className:`text-base sm:text-lg text-muted-foreground mt-2 max-w-2xl`,children:t(`home.heroTagline`,{defaultValue:`Pick up where you left off, or explore something new.`})}),(0,Q.jsx)(`div`,{className:`mt-5`,children:(0,Q.jsxs)(Y,{onClick:()=>e(`/ai?agent=metadata_assistant`),"data-testid":`home-build-with-ai`,children:[(0,Q.jsx)(Kt,{className:`mr-2 h-4 w-4`}),t(`home.buildWithAI`,{defaultValue:`Build with AI`})]})}),(0,Q.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center gap-2.5`,children:[(0,Q.jsx)(Ro,{icon:kn,tone:`text-indigo-600 dark:text-indigo-400`,value:c.length,label:t(`home.stats.apps`,{defaultValue:`Applications`})}),i.length>0&&(0,Q.jsx)(Ro,{icon:dn,tone:`text-sky-600 dark:text-sky-400`,value:i.length,label:t(`home.recentApps.title`,{defaultValue:`Recently Accessed`})}),a.length>0&&(0,Q.jsx)(Ro,{icon:Xt,tone:`text-amber-500 dark:text-amber-400`,value:a.length,label:t(`home.starredApps.title`,{defaultValue:`Starred`})})]})]})}),(0,Q.jsx)(`div`,{className:`px-4 sm:px-6 lg:px-8 pb-16`,children:(0,Q.jsxs)(`div`,{className:`max-w-7xl mx-auto space-y-10`,children:[u.length===0&&l.length===0&&(0,Q.jsx)(Lo,{t}),u.length>0&&(0,Q.jsx)(Fo,{items:u}),l.length>0&&(0,Q.jsx)(Mo,{items:l}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`flex items-end justify-between mb-5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,Q.jsx)(`span`,{className:`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-border bg-muted text-muted-foreground`,children:(0,Q.jsx)(kn,{className:`h-4 w-4`})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-2xl font-semibold tracking-tight`,children:t(`home.allApps`,{defaultValue:`All Applications`})}),(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground mt-0.5`,children:[c.length,` · `,t(`home.stats.apps`,{defaultValue:`Applications`})]})]})]}),s&&(0,Q.jsxs)(Y,{variant:`outline`,onClick:()=>e(`/apps/setup/system/marketplace`),"data-testid":`browse-marketplace-btn`,children:[(0,Q.jsx)(wt,{className:`mr-2 h-4 w-4`}),t(`home.browseMarketplace`,{defaultValue:`Browse App Marketplace`})]})]}),(0,Q.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:c.map((t,n)=>(0,Q.jsx)(ko,{app:t,index:n,onClick:()=>e(`/apps/${Ar(t)??t.name}`),isFavorite:a.some(e=>e.id===`app:${t.name}`)},t.name))})]})]})})]})}function Ho({children:e}){let{setContext:t}=dr();return(0,$.useEffect)(()=>{t(`home`)},[t]),(0,Q.jsxs)(`div`,{className:`flex min-h-svh w-full flex-col bg-background`,"data-testid":`organizations-layout`,children:[(0,Q.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:(0,Q.jsx)(ua,{variant:`orgs`})}),(0,Q.jsx)(`main`,{className:`flex-1 min-w-0 overflow-auto`,children:e})]})}function Uo(e){return e.toLowerCase().replace(/[^a-z0-9\s_-]/g,``).replace(/[\s_]+/g,`-`).replace(/-+/g,`-`).replace(/^-|-$/g,``).slice(0,48)}function Wo({open:e,onOpenChange:t,onCreated:n}){let{t:r}=M(),{createOrganization:i,getAuthConfig:a}=g(),[o,s]=(0,$.useState)(``),[c,l]=(0,$.useState)(``),[u,d]=(0,$.useState)(!1),[f,p]=(0,$.useState)(!1),[m,h]=(0,$.useState)(null),[_,v]=(0,$.useState)(!1);return(0,$.useEffect)(()=>{if(!e)return;let t=!1;return a().then(e=>{t||v(e?.features?.multiOrgEnabled===!1)}).catch(()=>{}),()=>{t=!0}},[e,a]),(0,$.useEffect)(()=>{u||l(Uo(o))},[o,u]),(0,$.useEffect)(()=>{e&&(s(``),l(``),d(!1),h(null))},[e]),(0,Q.jsx)(Ee,{open:e,onOpenChange:t,children:(0,Q.jsx)(Re,{className:`sm:max-w-[425px]`,"data-testid":`create-workspace-dialog`,children:(0,Q.jsxs)(`form`,{onSubmit:(0,$.useCallback)(async e=>{if(e.preventDefault(),!(!o.trim()||!c.trim())){if(_){h(r(`workspace.multiOrgDisabled`,{defaultValue:`Creating new organizations is disabled on this instance.`}));return}p(!0),h(null);try{let e=await i({name:o.trim(),slug:c.trim()});n?.(e)}catch(e){h(e instanceof Error?e.message:`Failed to create workspace`)}finally{p(!1)}}},[o,c,i,n]),children:[(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(ge,{children:r(`workspace.createTitle`,{defaultValue:`Create a workspace`})}),(0,Q.jsx)(An,{children:r(`workspace.createDescription`,{defaultValue:`A workspace is a shared space for your team to collaborate.`})})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(rn,{htmlFor:`workspace-name`,children:r(`workspace.nameLabel`,{defaultValue:`Workspace name`})}),(0,Q.jsx)(Zt,{id:`workspace-name`,placeholder:r(`workspace.namePlaceholder`,{defaultValue:`e.g., Acme Inc`}),value:o,onChange:e=>s(e.target.value),autoFocus:!0,"data-testid":`workspace-name-input`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(rn,{htmlFor:`workspace-slug`,children:r(`workspace.slugLabel`,{defaultValue:`URL slug`})}),(0,Q.jsx)(Zt,{id:`workspace-slug`,placeholder:`acme-inc`,value:c,onChange:e=>{l(e.target.value),d(!0)},"data-testid":`workspace-slug-input`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`workspace.slugHint`,{defaultValue:`Used in URLs. Only lowercase letters, numbers, and hyphens.`})})]}),m&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,"data-testid":`workspace-create-error`,children:m})]}),(0,Q.jsxs)(se,{children:[(0,Q.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>t(!1),disabled:f,children:r(`common.cancel`,{defaultValue:`Cancel`})}),(0,Q.jsxs)(Y,{type:`submit`,disabled:f||!o.trim()||!c.trim(),"data-testid":`workspace-create-submit`,children:[f&&(0,Q.jsx)(G,{className:`mr-2 h-4 w-4 animate-spin`}),r(`workspace.createButton`,{defaultValue:`Create workspace`})]})]})]})})})}function Go(e){if(e!==void 0)return new URL(`home`,e).toString();let t=document.querySelector(`base`)?.getAttribute(`href`),n=t?new URL(t,window.location.origin):new URL(`/`,window.location.origin);return new URL(`home`,n).toString()}function Ko(e){return e.split(/[\s_-]+/).map(e=>e[0]).join(``).toUpperCase().slice(0,2)}function qo(){let{t:e}=M(),t=m(),{organizations:n,activeOrganization:r,isOrganizationsLoading:i,switchOrganization:a,getAuthConfig:o}=g(),[s,c]=(0,$.useState)(``),[l,u]=(0,$.useState)(!1),[d,f]=(0,$.useState)(null),[p,h]=(0,$.useState)(!0);(0,$.useEffect)(()=>{let e=!1;return o().then(t=>{e||t?.features?.multiOrgEnabled===!1&&h(!1)}).catch(()=>{}),()=>{e=!0}},[o]);let _=n??[],v=(0,$.useMemo)(()=>{let e=s.trim().toLowerCase();return e?_.filter(t=>t.name.toLowerCase().includes(e)||t.slug?.toLowerCase().includes(e)):_},[_,s]),y=async e=>{f(e.id);try{e.id!==r?.id&&await a(e.id),window.location.href=Go()}catch(e){console.error(`[OrganizationsPage] Failed to switch:`,e),f(null)}},b=e=>{u(!1),y(e)},x=(0,$.useRef)(!1);(0,$.useEffect)(()=>{x.current||i||_.length===1&&(x.current=!0,y(_[0]))},[i,_.length]);let S=!i&&_.length===1;return i||S?(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-center py-20`,children:(0,Q.jsx)(G,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-5xl px-4 sm:px-6 py-8 sm:py-12`,children:[(0,Q.jsxs)(`div`,{className:`mb-8`,children:[(0,Q.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold tracking-tight`,children:e(`organizations.heading`,{defaultValue:`Your Organizations`})}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e(`organizations.subtitle`,{defaultValue:`Select an organization to continue, or create a new one.`})})]}),(0,Q.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`relative w-full sm:max-w-sm`,children:[(0,Q.jsx)(Ve,{className:`pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,Q.jsx)(Zt,{value:s,onChange:e=>c(e.target.value),placeholder:e(`organizations.searchPlaceholder`,{defaultValue:`Search for an organization`}),className:`pl-9`,"data-testid":`organizations-search`})]}),p&&(0,Q.jsxs)(Y,{onClick:()=>u(!0),"data-testid":`organizations-new`,children:[(0,Q.jsx)(qe,{className:`mr-2 h-4 w-4`}),e(`organizations.new`,{defaultValue:`New organization`})]})]}),_.length===0?(0,Q.jsxs)(Le,{children:[(0,Q.jsx)(H,{children:e(`organizations.emptyTitle`,{defaultValue:`No organizations yet`})}),(0,Q.jsx)(On,{children:e(`organizations.emptyDescription`,{defaultValue:`Create your first organization to get started.`})}),p&&(0,Q.jsxs)(Y,{className:`mt-6`,onClick:()=>u(!0),children:[(0,Q.jsx)(qe,{className:`mr-2 h-4 w-4`}),e(`organizations.new`,{defaultValue:`New organization`})]})]}):v.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-muted-foreground`,children:e(`organizations.noMatches`,{defaultValue:`No organizations match your search.`})}):(0,Q.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:v.map(n=>{let i=n.id===r?.id,a=d===n.id;return(0,Q.jsxs)(`button`,{onClick:()=>y(n),disabled:a,className:`group flex items-center gap-3 rounded-lg border bg-card p-4 text-left transition-colors hover:border-primary/50 hover:bg-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-60`,"data-testid":`organization-card-${n.slug}`,children:[(0,Q.jsxs)(Et,{className:`h-10 w-10 rounded-md shrink-0`,children:[n.logo&&(0,Q.jsx)(Qt,{src:n.logo,alt:n.name}),(0,Q.jsx)(vn,{className:`rounded-md bg-primary/10 text-primary text-sm font-medium`,children:Ko(n.name)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate font-medium`,children:n.name}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:i?e(`organizations.current`,{defaultValue:`Current organization`}):n.slug})]}),(0,Q.jsx)(`span`,{className:`text-xs text-primary underline-offset-4 hover:underline shrink-0`,onClick:e=>{e.stopPropagation(),t(`/organizations/${n.slug}/members`)},children:e(`organizations.manage`,{defaultValue:`Manage`})}),a&&(0,Q.jsx)(G,{className:`h-4 w-4 animate-spin text-muted-foreground`})]},n.id)})}),(0,Q.jsx)(Wo,{open:l,onOpenChange:u,onCreated:b})]})}function Jo(){let{t:e}=M(),t=m(),{slug:n}=a(),{organizations:r,activeOrganization:i,isOrganizationsLoading:s,switchOrganization:c}=g(),{setContext:u}=dr();(0,$.useEffect)(()=>{u(`home`)},[u]);let d=(0,$.useMemo)(()=>(r??[]).find(e=>e.slug===n)??null,[r,n]);if((0,$.useEffect)(()=>{d&&i?.id!==d.id&&c(d.id).catch(e=>{console.error(`[OrganizationLayout] switch failed`,e)})},[d,i,c]),s)return(0,Q.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center`,children:(0,Q.jsx)(G,{className:`h-5 w-5 animate-spin text-muted-foreground`})});if(!d)return(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-3xl px-4 py-12 text-center`,children:[(0,Q.jsx)(`h1`,{className:`text-xl font-semibold`,children:e(`organization.notFound`,{defaultValue:`Organization not found`})}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e(`organization.notFoundDescription`,{defaultValue:`This organization does not exist or you do not have access.`})}),(0,Q.jsx)(Y,{className:`mt-6`,onClick:()=>t(`/organizations`),children:e(`organization.backToList`,{defaultValue:`Back to organizations`})})]});let f=[{to:`members`,label:e(`organization.tabs.members`,{defaultValue:`Members`})},{to:`invitations`,label:e(`organization.tabs.invitations`,{defaultValue:`Invitations`})},{to:`settings`,label:e(`organization.tabs.settings`,{defaultValue:`Settings`})}];return(0,Q.jsxs)(`div`,{className:`flex min-h-svh w-full flex-col bg-background`,"data-testid":`organization-layout`,children:[(0,Q.jsx)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background px-2 sm:px-4`,children:(0,Q.jsx)(ua,{variant:`orgs`})}),(0,Q.jsx)(`div`,{className:`border-b`,children:(0,Q.jsxs)(`div`,{className:`mx-auto w-full max-w-5xl px-4 sm:px-6 pt-6`,children:[(0,Q.jsxs)(`button`,{onClick:()=>t(`/organizations`),className:`mb-3 inline-flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(pn,{className:`h-3.5 w-3.5`}),e(`organization.backToList`,{defaultValue:`Back to organizations`})]}),(0,Q.jsx)(`div`,{className:`flex items-center justify-between gap-4`,children:(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`h1`,{className:`truncate text-2xl font-bold tracking-tight`,children:d.name}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:d.slug})]})}),(0,Q.jsx)(`nav`,{className:`mt-4 flex gap-1 -mb-px`,children:f.map(e=>(0,Q.jsx)(o,{to:e.to,end:!0,className:({isActive:e})=>`border-b-2 px-3 py-2 text-sm font-medium transition-colors ${e?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:e.label},e.to))})]})}),(0,Q.jsx)(`main`,{className:`flex-1 min-w-0 overflow-auto`,children:(0,Q.jsx)(`div`,{className:`mx-auto w-full max-w-5xl px-4 sm:px-6 py-6`,children:(0,Q.jsx)(l,{context:{org:d}})})})]})}function Yo(){return i()}function Xo(e){let t=`./`.endsWith(`/`)?`./`:`.//`;return`${window.location.origin}${t}accept-invitation/${e}`}function Zo({organizationId:e,open:t,onOpenChange:n,onInvited:r}){let{t:i}=M(),{inviteMember:a}=g(),[o,s]=(0,$.useState)(``),[c,l]=(0,$.useState)(`member`),[u,d]=(0,$.useState)(!1),[f,p]=(0,$.useState)(null),[m,h]=(0,$.useState)(null),[_,v]=(0,$.useState)(!1);(0,$.useEffect)(()=>{t&&(s(``),l(`member`),p(null),h(null),v(!1))},[t]);let y=(0,$.useCallback)(async t=>{if(t.preventDefault(),o.trim()){d(!0),p(null);try{let t=await a({organizationId:e,email:o.trim(),role:c});h(t),r?.(t)}catch(e){p(e instanceof Error?e.message:`Failed to invite member`)}finally{d(!1)}}},[o,c,e,a,r]),b=(0,$.useCallback)(async()=>{if(!m)return;let e=Xo(m.id);try{await navigator.clipboard.writeText(e),v(!0),Z.success(i(`organization.invitations.linkCopied`,{defaultValue:`Invitation link copied`})),setTimeout(()=>v(!1),2e3)}catch{Z.error(i(`organization.invitations.copyFailed`,{defaultValue:`Failed to copy link`}))}},[m,i]);return(0,Q.jsx)(Ee,{open:t,onOpenChange:n,children:(0,Q.jsx)(Re,{className:`sm:max-w-[480px]`,"data-testid":`invite-member-dialog`,children:m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(ge,{children:i(`organization.invitations.sentTitle`,{defaultValue:`Invitation created`})}),(0,Q.jsx)(An,{children:i(`organization.invitations.sentDescription`,{defaultValue:`Share the link below with the invitee. They will need to sign in to accept.`})})]}),(0,Q.jsxs)(`div`,{className:`grid gap-3 py-4`,children:[(0,Q.jsx)(rn,{children:i(`organization.invitations.linkLabel`,{defaultValue:`Accept link`})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Zt,{readOnly:!0,value:Xo(m.id),className:`font-mono text-xs`,onFocus:e=>e.currentTarget.select()}),(0,Q.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,onClick:b,"aria-label":`Copy`,children:_?(0,Q.jsx)(Ne,{className:`h-4 w-4`}):(0,Q.jsx)(at,{className:`h-4 w-4`})})]}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`organization.invitations.invitedAs`,{defaultValue:`{{email}} invited as {{role}}`,email:m.email,role:m.role})})]}),(0,Q.jsx)(se,{children:(0,Q.jsx)(Y,{onClick:()=>n(!1),children:i(`common.done`,{defaultValue:`Done`})})})]}):(0,Q.jsxs)(`form`,{onSubmit:y,children:[(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(ge,{children:i(`organization.invitations.inviteTitle`,{defaultValue:`Invite a member`})}),(0,Q.jsx)(An,{children:i(`organization.invitations.inviteDescription`,{defaultValue:`They will receive an invitation to join this organization.`})})]}),(0,Q.jsxs)(`div`,{className:`grid gap-4 py-4`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(rn,{htmlFor:`invite-email`,children:i(`organization.invitations.emailLabel`,{defaultValue:`Email`})}),(0,Q.jsx)(Zt,{id:`invite-email`,type:`email`,required:!0,placeholder:`user@example.com`,value:o,onChange:e=>s(e.target.value),autoFocus:!0,"data-testid":`invite-email-input`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(rn,{htmlFor:`invite-role`,children:i(`organization.invitations.roleLabel`,{defaultValue:`Role`})}),(0,Q.jsxs)(F,{value:c,onValueChange:e=>l(e),children:[(0,Q.jsx)(Je,{id:`invite-role`,"data-testid":`invite-role-select`,children:(0,Q.jsx)(tt,{})}),(0,Q.jsxs)(Qe,{children:[(0,Q.jsx)(_e,{value:`member`,children:i(`organization.roles.member`,{defaultValue:`Member`})}),(0,Q.jsx)(_e,{value:`admin`,children:i(`organization.roles.admin`,{defaultValue:`Admin`})}),(0,Q.jsx)(_e,{value:`owner`,children:i(`organization.roles.owner`,{defaultValue:`Owner`})})]})]})]}),f&&(0,Q.jsx)(`p`,{className:`text-sm text-destructive`,"data-testid":`invite-error`,children:f})]}),(0,Q.jsxs)(se,{children:[(0,Q.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>n(!1),disabled:u,children:i(`common.cancel`,{defaultValue:`Cancel`})}),(0,Q.jsxs)(Y,{type:`submit`,disabled:u||!o.trim(),"data-testid":`invite-submit`,children:[u&&(0,Q.jsx)(G,{className:`mr-2 h-4 w-4 animate-spin`}),i(`organization.invitations.sendInvite`,{defaultValue:`Send invite`})]})]})]})})})}function Qo(e){return e?e.split(/[\s_-]+/).map(e=>e[0]).join(``).toUpperCase().slice(0,2):`?`}function $o(){let{t:e}=M(),{org:t}=Yo(),{getMembers:n,removeMember:r,updateMemberRole:i}=g(),[a,o]=(0,$.useState)([]),[s,c]=(0,$.useState)(!0),[l,u]=(0,$.useState)(null),[d,f]=(0,$.useState)(!1),[p,m]=(0,$.useState)(null),h=(0,$.useCallback)(async()=>{c(!0),u(null);try{o(await n(t.id))}catch(e){u(e instanceof Error?e.message:`Failed to load members`)}finally{c(!1)}},[t.id,n]);(0,$.useEffect)(()=>{h()},[h]);let _=async(n,r)=>{try{await i({organizationId:t.id,memberId:n.id,role:r}),Z.success(e(`organization.members.roleUpdated`,{defaultValue:`Role updated`})),h()}catch(t){Z.error(t instanceof Error?t.message:e(`organization.members.roleUpdateFailed`,{defaultValue:`Failed to update role`}))}};return s?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,Q.jsx)(G,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):l?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-destructive/50 bg-destructive/10 p-6 text-center text-sm text-destructive`,children:[l,(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,className:`ml-4`,onClick:h,children:e(`common.retry`,{defaultValue:`Retry`})})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`members-page`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsxs)(`h2`,{className:`text-lg font-semibold`,children:[e(`organization.members.title`,{defaultValue:`Members`}),` (`,a.length,`)`]}),(0,Q.jsx)(Y,{onClick:()=>f(!0),"data-testid":`invite-member-btn`,children:e(`organization.members.inviteMember`,{defaultValue:`Invite member`})})]}),(0,Q.jsx)(jn,{}),(0,Q.jsx)(`div`,{className:`space-y-2`,children:a.map(t=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border bg-card p-3`,"data-testid":`member-row-${t.id}`,children:[(0,Q.jsxs)(Et,{className:`h-9 w-9 shrink-0`,children:[t.user?.image&&(0,Q.jsx)(Qt,{src:t.user.image,alt:t.user.name}),(0,Q.jsx)(vn,{className:`text-xs font-medium`,children:Qo(t.user?.name)})]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate font-medium text-sm`,children:t.user?.name??`—`}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:t.user?.email??`—`})]}),(0,Q.jsx)(te,{variant:`outline`,className:`shrink-0 capitalize`,children:t.role}),t.createdAt&&(0,Q.jsx)(`span`,{className:`hidden shrink-0 text-xs text-muted-foreground sm:block`,children:new Date(t.createdAt).toLocaleDateString()}),(0,Q.jsxs)(hn,{children:[(0,Q.jsx)(Pt,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0`,"aria-label":`Member actions`,children:(0,Q.jsx)(W,{className:`h-4 w-4`})})}),(0,Q.jsxs)(_t,{align:`end`,children:[(0,Q.jsxs)(bn,{onClick:()=>_(t,`owner`),disabled:t.role===`owner`,children:[(0,Q.jsx)(Nt,{className:`mr-2 h-4 w-4`}),e(`organization.roles.owner`,{defaultValue:`Owner`})]}),(0,Q.jsxs)(bn,{onClick:()=>_(t,`admin`),disabled:t.role===`admin`,children:[(0,Q.jsx)(Nt,{className:`mr-2 h-4 w-4`}),e(`organization.roles.admin`,{defaultValue:`Admin`})]}),(0,Q.jsxs)(bn,{onClick:()=>_(t,`member`),disabled:t.role===`member`,children:[(0,Q.jsx)(Nt,{className:`mr-2 h-4 w-4`}),e(`organization.roles.member`,{defaultValue:`Member`})]}),(0,Q.jsxs)(bn,{className:`text-destructive focus:text-destructive`,onClick:()=>m(t),children:[(0,Q.jsx)(ke,{className:`mr-2 h-4 w-4`}),e(`organization.members.removeMember`,{defaultValue:`Remove member`})]})]})]})]},t.id))}),(0,Q.jsx)(on,{open:!!p,onOpenChange:e=>!e&&m(null),children:(0,Q.jsxs)(Jt,{children:[(0,Q.jsxs)(At,{children:[(0,Q.jsx)(sn,{children:e(`organization.members.removeConfirmTitle`,{defaultValue:`Remove member?`})}),(0,Q.jsx)(xn,{children:e(`organization.members.removeConfirmDescription`,{defaultValue:`This will remove {{name}} from the organization. They will lose access immediately.`,name:p?.user?.name??p?.userId??``})})]}),(0,Q.jsxs)(St,{children:[(0,Q.jsx)(yt,{children:e(`common.cancel`,{defaultValue:`Cancel`})}),(0,Q.jsx)(gn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:async()=>{if(p)try{await r({organizationId:t.id,memberIdOrUserId:p.id}),Z.success(e(`organization.members.memberRemoved`,{defaultValue:`Member removed`})),m(null),h()}catch(t){Z.error(t instanceof Error?t.message:e(`organization.members.removeFailed`,{defaultValue:`Failed to remove member`}))}},children:e(`organization.members.removeConfirmAction`,{defaultValue:`Remove`})})]})]})}),(0,Q.jsx)(Zo,{organizationId:t.id,open:d,onOpenChange:f,onInvited:()=>h()})]})}function es(e){let t=`./`.endsWith(`/`)?`./`:`.//`;return`${window.location.origin}${t}accept-invitation/${e}`}function ts(e){switch(e){case`pending`:return`outline`;case`accepted`:return`default`;case`rejected`:case`canceled`:return`destructive`;default:return`secondary`}}function ns(){let{t:e}=M(),{org:t}=Yo(),{listInvitations:n,cancelInvitation:r}=g(),[i,a]=(0,$.useState)([]),[o,s]=(0,$.useState)(!0),[c,l]=(0,$.useState)(null),[u,d]=(0,$.useState)(`all`),[f,p]=(0,$.useState)(null),[m,h]=(0,$.useState)(null),_=(0,$.useCallback)(async()=>{s(!0),l(null);try{a(await n(t.id))}catch(e){l(e instanceof Error?e.message:`Failed to load invitations`)}finally{s(!1)}},[t.id,n]);(0,$.useEffect)(()=>{_()},[_]);let v=async t=>{let n=es(t.id);try{await navigator.clipboard.writeText(n),h(t.id),Z.success(e(`organization.invitations.linkCopied`,{defaultValue:`Invitation link copied`})),setTimeout(()=>h(null),2e3)}catch{Z.error(e(`organization.invitations.copyFailed`,{defaultValue:`Failed to copy link`}))}},y=async()=>{if(f)try{await r(f.id),Z.success(e(`organization.invitations.canceled`,{defaultValue:`Invitation canceled`})),p(null),_()}catch(t){Z.error(t instanceof Error?t.message:e(`organization.invitations.cancelFailed`,{defaultValue:`Failed to cancel invitation`}))}},b=u===`all`?i:i.filter(e=>e.status===u),x={all:i.length,pending:i.filter(e=>e.status===`pending`).length,accepted:i.filter(e=>e.status===`accepted`).length,rejected:i.filter(e=>e.status===`rejected`).length,canceled:i.filter(e=>e.status===`canceled`).length};return o?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,Q.jsx)(G,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):c?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-destructive/50 bg-destructive/10 p-6 text-center text-sm text-destructive`,children:[c,(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,className:`ml-4`,onClick:_,children:e(`common.retry`,{defaultValue:`Retry`})})]}):(0,Q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`invitations-page`,children:[(0,Q.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,Q.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`organization.invitations.title`,{defaultValue:`Invitations`})})}),(0,Q.jsx)(`div`,{className:`flex gap-1 border-b`,children:[`all`,`pending`,`accepted`,`rejected`,`canceled`].map(t=>(0,Q.jsxs)(`button`,{onClick:()=>d(t),className:`px-3 py-2 text-sm font-medium border-b-2 transition-colors capitalize ${u===t?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`}`,children:[e(`organization.invitations.status.${t}`,{defaultValue:t}),x[t]>0&&(0,Q.jsx)(`span`,{className:`ml-1.5 rounded-full bg-muted px-1.5 py-0.5 text-xs`,children:x[t]})]},t))}),(0,Q.jsx)(jn,{}),b.length===0?(0,Q.jsx)(`div`,{className:`rounded-lg border border-dashed p-8 text-center text-sm text-muted-foreground`,children:e(`organization.invitations.empty`,{defaultValue:`No invitations found.`})}):(0,Q.jsx)(`div`,{className:`space-y-2`,children:b.map(t=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border bg-card p-3`,"data-testid":`invitation-row-${t.id}`,children:[(0,Q.jsx)(Et,{className:`h-9 w-9 shrink-0`,children:(0,Q.jsx)(vn,{className:`text-xs`,children:(0,Q.jsx)(je,{className:`h-4 w-4`})})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate font-medium text-sm`,children:t.email}),t.expiresAt&&(0,Q.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[e(`organization.invitations.expiresAt`,{defaultValue:`Expires`}),` `,new Date(t.expiresAt).toLocaleDateString()]})]}),(0,Q.jsx)(te,{variant:`outline`,className:`shrink-0 capitalize`,children:t.role}),(0,Q.jsx)(te,{variant:ts(t.status),className:`shrink-0 capitalize`,children:e(`organization.invitations.status.${t.status}`,{defaultValue:t.status})}),t.status===`pending`&&(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8`,onClick:()=>v(t),"aria-label":`Copy invitation link`,children:m===t.id?(0,Q.jsx)(Ne,{className:`h-4 w-4 text-green-600`}):(0,Q.jsx)(at,{className:`h-4 w-4`})}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8 text-destructive hover:text-destructive`,onClick:()=>p(t),"aria-label":`Cancel invitation`,children:(0,Q.jsx)(He,{className:`h-4 w-4`})})]})]},t.id))}),(0,Q.jsx)(on,{open:!!f,onOpenChange:e=>!e&&p(null),children:(0,Q.jsxs)(Jt,{children:[(0,Q.jsxs)(At,{children:[(0,Q.jsx)(sn,{children:e(`organization.invitations.cancelTitle`,{defaultValue:`Cancel invitation?`})}),(0,Q.jsx)(xn,{children:e(`organization.invitations.cancelDescription`,{defaultValue:`The invitation for {{email}} will be revoked.`,email:f?.email??``})})]}),(0,Q.jsxs)(St,{children:[(0,Q.jsx)(yt,{children:e(`common.cancel`,{defaultValue:`Cancel`})}),(0,Q.jsx)(gn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:y,children:e(`organization.invitations.cancelAction`,{defaultValue:`Cancel invitation`})})]})]})})]})}function rs(){let{t:e}=M(),{org:t}=Yo(),{user:n,getMembers:r,updateOrganization:i,deleteOrganization:a,leaveOrganization:o}=g(),s=m(),[c,l]=(0,$.useState)(t.name),[u,d]=(0,$.useState)(t.slug??``),[f,p]=(0,$.useState)(t.logo??``),[h,_]=(0,$.useState)(!1),[v,y]=(0,$.useState)(!1),b=(0,$.useRef)(null),{upload:x}=ft(),[S,C]=(0,$.useState)(null),[w,T]=(0,$.useState)(!0),[E,D]=(0,$.useState)(!1),[O,ee]=(0,$.useState)(!1),[k,A]=(0,$.useState)(``),[j,N]=(0,$.useState)(!1);(0,$.useEffect)(()=>{l(t.name),d(t.slug??``),p(t.logo??``)},[t]),(0,$.useEffect)(()=>{let e=!1;return T(!0),r(t.id).then(t=>{e||C(t.find(e=>e.userId===n?.id)?.role===`owner`)}).catch(()=>{e||C(!1)}).finally(()=>{e||T(!1)}),()=>{e=!0}},[t.id,n?.id,r]);let P=(0,$.useCallback)(async n=>{n.preventDefault(),_(!0);try{await i(t.id,{name:c.trim(),slug:u.trim()||void 0,logo:f.trim()||void 0}),Z.success(e(`organization.settings.saved`,{defaultValue:`Settings saved`}))}catch(t){Z.error(t instanceof Error?t.message:e(`organization.settings.saveFailed`,{defaultValue:`Failed to save settings`}))}finally{_(!1)}},[t.id,c,u,f,i,e]);return w?(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-20`,children:(0,Q.jsx)(G,{className:`h-5 w-5 animate-spin text-muted-foreground`})}):(0,Q.jsxs)(`div`,{className:`space-y-8`,"data-testid":`settings-page`,children:[(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold`,children:e(`organization.settings.generalTitle`,{defaultValue:`General`})}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground mt-1`,children:e(`organization.settings.generalDescription`,{defaultValue:`Update your organization information.`})}),(0,Q.jsx)(jn,{className:`my-4`}),S?(0,Q.jsxs)(`form`,{onSubmit:P,className:`space-y-4 max-w-md`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(rn,{htmlFor:`org-name`,children:e(`organization.settings.nameLabel`,{defaultValue:`Organization name`})}),(0,Q.jsx)(Zt,{id:`org-name`,value:c,onChange:e=>l(e.target.value),required:!0,"data-testid":`settings-name-input`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(rn,{htmlFor:`org-slug`,children:e(`organization.settings.slugLabel`,{defaultValue:`Slug`})}),(0,Q.jsx)(Zt,{id:`org-slug`,value:u,onChange:e=>d(e.target.value),"data-testid":`settings-slug-input`})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(rn,{children:e(`organization.settings.logoLabel`,{defaultValue:`Logo`})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(Et,{className:`size-16 rounded-md`,children:[f?(0,Q.jsx)(Qt,{src:f,alt:c,className:`object-cover`}):null,(0,Q.jsx)(vn,{className:`rounded-md text-base`,children:(c||`O`).slice(0,2).toUpperCase()})]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsx)(`input`,{ref:b,type:`file`,accept:`image/*`,className:`hidden`,onChange:async t=>{let n=t.target.files?.[0];if(b.current&&(b.current.value=``),n){y(!0);try{p((await x(n)).url),Z.success(e(`organization.settings.logoUploaded`,{defaultValue:`Logo uploaded — save to apply`}))}catch(t){Z.error(t instanceof Error?t.message:e(`organization.settings.logoUploadFailed`,{defaultValue:`Failed to upload logo`}))}finally{y(!1)}}},"data-testid":`settings-logo-file`}),(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,disabled:v,onClick:()=>b.current?.click(),"data-testid":`settings-logo-upload-btn`,children:[v?(0,Q.jsx)(G,{className:`mr-2 h-4 w-4 animate-spin`}):(0,Q.jsx)(Fe,{className:`mr-2 h-4 w-4`}),f?e(`organization.settings.logoReplace`,{defaultValue:`Replace`}):e(`organization.settings.logoUpload`,{defaultValue:`Upload`})]}),f&&(0,Q.jsxs)(Y,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>p(``),"data-testid":`settings-logo-clear-btn`,children:[(0,Q.jsx)(He,{className:`mr-2 h-4 w-4`}),e(`organization.settings.logoClear`,{defaultValue:`Remove`})]})]}),(0,Q.jsx)(Zt,{id:`org-logo`,type:`url`,value:f,onChange:e=>p(e.target.value),placeholder:`https://example.com/logo.png`,className:`text-xs`,"data-testid":`settings-logo-input`})]})]})]}),(0,Q.jsxs)(Y,{type:`submit`,disabled:h,"data-testid":`settings-save-btn`,children:[h&&(0,Q.jsx)(G,{className:`mr-2 h-4 w-4 animate-spin`}),e(`organization.settings.save`,{defaultValue:`Save changes`})]})]}):(0,Q.jsx)(`div`,{className:`rounded-lg border bg-muted/50 p-4 text-sm text-muted-foreground`,children:e(`organization.settings.readOnlyNote`,{defaultValue:`Only owners can change settings.`})})]}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h2`,{className:`text-lg font-semibold text-destructive`,children:e(`organization.settings.dangerZone`,{defaultValue:`Danger zone`})}),(0,Q.jsx)(jn,{className:`my-4`}),(0,Q.jsxs)(`div`,{className:`space-y-4 rounded-lg border border-destructive/50 bg-destructive/5 p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-sm`,children:e(`organization.settings.leaveTitle`,{defaultValue:`Leave organization`})}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`organization.settings.leaveDescription`,{defaultValue:`You will lose access to this organization.`})})]}),(0,Q.jsx)(Y,{variant:`destructive`,size:`sm`,onClick:()=>D(!0),children:e(`organization.settings.leaveAction`,{defaultValue:`Leave`})})]}),(0,Q.jsx)(jn,{}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-sm`,children:e(`organization.settings.deleteTitle`,{defaultValue:`Delete organization`})}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e(`organization.settings.deleteDescription`,{defaultValue:`Permanently delete this organization and all its data.`})})]}),(0,Q.jsx)(Y,{variant:`destructive`,size:`sm`,onClick:()=>{A(``),ee(!0)},disabled:!S,children:e(`organization.settings.deleteAction`,{defaultValue:`Delete`})})]})]})]}),(0,Q.jsx)(on,{open:E,onOpenChange:D,children:(0,Q.jsxs)(Jt,{children:[(0,Q.jsxs)(At,{children:[(0,Q.jsx)(sn,{children:e(`organization.settings.leaveConfirmTitle`,{defaultValue:`Leave organization?`})}),(0,Q.jsx)(xn,{children:e(`organization.settings.leaveConfirmDescription`,{defaultValue:`Are you sure you want to leave {{name}}? You will lose access immediately.`,name:t.name})})]}),(0,Q.jsxs)(St,{children:[(0,Q.jsx)(yt,{disabled:j,children:e(`common.cancel`,{defaultValue:`Cancel`})}),(0,Q.jsxs)(gn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:async()=>{N(!0);try{await o(t.id),Z.success(e(`organization.settings.leftOrg`,{defaultValue:`You have left the organization`})),s(`/organizations`)}catch(t){Z.error(t instanceof Error?t.message:e(`organization.settings.leaveFailed`,{defaultValue:`Failed to leave organization`}))}finally{N(!1)}},disabled:j,children:[j&&(0,Q.jsx)(G,{className:`mr-2 h-4 w-4 animate-spin`}),e(`organization.settings.leaveConfirmAction`,{defaultValue:`Leave`})]})]})]})}),(0,Q.jsx)(on,{open:O,onOpenChange:e=>{ee(e),e||A(``)},children:(0,Q.jsxs)(Jt,{children:[(0,Q.jsxs)(At,{children:[(0,Q.jsx)(sn,{children:e(`organization.settings.deleteConfirmTitle`,{defaultValue:`Delete organization?`})}),(0,Q.jsx)(xn,{children:e(`organization.settings.deleteConfirmDescription`,{defaultValue:`This action is irreversible. All data will be permanently deleted. Type the organization slug to confirm.`})})]}),(0,Q.jsxs)(`div`,{className:`px-6 pb-2`,children:[(0,Q.jsx)(rn,{htmlFor:`delete-confirm-slug`,className:`text-sm font-medium`,children:e(`organization.settings.deleteConfirmSlugLabel`,{defaultValue:`Type "{{slug}}" to confirm`,slug:t.slug})}),(0,Q.jsx)(Zt,{id:`delete-confirm-slug`,className:`mt-2`,value:k,onChange:e=>A(e.target.value),placeholder:t.slug,"data-testid":`delete-confirm-slug-input`})]}),(0,Q.jsxs)(St,{children:[(0,Q.jsx)(yt,{disabled:j,children:e(`common.cancel`,{defaultValue:`Cancel`})}),(0,Q.jsxs)(gn,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:async()=>{N(!0);try{await a(t.id),Z.success(e(`organization.settings.deleted`,{defaultValue:`Organization deleted`})),s(`/organizations`)}catch(t){Z.error(t instanceof Error?t.message:e(`organization.settings.deleteFailed`,{defaultValue:`Failed to delete organization`}))}finally{N(!1)}},disabled:j||k!==t.slug,children:[j&&(0,Q.jsx)(G,{className:`mr-2 h-4 w-4 animate-spin`}),e(`organization.settings.deleteConfirmAction`,{defaultValue:`Delete organization`})]})]})]})})]})}function is(e,t){if(!e)return``;let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=Date.now()-n.getTime(),i=60*1e3,a=60*i,o=24*a;return r<i?t(`console.ai.justNow`):r<a?t(`console.ai.minutesAgo`,{count:Math.floor(r/i)}):r<o?t(`console.ai.hoursAgo`,{count:Math.floor(r/a)}):r<7*o?t(`console.ai.daysAgo`,{count:Math.floor(r/o)}):n.toLocaleDateString()}function as(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:t.toLocaleString()}var os=[`today`,`yesterday`,`previous7Days`,`previous30Days`,`older`],ss={today:`Today`,yesterday:`Yesterday`,previous7Days:`Previous 7 days`,previous30Days:`Previous 30 days`,older:`Older`};function cs(e,t=Date.now()){let n=new Date(t);n.setHours(0,0,0,0);let r=n.getTime(),i=1440*60*1e3,a=e=>{let t=new Date(e.updatedAt??e.createdAt??0).getTime();return Number.isNaN(t)?0:t},o={today:[],yesterday:[],previous7Days:[],previous30Days:[],older:[]};for(let t of[...e].sort((e,t)=>a(t)-a(e))){let e=a(t);e>=r?o.today.push(t):e>=r-i?o.yesterday.push(t):e>=r-7*i?o.previous7Days.push(t):e>=r-30*i?o.previous30Days.push(t):o.older.push(t)}return os.filter(e=>o[e].length>0).map(e=>({key:e,items:o[e]}))}function ls({userId:e,apiBase:t,className:n,refreshKey:r,titleHints:i,onNavigate:o}){let{t:s}=M(),c=m(),{conversationId:l}=a(),{conversations:u,isLoading:d,error:f,remove:p,rename:h}=Qn({userId:e,apiBase:t,refreshKey:r}),[g,_]=(0,$.useState)(``),[v,y]=(0,$.useState)(void 0),b=(0,$.useMemo)(()=>u.map(e=>{let t=i?.[e.id]?.trim();return!t||e.title?.trim()||e.preview?.trim()?e:{...e,preview:t}}),[u,i]),x=(0,$.useMemo)(()=>{let e=g.trim().toLowerCase();return e?b.filter(t=>`${t.title??``} ${t.preview??``}`.toLowerCase().includes(e)):b},[b,g]),S=(0,$.useCallback)(()=>{c(`/ai?new=1`),o?.()},[c,o]),C=(0,$.useCallback)(async(e,t)=>{e.stopPropagation(),await p(t),t===l&&(c(`/ai`,{replace:!0}),o?.())},[p,l,c,o]),w=(0,$.useCallback)(async(e,t)=>{y(void 0);try{await h(e,t)}catch{}},[h]);return(0,Q.jsxs)(`aside`,{className:X(`flex h-full min-h-0 flex-col bg-muted/30`,n),"data-testid":`ai-conversations-sidebar`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 border-b px-3 py-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium`,children:s(`console.ai.chats`)}),(0,Q.jsxs)(Y,{size:`sm`,variant:`outline`,onClick:S,"data-testid":`ai-new-chat`,children:[(0,Q.jsx)(qe,{className:`h-3.5 w-3.5`}),s(`console.ai.newChat`)]})]}),(0,Q.jsxs)(`div`,{className:`relative`,children:[(0,Q.jsx)(Ve,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,Q.jsx)(Zt,{value:g,onChange:e=>_(e.target.value),placeholder:s(`console.ai.searchChats`),className:`h-7 pl-7 text-xs`,"data-testid":`ai-conversations-search`})]})]}),(0,Q.jsx)(V,{className:`flex-1 min-h-0`,children:d&&u.length===0?(0,Q.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground`,children:s(`common.loading`)}):f?(0,Q.jsx)(`div`,{className:`px-3 py-4 text-xs text-destructive`,children:f.message}):u.length===0?(0,Q.jsxs)(Le,{className:`px-3 py-8`,children:[(0,Q.jsx)(Be,{className:`h-8 w-8 text-muted-foreground`}),(0,Q.jsx)(H,{children:s(`console.ai.noChatsYet`)}),(0,Q.jsx)(On,{children:s(`console.ai.noChatsDescription`)})]}):x.length===0?(0,Q.jsx)(`div`,{className:`px-3 py-4 text-xs text-muted-foreground`,children:s(`console.ai.noMatchingChats`)}):(0,Q.jsx)(`div`,{className:`flex flex-col py-1`,children:cs(x).map(e=>(0,Q.jsxs)(`section`,{"data-testid":`ai-conversation-group-${e.key}`,children:[(0,Q.jsx)(`h3`,{className:`px-3 pb-1 pt-3 text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:s(`console.ai.group.${e.key}`,{defaultValue:ss[e.key]})}),(0,Q.jsx)(`ul`,{className:`flex flex-col`,children:e.items.map(e=>(0,Q.jsx)(ds,{conversation:e,query:g.trim(),active:e.id===l,renaming:e.id===v,onSelect:()=>{c(`/ai/${e.id}`),o?.()},onDelete:t=>C(t,e.id),onStartRename:()=>y(e.id),onCancelRename:()=>y(void 0),onSubmitRename:t=>w(e.id,t)},e.id))})]},e.key))})})]})}function us(e,t){if(!e)return e??null;let n=t?.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase(),i=[],a=0,o=0;for(;;){let t=r.indexOf(n,a);if(t===-1){i.push(e.slice(a));break}t>a&&i.push(e.slice(a,t)),i.push((0,Q.jsx)(`mark`,{className:`rounded-[2px] bg-primary/20 px-0.5 text-foreground`,children:e.slice(t,t+n.length)},o++)),a=t+n.length}return i}function ds({conversation:e,query:t,active:n,renaming:r,onSelect:i,onDelete:a,onStartRename:o,onCancelRename:s,onSubmitRename:c}){let{t:l}=M(),u=e.title?.trim()||e.preview?.trim()||l(`console.ai.newConversation`),[d,f]=(0,$.useState)(u),p=(0,$.useRef)(null);return(0,$.useEffect)(()=>{r&&(f(e.title?.trim()||e.preview?.trim()||``),setTimeout(()=>p.current?.select(),0))},[r,e.title,e.preview]),r?(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`div`,{className:X(`flex w-full items-center gap-1 border-l-2 px-3 py-2`,n?`border-primary bg-accent`:`border-transparent`),"data-testid":`ai-conversation-rename-row-${e.id}`,children:[(0,Q.jsx)(Zt,{ref:p,value:d,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),c(d)):e.key===`Escape`&&(e.preventDefault(),s())},className:`h-7 flex-1 text-sm`,"data-testid":`ai-conversation-rename-input-${e.id}`,"aria-label":l(`console.ai.renameConversation`)}),(0,Q.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0`,onClick:()=>c(d),"data-testid":`ai-conversation-rename-confirm-${e.id}`,"aria-label":l(`console.ai.saveRename`),children:(0,Q.jsx)(Ne,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Y,{size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0`,onClick:s,"aria-label":l(`console.ai.cancelRename`),children:(0,Q.jsx)(He,{className:`h-3.5 w-3.5`})})]})}):(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`div`,{className:X(`group flex w-full items-start gap-2 border-l-2 border-transparent px-3 py-2 text-sm transition-colors hover:bg-accent/50`,n&&`border-primary bg-accent`),"data-testid":`ai-conversation-row-${e.id}`,children:[(0,Q.jsxs)(`button`,{type:`button`,onClick:i,className:`min-w-0 flex-1 text-left`,"data-testid":`ai-conversation-select-${e.id}`,children:[(0,Q.jsx)(`span`,{className:`line-clamp-1 font-medium`,children:us(u,t)}),e.preview&&e.preview!==u?(0,Q.jsx)(`span`,{className:`mt-0.5 block line-clamp-1 text-xs text-muted-foreground`,children:us(e.preview,t)}):null,(0,Q.jsx)(`span`,{className:`mt-0.5 block text-[10px] text-muted-foreground`,title:as(e.updatedAt??e.createdAt),children:is(e.updatedAt??e.createdAt,l)})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100`,children:[(0,Q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0 hover:text-primary`,onClick:o,"data-testid":`ai-conversation-rename-${e.id}`,"aria-label":l(`console.ai.renameConversation`),children:(0,Q.jsx)(rt,{className:`h-3.5 w-3.5`})}),(0,Q.jsx)(Y,{type:`button`,size:`sm`,variant:`ghost`,className:`h-7 w-7 p-0 hover:text-destructive`,onClick:a,"data-testid":`ai-conversation-delete-${e.id}`,"aria-label":l(`console.ai.deleteConversation`),children:(0,Q.jsx)(Ze,{className:`h-3.5 w-3.5`})})]})]})})}function fs(){return typeof window>`u`?``:window.location.pathname.startsWith(`/_console`)?`/_console`:``}function ps(e,t){let n=`${fs()}/apps/${encodeURIComponent(e)}`;return t?n:`${n}?preview=draft`}function ms({appName:e,materialized:t=!1,refreshKey:n,onClose:r}){let{t:i}=M(),a=(0,$.useRef)(null);return(0,$.useEffect)(()=>{if(!a.current)return;let n=ps(e,t);try{a.current.getAttribute(`src`)!==n&&a.current.setAttribute(`src`,n)}catch{}},[e,t]),(0,$.useEffect)(()=>{if(n>0)try{a.current?.contentWindow?.location.reload()}catch{}},[n]),(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col border-l`,"data-testid":`live-canvas`,children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b bg-muted/30 px-3 py-1.5 text-xs text-muted-foreground`,children:[(0,Q.jsx)(Pe,{className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t?i(`console.ai.liveCanvasUnlisted`,{app:e,defaultValue:`Live app — {{app}} (unlisted until published)`}):i(`console.ai.liveCanvas`,{app:e,defaultValue:`Live preview — {{app}} (draft)`})}),(0,Q.jsx)(Y,{size:`sm`,variant:`ghost`,onClick:r,"data-testid":`live-canvas-close`,children:(0,Q.jsx)(He,{className:`h-3.5 w-3.5`})})]}),(0,Q.jsx)(`iframe`,{ref:a,title:`Draft preview: ${e}`,src:ps(e,t),className:`h-full w-full flex-1 border-0 bg-background`,"data-testid":`live-canvas-frame`})]})}var hs=`/api/v1/ai`;function gs(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}function _s(e){let t=gs(e,`state`);switch(t){case`input-streaming`:case`input-available`:return`output-available`;case`approval-requested`:case`approval-responded`:case`output-available`:case`output-error`:case`output-denied`:return t;default:return`output-available`}}function vs(e){return e.map(e=>{let t=[],n,r=e.parts.filter(e=>e.type===`text`).map(e=>e.text??``).join(``);if(e.role===`assistant`)for(let r of e.parts){if(!r.type.startsWith(`tool-`))continue;let i=gs(r,`toolName`)??r.type.slice(5),a=gs(r,`toolCallId`)??`${e.id}-${i}`,o=_s(r),s=r.output??r.result,c=Cr(s);if(t.push({toolCallId:a,toolName:i,...o?{state:o}:{},...s===void 0?{}:{result:s},...c?{draftReview:c}:{},...r.errorText?{errorText:String(r.errorText)}:{}}),!n){let e=wr(c);e&&(n=e)}}return{id:e.id,role:e.role,content:r,...t.length>0?{toolInvocations:t}:{},...n?{buildProgress:n}:{}}})}function ys(e){return e.find(e=>e.role===`user`)?.parts.filter(e=>e.type===`text`).map(e=>e.text??``).join(``).trim()||void 0}var bs={data_chat:{key:`console.ai.agentLabels.dataChat`,defaultValue:`Assistant`},metadata_assistant:{key:`console.ai.agentLabels.metadataAssistant`,defaultValue:`Metadata Assistant`}};function xs(e,t,n){let r=t?bs[t]:void 0;return r?e(r.key,{defaultValue:r.defaultValue}):n}function Ss(e){if(e)return e.replace(/\/$/,``);let t={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`},n=t.VITE_AI_BASE_URL;return n?n.replace(/\/$/,``):`${(t.VITE_SERVER_URL??``).replace(/\/$/,``)}${hs}`}var Cs=`ai-chats-collapsed`;function ws(){let[e,t]=(0,$.useState)(()=>{try{return localStorage.getItem(Cs)===`1`}catch{return!1}}),n=(0,$.useRef)(!1);return{collapsed:e,toggle:(0,$.useCallback)(()=>{n.current=!1,t(e=>{let t=!e;try{localStorage.setItem(Cs,t?`1`:`0`)}catch{}return t})},[]),handleCanvasOpenChange:(0,$.useCallback)(e=>{e?t(e=>e||(n.current=!0,!0)):n.current&&(n.current=!1,t(!1))},[])}}var Ts=`ai-chat-pane-width`,Es=480,Ds=360,Os=420,ks=24;function As(e,t){let n=t.containerWidth>0?Math.max(t.min,t.containerWidth-t.previewMin):1/0;return Math.min(Math.max(e,t.min),n)}function js(e){let t=(0,$.useRef)(null),[n,r]=(0,$.useState)(()=>{try{let e=Number(localStorage.getItem(Ts));return Number.isFinite(e)&&e>0?e:Es}catch{return Es}}),[i,a]=(0,$.useState)(!1),o=(0,$.useCallback)(e=>As(e,{min:Ds,previewMin:Os,containerWidth:t.current?.clientWidth??0}),[]),s=(0,$.useCallback)(e=>{try{localStorage.setItem(Ts,String(Math.round(e)))}catch{}},[]);return(0,$.useEffect)(()=>{if(!e)return;let n=t.current;if(!n||typeof ResizeObserver>`u`)return;let i=new ResizeObserver(()=>r(e=>o(e)));return i.observe(n),()=>i.disconnect()},[e,o]),{width:n,dragging:i,containerRef:t,onHandlePointerDown:(0,$.useCallback)(e=>{e.preventDefault();let t=e.clientX,i=n;a(!0);let c=e=>r(o(i+(e.clientX-t))),l=e=>{let n=o(i+(e.clientX-t));r(n),s(n),a(!1),window.removeEventListener(`pointermove`,c),window.removeEventListener(`pointerup`,l)};window.addEventListener(`pointermove`,c),window.addEventListener(`pointerup`,l)},[o,s,n]),onHandleKeyDown:(0,$.useCallback)(e=>{let t=e.key===`ArrowLeft`?-24:e.key===`ArrowRight`?ks:0;t&&(e.preventDefault(),r(e=>{let n=o(e+t);return s(n),n}))},[o,s]),reset:(0,$.useCallback)(()=>{let e=o(Es);r(e),s(e)},[o,s])}}function Ms(e){if(!(e.metaKey||e.ctrlKey)||!e.shiftKey||e.altKey)return null;switch(e.key.toLowerCase()){case`o`:return`new-chat`;case`s`:return`toggle-list`;default:return null}}function Ns({apiBase:e,defaultAgent:t}={}){let{user:n}=g(),{t:r}=M(),i=n?.id,{conversationId:o}=a(),[s]=u(),[c]=(0,$.useState)(()=>s.get(`agent`)??void 0),l=s.get(`new`)!==null,d=m(),{setContext:f}=dr();(0,$.useEffect)(()=>{f(`home`)},[f]);let p=(0,$.useMemo)(()=>Ss(e),[e]),h={BASE_URL:`./`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1,VITE_SENTRY_DSN:`https://1373a588ceb9da150b11e64bf85f583d@o4510356161757184.ingest.us.sentry.io/4511439670673408`,VITE_SENTRY_ENVIRONMENT:`production`,VITE_SENTRY_SEND_DEFAULT_PII:`true`,VITE_SERVER_URL:``,VITE_USE_MOCK_SERVER:`false`}.VITE_AI_DEFAULT_AGENT,{agents:_,isLoading:v,error:y}=br({apiBase:p}),[b,x]=(0,$.useState)(void 0);(0,$.useEffect)(()=>{if(!b&&_.length>0){let e=Er(_,c??t??h);e&&x(e)}},[_,b,c,t,h]);let S=b?`${p}/agents/${encodeURIComponent(b)}/chat`:void 0,{conversationId:C,initialMessages:w}=Gn({userId:i,scope:b,apiBase:p,activeId:o,forceNew:l}),[T,E]=(0,$.useState)(0),[D,O]=(0,$.useState)({}),[ee,k]=(0,$.useState)(!1),[A,j]=(0,$.useState)(!1),{collapsed:N,toggle:P,handleCanvasOpenChange:te}=ws();(0,$.useEffect)(()=>{let e=e=>{let t=Ms(e);t&&(e.preventDefault(),t===`toggle-list`?P():d(`/ai?new=1`))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[P,d]);let ne=(0,$.useMemo)(()=>p.replace(/\/v1\/ai$/,``).replace(/\/ai$/,``)||`/api`,[p]),re=(0,$.useMemo)(()=>{if(typeof window>`u`||typeof document>`u`)return;let e=``;try{let t=document.querySelector(`base`)?.getAttribute(`href`);t&&(e=new URL(t,window.location.origin).pathname.replace(/\/+$/,``))}catch{}return`${window.location.origin}${e}/s`},[]),ie=(0,$.useRef)(null);l?ie.current===null&&(ie.current={id:C}):ie.current=null,(0,$.useEffect)(()=>{if(!o&&C){if(ie.current&&ie.current.id===C)return;d(`/ai/${C}`,{replace:!0})}},[o,C,d]);let ae=(0,$.useRef)(new Set);(0,$.useEffect)(()=>{C&&w.length>0&&ae.current.add(C)},[C,w.length]),(0,$.useEffect)(()=>{if(!C)return;let e=ys(w);e&&O(t=>t[C]===e?t:{...t,[C]:e})},[C,w]);let oe=(0,$.useCallback)(e=>{if(E(e=>e+1),e&&C&&O(t=>({...t,[C]:e})),!e||!C||ae.current.has(C))return;ae.current.add(C);let t=()=>E(e=>e+1);setTimeout(t,2500),setTimeout(t,6e3)},[C]);return(0,Q.jsxs)(`div`,{className:`flex h-svh w-full flex-col bg-background`,"data-testid":`ai-chat-page`,children:[(0,Q.jsxs)(`header`,{className:`sticky top-0 z-30 flex h-14 w-full shrink-0 items-center gap-2 border-b bg-background/95 px-2 backdrop-blur sm:px-4`,children:[(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-8 w-8 shrink-0 md:hidden`,onClick:()=>j(!0),"aria-label":r(`console.ai.openChats`),"data-testid":`ai-chat-mobile-sidebar-trigger`,children:(0,Q.jsx)(Rt,{className:`h-4 w-4`})}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`hidden h-8 w-8 shrink-0 md:inline-flex`,onClick:P,"aria-label":N?r(`console.ai.showChats`,{defaultValue:`Show chats`}):r(`console.ai.hideChats`,{defaultValue:`Hide chats`}),title:N?r(`console.ai.showChats`,{defaultValue:`Show chats`}):r(`console.ai.hideChats`,{defaultValue:`Hide chats`}),"data-testid":`ai-chat-collapse-sidebar-trigger`,"aria-pressed":N,children:N?(0,Q.jsx)(ut,{className:`h-4 w-4`}):(0,Q.jsx)(tn,{className:`h-4 w-4`})}),(0,Q.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,Q.jsx)(ua,{variant:`home`})})]}),(0,Q.jsx)(Ie,{open:A,onOpenChange:j,children:(0,Q.jsxs)(B,{side:`left`,className:`w-[320px] p-0 sm:max-w-[360px]`,"data-testid":`ai-chat-mobile-sidebar`,children:[(0,Q.jsxs)(Oe,{className:`sr-only`,children:[(0,Q.jsx)(J,{children:r(`console.ai.chats`)}),(0,Q.jsx)(xe,{children:r(`console.ai.chatsDescription`)})]}),(0,Q.jsx)(ls,{userId:i,apiBase:p,refreshKey:T,titleHints:D,className:`h-full border-r-0`,onNavigate:()=>j(!1)})]})}),C&&(0,Q.jsx)(wn,{open:ee,onOpenChange:k,objectName:`ai_conversations`,recordId:C,recordLabel:`this conversation`,apiBase:ne,publicBaseUrl:re}),(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 w-full bg-muted/20`,children:[!N&&(0,Q.jsx)(ls,{userId:i,apiBase:p,refreshKey:T,titleHints:D,className:`hidden w-72 shrink-0 border-r md:flex`}),(0,Q.jsx)(`main`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,Q.jsx)(Ps,{agents:_,agentsLoading:v,agentsError:y,activeAgent:b,onAgentChange:x,showAgentPicker:!!c,chatApi:S,apiBase:p,conversationId:C,initialMessages:w,onSent:oe,onShare:()=>k(!0),onCanvasOpenChange:te},`${S??`local`}:${C??`pending`}`)})]})]})}function Ps({agents:e,agentsLoading:t,showAgentPicker:n,agentsError:r,activeAgent:i,onAgentChange:a,chatApi:o,apiBase:s,conversationId:c,initialMessages:l,onSent:u,onShare:d,onCanvasOpenChange:f}){let{t:p}=M(),h=m(),[g,_]=(0,$.useState)(null),[v,y]=(0,$.useState)(0),b=(0,$.useRef)(null);(0,$.useEffect)(()=>()=>{b.current&&window.clearTimeout(b.current)},[]);let x=g!==null;(0,$.useEffect)(()=>{f?.(x)},[x,f]);let S=js(x),C=(0,$.useCallback)(e=>{let t=e.find(e=>e.type===`app`);t&&_(e=>e??{name:t.name,materialized:!1}),b.current&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>y(e=>e+1),800)},[]),w=(0,$.useCallback)(e=>{_(t=>t&&t.name===e&&!t.materialized?{name:e,materialized:!0}:t??{name:e,materialized:!0})},[]);(0,$.useEffect)(()=>{_(null)},[c]);let T=(0,$.useMemo)(()=>xs(p,i,e.find(e=>e.name===i)?.label??i??p(`console.ai.assistant`)),[e,i,p]),E=(0,$.useMemo)(()=>vs(l),[l]),D=(0,$.useMemo)(()=>{if(!(E.length>0))return Rs(i,T,p)},[E.length,i,T,p]),{errorSuppressed:O,handleChatError:ee,setMessagesRef:k,resetSuppression:A}=er({chatApi:o,conversationId:c}),{messages:j,isLoading:N,error:P,sendMessage:te,stop:ne,reload:re,clear:ie,setMessages:ae}=xr({api:o,conversationId:c,onError:ee,body:{context:{activeApp:`AI`,agentName:i,autoPublishAiBuilds:Jr().features.autoPublishAiBuilds}},initialMessages:E,autoResponse:!o,autoResponseText:`Thanks for your message! I'm here to help.`,autoResponseDelay:600});(0,$.useEffect)(()=>{k.current=ae},[ae]),(0,$.useEffect)(()=>{Zn(c,Yn(j))},[c,j]);let oe=(0,$.useRef)(!1);(0,$.useEffect)(()=>{oe.current&&!N&&g&&y(e=>e+1),oe.current=N},[N,g]);let se=Tr({messages:j,apiBase:s,continueConversation:e=>{te(e)}}),I=(0,$.useCallback)((e,t)=>{A(),te(e,t),u(e)},[te,u]),L=(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-border/50 px-4 pb-2 pt-3 sm:px-6`,children:[(0,Q.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:n&&e.length>0?(0,Q.jsxs)(F,{value:i,onValueChange:a,disabled:t,children:[(0,Q.jsx)(Je,{className:`h-7 w-auto min-w-0 border-0 bg-transparent px-1.5 text-xs shadow-none hover:bg-accent focus:ring-0 focus:ring-offset-0 focus-visible:ring-1 focus-visible:ring-border/80 focus-visible:ring-offset-0 sm:min-w-[160px]`,"data-testid":`ai-chat-agent-picker`,children:(0,Q.jsx)(tt,{placeholder:`Choose agent...`})}),(0,Q.jsx)(Qe,{align:`start`,children:e.map(e=>(0,Q.jsxs)(_e,{value:e.name,className:`text-xs`,children:[(0,Q.jsx)(`span`,{className:`font-medium`,children:xs(p,e.name,e.label)}),e.description?(0,Q.jsx)(`span`,{className:`block text-muted-foreground text-[10px] truncate max-w-[260px]`,children:e.description}):null]},e.name))})]}):(0,Q.jsx)(`span`,{className:`truncate text-xs font-medium text-foreground/85`,children:T})}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,className:`h-7 w-7 text-muted-foreground hover:text-foreground`,onClick:d,disabled:!c,"aria-label":p(`console.ai.share`),"data-testid":`ai-chat-share-button`,title:p(c?`console.ai.shareTitle`:`console.ai.shareDisabledTitle`),children:(0,Q.jsx)(Sn,{className:`h-3.5 w-3.5`})})}),r?(0,Q.jsx)(`span`,{className:`basis-full text-[10px] text-amber-700 dark:text-amber-400`,title:r.message,children:p(`console.ai.offlineDemoMode`)}):null]});return(0,Q.jsxs)(`div`,{ref:S.containerRef,className:`relative flex min-h-0 flex-1 px-0`,children:[(0,Q.jsx)(`div`,{"data-chat-column":!0,className:g?`flex min-h-0 shrink-0 justify-center`:`flex min-h-0 flex-1 justify-center`,style:g?{width:S.width}:void 0,children:(0,Q.jsx)(Sr,{className:`min-h-0 flex-1 bg-background md:max-w-5xl`,onUpgrade:()=>window.open(Yr(),`_blank`,`noopener,noreferrer`),surface:`plain`,maxHeight:`100%`,headerSlot:L,messages:j,placeholder:i?p(`console.ai.askAgent`,{agent:T}):p(t?`console.ai.loadingAgents`:`console.ai.askAnything`),labels:{emptyTitle:p(`console.ai.emptyTitle`),emptyDescription:p(`console.ai.emptyDescription`),clear:p(`console.ai.clearConversation`),sendHint:p(`console.ai.sendHint`),agentActivity:p(`console.ai.agentActivity`),toolCompleted:p(`console.ai.toolCompleted`),toolRunning:p(`console.ai.toolRunning`),toolAwaitingApproval:p(`console.ai.toolAwaitingApproval`),toolFailed:p(`console.ai.toolFailed`),toolDetailsHidden:p(`console.ai.toolDetailsHidden`),copy:p(`console.ai.copy`),copied:p(`console.ai.copied`),regenerate:p(`console.ai.regenerate`),model:p(`console.ai.model`),submit:p(`console.ai.submit`),uploadFiles:p(`console.ai.uploadFiles`),stopResponse:p(`console.ai.stopResponse`),trace:p(`console.ai.trace`),viewTrace:p(`console.ai.viewTrace`)},suggestions:D,onSendMessage:I,onClear:ie,hideClearBar:!0,onStop:N?ne:void 0,onReload:re,isLoading:N,error:O?void 0:P,enableMarkdown:!0,onToolApprove:se.decide,toolDecisions:se.decisions,toolApproveLabel:`Approve & run`,toolDenyLabel:`Reject`,toolDenyReason:`Operator rejected from chat`,onOpenBuiltApp:e=>h(`/apps/${encodeURIComponent(e)}`),openBuiltAppLabel:p(`console.ai.openBuiltApp`,{defaultValue:`Open app`}),fetchPendingDraftCount:Xn,onPublishDrafts:async e=>{try{let t=await fetch(`/api/v1/packages/${encodeURIComponent(e)}/publish-drafts`,{method:`POST`,credentials:`include`,headers:{"Content-Type":`application/json`,Accept:`application/json`},body:`{}`}),n=await t.json().catch(()=>null);if(!t.ok||n?.success===!1)throw Error(n?.error?.message||`HTTP ${t.status}`);let r=n?.data?.failedCount??n?.failedCount??0;if(r)throw Error(String(r));let i=n?.data?.seedApplied??n?.seedApplied;return i&&i.success===!1?Z.warning(p(`console.ai.seedWarn`,{defaultValue:`Published, but some sample data failed to load.`}),{description:i.error??(Array.isArray(i.errors)&&i.errors.length?String(i.errors[0]):void 0)}):Z.success(p(`console.ai.publishOk`,{defaultValue:`Published — objects are now live.`})),{ok:!0,health:yr(n)}}catch(e){return Z.error(p(`console.ai.publishFailed`,{defaultValue:`Publish failed`}),{description:e instanceof Error?e.message:void 0}),!1}},publishDraftsLabel:p(`console.ai.publishDrafts`,{defaultValue:`Publish`}),publishedLabel:p(`console.ai.published`,{defaultValue:`Published`}),autoPublishDrafts:Jr().features.autoPublishAiBuilds,onDraftArtifacts:C,onPreviewDraftApp:(e,t)=>_({name:e,materialized:t?.materialized===!0}),onBuildMaterialized:w,previewDraftLabel:p(`console.ai.previewDraft`,{defaultValue:`Preview`}),"data-testid":`ai-chat-panel`})}),g?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":p(`console.ai.resizeSplit`,{defaultValue:`Resize chat and preview`}),tabIndex:0,onPointerDown:S.onHandlePointerDown,onKeyDown:S.onHandleKeyDown,onDoubleClick:S.reset,"data-testid":`ai-chat-split-handle`,className:X(`group relative hidden w-1.5 shrink-0 cursor-col-resize touch-none select-none md:block`,`focus:outline-none`),children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-y-0 -left-1.5 -right-1.5`}),(0,Q.jsx)(`span`,{"aria-hidden":!0,className:X(`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 bg-border transition-colors`,`group-hover:bg-primary/60 group-focus-visible:bg-primary`,S.dragging&&`bg-primary`)})]}),(0,Q.jsx)(ms,{appName:g.name,materialized:g.materialized,refreshKey:v,onClose:()=>_(null)}),S.dragging?(0,Q.jsx)(`div`,{className:`fixed inset-0 z-50 cursor-col-resize`,"data-testid":`ai-chat-split-overlay`}):null]}):null]})}function Fs(e){return[e(`console.ai.suggestions.dataChat.userCount`,{defaultValue:`How many users are in the system? List their emails.`}),e(`console.ai.suggestions.dataChat.recentRecords`,{defaultValue:`List the 5 most recently created records.`}),e(`console.ai.suggestions.dataChat.recordCounts`,{defaultValue:`Count records for each object.`})]}function Is(e){return[e(`console.ai.suggestions.metadataAssistant.buildCrm`,{defaultValue:`Build a CRM: customers, contacts and opportunities, with relationships.`}),e(`console.ai.suggestions.metadataAssistant.buildApp`,{defaultValue:`Create a project management app: projects, tasks and members.`}),e(`console.ai.suggestions.metadataAssistant.buildFlow`,{defaultValue:`Design a ticketing system: tickets, priority and a status flow.`})]}function Ls(e){return[e(`console.ai.suggestions.generic.help`,{defaultValue:`What can you help me with?`}),e(`console.ai.suggestions.generic.availableObjects`,{defaultValue:`List the available data objects.`}),e(`console.ai.suggestions.generic.recentActivity`,{defaultValue:`Summarize my recent activity.`})]}function Rs(e,t,n){if(e===`data_chat`)return Fs(n);if(e===`metadata_assistant`)return Is(n);let r=(e??t).toLowerCase();return r.includes(`data`)?Fs(n):r.includes(`metadata`)?Is(n):Ls(n)}function zs(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function Bs(e){return!zs(e)||e.viewKind?!1:!!(e.list||e.form||e.listViews||e.formViews)}function Vs(e){if(!zs(e))return;let t=e.config;if(zs(t)&&typeof t.type==`string`)return t.type;if(typeof e.type==`string`)return e.type;if(e.viewKind===`form`)return`form`;if(e.viewKind===`list`)return`list`}hi({ref:`metadata:directory`,label:`All Metadata Types`,source:`@object-ui/app-shell`,component:Ir}),hi({ref:`metadata:resource`,label:`Metadata Resource`,source:`@object-ui/app-shell`,component:Lr}),hi({ref:`developer:packages`,label:`Packages`,source:`@object-ui/app-shell`,component:jr}),Nr({type:`object`,label:`Objects`,description:`Domain entities — tables in the data model. Each object owns its fields, relationships, validations, and lifecycle hooks.`,domain:`data`,searchableFields:[`name`,`label`,`description`],listColumns:[{key:`name`,label:`Name`,width:`25%`},{key:`label`,label:`Label`,width:`25%`},{key:`description`,label:`Description`}]}),Nr({type:`field`,label:`Fields`,description:`Columns attached to objects — name, type, validation, and storage settings.`,domain:`data`,searchableFields:[`name`,`label`,`object`,`type`],listColumns:[{key:`name`,label:`Name`,width:`25%`},{key:`object`,label:`Object`,width:`20%`},{key:`type`,label:`Type`,width:`15%`},{key:`label`,label:`Label`}]}),Nr({type:`permission`,label:`Permission sets`,description:`Object-level CRUD + VAMA + lifecycle permissions, and field-level R/W. Profiles are permission sets with isProfile=true.`,domain:`security`,EditPage:Fr,searchableFields:[`name`,`label`],listColumns:[{key:`name`,label:`Name`,width:`30%`},{key:`label`,label:`Label`,width:`30%`},{key:`isProfile`,label:`Type`,width:`15%`,render:e=>e?`Profile`:`Permission set`}]}),Nr({type:`view`,label:`Views`,description:`Saved list / kanban / calendar / gantt configurations on top of an object.`,domain:`ui`,listColumns:[{key:`name`,label:`Name`,width:`30%`},{key:`object`,label:`Object`,width:`20%`},{key:`type`,label:`Type`,width:`15%`,render:(e,t)=>Vs(t)??`—`},{key:`label`,label:`Label`}],listFilter:e=>!Bs(e)}),Nr({type:`dashboard`,label:`Dashboards`,description:`Composed dashboards with charts, KPIs, and tables.`,domain:`ui`,listColumns:[{key:`name`,label:`Name`,width:`30%`},{key:`label`,label:`Label`,width:`30%`},{key:`description`,label:`Description`}]}),Nr({type:`page`,label:`Pages`,description:`Visual page layouts authored as JSON metadata.`,domain:`ui`,listColumns:[{key:`name`,label:`Name`,width:`30%`},{key:`label`,label:`Label`,width:`30%`},{key:`route`,label:`Route`}]}),Nr({type:`book`,label:`Documentation Books`,description:`Documentation navigation spine — ordered groups with membership derived over docs (glob/tag rules), plus an explicit pages override for curated order.`,domain:`system`,searchableFields:[`name`,`label`,`description`,`slug`],listColumns:[{key:`name`,label:`Name`,width:`25%`},{key:`label`,label:`Label`,width:`25%`},{key:`audience`,label:`Audience`,width:`12%`,render:e=>e==null?`org`:typeof e==`object`&&e&&`profile`in e?`profile: ${e.profile}`:String(e)},{key:`groups`,label:`Groups`,width:`10%`,render:e=>Array.isArray(e)?String(e.length):`0`},{key:`description`,label:`Description`}]});var Hs=`/api/v1/cloud-connection`;async function Us(e,t){let n=await fetch(e,{credentials:`same-origin`,headers:{"Content-Type":`application/json`},...t}),r=await n.json().catch(()=>({}));if(!n.ok&&r?.success!==!0){let e=r?.error?.message??r?.error?.code??r?.error??`HTTP ${n.status}`;throw Error(typeof e==`string`?e:JSON.stringify(e))}return r}function Ws(){let[e,t]=(0,$.useState)({kind:`loading`}),[n,r]=(0,$.useState)(!1),[i,a]=(0,$.useState)(!1),o=(0,$.useRef)(null),s=(0,$.useCallback)(()=>{o.current&&=(clearTimeout(o.current),null)},[]),c=(0,$.useCallback)(async()=>{try{let e=(await Us(`${Hs}/status`))?.data??{environmentId:null,bound:!1,connection:null};t(e.bound?{kind:`bound`,status:e}:{kind:`unbound`})}catch(e){t({kind:`error`,message:e?.message??String(e)})}},[]);(0,$.useEffect)(()=>(c(),s),[c,s]);let l=(0,$.useCallback)((e,n)=>{let r=Math.max(e.interval,2)*1e3,i=async()=>{if(Date.now()-n>e.expires_in*1e3){t({kind:`error`,message:`The request expired before it was approved. Start again.`});return}try{let n=await Us(`${Hs}/bind/poll`,{method:`POST`,body:JSON.stringify({device_code:e.device_code})});if(n?.data?.pending){o.current=setTimeout(i,r);return}if(n?.data?.bound||n?.success){await c();return}t({kind:`error`,message:n?.error?.code??`Binding failed.`})}catch(e){t({kind:`error`,message:e?.message??String(e)})}};o.current=setTimeout(i,r)},[c]),u=(0,$.useCallback)(async()=>{r(!0);try{let e=(await Us(`${Hs}/bind/start`,{method:`POST`,body:`{}`}))?.data;if(!e?.device_code||!e?.user_code)throw Error(`Device code request failed.`);let n=e.verification_uri_complete??e.verification_uri,r=!1;if(n)try{r=!!window.open(n,`_blank`,`noopener,width=520,height=720`)}catch{}t({kind:`waiting`,code:e,popupOpened:r}),l(e,Date.now())}catch(e){t({kind:`error`,message:e?.message??String(e)})}finally{r(!1)}},[l]),d=(0,$.useCallback)(async()=>{r(!0);try{await Us(`${Hs}/unbind`,{method:`POST`,body:`{}`}),await c()}catch(e){t({kind:`error`,message:e?.message??String(e)})}finally{r(!1)}},[c]),f=(0,$.useCallback)(async e=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),1500)}catch{}},[]);if(e.kind===`loading`)return(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg border p-6 text-sm text-muted-foreground`,children:[(0,Q.jsx)(G,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),` Checking connection…`]});if(e.kind===`error`)return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-destructive/40 bg-destructive/5 p-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-destructive`,children:[(0,Q.jsx)(En,{className:`h-4 w-4`,"aria-hidden":`true`}),` `,e.message]}),(0,Q.jsx)(`button`,{type:`button`,className:`self-start rounded-md border px-3 py-1.5 text-sm hover:bg-accent`,onClick:()=>{s(),c()},children:`Try again`})]});if(e.kind===`waiting`){let t=e.code.verification_uri_complete??e.code.verification_uri;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-lg border p-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(G,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}),e.popupOpened?`Approve the connection in the window that just opened — this page updates by itself.`:`Waiting for approval in the cloud console…`]}),!e.popupOpened&&t?(0,Q.jsxs)(`a`,{className:`inline-flex items-center gap-1.5 self-start rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90`,href:t,target:`_blank`,rel:`noreferrer`,children:[`Open the approval page `,(0,Q.jsx)(be,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})]}):null,(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsx)(`code`,{className:`rounded-md bg-muted px-4 py-2 text-2xl font-semibold tracking-[0.25em]`,children:e.code.user_code}),(0,Q.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-sm hover:bg-accent`,onClick:()=>void f(e.code.user_code),children:[(0,Q.jsx)(at,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),` `,i?`Copied`:`Copy`]})]}),(0,Q.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`The code is pre-filled on the approval page`,e.popupOpened&&t?(0,Q.jsxs)(Q.Fragment,{children:[` `,`— if the window did not appear,`,` `,(0,Q.jsxs)(`a`,{className:`inline-flex items-center gap-1 text-primary underline-offset-2 hover:underline`,href:t,target:`_blank`,rel:`noreferrer`,children:[`open it here `,(0,Q.jsx)(be,{className:`h-3 w-3`,"aria-hidden":`true`})]}),`.`]}):`.`]}),(0,Q.jsx)(`button`,{type:`button`,className:`self-start rounded-md border px-3 py-1.5 text-sm hover:bg-accent`,onClick:()=>{s(),c()},children:`Cancel`})]})}if(e.kind===`bound`){let t=e.status.connection??{},r=t.runtime_id??e.status.runtimeId;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-lg border p-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Ft,{className:`h-5 w-5 text-emerald-600`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:`Connected to ObjectStack Cloud`})]}),(0,Q.jsxs)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5 text-sm`,children:[t.name?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Runtime`}),(0,Q.jsx)(`dd`,{children:t.name})]}):null,t.organization_id?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Organization`}),(0,Q.jsx)(`dd`,{className:`font-mono`,children:t.organization_id})]}):null,t.account_email?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Approved by`}),(0,Q.jsx)(`dd`,{children:t.account_email})]}):null,r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Runtime ID`}),(0,Q.jsx)(`dd`,{className:`font-mono text-xs`,children:r})]}):null,e.status.environmentId?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Environment`}),(0,Q.jsx)(`dd`,{className:`font-mono`,children:e.status.environmentId})]}):null,t.bound_at?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-muted-foreground`,children:`Since`}),(0,Q.jsx)(`dd`,{children:new Date(t.bound_at).toLocaleString()})]}):null]}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Your organization's private packages now appear in the Marketplace under “Your organization”.`}),(0,Q.jsxs)(`button`,{type:`button`,disabled:n,className:`inline-flex items-center gap-1.5 self-start rounded-md border border-destructive/40 px-3 py-1.5 text-sm text-destructive hover:bg-destructive/5 disabled:opacity-50`,onClick:()=>void d(),children:[(0,Q.jsx)(he,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),` Disconnect`]})]})}return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-lg border p-6`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)($t,{className:`h-5 w-5 text-muted-foreground`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`font-medium`,children:`Not connected`})]}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Connect this runtime to an ObjectStack control plane to browse your organization's private packages and install them here. Approval is a single click in your cloud account — no ids or credentials are typed into this page.`}),(0,Q.jsxs)(`button`,{type:`button`,disabled:n,className:`inline-flex items-center gap-1.5 self-start rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,onClick:()=>void u(),children:[n?(0,Q.jsx)(G,{className:`h-4 w-4 animate-spin`,"aria-hidden":`true`}):(0,Q.jsx)(Dt,{className:`h-4 w-4`,"aria-hidden":`true`}),`Connect`]})]})}k.register(`cloud-connection:panel`,()=>(0,Q.jsx)(Ws,{}),{namespace:`app-shell`,label:`Cloud Connection Panel`,category:`plugin`,inputs:[]});export{wi as _,Jo as a,Vo as c,Ta as d,ba as f,yi as g,bi as h,$o as i,Eo as l,xi as m,rs as n,qo as o,ya as p,ns as r,Ho as s,Ns as t,go as u,Ti as v};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,m as n,t as r}from"./vendor-react-DR370ovB.js";import{ht as i}from"./framework-
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t,m as n,t as r}from"./vendor-react-DR370ovB.js";import{ht as i}from"./framework-BLEk-ou3.js";import{Mt as a}from"./ui-components-CrPYFyEM.js";var o=e(t(),1),s=r(),c=o.lazy(()=>n(()=>import(`./MonacoImpl-BsJjT9SV.js`),[],import.meta.url)),l=({schema:e,value:t,onChange:n})=>(0,s.jsx)(o.Suspense,{fallback:(0,s.jsx)(a,{className:`w-full h-[400px]`}),children:(0,s.jsx)(c,{value:t??e.value,language:e.language,theme:e.theme,height:e.height,onChange:n??e.onChange,readOnly:e.readOnly,className:e.className})});i.register(`code-editor`,l,{namespace:`plugin-editor`,label:`Code Editor`,category:`plugin`,inputs:[{name:`value`,type:`string`,label:`Code`,defaultValue:``},{name:`language`,type:`enum`,label:`Language`,enum:[`javascript`,`typescript`,`python`,`json`,`html`,`css`],defaultValue:`javascript`},{name:`theme`,type:`enum`,label:`Theme`,enum:[`vs-dark`,`light`],defaultValue:`vs-dark`},{name:`height`,type:`string`,label:`Height`,defaultValue:`400px`},{name:`readOnly`,type:`boolean`,label:`Read Only`,defaultValue:!1}],defaultProps:{value:`// Write your code here
|
|
2
2
|
console.log("Hello, World!");`,language:`javascript`,theme:`vs-dark`,height:`400px`,readOnly:!1}});export{l as CodeEditorRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t}from"./vendor-react-DR370ovB.js";import{$ as n,
|
|
1
|
+
import{o as e}from"./rolldown-runtime-CMxvf4Kt.js";import{_ as t}from"./vendor-react-DR370ovB.js";import{$ as n,Wo as r}from"./ui-components-CrPYFyEM.js";var i=e(t(),1);function a(e){return e.includes(`-`)?e.toLowerCase():e.replace(/([a-z0-9])([A-Z])/g,`$1-$2`).replace(/([A-Z]+)([A-Z][a-z])/g,`$1-$2`).toLowerCase()}var o=new Map;function s(e){if(!e)return r;let t=o.get(e);if(t)return t;let s=a(e),c=e=>i.createElement(n,{name:s,fallback:r,...e});return c.displayName=`LucideIcon(${e})`,o.set(e,c),c}var c=`${``.replace(/\/$/,``)}/api/settings`;async function l(e){if(!e.ok){let t=await e.json().catch(()=>({error:{message:e.statusText}})),n=Error(t?.error?.message??e.statusText);throw n.status=e.status,n.payload=t,n}return e.json()}var u=()=>({"Content-Type":`application/json`,Accept:`application/json`});async function d(){return l(await fetch(c,{credentials:`include`,headers:u()}))}async function f(e){return l(await fetch(`${c}/${encodeURIComponent(e)}`,{credentials:`include`,headers:u()}))}async function p(e,t){return l(await fetch(`${c}/${encodeURIComponent(e)}`,{method:`PUT`,credentials:`include`,headers:u(),body:JSON.stringify(t)}))}async function m(e,t,n){let r=await fetch(`${c}/${encodeURIComponent(e)}/${encodeURIComponent(t)}`,{method:`POST`,credentials:`include`,headers:u(),body:JSON.stringify(n??{})}),i=await r.json().catch(()=>({ok:!1,message:r.statusText}));return typeof i?.ok==`boolean`?i:{ok:r.ok,message:i?.error?.message??r.statusText}}function h(e){return typeof e==`string`?e:e?.defaultValue||e?.key||``}export{p as a,m as i,f as n,s as o,d as r,h as t};
|