1import{p as s,A as e,a}from"./chunk-6CSD65Y2-xYubHBmU.js";import{bd as t,cl as l,q as i,B as n,bE as c,h as r,G as o,cj as m,dF as d,dG as x}from"./CoreLayout-V9PVLCM0.js";import{W as p}from"./WorkspaceMenu-DuxeUjKB.js";import{U as u,P as h}from"./USTALogo-P-ie0qNe.js";import{A as j}from"./AccountSelector-BUcIR6dl.js";import{I as f}from"./voiceStore-D_K9cjIr.js";import{u as g,I as N}from"./useAvailableCockpits-CqJr96iI.js";import{L as b}from"./loader-circle-Mux4UJzI.js";import{C as v}from"./index-BcwKVuK3.js";import"./overlayFocus-BmDVzTk_.js";import"./AuthContextDefinition-CrUuQ85U.js";import"./createLucideIcon-B7UGDY3i.js";import"./index-BfJR_dAR.js";import"./user-BccZgP0Q.js";import"./AdminRoute-YaPmKRZJ.js";import"./command-C0bc47YX.js";import"./index-ATyz5JdO.js";const k={briefcase:l,headphones:t};function w(s){return 0===s.length?"â":s.length<=3?s.join(", "):`${s.slice(0,3).join(", ")} +${s.length-3}`}const y=({cockpit:e,installation:a,activating:t,onInstall:m,onOpen:d,onActivate:x,onUninstall:p})=>{const u=k[e.branding.iconId]||l,h=e.branding.accentColor,j=!!a,g=!1===a?.enabled||"disabled"===a?.lifecycle_state,N="dormant"===a?.lifecycle_state,b=(a?._uninstallPreview.connectedIntegrations??0)>0,v=a?.lifecycle_state?a.lifecycle_state.replace(/_/g," "):null;return s.jsxs("article",{"data-ui":"card",className:"flex flex-col rounded-xl border bg-card p-4","aria-label":`${e.displayName} cockpit card`,children:[s.jsxs("header",{className:"flex items-center gap-3 mb-3",children:[s.jsx("div",{className:"ui-icon-tile",style:{backgroundColor:`${h}1A`},children:s.jsx(u,{className:"h-5 w-5",style:{color:h}})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h2",{"data-ui":"card-title",className:"line-clamp-2 text-foreground",children:e.displayName}),s.jsx("p",{className:"text-xs uppercase tracking-wider text-muted-foreground",children:e.aclMode.replace(/_/g," ")})]})]}),s.jsx("p",{className:"max-w-[60ch] text-sm text-muted-foreground mb-4 flex-1",children:e.description}),s.jsxs("dl",{className:"text-xs space-y-1 mb-4",children:[s.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-baseline sm:gap-2",children:[s.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Signal sources:"}),s.jsx("dd",{className:"min-w-0 break-words text-foreground",children:w(e.signalSources)})]}),s.jsxs("div",{className:"flex flex-col gap-1 sm:flex-row sm:items-baseline sm:gap-2",children:[s.jsx("dt",{className:"text-muted-foreground shrink-0",children:"Produces:"}),s.jsx("dd",{className:"min-w-0 break-words text-foreground",children:w(e.assetTypes)})]})]}),s.jsxs("footer",{className:"grid grid-cols-2 items-center gap-2 sm:flex sm:flex-wrap sm:justify-end [&>button]:min-h-11 sm:[&>button]:min-h-0",children:[j&&v?s.jsx(i,{variant:g?"outline":"secondary",className:"col-span-2 justify-self-start text-xs capitalize",children:v}):null,j?g?s.jsxs(n,{size:"sm",className:"col-span-2",onClick:()=>m(e),children:[s.jsx(c,{className:"h-3.5 w-3.5"}),"Reinstall"]}):s.jsxs(s.Fragment,{children:[N?s.jsxs(n,{size:"sm",className:"col-span-2",onClick:()=>a&&x?.(a),disabled:!b||t,title:b?void 0:"Connect a matching channel first",children:[s.jsx(r,{className:"h-3.5 w-3.5"}),"Activate"]}):null,s.jsxs(n,{size:"sm",variant:"outline",onClick:()=>d?.(e),disabled:!d,children:[s.jsx(f,{className:"h-3.5 w-3.5"}),"Manage"]}),a&&p?s.jsxs(n,{size:"sm",variant:"outline",onClick:()=>p(a),children:[s.jsx(o,{className:"h-3.5 w-3.5"}),"Uninstall"]}):null]}):s.jsx(n,{size:"sm",className:"col-span-2",onClick:()=>m(e),children:"Install"})]})]})},C=()=>{const t=e(),l=g(),i=m(),c=d(),[r,o]=a.useState(null),[f,k]=a.useState(null),w=a.useMemo(()=>new Map((i.data?.installations??[]).map(s=>[s.cockpit_id,s])),[i.data]),C=s=>{t(`/core/cockpits/${s.cockpitId}`)},_=l.data?.cockpits??[];return s.jsxs("div",{className:"h-dvh flex flex-col bg-[hsl(var(--background))]",children:[s.jsx("div",{className:"border-b bg-[hsl(var(--muted))] shrink-0",children:s.jsx("div",{className:"max-w-[1400px] mx-auto px-4 py-3 sm:px-6 sm:py-4",children:s.jsxs("div",{className:"grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-2 sm:flex sm:gap-3",children:[s.jsx(u,{size:"md"}),s.jsx("div",{className:"min-w-0 [&_button]:h-11 sm:[&_button]:h-9",children:s.jsx(p,{currentPage:"cockpits"})}),s.jsx("div",{className:"justify-self-end sm:ml-auto [&_button]:h-11 [&_button]:w-11 sm:[&_button]:h-9 sm:[&_button]:w-9",children:s.jsx(h,{})})]})})}),s.jsx("div",{className:"min-h-0 flex-1 overflow-auto",children:s.jsxs("div",{className:"max-w-[1400px] mx-auto px-4 py-4 sm:px-6 sm:py-6",children:[s.jsxs("div",{className:"mb-4",children:[s.jsx("h1",{className:"text-2xl font-semibold text-foreground",children:"Cockpits"}),s.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Install, activate, manage, or reinstall workspace cockpits."})]}),s.jsx("div",{className:"mb-4",children:s.jsx(j,{className:"h-11 w-full max-w-full border-input bg-background sm:w-auto
1sm:max-w-[320px] [&>span]:text-sm"})}),l.isLoading?s.jsx("div",{className:"flex items-center justify-center h-64",children:s.jsx(b,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):l.error?s.jsxs("div",{role:"alert",className:"flex flex-col items-center justify-center h-64 p-6",children:[s.jsx(v,{className:"h-12 w-12 text-destructive mb-2"}),s.jsx("p",{className:"text-sm text-destructive mb-2",children:"Failed to load cockpit marketplace"}),s.jsx(n,{variant:"outline",size:"sm",onClick:()=>{l.refetch()},children:"Retry"})]}):0===_.length?s.jsx("p",{className:"text-sm text-muted-foreground",children:"No cockpits available."}):s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:_.map(e=>s.jsx(y,{cockpit:e,installation:w.get(e.cockpitId),activating:c.isPending&&c.variables===e.cockpitId,onInstall:o,onOpen:C,onActivate:s=>{(async s=>{await c.mutateAsync(s.cockpit_id),i.refetch()})(s)},onUninstall:k},e.cockpitId))}),s.jsx(N,{open:null!==r,onOpenChange:s=>!s&&o(null),cockpit:r,onInstalled:s=>{o(null),i.refetch()}}),s.jsx(x,{open:null!==f,onOpenChange:s=>!s&&k(null),installation:f,onUninstalled:()=>{k(null),i.refetch()}})]})})]})};export{C as CockpitMarketplacePage};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.