import{cx as p,j as e,ao as g,aa as f,bL as h,r as d,aJ as j,ah as t,cy as N,cz as w,c as v,ae as y,aG as C,y as b}from"./index-CfKY7XrC.js";function _(){const{owner:o,connectorKey:c}=p.useParams();return e.jsx(g,{owner:o,tabSegment:"connectors",title:"Connectors",headless:!0,children:({ownerSlug:r,organizationId:s,isWorkspaceLoading:a})=>e.jsx(L,{ownerSlug:r,organizationId:s,isWorkspaceLoading:a,connectorKey:c})})}function L({ownerSlug:o,organizationId:c,isWorkspaceLoading:r,connectorKey:s}){const{data:a=[],isLoading:n}=f(c??""),{data:i=[],isLoading:x}=h(c??"",{connectorKey:s}),l=d.useMemo(()=>a.find(u=>u.key===s),[a,s]),m=d.useMemo(()=>j(s,a,{name:i[0]?.connector_name??s}),[s,a,i]);return r||n?e.jsx("div",{className:"px-4 py-6 lg:px-6",children:e.jsxs("div",{className:"max-w-2xl space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(t,{className:"h-6 w-6 rounded"}),e.jsx(t,{className:"h-5 w-40"})]}),e.jsx(t,{className:"h-16 w-full rounded-lg"}),e.jsx(t,{className:"h-14 w-full rounded-lg"}),e.jsx(t,{className:"h-24 w-full rounded-lg"}),e.jsx(t,{className:"h-24 w-full rounded-lg"})]})}):e.jsx("div",{className:"px-4 py-6 lg:px-6",children:e.jsxs("div",{className:"max-w-2xl space-y-6",children:[l?e.jsx(N,{connector:l}):e.jsxs("div",{className:"space-y-3",children:[e.jsx(w,{connector:m,showDescription:!1,className:"gap-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["This connector isn't installed in this workspace, so its details aren't available.",i.length>0?" Existing connections still appear below.":""]})]}),e.jsx(k,{ownerSlug:o,connectorKey:s,connections:i,isLoading:x})]})})}function k({ownerSlug:o,connectorKey:c,connections:r,isLoading:s}){const a=v();return s?e.jsxs("div",{className:"space-y-2",children:[e.jsx(t,{className:"h-4 w-24"}),e.jsx(t,{className:"h-16 w-full rounded-lg"})]}):r.length===0?e.jsx(y,{icon:C,title:"No connections yet",description:"Add a connection to start pulling data from this source into your workspace.",actionLabel:"Add connection",onAction:()=>a({to:"/$owner/connectors/create",params:{owner:o}})}):e.jsxs("div",{className:"space-y-2",children:[e.jsx("span",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Connections"}),e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:r.map(n=>e.jsxs(b,{to:"/$owner/connectors/$connectorKey/$connectionId",params:{owner:o,connectorKey:c,connectionId:String(n.id)},className:"flex h-full flex-col gap-2 rounded-lg bg-card p-3 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[e.jsx("span",{className:"truncate text-sm font-medium",children:n.display_name??n.connector_name??n.connector_key}),e.jsxs("span",{className:"mt-auto text-xs text-muted-foreground",children:[n.feed_count," ",n.feed_count===1?"feed":"feeds"]})]},n.id))})]})}export{_ as component};
