@objectstack/console 14.7.0 → 14.8.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/.objectui-sha +1 -1
- package/dist/assets/{AdapterProvider-CmeZULrO.js → AdapterProvider-BzVT9qYv.js} +1 -1
- package/dist/assets/{AiPendingActionsPage-C4Iq12It.js → AiPendingActionsPage-B4I03oil.js} +1 -1
- package/dist/assets/{ApiConsolePage-CVxWz2Fc.js → ApiConsolePage-_wjPZg_8.js} +1 -1
- package/dist/assets/{AppDocsIndex-_Nk6Vrm0.js → AppDocsIndex-B3Y96Lvd.js} +1 -1
- package/dist/assets/{AppManagementPage-Ds4z81em.js → AppManagementPage-DxZABvOm.js} +1 -1
- package/dist/assets/{ApprovalsInboxPage-BYmqtmb8.js → ApprovalsInboxPage-DAjFkDy9.js} +1 -1
- package/dist/assets/{AuditLogPage-BY42e7b1.js → AuditLogPage-CuKdhFr9.js} +1 -1
- package/dist/assets/{ComponentNavView-CPizP2rl.js → ComponentNavView-DebBry51.js} +1 -1
- package/dist/assets/{CreateViewDialog-C6DeiGi1.js → CreateViewDialog-BCEk3ESW.js} +1 -1
- package/dist/assets/{DashboardView-CZ3rnuQw.js → DashboardView-Bi_ea9x6.js} +1 -1
- package/dist/assets/{DeveloperHubPage-cynqEJzi.js → DeveloperHubPage-CEFVU_4t.js} +1 -1
- package/dist/assets/{DocShell-DowMXJqg.js → DocShell-C09YMyAT.js} +1 -1
- package/dist/assets/{ExpressionProvider-jYh8yBEi.js → ExpressionProvider-gKUl8r3a.js} +1 -1
- package/dist/assets/{FlowRunsPage-BsxDtVro.js → FlowRunsPage-Of98wriv.js} +1 -1
- package/dist/assets/{IntegrationsPage-Dt3JjnPR.js → IntegrationsPage-D2Eh-wKl.js} +2 -2
- package/dist/assets/{InterfaceListPage-8ZC2DL6l.js → InterfaceListPage-BuAQSxuZ.js} +1 -1
- package/dist/assets/ManagedByBadge-3xVjmTY7.js +1 -0
- package/dist/assets/MarketplaceAccessDenied-YG6RAG6U.js +1 -0
- package/dist/assets/MarketplaceInstalledPage-BFESaZWD.js +1 -0
- package/dist/assets/MarketplacePackagePage-Vy7JiFQ0.js +4 -0
- package/dist/assets/MarketplacePage-C9kQ9UzP.js +1 -0
- package/dist/assets/{MetadataInspector-mHEFcIlV.js → MetadataInspector-Dc5CNMYV.js} +1 -1
- package/dist/assets/{MetadataProvider-DRMpRtkE.js → MetadataProvider-Bkb-vkjJ.js} +1 -1
- package/dist/assets/ObjectDataPage-B_qdf_tA.js +1 -0
- package/dist/assets/{PageView-Bvw39DGp.js → PageView-CO7Yco3U.js} +1 -1
- package/dist/assets/ProfilePage--OycjBXX.js +1 -0
- package/dist/assets/PublicFormsPage-CI1LZQKt.js +1 -0
- package/dist/assets/RecordDetailView-BQzH8bIG.js +2 -0
- package/dist/assets/{RecordFormPage-B8hs2UT_.js → RecordFormPage-D3fuaSOR.js} +1 -1
- package/dist/assets/ReportDefaultInspector-DfAMgr8D.js +3 -0
- package/dist/assets/{ReportView-C5EokVMt.js → ReportView-DyMm1CCA.js} +1 -1
- package/dist/assets/{SearchResultsPage-zgmMi_LJ.js → SearchResultsPage-CVsVjc9k.js} +1 -1
- package/dist/assets/{SettingsHub-D73rzMbT.js → SettingsHub-DTr02Vxf.js} +1 -1
- package/dist/assets/{SettingsView-BHmgUtG_.js → SettingsView-BN_M8m7j.js} +1 -1
- package/dist/assets/{SystemHubPage-HiWUvHtN.js → SystemHubPage-DGggPmsC.js} +1 -1
- package/dist/assets/{assistantBus-cGcVZa3R.js → assistantBus-CbDb2Mju.js} +1 -1
- package/dist/assets/data-adapter-CCueB_gY.js +7 -0
- package/dist/assets/framework-DUXRLJaF.js +36 -0
- package/dist/assets/{getIcon-DGciRPQd.js → getIcon-PwXhgLNw.js} +1 -1
- package/dist/assets/highlighted-body-OFNGDK62-Cdc_XtSh.js +1 -0
- package/dist/assets/{i18n-DzI3zFKr.js → i18n-DALEd5g8.js} +1 -1
- package/dist/assets/index-BCvtzf7n.css +2 -0
- package/dist/assets/index-C_G40cue.js +2 -0
- package/dist/assets/mermaid-GHXKKRXX-D6paxo1u.js +1 -0
- package/dist/assets/metadata-admin-DYtDZDTS.js +23 -0
- package/dist/assets/plugin-calendar-C5OJe0lx.js +1 -0
- package/dist/assets/plugin-charts-C4pZYso-.js +7 -0
- package/dist/assets/plugin-chatbot-B6HiHZjD.js +120 -0
- package/dist/assets/plugin-dashboard-BMm8A0um.js +6 -0
- package/dist/assets/plugin-form-zDPLpTAc.js +1 -0
- package/dist/assets/plugin-gantt-Bdm-Yvii.js +102 -0
- package/dist/assets/plugin-grid-BJGu5-41.js +8 -0
- package/dist/assets/plugin-kanban-BN37MzOm.js +1 -0
- package/dist/assets/plugin-map-Bamjhlg6.js +1 -0
- package/dist/assets/{plugin-markdown-hWqBbKBQ.js → plugin-markdown-Cg477jm9.js} +1 -1
- package/dist/assets/{plugin-report-Fk8OwuMv.js → plugin-report-9ivqW5g0.js} +4 -4
- package/dist/assets/plugin-timeline-C9C1_Un7.js +1 -0
- package/dist/assets/plugin-tree-BDrBkDUi.js +1 -0
- package/dist/assets/plugin-view-YLoG5wfy.js +1 -0
- package/dist/assets/plugins-views-DyIUCjnC.js +4 -0
- package/dist/assets/{skeletons-Dc-JqV4x.js → skeletons-CnYUdj-X.js} +1 -1
- package/dist/assets/{src-Ep8btdv1.js → src--kVwJFRS.js} +1 -1
- package/dist/assets/src-DD4w6yW2.js +18 -0
- package/dist/assets/src-LTygtqhe.js +1 -0
- package/dist/assets/{types-bxB_p8fZ.js → types-KTMf42UB.js} +1 -1
- package/dist/assets/ui-components-t1CVb1Ox.js +42 -0
- package/dist/assets/{ui-layout-elT9p0KY.js → ui-layout-C7dEpbqb.js} +1 -1
- package/dist/assets/{use-book-data-BNn214nk.js → use-book-data-Ddcv6p9p.js} +1 -1
- package/dist/assets/{useMetadata-B84fbReE.js → useMetadata-Ca0oaT4_.js} +1 -1
- package/dist/index.html +4 -4
- package/package.json +1 -1
- package/dist/assets/ConsoleFloatingChatbot-vRAPnn56.js +0 -1
- package/dist/assets/ManagedByBadge-DySgRsRf.js +0 -1
- package/dist/assets/MarketplaceAccessDenied-CQo3oKUv.js +0 -1
- package/dist/assets/MarketplaceInstalledPage-COPjvdZD.js +0 -1
- package/dist/assets/MarketplacePackagePage-BL5_Fzlm.js +0 -4
- package/dist/assets/MarketplacePage-BnHkiwG_.js +0 -1
- package/dist/assets/ObjectDataPage-D9wwntH8.js +0 -1
- package/dist/assets/ProfilePage-CkS1AQDC.js +0 -1
- package/dist/assets/PublicFormsPage-onVYVDnz.js +0 -1
- package/dist/assets/RecordDetailView-DsaGwX7Z.js +0 -2
- package/dist/assets/ReportDefaultInspector-DacLe5p0.js +0 -3
- package/dist/assets/data-adapter-BaIWVzG-.js +0 -7
- package/dist/assets/framework-DNWcCoBP.js +0 -36
- package/dist/assets/highlighted-body-OFNGDK62-obGa3VW9.js +0 -1
- package/dist/assets/index-CETzvR9k.js +0 -2
- package/dist/assets/index-DZuzAri6.css +0 -2
- package/dist/assets/marketplaceApi-BZG2zqqI.js +0 -1
- package/dist/assets/mermaid-GHXKKRXX-zDa01SPQ.js +0 -1
- package/dist/assets/metadata-admin-B3pnFq3D.js +0 -23
- package/dist/assets/plugin-calendar-DI8_y72D.js +0 -1
- package/dist/assets/plugin-charts-8kHRsJ26.js +0 -7
- package/dist/assets/plugin-chatbot-5rciOKdr.js +0 -120
- package/dist/assets/plugin-dashboard-g6z_zZXP.js +0 -6
- package/dist/assets/plugin-form-DWcrPPUr.js +0 -1
- package/dist/assets/plugin-gantt-BmusZEIw.js +0 -100
- package/dist/assets/plugin-grid-DdzrFURM.js +0 -8
- package/dist/assets/plugin-kanban-DtXDjkdV.js +0 -1
- package/dist/assets/plugin-map-B7RVCjPN.js +0 -1
- package/dist/assets/plugin-timeline-BLradJ31.js +0 -1
- package/dist/assets/plugin-tree-Dd-qjC-G.js +0 -1
- package/dist/assets/plugin-view-Beo3HWpE.js +0 -1
- package/dist/assets/plugins-views-D0GqJrx_.js +0 -4
- package/dist/assets/src-DZVwE2OF.js +0 -18
- package/dist/assets/src-DxI3szM2.js +0 -1
- package/dist/assets/surfaceAgent-DPt23-K5.js +0 -1
- package/dist/assets/ui-components-CmbUYw-E.js +0 -42
- package/dist/assets/useRecordApprovals-CwD1sHs0.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as e}from"./rolldown-runtime-DAXXjFlN.js";import{r as t,y as n}from"./vendor-react-BKSb6vFP.js";import{c as r,o as i,s as a}from"./plugin-chatbot-5rciOKdr.js";var o=e(n(),1),s=t(),c=({code:e,language:t,raw:n,className:c,startLine:l,lineNumbers:u,...d})=>{let{shikiTheme:f}=(0,o.useContext)(r),p=a(),[m,h]=(0,o.useState)(n);return(0,o.useEffect)(()=>{if(!p){h(n);return}let r=p.highlight({code:e,language:t,themes:f},e=>{h(e)});r&&h(r)},[e,t,f,p,n]),(0,s.jsx)(i,{className:c,language:t,lineNumbers:u,result:m,startLine:l,...d})};export{c as HighlightedCodeBlockBody};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./ui-components-BL3SEdAz.css","./plugin-dashboard-DnNKJB60.css","./plugin-map-CsMXqW6n.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{o as e,r as t}from"./rolldown-runtime-DAXXjFlN.js";import{_ as n,a as r,c as i,d as a,f as o,g as s,h as c,i as l,l as u,m as d,r as f,s as p,u as m,y as h}from"./vendor-react-BKSb6vFP.js";import{a as g,c as _,d as v,i as y,l as b,m as x,p as S,r as C,s as ee,u as te}from"./infrastructure-Bc4DRENl.js";import{L as ne,R as w,Y as T,c as re,l as E,qt as D}from"./framework-DNWcCoBP.js";import{Ar as ie,C as ae,Cr as O,Ha as k,Kr as oe,Mc as se,P as ce,Pa as le,Ps as ue,Qi as de,S as fe,Ss as pe,Us as me,Vs as he,Wi as ge,Ya as _e,Yo as ve,Yr as ye,Za as be,Zs as xe,aa as Se,ai as Ce,ar as A,b as we,dt as Te,ft as Ee,io as De,ir as j,ja as Oe,js as ke,kc as Ae,ki as je,la as Me,ln as M,lt as Ne,nr as N,pn as P,pt as Pe,rr as F,sr as I,tr as L,uc as Fe,us as Ie,ut as Le,za as Re,zo as ze}from"./ui-components-CmbUYw-E.js";import{r as R}from"./vendor-ui-utils-D-WJ115h.js";import{C as z,S as Be,_ as Ve,a as He,b as Ue,c as We,d as Ge,f as Ke,g as qe,h as Je,i as Ye,l as Xe,m as Ze,n as Qe,o as $e,p as et,r as tt,s as nt,u as rt,v as it,x as at,y as ot}from"./src-DZVwE2OF.js";import"./plugin-form-DWcrPPUr.js";import{d as st,m as ct,o as lt}from"./surfaceAgent-DPt23-K5.js";import{i as ut}from"./useRecordApprovals-CwD1sHs0.js";import{i as dt}from"./plugin-chatbot-5rciOKdr.js";import{C as ft,D as pt,S as B,T as mt,b as ht,w as gt,y as _t}from"./marketplaceApi-BZG2zqqI.js";import{a as vt,o as yt}from"./plugin-grid-DdzrFURM.js";import"./plugins-views-D0GqJrx_.js";import"./plugin-view-Beo3HWpE.js";import{n as V}from"./componentRegistry-ByxoJqMW.js";import{r as bt,t as xt}from"./plugin-markdown-hWqBbKBQ.js";import{t as H}from"./DocShell-DowMXJqg.js";import{a as St,i as U,l as Ct,n as W,o as wt,r as Tt,s as Et,t as Dt,u as Ot}from"./use-book-data-BNn214nk.js";import{n as kt}from"./src-DxI3szM2.js";var G=e(h(),1),At=e(n(),1),K=f(),jt={type:`object-master-detail-form`,objectName:`expense_claim`,mode:`create`,formType:`simple`,title:`New Expense Claim`,submitText:`Create Claim`,fields:[`title`,`applicant`,`department`,`reason`,`currency`,`claim_status`,`payment_status`,`remarks`],details:[{title:`Expense Lines`,childObject:`expense_line`,relationshipField:`expense_claim`,amountField:`amount`,totalField:`total_amount`,columns:[{field:`expense_date`,label:`Date`,type:`date`},{field:`category`,label:`Category`,type:`select`,options:[{label:`Travel & Transport`,value:`travel_transport`},{label:`Lodging`,value:`lodging`},{label:`Meals & Entertainment`,value:`meals_entertainment`},{label:`Office Supplies`,value:`office_supplies`},{label:`Communications`,value:`communications`},{label:`Training & Conference`,value:`training_conference`},{label:`Client / Project`,value:`client_project`},{label:`Other`,value:`other`}]},{field:`description`,label:`Description`,type:`text`},{field:`merchant_vendor`,label:`Merchant`,type:`text`},{field:`amount`,label:`Amount`,type:`currency`}]}]},Mt=()=>(0,K.jsxs)(`div`,{className:`mx-auto max-w-3xl p-6`,children:[(0,K.jsx)(`h1`,{className:`mb-4 text-lg font-semibold`,children:`Dev · Master-Detail Form (ADR-0001)`}),(0,K.jsx)(T,{schema:jt})]}),Nt={type:`element:definition-list`,properties:{columns:2,items:[{term:`Status`,description:`Active`},{term:`Owner`,description:`Ada Lovelace`},{term:`Plan`,description:`Enterprise`},{term:`Renewal`,description:`2026-12-01`}]}},Pt={type:`element:repeater`,properties:{object:`showcase_category`,titleField:`name`,fields:[`color`],limit:10,emptyText:`No categories`}},Ft=()=>(0,K.jsxs)(`div`,{className:`mx-auto max-w-2xl space-y-8 p-6`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`mb-3 text-lg font-semibold`,children:`Dev · element:definition-list`}),(0,K.jsx)(`div`,{className:`rounded-lg border p-4`,children:(0,K.jsx)(T,{schema:Nt})})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h1`,{className:`mb-3 text-lg font-semibold`,children:`Dev · element:repeater (showcase_category)`}),(0,K.jsx)(`div`,{className:`rounded-lg border p-4`,children:(0,K.jsx)(T,{schema:Pt})})]})]}),q={type:`element:definition-list`,properties:{columns:2,items:[{term:`Status`,description:`Active`},{term:`Owner`,description:`Ada Lovelace`},{term:`Plan`,description:`Enterprise`},{term:`Renewal`,description:`2026-12-01`}]}},It=()=>{let{modalHandler:e,modalElement:t}=ut();return(0,K.jsxs)(`div`,{className:`space-y-4 p-6`,children:[(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Dev · Action modal transport`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`One `,(0,K.jsx)(`code`,{children:`onModal`}),` handler, four placements, arbitrary SchemaNode content.`]}),(0,K.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,K.jsx)(O,{"data-testid":`open-center`,onClick:()=>e({placement:`center`,size:`lg`,title:`Center modal`,content:q}),children:`Center`}),(0,K.jsx)(O,{"data-testid":`open-side`,variant:`outline`,onClick:()=>e({placement:`side`,title:`Side drawer`,content:q}),children:`Side drawer`}),(0,K.jsx)(O,{"data-testid":`open-bottom`,variant:`outline`,onClick:()=>e({placement:`bottom`,title:`Bottom sheet`,content:q}),children:`Bottom sheet`}),(0,K.jsx)(O,{"data-testid":`open-fullscreen`,variant:`outline`,onClick:()=>e({placement:`fullscreen`,title:`Fullscreen`,content:q}),children:`Fullscreen`})]}),t]})},Lt=()=>{let[e,t]=G.useState([{},{}]);return(0,K.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4 p-6`,children:[(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Dev · Line-item grid with a lookup cell`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`The `,(0,K.jsx)(`code`,{children:`Account`}),` column is a real lookup picker bound to live `,(0,K.jsx)(`code`,{children:`showcase_account`}),`.`]}),(0,K.jsx)(we,{value:e,onChange:t,field:{columns:[{field:`account`,label:`Account`,type:`lookup`,reference:`showcase_account`,displayField:`name`},{field:`note`,label:`Note`,type:`text`},{field:`amount`,label:`Amount`,type:`currency`}],total_field:`amount`}}),(0,K.jsx)(`pre`,{className:`rounded bg-muted p-3 text-xs`,"data-testid":`rows-json`,children:JSON.stringify(e)})]})};function Rt({endpoint:e,children:t}){let[n,r]=(0,G.useState)({});return(0,G.useEffect)(()=>{let t=!1;return fetch(e,{credentials:`include`,headers:{Accept:`application/json`}}).then(e=>e.ok?e.json():null).then(e=>{t||!e||r({currency:e.currency??void 0,locale:e.locale??void 0})}).catch(()=>{}),()=>{t=!0}},[e]),(0,K.jsx)(se,{value:n,children:t})}var zt=(0,G.lazy)(()=>s(()=>import(`./SystemHubPage-HiWUvHtN.js`).then(e=>({default:e.SystemHubPage})),__vite__mapDeps([0,1]),import.meta.url)),Bt=(0,G.lazy)(()=>s(()=>import(`./AppManagementPage-Ds4z81em.js`).then(e=>({default:e.AppManagementPage})),__vite__mapDeps([0,1]),import.meta.url)),Vt=(0,G.lazy)(()=>s(()=>import(`./ProfilePage-CkS1AQDC.js`).then(e=>({default:e.ProfilePage})),__vite__mapDeps([0]),import.meta.url)),Ht=(0,G.lazy)(()=>s(()=>import(`./ApprovalsInboxPage-BYmqtmb8.js`).then(e=>({default:e.ApprovalsInboxPage})),__vite__mapDeps([0]),import.meta.url)),Ut=(0,G.lazy)(()=>s(()=>import(`./AiPendingActionsPage-C4Iq12It.js`).then(e=>({default:e.AiPendingActionsPage})),__vite__mapDeps([0]),import.meta.url)),Wt=(0,G.lazy)(()=>s(()=>import(`./AuditLogPage-BY42e7b1.js`).then(e=>({default:e.AuditLogPage})),__vite__mapDeps([0]),import.meta.url)),Gt=(0,G.lazy)(()=>s(()=>import(`./SettingsHub-D73rzMbT.js`).then(e=>({default:e.SettingsHub})),__vite__mapDeps([0]),import.meta.url)),Kt=(0,G.lazy)(()=>s(()=>import(`./SettingsView-BHmgUtG_.js`).then(e=>({default:e.SettingsView})),__vite__mapDeps([0]),import.meta.url)),qt=(0,G.lazy)(()=>s(()=>import(`./DeveloperHubPage-cynqEJzi.js`).then(e=>({default:e.DeveloperHubPage})),__vite__mapDeps([0]),import.meta.url)),Jt=(0,G.lazy)(()=>s(()=>import(`./ApiConsolePage-CVxWz2Fc.js`).then(e=>({default:e.ApiConsolePage})),__vite__mapDeps([0,1]),import.meta.url)),Yt=(0,G.lazy)(()=>s(()=>import(`./FlowRunsPage-BsxDtVro.js`).then(e=>({default:e.FlowRunsPage})),__vite__mapDeps([0,1]),import.meta.url)),Xt=(0,G.lazy)(()=>s(()=>import(`./PublicFormsPage-onVYVDnz.js`).then(e=>({default:e.PublicFormsPage})),__vite__mapDeps([0,1]),import.meta.url)),Zt=(0,G.lazy)(()=>s(()=>import(`./IntegrationsPage-Dt3JjnPR.js`).then(e=>({default:e.IntegrationsPage})),__vite__mapDeps([0]),import.meta.url)),Qt=(0,G.lazy)(()=>s(()=>Promise.resolve().then(()=>Mn),void 0,import.meta.url)),$t=(0,G.lazy)(()=>s(()=>import(`./AppDocsIndex-_Nk6Vrm0.js`),__vite__mapDeps([0,1]),import.meta.url)),en=(0,G.lazy)(()=>s(()=>Promise.resolve().then(()=>In),void 0,import.meta.url)),tn=(0,G.lazy)(()=>s(()=>Promise.resolve().then(()=>Rn),void 0,import.meta.url));function nn(){let{objectName:e}=d(),t=a().pathname.replace(/\/(system\/)?objects(\/.*)?$/,``);return(0,K.jsx)(p,{to:e?`${t}/component/metadata/resource/${e}?type=object`:`${t}/component/metadata/resource?type=object`,replace:!0})}function rn(){let{metadataType:e,itemName:t}=d(),n=a().pathname.replace(/\/(system\/)?metadata(\/.*)?$/,``),r=`${n}/component/metadata/resource`;return(0,K.jsx)(p,{to:e?t?`${r}/${t}?type=${e}`:`${r}?type=${e}`:`${n}/component/metadata/directory`,replace:!0})}var an=(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(u,{path:`system`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(zt,{})})}),(0,K.jsx)(u,{path:`system/apps`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Bt,{})})}),(0,K.jsx)(u,{path:`system/profile`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Vt,{})})}),(0,K.jsx)(u,{path:`system/approvals`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Ht,{})})}),(0,K.jsx)(u,{path:`system/ai-approvals`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Ut,{})})}),(0,K.jsx)(u,{path:`system/audit-log`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Wt,{})})}),(0,K.jsx)(u,{path:`system/settings`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Gt,{})})}),(0,K.jsx)(u,{path:`system/settings/:namespace`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Kt,{})})}),(0,K.jsx)(u,{path:`developer`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(qt,{})})}),(0,K.jsx)(u,{path:`developer/api-console`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Jt,{})})}),(0,K.jsx)(u,{path:`developer/flow-runs`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Yt,{})})}),(0,K.jsx)(u,{path:`developer/public-forms`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Xt,{})})}),(0,K.jsx)(u,{path:`developer/integrations`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Zt,{})})}),(0,K.jsxs)(u,{path:`docs`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(tn,{})}),children:[(0,K.jsx)(u,{index:!0,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)($t,{})})}),(0,K.jsx)(u,{path:`:slug`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(en,{})})}),(0,K.jsx)(u,{path:`:slug/:name`,element:(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Qt,{})})})]}),(0,K.jsx)(u,{path:`system/objects`,element:(0,K.jsx)(nn,{})}),(0,K.jsx)(u,{path:`system/objects/:objectName`,element:(0,K.jsx)(nn,{})}),(0,K.jsx)(u,{path:`system/metadata`,element:(0,K.jsx)(rn,{})}),(0,K.jsx)(u,{path:`system/metadata/:metadataType`,element:(0,K.jsx)(rn,{})}),(0,K.jsx)(u,{path:`system/metadata/:metadataType/:itemName`,element:(0,K.jsx)(rn,{})})]});function on(){let e=(0,G.useMemo)(()=>ae({baseUrl:``}),[``]);return(0,K.jsx)(C,{endpoint:`/api/v1/auth/me/permissions`,loadingFallback:(0,K.jsx)(z,{}),children:(0,K.jsx)(Rt,{endpoint:`/api/v1/auth/me/localization`,children:(0,K.jsx)(fe,{adapter:e,children:(0,K.jsx)(Ke,{extraRoutes:an,extraRoutesNoApp:an})})})})}function sn(e){let t=(e??[]).filter(e=>!!e?.name),n=t.find(e=>e.isDefault===!0);if(n)return`/apps/${n.name}`;let r=t.filter(e=>e.active!==!1&&e.hidden!==!0);return r.length===1?`/apps/${r[0].name}`:`/home`}function cn(){let{apps:e,loading:t}=w();return t?(0,K.jsx)(ot,{}):(0,K.jsx)(p,{to:sn(e),replace:!0})}var ln=`/api/v1`,un=new Set([`simple`,`tabbed`,`wizard`,`split`,`drawer`,`modal`]);function dn(e){let t=typeof e==`string`?parseInt(e,10):e;return t===1||t===2||t===3||t===4?t:2}function fn(e){if(Array.isArray(e))return e.map(e=>{if(typeof e==`string`)return{value:e,label:e};if(e&&typeof e==`object`){let t=String(e.value??e.id??``);return{value:t,label:String(e.label??e.name??t)}}return{value:String(e),label:String(e)}})}function pn(e,t){let n=e.sections??e.groups??[],r=t?.fields??{};return n.map(e=>{let t=dn(e.columns),n=[];for(let t of e.fields??[]){let e=typeof t==`string`?{field:t}:{...t},i=r[e.field]??{type:`text`};n.push({name:e.field,label:e.label??i.label??e.field,type:i.type??`text`,required:e.required??i.required??!1,readonly:e.readonly??!1,hidden:e.hidden??!1,placeholder:e.placeholder??i.placeholder,helpText:e.helpText??i.helpText,defaultValue:i.defaultValue,options:fn(i.options),maxLength:i.maxLength,colSpan:e.colSpan??1})}return{label:e.label,columns:t,collapsible:!!e.collapsible,collapsed:!!e.collapsed,fields:n}})}function mn(e,t){let n={};for(let r of e){r.defaultValue!==void 0&&(n[r.name]=r.defaultValue);let e=t.get(`prefill_${r.name}`);e!==null&&(n[r.name]=e)}return n}async function J(e,t){return fetch(`${ln}${e}`,{credentials:`include`,headers:{"Content-Type":`application/json`,...t?.headers??{}},...t})}async function hn(e){let t=await J(`/forms/${encodeURIComponent(e)}`);if(!t.ok){let e=await t.text().catch(()=>``);throw Error(`Failed to load form (${t.status}): ${e||t.statusText}`)}let n=await t.json();return{label:n.label??n.form?.label??n.object,object:n.object,form:n.form,objectSchema:n.objectSchema}}function gn(e,t){let n=t,r=n?.item??n,i=r?.spec??r,a=i&&typeof i==`object`&&i.config&&typeof i.config==`object`&&(`viewKind`in i||`object`in i),o=i&&typeof i==`object`?i.viewKind:void 0;if(o&&o!==`form`)throw Error(`View "${e}" is a ${o} view, not a form view — check the action or link that targets it.`);let s=a?i.config:i;if(!o&&s&&typeof s==`object`&&typeof s.type==`string`&&!un.has(s.type))throw Error(`View "${e}" is a ${s.type} view, not a form view — check the action or link that targets it.`);return{label:(a?i.label:void 0)??s?.label??e,object:(a?i.object:void 0)??s?.data?.object??i?.object,form:s}}async function _n(e){let t=await J(`/meta/view/${encodeURIComponent(e)}`);if(!t.ok)throw Error(`Form metadata not found: view/${e}`);let{label:n,object:r,form:i}=gn(e,await t.json());if(!r)throw Error(`FormView "${e}" is missing an "object" target`);let a=null;try{let e=await J(`/meta/object/${encodeURIComponent(r)}`);if(e.ok){let t=await e.json(),n=t?.item??t,i=n?.spec??n;i?.fields&&typeof i.fields==`object`&&(a={name:i.name??r,label:i.label,fields:i.fields})}}catch{}return{label:n,object:r,form:i,objectSchema:a}}async function vn(e,t){let n=await J(`/forms/${encodeURIComponent(e)}/submit`,{method:`POST`,body:JSON.stringify(t)});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Submit failed (${n.status}): ${e||n.statusText}`)}return n.json().catch(()=>({}))}async function yn(e,t){let n=await J(`/data/${encodeURIComponent(e)}`,{method:`POST`,body:JSON.stringify(t)});if(!n.ok){let e=await n.text().catch(()=>``);throw Error(`Create failed (${n.status}): ${e||n.statusText}`)}return n.json().catch(()=>({}))}var bn=`w-full rounded-md border border-input bg-background px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring disabled:opacity-50`;function xn({field:e,value:t,onChange:n}){let r={id:`f_${e.name}`,name:e.name,required:e.required,disabled:e.readonly,placeholder:e.placeholder,className:bn},i=t??``;switch(e.type){case`textarea`:case`paragraph`:case`long_text`:return(0,K.jsx)(`textarea`,{...r,rows:5,maxLength:e.maxLength,value:String(i),onChange:e=>n(e.target.value)});case`number`:case`integer`:case`decimal`:case`currency`:return(0,K.jsx)(`input`,{...r,type:`number`,value:i===``?``:Number(i),onChange:e=>n(e.target.value===``?null:Number(e.target.value))});case`email`:return(0,K.jsx)(`input`,{...r,type:`email`,value:String(i),onChange:e=>n(e.target.value)});case`url`:return(0,K.jsx)(`input`,{...r,type:`url`,value:String(i),onChange:e=>n(e.target.value)});case`password`:return(0,K.jsx)(`input`,{...r,type:`password`,value:String(i),onChange:e=>n(e.target.value)});case`date`:return(0,K.jsx)(`input`,{...r,type:`date`,value:String(i),onChange:e=>n(e.target.value)});case`time`:return(0,K.jsx)(`input`,{...r,type:`time`,value:String(i),onChange:e=>n(e.target.value)});case`datetime`:case`timestamp`:return(0,K.jsx)(`input`,{...r,type:`datetime-local`,value:String(i),onChange:e=>n(e.target.value)});case`boolean`:case`toggle`:case`checkbox`:return(0,K.jsxs)(`label`,{className:`inline-flex items-center gap-2 text-sm`,children:[(0,K.jsx)(`input`,{id:r.id,name:r.name,type:`checkbox`,disabled:e.readonly,checked:!!i,onChange:e=>n(e.target.checked),className:`h-4 w-4 rounded border-input`}),(0,K.jsx)(`span`,{children:e.placeholder??e.label})]});case`select`:case`picklist`:case`enum`:{let t=e.options??[];return(0,K.jsxs)(`select`,{...r,value:String(i),onChange:e=>n(e.target.value),children:[(0,K.jsx)(`option`,{value:``,disabled:e.required,children:e.placeholder??`— Select —`}),t.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))]})}case`radio`:return(0,K.jsx)(`div`,{className:`flex flex-wrap gap-3`,children:(e.options??[]).map(t=>(0,K.jsxs)(`label`,{className:`inline-flex items-center gap-1.5 text-sm`,children:[(0,K.jsx)(`input`,{type:`radio`,name:e.name,value:t.value,checked:String(i)===t.value,disabled:e.readonly,onChange:()=>n(t.value)}),(0,K.jsx)(`span`,{children:t.label})]},t.value))});default:return(0,K.jsx)(`input`,{...r,type:`text`,maxLength:e.maxLength,value:String(i),onChange:e=>n(e.target.value)})}}function Sn({mode:e}){let t=d(),[n]=c(),r=(e===`public`?t.slug:t.name)??``,[i,a]=(0,G.useState)(!0),[o,s]=(0,G.useState)(null),[l,u]=(0,G.useState)(null),[f,p]=(0,G.useState)({}),[m,h]=(0,G.useState)(!1),[g,_]=(0,G.useState)(!1);(0,G.useEffect)(()=>{let t=!1;return a(!0),s(null),(e===`public`?hn(r):_n(r)).then(e=>{if(t)return;u(e);let r=pn(e.form,e.objectSchema).flatMap(e=>e.fields);p(mn(r,n))}).catch(e=>{t||s(e?.message??String(e))}).finally(()=>{t||a(!1)}),()=>{t=!0}},[e,r,n]);let v=(0,G.useMemo)(()=>l?pn(l.form,l.objectSchema):[],[l]),y=l?.form?.submitBehavior??{kind:`thank-you`};return i?(0,K.jsx)(`div`,{className:`flex min-h-[60vh] items-center justify-center`,children:(0,K.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Loading…`})}):o&&!l?(0,K.jsx)(`div`,{className:`mx-auto max-w-2xl p-6`,children:(0,K.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-4 text-sm text-destructive`,children:o})}):l?g&&y.kind===`thank-you`?(0,K.jsx)(`div`,{className:`mx-auto max-w-2xl p-6`,children:(0,K.jsxs)(`div`,{className:`rounded-md border bg-card p-6 text-center`,children:[(0,K.jsx)(`h2`,{className:`mb-2 text-lg font-semibold`,children:y.title??`Thanks!`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:y.message??`Your submission has been received.`})]})}):g&&y.kind===`redirect`?(0,K.jsx)(`div`,{className:`mx-auto max-w-2xl p-6 text-center text-sm text-muted-foreground`,children:`Redirecting…`}):(0,K.jsxs)(`div`,{className:`mx-auto max-w-2xl p-4 sm:p-6`,children:[(0,K.jsxs)(`header`,{className:`mb-6`,children:[(0,K.jsx)(`h1`,{className:`text-xl font-semibold`,children:l.label}),l.form?.label&&l.form.label!==l.label&&(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:l.form.label})]}),(0,K.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),l){h(!0),s(null);try{switch(e===`public`?await vn(r,f):await yn(l.object,f),R.success(`Submitted`),y.kind){case`redirect`:{let e=y.delayMs??0;setTimeout(()=>window.location.assign(y.url),e),_(!0);break}case`continue`:{let e=v.flatMap(e=>e.fields);p(mn(e,n));break}default:_(!0);break}}catch(e){let t=e?.message??String(e);s(t),R.error(t)}finally{h(!1)}}},className:`space-y-6`,children:[v.map((e,t)=>(0,K.jsxs)(`section`,{className:`rounded-md border bg-card p-4 sm:p-5`,children:[e.label&&(0,K.jsx)(`h2`,{className:`mb-3 text-sm font-medium`,children:e.label}),(0,K.jsx)(`div`,{className:e.columns===1?`grid grid-cols-1 gap-4`:e.columns===2?`grid grid-cols-1 gap-4 sm:grid-cols-2`:e.columns===3?`grid grid-cols-1 gap-4 sm:grid-cols-3`:`grid grid-cols-1 gap-4 sm:grid-cols-4`,children:e.fields.filter(e=>!e.hidden).map(e=>(0,K.jsxs)(`div`,{className:e.colSpan===2?`sm:col-span-2`:e.colSpan===3?`sm:col-span-3`:e.colSpan===4?`sm:col-span-4`:``,children:[(0,K.jsxs)(`label`,{htmlFor:`f_${e.name}`,className:`mb-1 block text-xs font-medium text-foreground`,children:[e.label,e.required&&(0,K.jsx)(`span`,{className:`ml-0.5 text-destructive`,children:`*`})]}),(0,K.jsx)(xn,{field:e,value:f[e.name],onChange:t=>p(n=>({...n,[e.name]:t}))}),e.helpText&&(0,K.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.helpText})]},e.name))})]},t)),o&&(0,K.jsx)(`div`,{className:`rounded-md border border-destructive/40 bg-destructive/10 p-3 text-sm text-destructive`,children:o}),(0,K.jsx)(`div`,{className:`flex justify-end gap-2`,children:(0,K.jsx)(`button`,{type:`submit`,disabled:m,className:`rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow-sm hover:bg-primary/90 disabled:opacity-50`,children:m?`Submitting…`:`Submit`})})]})]}):null}function Cn({enabled:e=!1,url:t=`/api/v1/dev/metadata-events`,debounceMs:n=400,reconnectDelayMs:r=2e3}){let i=(0,G.useRef)(null);return(0,G.useEffect)(()=>{if(!e||typeof window>`u`||typeof EventSource>`u`)return;let a=null,o=null,s=!1,c=e=>{i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{try{R.info(`Metadata changed (${e}) — reloading…`,{duration:800})}catch{}setTimeout(()=>{try{window.location.reload()}catch{}},150)},n)},l=e=>{try{let t=JSON.parse(e.data),n=t?.name?`${t.metadataType??`metadata`}:${t.name}`:`metadata`;c(n)}catch{c(`change`)}},u=e=>{let t=`rebuild`;try{t=JSON.parse(e.data)?.reason??t}catch{}c(t)},d=()=>{if(!s)try{a=new EventSource(t),a.addEventListener(`metadata-change`,l),a.addEventListener(`reload`,u),a.addEventListener(`error`,()=>{s||a?.readyState===EventSource.CLOSED&&(a=null,o=setTimeout(d,r))})}catch{o=setTimeout(d,r)}};return d(),()=>{if(s=!0,o&&clearTimeout(o),i.current&&clearTimeout(i.current),a)try{a.close()}catch{}}},[e,t,n,r]),null}function wn(){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`}.VITE_SERVER_URL??``;return e?e.replace(/\/$/,``):typeof window<`u`?window.location.origin:``}function Tn(){let{token:e}=d(),t=`${(0,G.useMemo)(()=>wn(),[])}/api/v1`,[n,r]=(0,G.useState)(null),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(!0),[c,l]=(0,G.useState)(!1),[u,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(null),h=(0,G.useCallback)(async n=>{if(e){s(!0),a(null);try{let i=new URL(`${t}/share-links/${encodeURIComponent(e)}/resolve`);n&&i.searchParams.set(`password`,n);let o=await fetch(i.toString(),{headers:{Accept:`application/json`}});if(o.status===401){l(!0),a(n?`Wrong password.`:null),s(!1);return}if(o.status===404){a(`This link is invalid or no longer available.`),s(!1);return}if(o.status===410){a(`This link has expired or was revoked.`),s(!1);return}if(!o.ok){let e=await o.json().catch(()=>null);a(e?.error?.message??`Failed to load (HTTP ${o.status}).`),s(!1);return}let c=await o.json(),u=`data`in c?c.data:{record:c.record,link:c.link,redactedFields:c.redactFields};r(u),l(!1)}catch(e){a(e?.message??`Failed to load shared content.`)}finally{s(!1)}}},[t,e]);(0,G.useEffect)(()=>{h()},[h]),(0,G.useEffect)(()=>{if(!n||n.link.object_name!==`ai_conversations`)return;let e=`${t}/share-links/${encodeURIComponent(n.link.token)}/messages`;fetch(e,{headers:{Accept:`application/json`}}).then(e=>e.ok?e.json():null).then(e=>m(e?.data??[])).catch(()=>m([]))},[t,n]);let g=(0,G.useMemo)(()=>p?qe(ct(st(p))):[],[p]);if(o)return(0,K.jsxs)(`div`,{className:`flex h-svh w-full items-center justify-center bg-background text-muted-foreground`,children:[(0,K.jsx)(k,{className:`mr-2 h-4 w-4 animate-spin`}),`Loading…`]});if(c)return(0,K.jsxs)(`div`,{className:`mx-auto flex h-svh max-w-md flex-col items-center justify-center gap-4 px-4 text-center`,children:[(0,K.jsx)(_e,{className:`h-8 w-8 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Password required`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The owner protected this link with a password.`}),(0,K.jsxs)(`form`,{className:`flex w-full flex-col gap-2`,onSubmit:e=>{e.preventDefault(),h(u)},children:[(0,K.jsx)(P,{htmlFor:`share-pw`,className:`sr-only`,children:`Password`}),(0,K.jsx)(M,{id:`share-pw`,type:`password`,value:u,onChange:e=>f(e.target.value),autoFocus:!0,placeholder:`Enter password`}),i&&(0,K.jsx)(`p`,{className:`text-xs text-destructive`,children:i}),(0,K.jsx)(O,{type:`submit`,size:`sm`,children:`Continue`})]})]});if(i)return(0,K.jsxs)(`div`,{className:`mx-auto flex h-svh max-w-md flex-col items-center justify-center gap-3 px-4 text-center`,children:[(0,K.jsx)(oe,{className:`h-8 w-8 text-amber-500`}),(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Can't open this link`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i})]});if(!n)return null;if(n.link.object_name===`ai_conversations`){let e=n.record;return(0,K.jsxs)(`div`,{className:`mx-auto flex h-svh max-w-3xl flex-col bg-background`,children:[(0,K.jsxs)(`header`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b bg-background px-4 py-3`,children:[(0,K.jsx)(Oe,{className:`h-5 w-5 text-muted-foreground`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`h1`,{className:`truncate text-sm font-semibold`,children:e.title??`Shared conversation`}),(0,K.jsx)(`p`,{className:`truncate text-[11px] text-muted-foreground`,children:`Read-only · Shared via ObjectStack`})]}),(0,K.jsx)(I,{variant:`outline`,className:`text-[10px] capitalize`,children:n.link.permission})]}),(0,K.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col`,children:p==null?(0,K.jsxs)(`div`,{className:`flex flex-1 items-center justify-center py-12 text-sm text-muted-foreground`,children:[(0,K.jsx)(k,{className:`mr-2 h-4 w-4 animate-spin`}),`Loading messages…`]}):p.length===0?(0,K.jsx)(`p`,{className:`py-12 text-center text-sm text-muted-foreground`,children:`This conversation has no messages yet.`}):(0,K.jsx)(dt,{readOnly:!0,surface:`plain`,messages:g,showAvatars:!0,maxHeight:`100%`,className:`flex-1`})}),(0,K.jsx)(`footer`,{className:`border-t bg-muted/30 px-4 py-2 text-center text-[11px] text-muted-foreground`,children:`Powered by ObjectStack`})]})}return(0,K.jsxs)(`div`,{className:`mx-auto flex h-svh max-w-3xl flex-col bg-background`,children:[(0,K.jsx)(`header`,{className:`border-b px-4 py-3`,children:(0,K.jsxs)(`h1`,{className:`text-sm font-semibold`,children:[`Shared `,n.link.object_name]})}),(0,K.jsxs)(`main`,{className:`flex-1 overflow-y-auto p-4`,children:[(0,K.jsx)(`pre`,{className:`overflow-x-auto rounded-md border bg-muted/30 p-3 text-[12px]`,children:JSON.stringify(n.record,null,2)}),n.redactedFields&&n.redactedFields.length>0&&(0,K.jsxs)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:[`Some fields are hidden by the owner: `,n.redactedFields.join(`, `)]})]})]})}var En=/(^```[^\n]*\n[\s\S]*?\n```[ \t]*$|^~~~[^\n]*\n[\s\S]*?\n~~~[ \t]*$)/m,Dn=/(`[^`\n]+`)/,On=/\]\((?:\.\/)?([a-z][a-z0-9_]*)\.md(#[^)\s]*)?\)/g;function kn(e){return e.split(Dn).map((e,t)=>t%2==1?e:e.replace(On,`](/docs/$1$2)`)).join(``)}function An(e){let t=[],n=e;for(;;){let e=En.exec(n);if(!e||e.index===void 0)return t.push(kn(n)),t.join(``);t.push(kn(n.slice(0,e.index)),e[0]),n=n.slice(e.index+e[0].length)}}function jn({book:e,activeDoc:t,docHref:n}){return(0,K.jsxs)(`nav`,{"aria-label":e.label??e.name,className:`text-sm`,children:[e.label?(0,K.jsx)(`div`,{className:`mb-3 px-2 text-sm font-semibold text-foreground`,children:e.label}):null,(0,K.jsx)(`div`,{className:`space-y-5`,children:e.groups.map(e=>(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`div`,{className:`mb-1 px-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,K.jsx)(`ul`,{className:`space-y-0.5`,children:e.entries.map((e,i)=>{if(e.separator)return(0,K.jsx)(`li`,{className:`my-1.5 border-t border-border/60`,"aria-hidden":!0},`sep-${i}`);if(e.href)return(0,K.jsx)(`li`,{children:(0,K.jsxs)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,className:`flex items-center gap-1.5 rounded px-2 py-1 text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,K.jsx)(`span`,{className:`truncate`,children:e.label??e.href}),(0,K.jsx)(ve,{className:`h-3 w-3 shrink-0 opacity-60`})]})},`ext-${i}`);if(!e.doc)return null;let a=e.doc===t;return(0,K.jsx)(`li`,{children:(0,K.jsx)(r,{to:n(e.doc),"aria-current":a?`page`:void 0,className:`block truncate rounded px-2 py-1 transition ${a?`bg-primary/10 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`}`,children:e.label??e.doc})},e.doc)})})]},e.key))})]})}var Mn=t({default:()=>Nn});function Nn(){let{slug:e,name:t,appName:n}=d(),r=o(),i=ne(),{t:a}=E(),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(`loading`),[f,p]=(0,G.useState)(``);(0,G.useEffect)(()=>{let e=!1;async function r(){if(!(!t||!i)){u(`loading`);try{let r=await i.getClient().meta.getItem(`doc`,t,n?{packageId:n}:void 0),a=r?.item??r?.data??r;if(e)return;a&&typeof a.content==`string`?(c({name:t,label:a.label,content:a.content}),u(`ready`)):u(`missing`)}catch(t){if(e)return;(t?.status??t?.response?.status)===404||/not found/i.test(t?.message??``)?u(`missing`):(p(t?.message??`Failed to load documentation`),u(`error`))}}}return r(),()=>{e=!0}},[t,n,i]);let m=(0,G.useCallback)(e=>{document.getElementById(e)?.scrollIntoView({behavior:`smooth`,block:`start`}),window.history.replaceState(null,``,`${window.location.pathname}${window.location.search}#${e}`)},[]),h=(0,G.useCallback)(e=>{if(e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0)return;let t=e.target.closest(`a`)?.getAttribute(`href`);t&&(t.startsWith(`/docs/`)?(e.preventDefault(),r(t)):t.startsWith(`#`)&&(e.preventDefault(),m(decodeURIComponent(t.slice(1)))))},[r,m]),g=(0,G.useCallback)((e,t)=>{e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||e.button!==0||(e.preventDefault(),m(t))},[m]),_=(0,G.useMemo)(()=>bt(s?.content??``),[s?.content]),v=a(`help.onThisPage`,{defaultValue:`On this page`}),{books:y,docs:b}=W(),x=n?`/apps/${n}/docs`:`/docs`,S=(0,G.useMemo)(()=>{let t=y.find(t=>U(t)===e);return t?Ct(t,Ot(t,b)):null},[y,b,e]),C=(0,G.useCallback)(t=>`${x}/${e}/${t}`,[x,e]);return l===`loading`?(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,K.jsx)(k,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):l===`missing`?(0,K.jsx)(H,{breadcrumb:t,children:(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,K.jsx)(ze,{className:`h-10 w-10 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Documentation not found`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No document named `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:t}),` is installed. It may belong to a package that is not installed, or it was removed in a newer version.`]})]})}):l===`error`?(0,K.jsx)(H,{breadcrumb:t,children:(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,K.jsx)(ue,{className:`h-10 w-10 text-destructive`}),(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Failed to load documentation`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f})]})}):(0,K.jsxs)(H,{breadcrumb:s?.label??t,children:[S?(0,K.jsxs)(`details`,{className:`group mx-auto max-w-6xl px-4 pt-4 sm:px-6 lg:hidden`,children:[(0,K.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-md border bg-muted/30 px-3 py-2 text-sm font-medium [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(le,{className:`h-4 w-4 text-muted-foreground`}),(0,K.jsx)(`span`,{className:`truncate`,children:S.label??`Contents`}),(0,K.jsx)(he,{className:`ml-auto h-4 w-4 text-muted-foreground transition-transform group-open:rotate-180`})]}),(0,K.jsx)(`div`,{className:`mt-2 rounded-md border p-3`,children:(0,K.jsx)(jn,{book:S,activeDoc:t,docHref:C})})]}):null,(0,K.jsxs)(`div`,{className:`mx-auto flex gap-8 p-4 sm:p-6 ${S?`max-w-6xl`:`max-w-5xl`}`,children:[S?(0,K.jsx)(`aside`,{className:`hidden w-56 shrink-0 lg:block`,children:(0,K.jsx)(`nav`,{className:`sticky top-20 max-h-[calc(100vh-6rem)] overflow-auto pr-1`,children:(0,K.jsx)(jn,{book:S,activeDoc:t,docHref:C})})}):null,(0,K.jsx)(`article`,{className:`min-w-0 max-w-3xl flex-1 [&_h1]:scroll-mt-24 [&_h2]:scroll-mt-24 [&_h3]:scroll-mt-24`,onClick:h,children:(0,K.jsx)(xt,{schema:{type:`markdown`,content:An(s?.content??``)}})}),_.length>=3?(0,K.jsx)(`aside`,{className:`hidden xl:block w-56 shrink-0`,children:(0,K.jsxs)(`nav`,{"aria-label":v,className:`sticky top-20 max-h-[calc(100vh-6rem)] overflow-auto`,children:[(0,K.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:v}),(0,K.jsx)(`ul`,{className:`border-l border-border text-sm`,children:_.map(e=>(0,K.jsx)(`li`,{style:{paddingLeft:(e.depth-2)*12},children:(0,K.jsx)(`a`,{href:`#${e.id}`,onClick:t=>g(t,e.id),className:`-ml-px block border-l border-transparent py-0.5 pl-3 text-muted-foreground hover:border-primary hover:text-foreground`,children:e.text})},e.id))})]})}):null]})]})}function Pn(){let{books:e,docs:t,state:n,error:i}=W(),a=(0,G.useMemo)(()=>St(e,t),[e,t]);return n===`loading`?(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,K.jsx)(k,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):n===`error`?(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,K.jsx)(ue,{className:`h-10 w-10 text-destructive`}),(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Failed to load documentation`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:i})]}):(0,K.jsx)(H,{children:(0,K.jsxs)(`div`,{className:`mx-auto max-w-4xl p-4 sm:p-6`,children:[(0,K.jsxs)(`header`,{className:`mb-6`,children:[(0,K.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:`Documentation`}),(0,K.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Books and guides from your installed packages.`})]}),a.length===0?(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-16 text-center text-muted-foreground`,children:[(0,K.jsx)(Fe,{className:`h-10 w-10`}),(0,K.jsxs)(`p`,{className:`text-sm`,children:[`No documentation is installed. Packages ship docs as flat`,(0,K.jsx)(`code`,{className:`mx-1 rounded bg-muted px-1 py-0.5`,children:`src/docs/*.md`}),`files, organised by a `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:`book`}),` (ADR-0046).`]})]}):(0,K.jsx)(`ul`,{className:`grid items-stretch gap-3 sm:grid-cols-2`,children:a.map(e=>(0,K.jsx)(`li`,{className:`h-full`,children:(0,K.jsxs)(r,{to:`/docs/${e.slug}`,className:`flex h-full items-start gap-3 rounded-md border border-border p-3 hover:bg-muted/50`,children:[(0,K.jsx)(Fe,{className:`mt-0.5 h-5 w-5 shrink-0 text-muted-foreground`}),(0,K.jsxs)(`div`,{className:`min-w-0`,children:[(0,K.jsx)(`div`,{className:`text-sm font-semibold`,children:e.label}),e.description?(0,K.jsx)(`div`,{className:`mt-0.5 line-clamp-2 text-xs text-muted-foreground`,children:e.description}):e.subtitle?(0,K.jsx)(`div`,{className:`mt-0.5 truncate font-mono text-[11px] text-muted-foreground/70`,children:e.subtitle}):null,(0,K.jsxs)(`div`,{className:`mt-1 text-xs text-muted-foreground/80`,children:[e.docCount,` `,e.docCount===1?`article`:`articles`]})]})]})},e.name))})]})})}function Fn(){let{slug:e,appName:t}=d(),{books:n,docs:r,state:i}=W(),a=(0,G.useMemo)(()=>n.find(t=>U(t)===e),[n,e]),o=(0,G.useMemo)(()=>a?wt(Ct(a,Ot(a,r))):void 0,[a,r]);return i===`loading`?(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,K.jsx)(k,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})}):a&&o?(0,K.jsx)(p,{to:`${t?`/apps/${t}/docs`:`/docs`}/${e}/${o}`,replace:!0}):(0,K.jsx)(H,{breadcrumb:a?a.label??e:e,children:(0,K.jsx)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:a?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(Fe,{className:`h-10 w-10 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:a.label??e}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This book has no documents yet.`})]}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ze,{className:`h-10 w-10 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Book not found`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No book named `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:e}),` is installed.`]})]})})})}var In=t({default:()=>Ln});function Ln(){let{slug:e,appName:t}=d(),{books:n,docs:r,state:i}=W();if(i===`loading`)return(0,K.jsx)(`div`,{className:`flex h-full items-center justify-center p-10 text-muted-foreground`,children:(0,K.jsx)(k,{className:`h-5 w-5 animate-spin`,"aria-label":`Loading documentation`})});if(e&&n.some(t=>U(t)===e))return(0,K.jsx)(Fn,{});let a=t?`/apps/${t}/docs`:`/docs`,o=e?Et(e,n,r):null;return o&&e?(0,K.jsx)(p,{to:`${a}/${U(o)}/${e}`,replace:!0}):(0,K.jsx)(H,{breadcrumb:e,children:(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center`,children:[(0,K.jsx)(ze,{className:`h-10 w-10 text-muted-foreground`}),(0,K.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Documentation not found`}),(0,K.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`No book or document named `,(0,K.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5`,children:e}),` is installed.`]})]})})}var Rn=t({default:()=>zn});function zn(){let e=Tt();return(0,K.jsx)(Dt.Provider,{value:e,children:(0,K.jsx)(i,{})})}function Bn(e){let t=e.split(`:`)[0].toLowerCase();return/^cloud\./.test(t)}function Vn(e){let t=e.split(`:`)[0].toLowerCase();return t===`localhost`||t===`127.0.0.1`||t===`[::1]`||t.endsWith(`.local`)}function Hn(){return typeof window>`u`?null:window.location.host||null}function Un(){let e=B(),t=ht();return(0,K.jsxs)(`div`,{className:`flex items-center justify-center gap-2.5 select-none`,children:[(0,K.jsx)(`span`,{className:`inline-flex h-9 w-9 items-center justify-center rounded-xl bg-gradient-to-br from-indigo-500 to-indigo-600 text-white shadow-sm shadow-indigo-500/30 overflow-hidden`,children:t?(0,K.jsx)(`img`,{src:t,alt:e,className:`h-full w-full object-contain`}):(0,K.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,K.jsx)(`path`,{d:`M12 2 2 7l10 5 10-5-10-5Z`}),(0,K.jsx)(`path`,{d:`m2 17 10 5 10-5`}),(0,K.jsx)(`path`,{d:`m2 12 10 5 10-5`})]})}),(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-foreground`,children:e})]})}function Y({children:e,formWidth:t=`sm`}){let{t:n}=E(),r=t===`md`?`max-w-md`:`max-w-sm`,i=Hn(),a=!!i&&!Bn(i)&&!Vn(i);return(0,G.useEffect)(()=>{if(typeof document>`u`||!i)return;let e=document.title;return a&&(document.title=i),()=>{document.title=e}},[i,a]),(0,K.jsxs)(`div`,{className:`relative flex min-h-svh w-full items-center justify-center overflow-hidden bg-background p-6`,children:[(0,K.jsxs)(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-0 -z-10`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 opacity-[0.35] dark:opacity-[0.25] [mask-image:radial-gradient(ellipse_at_center,black,transparent_72%)] [-webkit-mask-image:radial-gradient(ellipse_at_center,black,transparent_72%)]`,style:{backgroundImage:`radial-gradient(hsl(var(--border)) 1px, transparent 1px)`,backgroundSize:`22px 22px`}}),(0,K.jsx)(`div`,{className:`absolute left-1/2 top-1/2 h-[34rem] w-[34rem] -translate-x-1/2 -translate-y-1/2 rounded-full bg-gradient-to-br from-indigo-500/10 to-indigo-600/10 blur-3xl dark:from-indigo-500/10 dark:to-indigo-600/10`})]}),(0,K.jsxs)(`div`,{className:Ae(`flex w-full flex-col gap-5`,r),children:[(0,K.jsx)(Un,{}),a?(0,K.jsx)(`div`,{className:`flex justify-center`,children:(0,K.jsx)(`span`,{className:`rounded-full border border-border/60 bg-background/60 px-2 py-0.5 font-mono text-[10px] uppercase tracking-wide text-muted-foreground`,title:n(`auth.shell.tenantHostHint`,{defaultValue:`You are signing in to this workspace`}),children:i})}):null,e]})]})}function Wn(e){let t=`/api/v1/auth/oauth2/authorize${e}`,n=()=>window.location.assign(t);fetch(t,{credentials:`include`,redirect:`manual`,headers:{accept:`application/json`}}).then(async e=>{let t=await e.json().catch(()=>null),r=t?.url??t?.redirect_uri??t?.redirectURI;if(e.ok&&r){window.location.href=r;return}n()}).catch(n)}function Gn(e){return!!e&&e.startsWith(`/`)&&!e.startsWith(`//`)}function Kn(e){return e.startsWith(`/_`)?e:`./`.replace(/\/$/,``)+(e.startsWith(`/`)?e:`/${e}`)}function qn(e){return(0,K.jsx)(r,{to:e.href,className:e.className,children:e.children})}function Jn(){let{t:e}=E(),[t]=c(),n=t.get(`redirect`),{user:r,isLoading:i,organizations:a,isOrganizationsLoading:o,activeOrganization:s,switchOrganization:l,getAuthConfig:u}=S(),[d,f]=(0,G.useState)(!1),[p,m]=(0,G.useState)(!1),h=(0,G.useRef)(!1),[g,_]=(0,G.useState)(!1);(0,G.useLayoutEffect)(()=>{i||_(!0)},[i]);let v=(0,G.useMemo)(()=>{if(typeof window>`u`)return null;let e=new URLSearchParams(window.location.search),t=e.get(`redirect_uri`);if(!e.has(`client_id`)||!t)return null;try{return new URL(t).host}catch{return null}},[]),y=(0,G.useMemo)(()=>{let e=t.get(`error`);return e?{code:e,description:t.get(`error_description`)}:null},[]);if((0,G.useEffect)(()=>{let e=!1;return u().then(t=>{e||f(t?.emailPassword?.disableSignUp===!0)}).catch(()=>{}),()=>{e=!0}},[u]),(0,G.useEffect)(()=>{if(r){if(typeof window<`u`){let e=new URLSearchParams(window.location.search);if(e.has(`client_id`)&&e.has(`redirect_uri`)){h.current||(h.current=!0,Wn(window.location.search));return}}if(!s){if(o||p)return;if(a.length===1){m(!0),l(a[0].id).catch(()=>void 0).finally(()=>m(!1));return}if(a.length===0){window.location.assign(Kn(Gn(n)?n:`/`));return}window.location.assign(Kn(`/organizations`));return}p||window.location.assign(Kn(Gn(n)?n:`/`))}},[r,s,a,o,p,n,l]),i&&!g||r)return(0,K.jsx)(Y,{children:(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-sm text-muted-foreground`,children:[(0,K.jsx)(`div`,{className:`size-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`}),(0,K.jsx)(`span`,{children:e(`auth.login.signingIn`,{defaultValue:`Signing you in…`})})]})});let b=n?`/register?redirect=${encodeURIComponent(n)}`:`/register`;return(0,K.jsx)(Y,{formWidth:`md`,children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[y?(0,K.jsx)(te,{message:e(`auth.login.errors.oauthCallbackFailed`,{defaultValue:`Single sign-on could not be completed — the sign-in link expired or was already used. Please try again.`})+(y.description?` (${y.description})`:` (${y.code})`)}):null,v?(0,K.jsxs)(`div`,{role:`status`,className:`flex items-start gap-3 rounded-md border border-primary/30 bg-primary/5 px-4 py-3 text-sm text-foreground`,children:[(0,K.jsx)(`span`,{className:`mt-0.5 inline-block size-2 shrink-0 rounded-full bg-primary`}),(0,K.jsx)(`span`,{children:e(`auth.login.ssoHandoff`,{target:v,defaultValue:`Continue to ${v}`})})]}):null,(0,K.jsx)(L,{className:`border-border/60 px-4 py-8 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:(0,K.jsx)(Yn,{registerUrl:d?void 0:b,redirect:n})})]})})}function Yn({registerUrl:e,redirect:t}){let{t:n}=E(),r=o(),i=(0,G.useRef)(``);return(0,G.useEffect)(()=>{let e=e=>{let t=e.target;t?.id===`login-email`&&(i.current=t.value)};return document.addEventListener(`input`,e,!0),()=>document.removeEventListener(`input`,e,!0)},[]),(0,K.jsx)(b,{onError:e=>{let n=e.message||``,a=e.code,o=n.toLowerCase();if(a===`EMAIL_NOT_VERIFIED`||o.includes(`email`)&&(o.includes(`verif`)||o.includes(`not verified`))){let e=new URLSearchParams;i.current&&e.set(`email`,i.current),t&&e.set(`redirect`,t),r(`/verify-email-prompt?${e.toString()}`)}},title:n(`auth.login.title`,{defaultValue:`Sign in to your account`}),description:n(`auth.login.description`,{defaultValue:`Enter your email and password to continue`}),registerUrl:e,forgotPasswordUrl:`/forgot-password`,linkComponent:qn,errorMessages:{INVALID_EMAIL_OR_PASSWORD:n(`auth.login.errors.invalidCredentials`,{defaultValue:`Invalid email or password`}),EMAIL_NOT_VERIFIED:n(`auth.login.errors.emailNotVerified`,{defaultValue:`Please verify your email address before signing in.`})},labels:{emailLabel:n(`auth.login.emailLabel`,{defaultValue:`Email`}),emailPlaceholder:n(`auth.login.emailPlaceholder`,{defaultValue:`name@example.com`}),emailOrPhoneLabel:n(`auth.login.emailOrPhoneLabel`,{defaultValue:`Email or phone number`}),emailOrPhonePlaceholder:n(`auth.login.emailOrPhonePlaceholder`,{defaultValue:`name@example.com or +1 555 000 0000`}),passwordLabel:n(`auth.login.passwordLabel`,{defaultValue:`Password`}),passwordPlaceholder:n(`auth.login.passwordPlaceholder`,{defaultValue:`Enter your password`}),forgotPasswordText:n(`auth.login.forgotPasswordText`,{defaultValue:`Forgot password?`}),submitButton:n(`auth.login.submitButton`,{defaultValue:`Sign In`}),submittingButton:n(`auth.login.submittingButton`,{defaultValue:`Signing in…`}),noAccountText:n(`auth.login.noAccountText`,{defaultValue:`Don't have an account?`}),signUpText:n(`auth.login.signUpText`,{defaultValue:`Sign up`}),phoneLabel:n(`auth.login.phoneLabel`,{defaultValue:`Phone number`}),phonePlaceholder:n(`auth.login.phonePlaceholder`,{defaultValue:`+1 555 000 0000`}),otpCodeLabel:n(`auth.login.otpCodeLabel`,{defaultValue:`Verification code`}),otpCodePlaceholder:n(`auth.login.otpCodePlaceholder`,{defaultValue:`6-digit code`}),sendOtpButton:n(`auth.login.sendOtpButton`,{defaultValue:`Get code`}),resendOtpCountdownText:n(`auth.login.resendOtpCountdownText`,{defaultValue:`Resend in {seconds}s`}),usePhoneOtpText:n(`auth.login.usePhoneOtpText`,{defaultValue:`Sign in with verification code`}),usePasswordSignInText:n(`auth.login.usePasswordSignInText`,{defaultValue:`Sign in with password instead`})}})}function Xn(e){return!!e&&e.startsWith(`/`)&&!e.startsWith(`//`)}function Zn(e){return e.startsWith(`/_`)?e:`./`.replace(/\/$/,``)+(e.startsWith(`/`)?e:`/${e}`)}function Qn(e){return(0,K.jsx)(r,{to:e.href,className:e.className,children:e.children})}function $n(){let{t:e}=E(),t=o(),[n]=c(),r=n.get(`redirect`),{user:i,isLoading:a,organizations:s,isOrganizationsLoading:l,activeOrganization:u,switchOrganization:d,getAuthConfig:f}=S(),[p,m]=(0,G.useState)(null),[h,g]=(0,G.useState)(!1),v=(0,G.useRef)(!1),[y,b]=(0,G.useState)(!1);if((0,G.useLayoutEffect)(()=>{a||b(!0)},[a]),(0,G.useEffect)(()=>{let e=!1;return f().then(n=>{if(e)return;let i=n?.emailPassword?.disableSignUp===!0;if(m(i),i){let e=r?`?redirect=${encodeURIComponent(r)}`:``;t(`/login${e}`,{replace:!0})}}).catch(()=>{e||m(!1)}),()=>{e=!0}},[f,t,r]),(0,G.useEffect)(()=>{if(i){if(typeof window<`u`){let e=new URLSearchParams(window.location.search);if(e.has(`client_id`)&&e.has(`redirect_uri`)){v.current||(v.current=!0,Wn(window.location.search));return}}if(!u){if(l||h)return;if(s.length===1){g(!0),d(s[0].id).catch(()=>void 0).finally(()=>g(!1));return}if(s.length===0){window.location.assign(Zn(Xn(r)?r:`/`));return}window.location.assign(Zn(`/organizations`));return}h||window.location.assign(Zn(Xn(r)?r:`/`))}},[i,u,s,l,h,r,d]),p===null||a&&!y||i)return(0,K.jsx)(Y,{children:(0,K.jsx)(`div`,{className:`flex flex-col items-center gap-3 py-10 text-sm text-muted-foreground`,children:(0,K.jsx)(`div`,{className:`size-6 animate-spin rounded-full border-2 border-muted-foreground border-t-transparent`})})});let x=r?`/login?redirect=${encodeURIComponent(r)}`:`/login`;return(0,K.jsx)(Y,{formWidth:`md`,children:(0,K.jsx)(L,{className:`border-border/60 px-4 py-8 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:(0,K.jsx)(_,{title:e(`auth.register.title`,{defaultValue:`Create your account`}),description:e(`auth.register.description`,{defaultValue:`Sign up to get started`}),loginUrl:x,linkComponent:Qn,errorMessages:{USER_ALREADY_EXISTS_USE_ANOTHER_EMAIL:e(`auth.register.errors.userExists`,{defaultValue:`An account with this email already exists. Try signing in instead.`}),USER_ALREADY_EXISTS:e(`auth.register.errors.userExists`,{defaultValue:`An account with this email already exists. Try signing in instead.`})},onVerificationRequired:e=>{let n=new URLSearchParams;n.set(`email`,e),r&&n.set(`redirect`,r),t(`/verify-email-prompt?${n.toString()}`,{replace:!0})},labels:{nameLabel:e(`auth.register.nameLabel`,{defaultValue:`Name`}),namePlaceholder:e(`auth.register.namePlaceholder`,{defaultValue:`John Doe`}),emailLabel:e(`auth.register.emailLabel`,{defaultValue:`Email`}),emailPlaceholder:e(`auth.register.emailPlaceholder`,{defaultValue:`name@example.com`}),passwordLabel:e(`auth.register.passwordLabel`,{defaultValue:`Password`}),passwordPlaceholder:e(`auth.register.passwordPlaceholder`,{defaultValue:`Create a password (min. 8 characters)`}),confirmPasswordLabel:e(`auth.register.confirmPasswordLabel`,{defaultValue:`Confirm password`}),confirmPasswordPlaceholder:e(`auth.register.confirmPasswordPlaceholder`,{defaultValue:`Confirm your password`}),passwordMismatchError:e(`auth.register.passwordMismatchError`,{defaultValue:`Passwords do not match`}),passwordTooShortError:e(`auth.register.passwordTooShortError`,{defaultValue:`Password must be at least 8 characters`}),submitButton:e(`auth.register.submitButton`,{defaultValue:`Create account`}),submittingButton:e(`auth.register.submittingButton`,{defaultValue:`Creating account…`}),hasAccountText:e(`auth.register.hasAccountText`,{defaultValue:`Already have an account?`}),signInText:e(`auth.register.signInText`,{defaultValue:`Sign in`})}})})})}function er(e){return(0,K.jsx)(r,{to:e.href,className:e.className,children:e.children})}function tr(){let{t:e}=E();return(0,K.jsx)(Y,{formWidth:`md`,children:(0,K.jsx)(L,{className:`border-border/60 px-4 py-8 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:(0,K.jsx)(ee,{loginUrl:`/login`,linkComponent:er,title:e(`auth.forgotPassword.title`,{defaultValue:`Reset your password`}),description:e(`auth.forgotPassword.description`,{defaultValue:`Enter your email and we'll send you a reset link.`}),labels:{emailLabel:e(`auth.forgotPassword.emailLabel`,{defaultValue:`Email`}),emailPlaceholder:e(`auth.forgotPassword.emailPlaceholder`,{defaultValue:`name@example.com`}),submitButton:e(`auth.forgotPassword.submitButton`,{defaultValue:`Send reset link`}),submittingButton:e(`auth.forgotPassword.submittingButton`,{defaultValue:`Sending…`}),successTitle:e(`auth.forgotPassword.successTitle`,{defaultValue:`Check your email`}),successDescription:e(`auth.forgotPassword.successDescription`,{defaultValue:`If an account exists, a reset link has been sent.`}),backToSignInText:e(`auth.forgotPassword.backToSignInText`,{defaultValue:`Back to sign in`}),phoneLabel:e(`auth.forgotPassword.phoneLabel`,{defaultValue:`Phone number`}),phonePlaceholder:e(`auth.forgotPassword.phonePlaceholder`,{defaultValue:`+1 555 000 0000`}),otpCodeLabel:e(`auth.forgotPassword.otpCodeLabel`,{defaultValue:`Verification code`}),otpCodePlaceholder:e(`auth.forgotPassword.otpCodePlaceholder`,{defaultValue:`6-digit code`}),sendOtpButton:e(`auth.forgotPassword.sendOtpButton`,{defaultValue:`Get code`}),resendOtpCountdownText:e(`auth.forgotPassword.resendOtpCountdownText`,{defaultValue:`Resend in {seconds}s`}),newPasswordLabel:e(`auth.forgotPassword.newPasswordLabel`,{defaultValue:`New password`}),newPasswordPlaceholder:e(`auth.forgotPassword.newPasswordPlaceholder`,{defaultValue:`Enter a new password`}),resetButton:e(`auth.forgotPassword.resetButton`,{defaultValue:`Reset Password`}),usePhoneResetText:e(`auth.forgotPassword.usePhoneResetText`,{defaultValue:`Reset via SMS code`}),useEmailResetText:e(`auth.forgotPassword.useEmailResetText`,{defaultValue:`Reset via email instead`}),phoneSuccessTitle:e(`auth.forgotPassword.phoneSuccessTitle`,{defaultValue:`Password reset`}),phoneSuccessDescription:e(`auth.forgotPassword.phoneSuccessDescription`,{defaultValue:`Your password has been reset. You can now sign in with your new password.`}),rememberPasswordText:e(`auth.forgotPassword.rememberPasswordText`,{defaultValue:`Remember your password?`}),signInText:e(`auth.forgotPassword.signInText`,{defaultValue:`Sign in`})}})})})}function nr(){let{t:e}=E(),t=o(),[n]=c(),i=n.get(`token`),{resetPassword:a}=S(),[s,l]=(0,G.useState)(``),[u,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(!1);return(0,K.jsx)(Y,{children:(0,K.jsxs)(L,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(A,{className:`text-xl tracking-tight`,children:e(`auth.resetPassword.title`,{defaultValue:`Set a new password`})}),(0,K.jsx)(F,{children:e(`auth.resetPassword.description`,{defaultValue:`Choose a password you have not used before.`})})]}),(0,K.jsx)(N,{children:i?(0,K.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),s!==u){R.error(e(`auth.resetPassword.passwordsMismatch`,{defaultValue:`Passwords do not match`}));return}if(!i){R.error(e(`auth.resetPassword.missingToken`,{defaultValue:`Reset link is missing or expired`}));return}p(!0);try{await a(i,s),R.success(e(`auth.resetPassword.success`,{defaultValue:`Password updated`})),t(`/login`)}catch(t){R.error(e(`auth.resetPassword.failed`,{defaultValue:`Reset failed`}),{description:t.message})}finally{p(!1)}},className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(P,{htmlFor:`new-password`,children:e(`auth.resetPassword.newPassword`,{defaultValue:`New password`})}),(0,K.jsx)(M,{id:`new-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:s,onChange:e=>l(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(P,{htmlFor:`confirm-password`,children:e(`auth.resetPassword.confirmPassword`,{defaultValue:`Confirm password`})}),(0,K.jsx)(M,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:u,onChange:e=>d(e.target.value)})]}),(0,K.jsx)(O,{type:`submit`,className:`w-full`,disabled:f,children:f?e(`auth.resetPassword.submitting`,{defaultValue:`Updating…`}):e(`auth.resetPassword.submit`,{defaultValue:`Update password`})})]}):(0,K.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.resetPassword.invalidToken`,{defaultValue:`This reset link is invalid or has expired.`}),` `,(0,K.jsx)(r,{to:`/forgot-password`,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.resetPassword.requestNewLink`,{defaultValue:`Request a new link`})})]})})]})})}function rr(e){return e&&e.startsWith(`/`)&&!e.startsWith(`//`)?e:`/`}function ir(){let{t:e}=E(),t=o(),[n]=c(),i=rr(n.get(`next`)),{user:a,isLoading:s,setInitialPassword:l}=S(),[u,d]=(0,G.useState)(``),[f,p]=(0,G.useState)(``),[m,h]=(0,G.useState)(!1);return(0,K.jsx)(Y,{children:(0,K.jsxs)(L,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(A,{className:`text-xl tracking-tight`,children:e(`auth.setPassword.title`,{defaultValue:`Set a recovery password`})}),(0,K.jsx)(F,{children:e(`auth.setPassword.description`,{defaultValue:`You signed in via single sign-on. Set a local password so you can still sign in to this environment directly if SSO ever becomes unavailable.`})})]}),(0,K.jsx)(N,{children:!s&&!a?(0,K.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.setPassword.noSession`,{defaultValue:`Your session has expired.`}),` `,(0,K.jsx)(r,{to:`/login`,className:`font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.setPassword.backToSignIn`,{defaultValue:`Sign in again`})})]}):(0,K.jsxs)(`form`,{onSubmit:async n=>{if(n.preventDefault(),u!==f){R.error(e(`auth.setPassword.passwordsMismatch`,{defaultValue:`Passwords do not match`}));return}h(!0);try{await l(u),R.success(e(`auth.setPassword.success`,{defaultValue:`Local password set`})),t(i)}catch(t){R.error(e(`auth.setPassword.failed`,{defaultValue:`Could not set password`}),{description:t.message})}finally{h(!1)}},className:`flex flex-col gap-4`,children:[a?.email?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(P,{htmlFor:`set-password-email`,children:e(`auth.setPassword.email`,{defaultValue:`Email`})}),(0,K.jsx)(M,{id:`set-password-email`,type:`email`,autoComplete:`username`,value:a.email,disabled:!0,className:`bg-muted text-muted-foreground`})]}):null,(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(P,{htmlFor:`new-password`,children:e(`auth.setPassword.newPassword`,{defaultValue:`New password`})}),(0,K.jsx)(M,{id:`new-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:u,onChange:e=>d(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(P,{htmlFor:`confirm-password`,children:e(`auth.setPassword.confirmPassword`,{defaultValue:`Confirm password`})}),(0,K.jsx)(M,{id:`confirm-password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,value:f,onChange:e=>p(e.target.value)})]}),(0,K.jsx)(O,{type:`submit`,className:`w-full`,disabled:m,children:m?e(`auth.setPassword.submitting`,{defaultValue:`Saving…`}):e(`auth.setPassword.submit`,{defaultValue:`Set password`})})]})})]})})}var ar=`/api/v1/auth`;function or(){let{t:e}=E(),[t]=c(),n=t.get(`token`),[i,a]=(0,G.useState)(`loading`),[o,s]=(0,G.useState)(``);return(0,G.useEffect)(()=>{if(!n){a(`error`),s(e(`auth.verifyEmail.missingToken`,{defaultValue:`Verification link is missing a token.`}));return}let t=!1;return(async()=>{try{let e=await fetch(`${ar}/verify-email`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({token:n})});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t?.message||`Verification failed: ${e.status}`)}t||a(`success`)}catch(n){t||(a(`error`),s(n.message||e(`auth.verifyEmail.errorDescription`,{defaultValue:`Verification failed. Please request a new link.`})))}})(),()=>{t=!0}},[n,e]),(0,K.jsx)(Y,{children:(0,K.jsxs)(L,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[i===`loading`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(A,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.verifyingTitle`,{defaultValue:`Verifying…`})}),(0,K.jsx)(F,{children:e(`auth.verifyEmail.verifyingDescription`,{defaultValue:`Hang tight while we confirm your email.`})})]}),(0,K.jsx)(N,{className:`flex justify-center py-6`,children:(0,K.jsx)(`div`,{className:`h-10 w-10 animate-spin rounded-full border-4 border-muted border-t-primary`})})]}),i===`success`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(`div`,{className:`mx-auto mb-2 flex size-12 items-center justify-center rounded-full bg-emerald-500/10 text-emerald-500 ring-1 ring-emerald-500/30`,children:(0,K.jsx)(ke,{className:`size-6`})}),(0,K.jsx)(A,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.successTitle`,{defaultValue:`Email verified`})}),(0,K.jsx)(F,{children:e(`auth.verifyEmail.successDescription`,{defaultValue:`Your email is confirmed. You can now sign in.`})})]}),(0,K.jsx)(N,{className:`text-center`,children:(0,K.jsx)(r,{to:`/login`,className:`text-sm font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.verifyEmail.signInLink`,{defaultValue:`Go to sign in`})})})]}),i===`error`&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(`div`,{className:`mx-auto mb-2 flex size-12 items-center justify-center rounded-full bg-destructive/10 text-destructive ring-1 ring-destructive/30`,children:(0,K.jsx)(pe,{className:`size-6`})}),(0,K.jsx)(A,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.errorTitle`,{defaultValue:`Verification failed`})}),(0,K.jsx)(F,{children:o||e(`auth.verifyEmail.errorDescription`,{defaultValue:`Verification failed. Please request a new link.`})})]}),(0,K.jsx)(N,{className:`text-center`,children:(0,K.jsx)(r,{to:`/login`,className:`text-sm font-medium text-primary underline-offset-4 hover:underline`,children:e(`auth.verifyEmail.backToSignIn`,{defaultValue:`Back to sign in`})})})]})]})})}function sr(){let{t:e}=E(),t=o(),[n]=c(),r=n.get(`email`)??``,i=n.get(`redirect`)??``,{sendVerificationEmail:a}=S(),[s,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(!1),[f,p]=(0,G.useState)(null);return(0,K.jsx)(Y,{children:(0,K.jsxs)(L,{className:`border-border/60 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95`,children:[(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(`div`,{className:`mx-auto mb-4 flex size-16 items-center justify-center rounded-full bg-primary/10`,children:(0,K.jsx)(Re,{className:`size-8 text-primary`})}),(0,K.jsx)(A,{className:`text-xl tracking-tight`,children:e(`auth.verifyEmail.title`,{defaultValue:`Verify your email address`})}),(0,K.jsx)(F,{children:e(`auth.verifyEmail.description`,{defaultValue:`We sent a verification link to your email address. Please click the link to verify your account.`})})]}),(0,K.jsx)(N,{children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[r?(0,K.jsxs)(`p`,{className:`text-center text-sm text-muted-foreground`,children:[e(`auth.verifyEmail.sentTo`,{defaultValue:`Sent to:`}),` `,(0,K.jsx)(`span`,{className:`font-medium text-foreground`,children:r})]}):null,f?(0,K.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:[(0,K.jsx)(`p`,{className:`font-medium`,children:e(`auth.verifyEmail.resendFailed`,{defaultValue:`Failed to resend verification email`})}),(0,K.jsx)(`p`,{className:`mt-1 text-destructive/90`,children:f})]}):null,(0,K.jsx)(O,{onClick:async()=>{if(!r){R.error(e(`auth.verifyEmail.resendFailed`,{defaultValue:`Cannot resend verification email`}),{description:e(`auth.verifyEmail.emailMissing`,{defaultValue:`Email address is missing`})});return}l(!0),p(null);try{await a(r,i||`/`),d(!0),R.success(e(`auth.verifyEmail.resentSuccess`,{defaultValue:`Verification email sent!`}),{description:e(`auth.verifyEmail.resentDescription`,{defaultValue:`Please check your inbox and click the verification link.`})})}catch(t){let n=t?.message?.trim()||e(`auth.verifyEmail.resendUnavailable`,{defaultValue:`Email delivery may not be configured for this environment. Contact support if this persists.`});d(!1),p(n),R.error(e(`auth.verifyEmail.resendFailed`,{defaultValue:`Failed to resend verification email`}),{description:n})}finally{l(!1)}},disabled:s||u,className:`w-full`,variant:u?`outline`:`default`,children:s?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ge,{className:`mr-2 size-4 animate-spin`}),e(`auth.verifyEmail.resending`,{defaultValue:`Sending…`})]}):u?e(`auth.verifyEmail.resent`,{defaultValue:`Email sent! Check your inbox`}):(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(ge,{className:`mr-2 size-4`}),e(`auth.verifyEmail.resendButton`,{defaultValue:`Resend verification email`})]})}),(0,K.jsxs)(`div`,{className:`relative`,children:[(0,K.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,K.jsx)(`span`,{className:`w-full border-t`})}),(0,K.jsx)(`div`,{className:`relative flex justify-center text-xs uppercase`,children:(0,K.jsx)(`span`,{className:`bg-card px-2 text-muted-foreground`,children:e(`auth.verifyEmail.or`,{defaultValue:`Or`})})})]}),(0,K.jsx)(O,{onClick:()=>{let e=i?`?redirect=${encodeURIComponent(i)}`:``;t(`/login${e}`)},variant:`ghost`,className:`w-full`,children:e(`auth.verifyEmail.backToLogin`,{defaultValue:`Back to login`})}),(0,K.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:e(`auth.verifyEmail.checkSpam`,{defaultValue:`Didn't receive the email? Check your spam folder or contact support.`})})]})})]})})}var cr=`/api/v1/auth`;function lr(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)}function ur(){let{t:e}=E(),t=o(),{user:n,signUp:r,refreshOrganizations:i,updateOrganization:a,createOrganization:s,switchOrganization:c}=S(),[l,u]=(0,G.useState)(``),[d,f]=(0,G.useState)(``),[p,m]=(0,G.useState)(``),[h,g]=(0,G.useState)(``),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(null);return(0,G.useEffect)(()=>{let e=!1;return(async()=>{try{let t=await fetch(`${cr}/bootstrap-status`,{credentials:`include`}),n=t.ok?await t.json().catch(()=>({})):{};e||b(n.hasOwner===!0)}catch{e||b(!1)}})(),()=>{e=!0}},[]),(0,G.useEffect)(()=>{y===!0&&!n&&t(`/login`,{replace:!0})},[y,n,t]),(0,G.useEffect)(()=>{n&&!_&&window.location.assign(`/`)},[n,_]),y===null?(0,K.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center bg-muted`,children:(0,K.jsx)(`div`,{className:`h-8 w-8 animate-spin rounded-full border-4 border-muted-foreground/20 border-t-primary`})}):(0,K.jsx)(`div`,{className:`flex min-h-svh w-full items-center justify-center bg-muted p-6`,children:(0,K.jsx)(`div`,{className:`flex w-full max-w-md flex-col gap-6`,children:(0,K.jsxs)(L,{children:[(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(A,{children:e(`auth.setup.welcomeTitle`,{defaultValue:`Welcome to ObjectStack`})}),(0,K.jsx)(F,{children:e(`auth.setup.description`,{defaultValue:`Create the first owner account to finish setting up this deployment.`})})]}),(0,K.jsx)(N,{children:(0,K.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),v(!0);try{await r(l,d,p);let e=h.trim();if(e)try{let t;for(let e=0;e<4&&!t?.id;e++)e>0&&await new Promise(e=>setTimeout(e,500)),t=(await i())?.[0];let n=lr(e),r;t?.id?(await a(t.id,{name:e,...n?{slug:n}:{}}),r=t.id):r=(await s({name:e,slug:n||`org-${Date.now().toString(36)}`}))?.id,r&&await c(r).catch(()=>void 0)}catch(e){console.warn(`[setup] organization rename/create failed`,e)}window.location.assign(`/`)}catch(t){R.error(e(`auth.setup.failed`,{defaultValue:`Setup failed`}),{description:t.message})}finally{v(!1)}},className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(P,{htmlFor:`name`,children:e(`auth.setup.yourName`,{defaultValue:`Your name`})}),(0,K.jsx)(M,{id:`name`,autoComplete:`name`,required:!0,value:l,onChange:e=>u(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(P,{htmlFor:`orgName`,children:e(`auth.setup.orgName`,{defaultValue:`Organization name`})}),(0,K.jsx)(M,{id:`orgName`,required:!0,placeholder:e(`auth.setup.orgNamePlaceholder`,{defaultValue:`Acme Inc.`}),value:h,onChange:e=>g(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(P,{htmlFor:`email`,children:e(`auth.setup.emailLabel`,{defaultValue:`Email`})}),(0,K.jsx)(M,{id:`email`,type:`email`,placeholder:e(`auth.setup.emailPlaceholder`,{defaultValue:`name@example.com`}),autoComplete:`email`,required:!0,value:d,onChange:e=>f(e.target.value)})]}),(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(P,{htmlFor:`password`,children:e(`auth.setup.passwordLabel`,{defaultValue:`Password`})}),(0,K.jsx)(M,{id:`password`,type:`password`,autoComplete:`new-password`,required:!0,minLength:8,placeholder:e(`auth.setup.passwordHint`,{defaultValue:`Minimum 8 characters`}),value:p,onChange:e=>m(e.target.value)})]}),(0,K.jsx)(O,{type:`submit`,className:`mt-2 w-full`,disabled:_,children:_?e(`auth.setup.submitting`,{defaultValue:`Setting up…`}):e(`auth.setup.submit`,{defaultValue:`Create owner account`})})]})})]})})})}var dr=`/api/v1/auth`;function fr(){let{t:e}=E(),t=o(),{user:n,isLoading:r}=S(),[i,a]=(0,G.useState)(!1),[s,c]=(0,G.useState)(null),l=typeof window<`u`?window.location.search:``,u=l.startsWith(`?`)?l.slice(1):l,d=new URLSearchParams(u),f=d.get(`client_id`)??void 0,p=d.get(`scope`)??``;(0,G.useEffect)(()=>{if(!r&&!n){let e=window.location.pathname+window.location.search;t(`/login?redirect=${encodeURIComponent(e)}`,{replace:!0})}},[n,r,t]),(0,G.useEffect)(()=>{if(!f)return;let e=!1;return fetch(`${dr}/oauth2/applications/${encodeURIComponent(f)}/public`,{credentials:`include`}).then(async t=>{if(!t.ok)return;let n=await t.json().catch(()=>({}));if(e)return;let r=n?.data??n;c(r)}).catch(()=>{}),()=>{e=!0}},[f]);let m=p.split(/\s+/).filter(Boolean),h=async t=>{a(!0);try{let n=await fetch(`${dr}/oauth2/consent`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({accept:t,oauth_query:u})}),r=await n.json().catch(()=>({}));if(!n.ok)throw Error(r?.message||`Consent failed: ${n.status}`);let i=r.redirect_uri??r.redirectURI??r.url;if(i){window.location.href=i;return}R(t?e(`oauth.consent.granted`,{defaultValue:`Access granted`}):e(`oauth.consent.denied`,{defaultValue:`Access denied`}),{description:e(`oauth.consent.noRedirect`,{defaultValue:`No redirect URL returned by the server.`})})}catch(t){R.error(e(`oauth.consent.failed`,{defaultValue:`Consent failed`}),{description:t.message})}finally{a(!1)}},g=s?.name??s?.client_name??f??e(`oauth.consent.unknownApp`,{defaultValue:`an application`});return(0,K.jsx)(`div`,{className:`flex min-h-svh w-full flex-1 items-center justify-center bg-background px-4`,children:(0,K.jsxs)(L,{className:`w-full max-w-md`,children:[(0,K.jsxs)(j,{className:`items-center text-center`,children:[(0,K.jsx)(`div`,{className:`mb-3 rounded-full border bg-muted p-3`,children:s?.icon||s?.logo_uri?(0,K.jsx)(`img`,{src:s.icon||s.logo_uri,alt:``,className:`h-8 w-8 rounded`,onError:e=>{e.currentTarget.style.display=`none`}}):(0,K.jsx)(De,{className:`h-7 w-7 text-muted-foreground`})}),(0,K.jsx)(A,{className:`text-xl`,children:e(`oauth.consent.title`,{appName:g,defaultValue:`${g} wants to access your account`})}),(0,K.jsx)(F,{children:e(`oauth.consent.request`,{appName:g,suffix:n?.email?` (${n.email})`:``,defaultValue:`${g} is requesting permission${n?.email?` for ${n.email}`:``}.`})})]}),(0,K.jsxs)(N,{className:`space-y-4`,children:[m.length>0&&(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`p`,{className:`mb-2 text-sm font-medium`,children:e(`oauth.consent.willAllow`,{defaultValue:`This app will be able to:`})}),(0,K.jsx)(`ul`,{className:`space-y-1.5 rounded-md border bg-muted/40 p-3 text-sm`,children:m.map(t=>(0,K.jsxs)(`li`,{className:`flex items-start gap-2`,children:[(0,K.jsx)(me,{className:`mt-0.5 h-4 w-4 text-green-600 dark:text-green-400`}),(0,K.jsx)(`span`,{children:pr(t,e)})]},t))})]}),(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 pt-2`,children:[(0,K.jsxs)(O,{variant:`outline`,onClick:()=>h(!1),disabled:i,children:[(0,K.jsx)(ie,{className:`mr-2 h-4 w-4`}),e(`oauth.consent.deny`,{defaultValue:`Deny`})]}),(0,K.jsxs)(O,{onClick:()=>h(!0),disabled:i,children:[(0,K.jsx)(me,{className:`mr-2 h-4 w-4`}),i?e(`oauth.consent.submitting`,{defaultValue:`Authorizing…`}):e(`oauth.consent.authorize`,{defaultValue:`Authorize`})]})]}),(0,K.jsx)(`p`,{className:`pt-2 text-center text-xs text-muted-foreground`,children:e(`oauth.consent.footer`,{defaultValue:`You can revoke access at any time from your account settings.`})})]})]})})}function pr(e,t){switch(e){case`openid`:return t(`oauth.consent.scope.openid`,{defaultValue:`Confirm your identity`});case`profile`:return t(`oauth.consent.scope.profile`,{defaultValue:`Read your basic profile (name, picture)`});case`email`:return t(`oauth.consent.scope.email`,{defaultValue:`Read your email address`});case`offline_access`:return t(`oauth.consent.scope.offlineAccess`,{defaultValue:`Stay signed in (refresh access)`});default:return e}}var mr=`/api/v1/auth`;function X({children:e}){return(0,K.jsx)(`div`,{className:`flex min-h-svh w-full flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10`,children:(0,K.jsxs)(`div`,{className:`flex w-full max-w-sm flex-col gap-6`,children:[(0,K.jsxs)(`a`,{href:`#`,className:`flex items-center gap-2 self-center font-medium`,children:[(0,K.jsx)(`div`,{className:`flex size-6 items-center justify-center rounded-md bg-primary text-primary-foreground overflow-hidden`,children:ht()?(0,K.jsx)(`img`,{src:ht(),alt:B(),className:`h-full w-full object-contain`}):(0,K.jsx)(ke,{className:`size-4`})}),B()]}),(0,K.jsx)(`div`,{className:`flex flex-col gap-6`,children:e})]})})}function hr(){let{t:e}=E(),t=a(),[n]=c(),r=n.get(`user_code`)??n.get(`code`)??``,i=n.get(`runtime_name`)??``,s=n.get(`runtime_version`)??``,{user:l,isLoading:u}=S(),d=o(),[f,m]=(0,G.useState)(!1),[h,g]=(0,G.useState)(!1),[_,v]=(0,G.useState)(!1),[y,b]=(0,G.useState)(!1),[x,C]=(0,G.useState)(``);if(!r)return(0,K.jsx)(X,{children:(0,K.jsx)(L,{children:(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(A,{children:e(`auth.device.invalidTitle`,{defaultValue:`Invalid device link`})}),(0,K.jsx)(F,{children:e(`auth.device.invalidDescription`,{defaultValue:`No device code was provided in the URL.`})})]})})});if(u)return(0,K.jsx)(X,{children:(0,K.jsx)(L,{children:(0,K.jsx)(j,{className:`text-center`,children:(0,K.jsx)(F,{children:e(`auth.device.loading`,{defaultValue:`Loading…`})})})})});if(!l)return(0,K.jsx)(p,{to:`/login?redirect=${encodeURIComponent(`/auth/device${t.search}`)}`,replace:!0});if(_)return(0,K.jsx)(X,{children:(0,K.jsx)(L,{children:(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(ke,{className:`mx-auto mb-2 h-10 w-10 text-green-500`}),(0,K.jsx)(A,{children:e(`auth.device.approvedTitle`,{defaultValue:`Device authorized`})}),(0,K.jsx)(F,{children:e(`auth.device.approvedDescription`,{defaultValue:`You can return to the device — it should sign in shortly.`})})]})})});if(y)return(0,K.jsx)(X,{children:(0,K.jsx)(L,{children:(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(A,{children:e(`auth.device.deniedTitle`,{defaultValue:`Access denied`})}),(0,K.jsx)(F,{children:e(`auth.device.deniedDescription`,{defaultValue:`The device will not be granted access.`})})]})})});let ee=async()=>{await fetch(`${mr}/device?user_code=${encodeURIComponent(r)}`,{credentials:`include`}).catch(()=>{})};return(0,K.jsx)(X,{children:(0,K.jsxs)(L,{children:[(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(A,{children:e(`auth.device.title`,{defaultValue:`Authorize new device`})}),(0,K.jsx)(F,{children:e(`auth.device.subtitle`,{email:l.email,defaultValue:`Approve this device to sign in as ${l.email}.`})})]}),(0,K.jsxs)(N,{className:`space-y-4`,children:[i?(0,K.jsxs)(`div`,{className:`rounded-md border bg-background px-4 py-3 text-center`,children:[(0,K.jsx)(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e(`auth.device.requesterLabel`,{defaultValue:`Connection request from`})}),(0,K.jsx)(`p`,{className:`font-medium`,children:i}),s?(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[B().toLowerCase(),` `,s]}):null]}):null,(0,K.jsxs)(`div`,{className:`rounded-md border bg-background px-4 py-3 text-center`,children:[(0,K.jsx)(`p`,{className:`mb-1 text-xs text-muted-foreground`,children:e(`auth.device.userCodeLabel`,{defaultValue:`Device code`})}),(0,K.jsx)(`p`,{className:`font-mono text-lg font-semibold tracking-widest`,children:r})]}),(0,K.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:e(`auth.device.approveWarning`,{defaultValue:`Only approve if you started this connection yourself a moment ago. Once approved, this runtime can access your organization's private packages.`})}),(0,K.jsxs)(`div`,{className:`space-y-4`,children:[(0,K.jsx)(`p`,{className:`text-center text-sm text-muted-foreground`,children:e(`auth.device.loggedInAs`,{email:l.email,defaultValue:`Signed in as ${l.email}`})}),x&&(0,K.jsx)(`p`,{className:`text-center text-sm text-destructive`,children:x}),(0,K.jsx)(O,{onClick:async()=>{C(``),m(!0);try{await ee();let t=await fetch(`${mr}/device/approve`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({userCode:r})});if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n?.message??n?.error?.message??e(`auth.device.approveFailed`,{defaultValue:`Approval failed`}))}v(!0),R.success(e(`auth.device.approveSuccess`,{defaultValue:`Device authorized`}),{description:e(`auth.device.approveSuccessDescription`,{defaultValue:`You can close this window.`})})}catch(t){C(t?.message??e(`auth.device.approveFailed`,{defaultValue:`Approval failed`}))}finally{m(!1)}},className:`w-full`,disabled:f||h,children:f?e(`auth.device.approving`,{defaultValue:`Approving…`}):e(`auth.device.approve`,{defaultValue:`Approve device`})}),(0,K.jsx)(O,{onClick:async()=>{C(``),g(!0);try{await ee(),await fetch(`${mr}/device/deny`,{method:`POST`,headers:{"Content-Type":`application/json`},credentials:`include`,body:JSON.stringify({userCode:r})}),b(!0)}catch(t){C(t?.message??e(`auth.device.denyFailed`,{defaultValue:`Failed to deny request`}))}finally{g(!1)}},variant:`outline`,className:`w-full`,disabled:f||h,children:h?e(`auth.device.denying`,{defaultValue:`Denying…`}):e(`auth.device.deny`,{defaultValue:`Deny request`})}),(0,K.jsx)(`div`,{className:`text-center`,children:(0,K.jsx)(`button`,{type:`button`,className:`text-sm text-muted-foreground underline-offset-4 hover:underline`,onClick:()=>d(`/`),children:e(`auth.device.cancel`,{defaultValue:`Cancel`})})})]})]})]})})}function gr(){let{t:e}=E(),{invitationId:t}=d(),n=o(),{user:r,isLoading:i,acceptInvitation:a,rejectInvitation:s,refreshOrganizations:c}=S(),[l,u]=(0,G.useState)(!1),[f,p]=(0,G.useState)(!1);return(0,G.useEffect)(()=>{if(!i&&!r&&t){let e=`/accept-invitation/${t}`;n(`/login?redirect=${encodeURIComponent(e)}`,{replace:!0})}},[i,r,t,n]),t?(0,K.jsx)(`div`,{className:`flex min-h-svh w-full flex-col items-center justify-center gap-6 bg-muted p-6 md:p-10`,children:(0,K.jsx)(`div`,{className:`flex w-full max-w-sm flex-col gap-6`,children:(0,K.jsxs)(L,{children:[(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(A,{className:`text-xl`,children:e(`acceptInvitation.title`,{defaultValue:`Accept organization invitation`})}),(0,K.jsx)(F,{children:e(`acceptInvitation.description`,{defaultValue:`You've been invited to join an organization.`})})]}),(0,K.jsxs)(N,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(O,{className:`w-full`,onClick:async()=>{u(!0);try{await a(t),await c().catch(()=>void 0),R.success(e(`acceptInvitation.accepted`,{defaultValue:`Invitation accepted`})),n(`/organizations`)}catch(t){R.error(e(`acceptInvitation.acceptFailed`,{defaultValue:`Could not accept`}),{description:t.message})}finally{u(!1)}},disabled:l||f,children:l?e(`acceptInvitation.accepting`,{defaultValue:`Accepting…`}):e(`acceptInvitation.accept`,{defaultValue:`Accept invitation`})}),(0,K.jsx)(O,{variant:`outline`,className:`w-full`,onClick:async()=>{p(!0);try{await s(t),R.success(e(`acceptInvitation.declined`,{defaultValue:`Invitation declined`})),n(`/organizations`)}catch(t){R.error(e(`acceptInvitation.declineFailed`,{defaultValue:`Could not decline`}),{description:t.message})}finally{p(!1)}},disabled:l||f,children:f?e(`acceptInvitation.declining`,{defaultValue:`Declining…`}):e(`acceptInvitation.decline`,{defaultValue:`Decline`})})]})]})})}):(0,K.jsx)(`div`,{className:`flex min-h-svh w-full flex-col items-center justify-center bg-muted p-6`,children:(0,K.jsx)(L,{className:`w-full max-w-sm`,children:(0,K.jsxs)(j,{className:`text-center`,children:[(0,K.jsx)(A,{className:`text-xl`,children:e(`acceptInvitation.invalidTitle`,{defaultValue:`Invalid invitation link`})}),(0,K.jsx)(F,{children:e(`acceptInvitation.invalidDescription`,{defaultValue:`The invitation id is missing from the URL.`})})]})})})}var _r=`/api/v1/auth`;function vr(){try{if(typeof document>`u`)return`/`;let e=document.querySelector(`base`)?.getAttribute(`href`);return e&&new URL(e,window.location.origin).pathname.replace(/\/$/,``)||`/`}catch{return`/`}}var yr=vr();function br(){let e=a(),t=e.pathname+e.search;return(0,K.jsx)(p,{to:`/login${t&&t!==`/`?`?redirect=${encodeURIComponent(t)}`:``}`,replace:!0})}function Z({children:e,requireOrganization:t=!0}){return(0,K.jsx)(v,{fallback:(0,K.jsx)(br,{}),loadingFallback:(0,K.jsx)(ot,{}),children:(0,K.jsx)(Ve,{children:t?(0,K.jsx)(at,{children:e}):e})})}function xr(){let{user:e}=S();return(0,K.jsx)(Ge,{userId:e?.id,children:(0,K.jsx)(rt,{})})}function Sr(){return(0,G.useEffect)(()=>{document.title=B();let e=_t();if(e){let t=document.getElementById(`favicon`);t&&(t.href=e,t.type=e.endsWith(`.svg`)?`image/svg+xml`:`image/png`)}},[a()]),null}function Cr(){return(0,K.jsxs)(x,{authUrl:_r,children:[(0,K.jsx)(Ze,{position:`bottom-right`}),(0,K.jsx)(Cn,{}),(0,K.jsxs)(l,{basename:yr,children:[(0,K.jsx)(Sr,{}),(0,K.jsx)(it,{children:(0,K.jsxs)(m,{children:[(0,K.jsx)(u,{path:`/login`,element:(0,K.jsx)(Jn,{})}),(0,K.jsx)(u,{path:`/register`,element:(0,K.jsx)($n,{})}),(0,K.jsx)(u,{path:`/forgot-password`,element:(0,K.jsx)(tr,{})}),(0,K.jsx)(u,{path:`/reset-password`,element:(0,K.jsx)(nr,{})}),(0,K.jsx)(u,{path:`/set-password`,element:(0,K.jsx)(ir,{})}),(0,K.jsx)(u,{path:`/verify-email`,element:(0,K.jsx)(or,{})}),(0,K.jsx)(u,{path:`/verify-email-prompt`,element:(0,K.jsx)(sr,{})}),(0,K.jsx)(u,{path:`/setup`,element:(0,K.jsx)(ur,{})}),(0,K.jsx)(u,{path:`/oauth/consent`,element:(0,K.jsx)(fr,{})}),(0,K.jsx)(u,{path:`/auth/device`,element:(0,K.jsx)(hr,{})}),(0,K.jsx)(u,{path:`/accept-invitation/:invitationId`,element:(0,K.jsx)(gr,{})}),(0,K.jsx)(u,{path:`/f/:slug`,element:(0,K.jsx)(Sn,{mode:`public`})}),(0,K.jsx)(u,{path:`/s/:token`,element:(0,K.jsx)(Tn,{})}),(0,K.jsx)(u,{path:`/studio`,element:(0,K.jsx)(Z,{children:(0,K.jsxs)(`div`,{className:`flex min-h-screen flex-col bg-background text-foreground`,children:[(0,K.jsx)(`header`,{className:`flex shrink-0 items-center border-b px-3 py-2`,children:(0,K.jsx)(r,{to:`/home`,title:`返回主页`,className:`inline-flex items-center gap-1.5 rounded-md px-1.5 py-0.5 text-[13px] font-semibold hover:bg-muted`,children:B()})}),(0,K.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:(0,K.jsx)(Qe,{})})]})})}),(0,K.jsx)(u,{path:`/studio/:packageId`,element:(0,K.jsx)(p,{to:`data`,replace:!0})}),(0,K.jsx)(u,{path:`/studio/:packageId/:tab`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(tt,{})})}),(0,K.jsx)(u,{path:`/forms/:name`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(Sn,{mode:`internal`})})}),(0,K.jsxs)(u,{path:`/docs`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(zn,{})}),children:[(0,K.jsx)(u,{index:!0,element:(0,K.jsx)(Pn,{})}),(0,K.jsx)(u,{path:`:slug`,element:(0,K.jsx)(Ln,{})}),(0,K.jsx)(u,{path:`:slug/:name`,element:(0,K.jsx)(Nn,{})})]}),(0,K.jsx)(u,{path:`/home`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(xr,{})})}),(0,K.jsx)(u,{path:`/dev/master-detail`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(Mt,{})})}),(0,K.jsx)(u,{path:`/dev/lists`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(Ft,{})})}),(0,K.jsx)(u,{path:`/dev/modal`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(It,{})})}),(0,K.jsx)(u,{path:`/dev/lookup`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(Lt,{})})}),(0,K.jsx)(u,{path:`/organizations`,element:(0,K.jsx)(Z,{requireOrganization:!1,children:(0,K.jsx)(Xe,{children:(0,K.jsx)(We,{})})})}),(0,K.jsxs)(u,{path:`/organizations/:slug`,element:(0,K.jsx)(Z,{requireOrganization:!1,children:(0,K.jsx)(nt,{})}),children:[(0,K.jsx)(u,{index:!0,element:(0,K.jsx)(p,{to:`members`,replace:!0})}),(0,K.jsx)(u,{path:`members`,element:(0,K.jsx)($e,{})}),(0,K.jsx)(u,{path:`invitations`,element:(0,K.jsx)(He,{})}),(0,K.jsx)(u,{path:`settings`,element:(0,K.jsx)(Ye,{})})]}),(0,K.jsx)(u,{path:`/system/*`,element:(0,K.jsx)(Be,{})}),(0,K.jsx)(u,{path:`/ai`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(Ue,{children:(0,K.jsx)(Je,{})})})}),(0,K.jsx)(u,{path:`/ai/:agent`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(Ue,{children:(0,K.jsx)(Je,{})})})}),(0,K.jsx)(u,{path:`/ai/:agent/:conversationId`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(Ue,{children:(0,K.jsx)(Je,{})})})}),(0,K.jsx)(u,{path:`/apps/:appName/*`,element:(0,K.jsx)(Z,{children:(0,K.jsx)(on,{})})}),(0,K.jsx)(u,{path:`/`,element:(0,K.jsx)(Ve,{children:(0,K.jsx)(cn,{})})}),(0,K.jsx)(u,{path:`*`,element:(0,K.jsx)(p,{to:`/`,replace:!0})})]})})]})]})}async function wr(e){try{let t=await fetch(`/api/v1/i18n/translations/${e}`);if(!t.ok)return console.warn(`[i18n] Failed to load translations for '${e}': HTTP ${t.status}`),{};let n=await t.json(),r;return r=n?.data?.translations&&typeof n.data.translations==`object`?n.data.translations:n,y(r)?g(r):r}catch(t){return console.warn(`[i18n] Failed to load translations for '${e}':`,t),{}}}var Tr=`auth-session-token`,Er=`auth-active-organization-id`;async function Dr(e){if(typeof window>`u`)return;let t=null;try{t=localStorage.getItem(Tr)}catch{return}if(t)try{let n=await fetch(`${e}/get-session`,{method:`GET`,credentials:`omit`,headers:{Authorization:`Bearer ${t}`,Accept:`application/json`}});if(n.ok){let e=await n.json().catch(()=>null);if(e?.user??e?.data?.user??null)return}localStorage.removeItem(Tr),localStorage.removeItem(Er)}catch{}}function Or(e,t){let n=Array.isArray(e.fields)?e.fields:Object.values(e.fields||{});return{id:e.name||`obj_${t}`,name:e.name||``,label:typeof e.label==`object`?e.label.defaultValue||e.label.key||``:e.label||e.name||``,pluralLabel:e.pluralLabel||e.plural_label||void 0,description:typeof e.description==`object`?e.description.defaultValue:e.description||void 0,icon:e.icon||void 0,group:e.name?.startsWith(`sys_`)?`System Objects`:`Custom Objects`,sortOrder:t,isSystem:e.name?.startsWith(`sys_`)||!1,enabled:e.enabled!==!1,fieldCount:n.length,relationships:Array.isArray(e.relationships)?e.relationships.map(e=>({relatedObject:e.object||e.relatedObject||``,type:e.type||`one-to-many`,label:e.label||e.name||void 0,foreignKey:e.foreign_key||e.foreignKey||void 0})):void 0}}function kr(e,t){return{id:e.name||`fld_${t}`,name:e.name||``,label:typeof e.label==`object`?e.label.defaultValue||e.label.key||``:e.label||e.name||``,type:e.type||`text`,group:e.group||void 0,sortOrder:t,description:e.description||e.help||void 0,required:e.required||!1,unique:e.unique||!1,readonly:e.readonly||!1,hidden:e.hidden||!1,defaultValue:e.defaultValue||e.default_value||void 0,placeholder:e.placeholder||void 0,options:Array.isArray(e.options)?e.options.map(e=>typeof e==`string`?{label:e,value:e}:{label:e.label||e.value,value:e.value,color:e.color}):void 0,isSystem:e.readonly===!0&&(e.name===`id`||e.name===`createdAt`||e.name===`updatedAt`),externalId:e.externalId||!1,trackHistory:e.trackHistory||e.track_history||!1,indexed:e.indexed||!1,referenceTo:e.reference_to||e.referenceTo||void 0,formula:e.formula||void 0}}function Q(e){let{objects:t}=w(),n=(0,G.useMemo)(()=>(t||[]).find(t=>t.name===e),[t,e]);return{object:(0,G.useMemo)(()=>n?Or(n,0):null,[n]),fields:(0,G.useMemo)(()=>n?(Array.isArray(n.fields)?n.fields:Object.values(n.fields||{})).map(kr):[],[n]),metadataObject:n}}function Ar({label:e,value:t,onSave:n,multiline:r=!1,disabled:i=!1,placeholder:a}){let[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(t),[u,d]=(0,G.useState)(!1),f=(0,G.useRef)(null),p=()=>{l(t),s(!0),setTimeout(()=>f.current?.focus(),0)},m=(0,G.useCallback)(async()=>{if(c===t){s(!1);return}d(!0);try{await n(c),s(!1)}catch{}finally{d(!1)}},[c,t,n]),h=()=>{l(t),s(!1)},g=e=>{e.key===`Enter`&&!r&&(e.preventDefault(),m()),e.key===`Escape`&&h()};return(0,K.jsxs)(`div`,{className:`space-y-1.5 group`,children:[(0,K.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:e}),(0,K.jsx)(`dd`,{children:o?(0,K.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[r?(0,K.jsx)(Ne,{ref:f,value:c,onChange:e=>l(e.target.value),onKeyDown:g,placeholder:a,rows:3,className:`text-sm flex-1 min-w-0`,disabled:u}):(0,K.jsx)(M,{ref:f,value:c,onChange:e=>l(e.target.value),onKeyDown:g,placeholder:a,className:`text-sm h-7 flex-1 min-w-0`,disabled:u}),(0,K.jsx)(`button`,{onClick:()=>void m(),disabled:u,className:`mt-0.5 p-1 rounded text-green-600 hover:bg-green-50 disabled:opacity-50 shrink-0`,"aria-label":`Save`,children:u?(0,K.jsx)(k,{className:`h-3.5 w-3.5 animate-spin`}):(0,K.jsx)(me,{className:`h-3.5 w-3.5`})}),(0,K.jsx)(`button`,{onClick:h,disabled:u,className:`mt-0.5 p-1 rounded text-muted-foreground hover:bg-accent shrink-0`,"aria-label":`Cancel`,children:(0,K.jsx)(ie,{className:`h-3.5 w-3.5`})})]}):(0,K.jsxs)(`div`,{className:`flex items-center gap-2 min-h-7`,children:[(0,K.jsx)(`span`,{className:`text-sm flex-1 min-w-0 truncate`,children:t||(0,K.jsx)(`span`,{className:`text-muted-foreground italic`,children:a||`—`})}),!i&&(0,K.jsx)(`button`,{onClick:p,className:`p-1 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:bg-accent transition-opacity shrink-0`,"aria-label":`Edit ${e}`,children:(0,K.jsx)(Se,{className:`h-3 w-3`})})]})})]})}function jr({schema:e}){let t=e.objectName,{object:n,fields:r,metadataObject:i}=Q(t),{refresh:a}=w(),o=lt(),s=(0,G.useCallback)(async(e,n)=>{if(!o||!i)return;let r={...i,[e]:n};try{await o.saveMetadataItem(`object`,t,r),await a(),R.success(`${e===`label`?`Display name`:`Field`} updated`)}catch(e){throw R.error(e?.message||`Failed to save`),e}},[o,i,t,a]);if(!n)return null;let c=n.isSystem;return(0,K.jsxs)(`div`,{className:`space-y-6`,"data-testid":`object-properties`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`基本信息`}),(0,K.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-5`,children:[(0,K.jsx)(Ar,{label:`显示名称`,value:n.label,onSave:e=>s(`label`,e),placeholder:`输入显示名称`,disabled:c}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:`API 名称`}),(0,K.jsx)(`dd`,{className:`text-sm font-mono bg-muted/50 rounded px-2 py-1 inline-block`,children:n.name})]}),(0,K.jsx)(Ar,{label:`复数名称`,value:n.pluralLabel||``,onSave:e=>s(`pluralLabel`,e),placeholder:`例如:客户们`,disabled:c}),(0,K.jsx)(Ar,{label:`分组`,value:n.group||``,onSave:e=>s(`group`,e),placeholder:`对象分组`,disabled:c}),(0,K.jsx)(`div`,{className:`sm:col-span-2`,children:(0,K.jsx)(Ar,{label:`描述`,value:n.description||``,onSave:e=>s(`description`,e),multiline:!0,placeholder:`输入对象描述`,disabled:c})})]})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`配置`}),(0,K.jsxs)(`dl`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:`状态`}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(I,{variant:n.enabled===!1?`secondary`:`default`,className:`font-normal`,children:n.enabled===!1?`已禁用`:`已启用`})})]}),(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:`字段数量`}),(0,K.jsxs)(`dd`,{className:`text-sm font-medium`,children:[n.fieldCount??r.length,` 个字段`]})]}),c&&(0,K.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,K.jsx)(`dt`,{className:`text-xs font-medium text-muted-foreground`,children:`类型`}),(0,K.jsx)(`dd`,{children:(0,K.jsx)(I,{variant:`secondary`,className:`font-normal`,children:`系统对象`})})]})]})]})]})}var Mr=[{label:`一对多`,value:`one-to-many`},{label:`多对多`,value:`many-to-many`},{label:`一对一`,value:`one-to-one`},{label:`多对一`,value:`many-to-one`}];function Nr({schema:e}){let t=e.objectName,{object:n,metadataObject:r}=Q(t),{refresh:i}=w(),a=lt(),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)({relatedObject:``,type:`one-to-many`,label:``,foreignKey:``}),f=(0,G.useCallback)(async()=>{if(!a||!r||!u.relatedObject.trim())return;let e={relatedObject:u.relatedObject.trim(),type:u.type,label:u.label.trim()||void 0,foreignKey:u.foreignKey.trim()||void 0},n={...r,relationships:[...Array.isArray(r.relationships)?r.relationships:[],e]};l(!0);try{await a.saveMetadataItem(`object`,t,n),await i(),R.success(`关联关系已添加`),s(!1),d({relatedObject:``,type:`one-to-many`,label:``,foreignKey:``})}catch(e){R.error(e?.message||`保存失败`)}finally{l(!1)}},[a,r,n,u,t,i]),p=(0,G.useCallback)(async e=>{if(!a||!r)return;let n=Array.isArray(r.relationships)?[...r.relationships]:[];n.splice(e,1);let o={...r,relationships:n};l(!0);try{await a.saveMetadataItem(`object`,t,o),await i(),R.success(`关联关系已删除`)}catch(e){R.error(e?.message||`删除失败`)}finally{l(!1)}},[a,r,t,i]);if(!n)return null;let m=n.relationships&&n.relationships.length>0;return(0,K.jsx)(`div`,{className:`space-y-4`,"data-testid":`relationships-section`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,K.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:`关联关系`}),!n.isSystem&&(0,K.jsxs)(O,{size:`sm`,variant:`outline`,onClick:()=>s(e=>!e),className:`h-7 text-xs`,children:[(0,K.jsx)(de,{className:`h-3 w-3 mr-1`}),`添加关联`]})]}),o&&(0,K.jsxs)(`div`,{className:`mb-4 p-4 border rounded-lg bg-muted/30 space-y-3`,children:[(0,K.jsx)(`h4`,{className:`text-sm font-medium`,children:`新建关联关系`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`关联对象 *`}),(0,K.jsx)(M,{value:u.relatedObject,onChange:e=>d(t=>({...t,relatedObject:e.target.value})),placeholder:`例如:account`,className:`h-7 text-xs`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`关联类型`}),(0,K.jsx)(`select`,{value:u.type,onChange:e=>d(t=>({...t,type:e.target.value})),className:`w-full h-7 text-xs rounded-md border border-input bg-background px-2`,children:Mr.map(e=>(0,K.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`显示名称`}),(0,K.jsx)(M,{value:u.label,onChange:e=>d(t=>({...t,label:e.target.value})),placeholder:`可选`,className:`h-7 text-xs`})]}),(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`label`,{className:`text-xs text-muted-foreground block mb-1`,children:`外键字段`}),(0,K.jsx)(M,{value:u.foreignKey,onChange:e=>d(t=>({...t,foreignKey:e.target.value})),placeholder:`例如:account_id`,className:`h-7 text-xs`})]})]}),(0,K.jsxs)(`div`,{className:`flex items-center gap-2 justify-end`,children:[(0,K.jsx)(O,{size:`sm`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>s(!1),disabled:c,children:`取消`}),(0,K.jsxs)(O,{size:`sm`,className:`h-7 text-xs`,onClick:()=>void f(),disabled:c||!u.relatedObject.trim(),children:[c?(0,K.jsx)(k,{className:`h-3 w-3 animate-spin mr-1`}):null,`保存`]})]})]}),m?(0,K.jsx)(`div`,{className:`space-y-2`,children:n.relationships?.map((e,t)=>(0,K.jsxs)(`div`,{className:`flex items-start gap-4 p-3 rounded-lg border bg-card hover:bg-accent/30 transition-colors group`,children:[(0,K.jsx)(I,{variant:`outline`,className:`text-xs shrink-0 mt-0.5`,children:Mr.find(t=>t.value===e.type)?.label||e.type}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`font-medium text-sm`,children:e.label||e.relatedObject}),e.label&&e.label!==e.relatedObject&&(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`关联对象: `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.relatedObject})]}),e.foreignKey&&(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`外键: `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.foreignKey})]})]}),!n.isSystem&&(0,K.jsx)(`button`,{onClick:()=>void p(t),disabled:c,className:`p-1 rounded text-muted-foreground opacity-0 group-hover:opacity-100 hover:text-destructive hover:bg-destructive/10 transition-all shrink-0`,"aria-label":`删除关联`,children:(0,K.jsx)(ye,{className:`h-3.5 w-3.5`})})]},t))}):!o&&(0,K.jsxs)(`div`,{className:`text-center py-8 px-4 border border-dashed rounded-lg`,children:[(0,K.jsx)(_e,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground opacity-40`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`暂无关联关系。`}),!n.isSystem&&(0,K.jsxs)(O,{size:`sm`,variant:`outline`,className:`mt-3 h-7 text-xs`,onClick:()=>s(!0),children:[(0,K.jsx)(de,{className:`h-3 w-3 mr-1`}),`添加关联`]})]})]})})}function Pr({schema:e}){let t=e.objectName,{fields:n}=Q(t),r=(0,G.useMemo)(()=>n.filter(e=>e.unique||e.name===`id`||e.externalId),[n]);return(0,K.jsx)(`div`,{className:`space-y-4`,"data-testid":`keys-section`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`唯一键`}),r.length>0?(0,K.jsx)(`div`,{className:`space-y-2`,children:r.map(e=>(0,K.jsxs)(`div`,{className:`flex items-start gap-4 p-3 rounded-lg border bg-card hover:bg-accent/30 transition-colors`,children:[(0,K.jsx)(I,{variant:e.name===`id`?`default`:`outline`,className:`text-xs shrink-0 mt-0.5`,children:e.name===`id`?`主键`:e.externalId?`外部 ID`:`唯一`}),(0,K.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,K.jsx)(`p`,{className:`font-medium text-sm`,children:e.label||e.name}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[`类型: `,(0,K.jsx)(`span`,{className:`font-mono`,children:e.type})]})]})]},e.name))}):(0,K.jsxs)(`div`,{className:`text-center py-8 px-4 border border-dashed rounded-lg`,children:[(0,K.jsx)(De,{className:`h-8 w-8 mx-auto mb-2 text-muted-foreground opacity-40`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`未找到唯一键或主键。`})]})]})})}function Fr(e){return(0,K.jsx)(`div`,{className:`space-y-4`,"data-testid":`data-experience-section`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`数据体验`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:`配置用户与此对象数据的交互方式`}),(0,K.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-3 gap-4`,children:[(0,K.jsxs)(`div`,{className:`rounded-lg border p-5 text-center hover:bg-accent/30 transition-colors cursor-pointer`,"data-testid":`data-experience-forms`,children:[(0,K.jsx)(Me,{className:`h-7 w-7 mx-auto mb-2.5 text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-sm font-semibold mb-1`,children:`表单`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`设计数据录入表单`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg border p-5 text-center hover:bg-accent/30 transition-colors cursor-pointer`,"data-testid":`data-experience-views`,children:[(0,K.jsx)(be,{className:`h-7 w-7 mx-auto mb-2.5 text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-sm font-semibold mb-1`,children:`视图`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`配置列表和详情视图`})]}),(0,K.jsxs)(`div`,{className:`rounded-lg border p-5 text-center hover:bg-accent/30 transition-colors cursor-pointer`,"data-testid":`data-experience-dashboards`,children:[(0,K.jsx)(xe,{className:`h-7 w-7 mx-auto mb-2.5 text-muted-foreground`}),(0,K.jsx)(`p`,{className:`text-sm font-semibold mb-1`,children:`仪表盘`}),(0,K.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`构建可视化仪表盘`})]})]})]})})}function Ir({schema:e}){let t=e.objectName,{object:n}=Q(t);return(0,K.jsx)(`div`,{className:`space-y-4`,"data-testid":`data-preview-section`,children:(0,K.jsxs)(`div`,{children:[(0,K.jsx)(`h3`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider mb-4`,children:`数据预览`}),(0,K.jsx)(`p`,{className:`text-sm text-muted-foreground mb-4`,children:`查看此对象的示例记录`}),(0,K.jsxs)(`div`,{className:`rounded-lg border border-dashed p-12 text-center`,children:[(0,K.jsx)(Ce,{className:`h-12 w-12 mx-auto mb-4 text-muted-foreground opacity-40`}),(0,K.jsx)(`p`,{className:`text-sm font-medium mb-1`,children:`示例数据`}),(0,K.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`“`,n?.label||t,`” 的实时数据预览将在此处显示`]})]})]})})}function Lr(e,t){return{name:e.name,label:e.label,pluralLabel:e.pluralLabel,description:e.description,icon:e.icon,group:e.group,sortOrder:e.sortOrder,enabled:e.enabled,fields:t,relationships:e.relationships}}function Rr(e){return{name:e.name,label:e.label,type:e.type,group:e.group,description:e.description,required:e.required,unique:e.unique,readonly:e.readonly,hidden:e.hidden,defaultValue:e.defaultValue,placeholder:e.placeholder,options:e.options,externalId:e.externalId,trackHistory:e.trackHistory,indexed:e.indexed,referenceTo:e.referenceTo,formula:e.formula,sortOrder:e.sortOrder}}var zr=class{adapter;constructor(e){this.adapter=e}async getItems(e){let t=await this.adapter.getClient().meta.getItems(e);return t&&typeof t==`object`&&`items`in t&&Array.isArray(t.items)?t.items:[]}async saveMetadataItem(e,t,n){await this.adapter.getClient().meta.saveItem(e,t,n),this.adapter.invalidateCache(`${e}:${t}`)}async deleteMetadataItem(e,t){await this.adapter.getClient().meta.saveItem(e,t,{name:t,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`${e}:${t}`)}async saveObject(e,t){let n=this.adapter.getClient(),r=Lr(e,t);await n.meta.saveItem(`object`,e.name,r),this.adapter.invalidateCache(`object:${e.name}`)}async deleteObject(e){await this.adapter.getClient().meta.saveItem(`object`,e,{name:e,enabled:!1,_deleted:!0}),this.adapter.invalidateCache(`object:${e}`)}async saveFields(e,t){let n=this.adapter.getClient(),r={};try{let t=await n.meta.getItem(`object`,e);r=t?.item??t??{}}catch{}let i={...r,name:e,fields:t.map(Rr)};await n.meta.saveItem(`object`,e,i),this.adapter.invalidateCache(`object:${e}`)}static diffObjects(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,object:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,object:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,object:t}}return null}static diffFields(e,t){let n=new Map(e.map(e=>[e.id,e])),r=new Map(t.map(e=>[e.id,e]));for(let[e,t]of r)if(!n.has(e))return{type:`create`,field:t};for(let[e,t]of n)if(!r.has(e))return{type:`delete`,field:t};for(let[e,t]of r){let r=n.get(e);if(r&&JSON.stringify(r)!==JSON.stringify(t))return{type:`update`,field:t}}return null}};function Br({schema:e}){let t=e.objectName,{objects:n,refresh:r}=w(),i=lt(),a=(0,G.useMemo)(()=>(n||[]).find(e=>e.name===t),[n,t]),o=(0,G.useMemo)(()=>a?(Array.isArray(a.fields)?a.fields:Object.values(a.fields||{})).map(kr):[],[a]),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(!1),d=s??o,f=(0,G.useRef)(d),p=(0,G.useCallback)(async e=>{let n=f.current;if(c(e),f.current=e,!i){R.error(`Service unavailable — changes saved locally only`);return}let a=zr.diffFields(n,e),o=a?a.type===`create`?`Field "${a.field.label||a.field.name}" created`:a.type===`update`?`Field "${a.field.label||a.field.name}" updated`:`Field "${a.field.label||a.field.name}" deleted`:`Field configuration updated`;u(!0);try{await i.saveFields(t,e),await r(),R.success(o)}catch(e){c(n),f.current=n,R.error(e?.message||`Failed to save field changes`)}finally{u(!1)}},[i,t,r]);return(0,K.jsxs)(`div`,{className:`space-y-3`,"data-testid":`field-management-section`,children:[l&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,"data-testid":`field-saving-indicator`,children:[(0,K.jsx)(k,{className:`h-4 w-4 animate-spin`}),`Saving field changes…`]}),d.some(e=>e.isSystem)&&(0,K.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground bg-muted/50 rounded-md px-3 py-2`,"data-testid":`system-field-hint`,children:[(0,K.jsx)(ue,{className:`h-3.5 w-3.5 shrink-0`}),`System fields (e.g. id, createdAt, updatedAt) are read-only and cannot be edited or deleted.`]}),(0,K.jsx)(kt,{objectName:t,fields:d,onFieldsChange:p})]})}function Vr({schema:e}){let t=e.objectName,[n,r]=(0,G.useState)(`details`),i={type:`object-properties`,id:`${t}-properties`,objectName:t},a={type:`object-field-designer`,id:`${t}-field-designer`,objectName:t},o={type:`object-relationships`,id:`${t}-relationships`,objectName:t},s={type:`object-keys`,id:`${t}-keys`,objectName:t},c={type:`object-data-experience`,id:`${t}-data-experience`,objectName:t},l={type:`object-data-preview`,id:`${t}-data-preview`,objectName:t};return(0,K.jsx)(`div`,{className:`w-full`,"data-testid":`object-detail-tabs`,children:(0,K.jsxs)(Le,{value:n,onValueChange:r,className:`w-full`,children:[(0,K.jsxs)(Ee,{className:`w-full justify-start border-b rounded-none bg-transparent p-0 h-auto`,children:[(0,K.jsxs)(Pe,{value:`details`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,K.jsx)(je,{className:`h-4 w-4 mr-2`}),`详情`]}),(0,K.jsxs)(Pe,{value:`fields`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,K.jsx)(Ie,{className:`h-4 w-4 mr-2`}),`字段`]}),(0,K.jsxs)(Pe,{value:`relationships`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,K.jsx)(_e,{className:`h-4 w-4 mr-2`}),`关联关系`]}),(0,K.jsxs)(Pe,{value:`data`,className:`relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent data-[state=active]:shadow-none`,children:[(0,K.jsx)(Ce,{className:`h-4 w-4 mr-2`}),`数据`]})]}),(0,K.jsx)(Te,{value:`details`,className:`mt-6`,children:(0,K.jsx)(`div`,{className:`space-y-6`,children:(0,K.jsx)(T,{schema:i})})}),(0,K.jsx)(Te,{value:`fields`,className:`mt-6`,children:(0,K.jsx)(`div`,{className:`space-y-6`,children:(0,K.jsx)(T,{schema:a})})}),(0,K.jsx)(Te,{value:`relationships`,className:`mt-6`,children:(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsx)(T,{schema:o}),(0,K.jsx)(T,{schema:s})]})}),(0,K.jsx)(Te,{value:`data`,className:`mt-6`,children:(0,K.jsxs)(`div`,{className:`space-y-6`,children:[(0,K.jsx)(T,{schema:l}),(0,K.jsx)(T,{schema:c})]})})]})})}var $={namespace:`console`,category:`system`};D.register(`object-detail-tabs`,Vr,{...$,label:`Object Detail Tabs`,icon:`LayoutDashboard`}),D.register(`object-properties`,jr,{...$,label:`Object Properties`,icon:`Settings2`}),D.register(`object-relationships`,Nr,{...$,label:`Object Relationships`,icon:`Link2`}),D.register(`object-keys`,Pr,{...$,label:`Object Keys`,icon:`KeyRound`}),D.register(`object-data-experience`,Fr,{...$,label:`Data Experience`,icon:`LayoutList`}),D.register(`object-data-preview`,Ir,{...$,label:`Data Preview`,icon:`Table`}),D.register(`object-field-designer`,Br,{...$,label:`Field Designer`,icon:`Columns`});var Hr=(0,G.lazy)(()=>s(()=>import(`./ApiConsolePage-CVxWz2Fc.js`).then(e=>({default:e.ApiConsolePage})),__vite__mapDeps([0,1]),import.meta.url)),Ur=(0,G.lazy)(()=>s(()=>import(`./FlowRunsPage-BsxDtVro.js`).then(e=>({default:e.FlowRunsPage})),__vite__mapDeps([0,1]),import.meta.url)),Wr=(0,G.lazy)(()=>s(()=>import(`./PublicFormsPage-onVYVDnz.js`).then(e=>({default:e.PublicFormsPage})),__vite__mapDeps([0,1]),import.meta.url));function Gr({label:e}){return(0,K.jsxs)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:[`Loading `,e,`…`]})}V({ref:`developer:api-console`,label:`API Console`,source:`@objectstack/console`,component:e=>(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Gr,{label:`API console`}),children:(0,K.jsx)(Hr,{...e})})}),V({ref:`developer:flow-runs`,label:`Flow Runs`,source:`@objectstack/console`,component:e=>(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Gr,{label:`flow runs`}),children:(0,K.jsx)(Ur,{...e})})}),V({ref:`developer:public-forms`,label:`Public Forms`,source:`@objectstack/console`,component:e=>(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Gr,{label:`public forms`}),children:(0,K.jsx)(Wr,{...e})})});var Kr=(0,G.lazy)(()=>s(()=>import(`./src-DZVwE2OF.js`).then(e=>e.t).then(e=>({default:e.BuilderLanding})),__vite__mapDeps([0,1]),import.meta.url));V({ref:`studio:builder`,label:`应用构建`,source:`@objectstack/console`,component:e=>(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`加载应用构建器…`}),children:(0,K.jsx)(Kr,{...e})})});var qr=(0,G.lazy)(()=>s(()=>import(`./ProfilePage-CkS1AQDC.js`).then(e=>({default:e.ProfilePage})),__vite__mapDeps([0]),import.meta.url));function Jr({label:e}){return(0,K.jsxs)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:[`Loading `,e,`…`]})}V({ref:`account:profile_card`,label:`My Profile`,source:`@objectstack/console`,component:e=>(0,K.jsx)(G.Suspense,{fallback:(0,K.jsx)(Jr,{label:`profile`}),children:(0,K.jsx)(qr,{...e})})});var Yr=`/api/v1/auth`;et(),D.registerLazy(`object-map`,()=>s(()=>import(`./plugin-map-B7RVCjPN.js`).then(e=>e.t),__vite__mapDeps([0,2]),import.meta.url),{namespace:`plugin-map`,category:`view`}),D.registerLazy(`map`,()=>s(()=>import(`./plugin-map-B7RVCjPN.js`).then(e=>e.t),__vite__mapDeps([0,2]),import.meta.url),{namespace:`view`,category:`view`}),D.registerLazy(`object-tree`,()=>s(()=>import(`./plugin-tree-Dd-qjC-G.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-tree`,category:`view`}),D.registerLazy(`tree`,()=>s(()=>import(`./plugin-tree-Dd-qjC-G.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`view`,category:`view`});for(let e of[`dashboard`,`metric`,`metric-card`,`object-metric`,`pivot`,`object-pivot`,`dashboard-grid`,`object-data-table`])D.registerLazy(e,()=>s(()=>import(`./plugin-dashboard-g6z_zZXP.js`).then(e=>e.t),__vite__mapDeps([0,1]),import.meta.url),{namespace:`plugin-dashboard`,category:`view`});D.registerLazy(`chart`,()=>s(()=>import(`./plugin-charts-8kHRsJ26.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-charts`,category:`chart`});for(let e of[`object-chart`,`bar-chart`,`pie-chart`,`donut-chart`,`radar-chart`,`scatter-chart`,`line-chart`,`area-chart`,`advanced-chart`,`chart:bar`])D.registerLazy(e,()=>s(()=>import(`./plugin-charts-8kHRsJ26.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-charts`,category:`chart`});D.registerLazy(`object-gantt`,()=>s(()=>import(`./plugin-gantt-BmusZEIw.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-gantt`,category:`view`}),D.registerLazy(`gantt`,()=>s(()=>import(`./plugin-gantt-BmusZEIw.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`view`,category:`view`}),D.registerLazy(`markdown`,()=>s(()=>import(`./plugin-markdown-hWqBbKBQ.js`).then(e=>e.n),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-markdown`,category:`display`}),D.registerLazy(`object-timeline`,()=>s(()=>import(`./plugin-timeline-BLradJ31.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-timeline`,category:`view`}),D.registerLazy(`timeline`,()=>s(()=>import(`./plugin-timeline-BLradJ31.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`view`,category:`view`}),D.registerLazy(`object-calendar`,()=>s(()=>import(`./plugin-calendar-DI8_y72D.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-calendar`,category:`view`}),D.registerLazy(`calendar`,()=>s(()=>import(`./plugin-calendar-DI8_y72D.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`view`,category:`view`}),D.registerLazy(`calendar-view`,()=>s(()=>import(`./plugin-calendar-DI8_y72D.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-calendar`,category:`view`}),D.registerLazy(`object-kanban`,()=>s(()=>import(`./plugin-kanban-DtXDjkdV.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-kanban`,category:`view`}),D.registerLazy(`kanban`,()=>s(()=>import(`./plugin-kanban-DtXDjkdV.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`view`,category:`view`});for(let e of[`kanban-ui`,`kanban-enhanced`])D.registerLazy(e,()=>s(()=>import(`./plugin-kanban-DtXDjkdV.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-kanban`,category:`view`});D.registerLazy(`report`,()=>s(()=>import(`./plugin-report-Fk8OwuMv.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-report`,category:`view`});for(let e of[`report-viewer`,`spec-report`])D.registerLazy(e,()=>s(()=>import(`./plugin-report-Fk8OwuMv.js`).then(e=>e.t),__vite__mapDeps([0]),import.meta.url),{namespace:`plugin-report`,category:`view`});ce();var Xr=``.replace(/\/+$/,``);Promise.all([pt(Xr),Dr(Yr)]).finally(()=>{document.title=B();let e=_t();if(e){let t=document.getElementById(`favicon`);t&&(t.href=e,t.type=e.endsWith(`.svg`)?`image/svg+xml`:`image/png`)}let t=vt({enabled:!0,name:B(),shortName:ft(),description:gt(),themeColor:mt(),backgroundColor:`#ffffff`,display:`standalone`,startUrl:`./`,scope:`./`,orientation:`any`,icons:[{src:e||`./favicon.svg`,sizes:`any`,type:`image/svg+xml`,purpose:`any`}]}),n=new Blob([JSON.stringify(t)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.querySelector(`link[rel="manifest"]`);i&&i.remove();let a=document.createElement(`link`);a.rel=`manifest`,a.href=r,document.head.appendChild(a),At.createRoot(document.getElementById(`root`)).render((0,K.jsx)(G.StrictMode,{children:(0,K.jsx)(yt,{pwa:{enabled:!0,name:B(),shortName:ft()},children:(0,K.jsx)(re,{loadLanguage:wr,children:(0,K.jsx)(Cr,{})})})}))});
|