import{j as e,aw as u,B as o,T as l,I as j,ax as y,ay as N,s as b}from"./index-BX768Frx.js";import{A as I}from"./alert-BrzNrLBf.js";import{T as n}from"./tag-DIbqHQC5.js";import{u as w}from"./useQuery-DHwdh6Ld.js";function C({name:s="<name>",version:a="<version>",os:t="<os>",arch:r="<arch>"}){return e.jsxs(I,{title:"Login is required to install pre-built integrations",variant:"warning",actions:e.jsx(o,{variant:"secondary",href:{to:"/login",search:{returnUrl:"/integrations"}},children:"Login"}),children:[e.jsx("p",{children:"To make your life easier, we host pre-built integrations for various systems that can be installed in one click directly from the UI (login required)."}),e.jsx("p",{className:"mt-2",children:"Alternatively, you can build and install integrations manually with the CLI."}),e.jsx("div",{className:"mt-2",children:e.jsxs(u,{title:"Build & Install integration with the CLI",children:[e.jsx(u.Command,{prompt:"$ ",command:`plakar pkg build ${s}`}),e.jsx(u.Command,{prompt:"$ ",command:`plakar pkg add ./${s}_${a}_${t}_${r}.ptar`})]})})]})}function k({stage:s}){const t={stable:"green",testing:"blue",beta:"yellow",devel:"red"}[s]??"red";return e.jsx(n,{variant:t,size:"sm",children:s})}function A({icon:s,name:a,version:t,stage:r,installationStatus:i,types:m,tags:g,description:p,documentationProps:c,onInstall:x,onRemove:f,pending:d}){return e.jsxs("div",{className:"border-primary bg-primary flex flex-col gap-4 rounded-xl border p-4",children:[e.jsxs("div",{className:"flex gap-2",children:[s&&e.jsx("div",{className:"h-14 w-14 shrink-0",children:e.jsx("img",{src:s,className:"h-full w-full object-cover object-center",alt:""})}),e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsx(l,{as:"h2",variant:"heading",weight:"medium",size:"sm",className:"text-primary leading-none break-all",children:a}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(l,{className:"text-tertiary leading-none break-all",children:t}),e.jsx(k,{stage:r})]})]}),(c!==void 0||i!=="not-installed")&&e.jsx("div",{className:"ml-auto",children:e.jsx(v,{status:i,onInstall:x,pending:d})})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[m.storage&&e.jsx(n,{variant:"heavy",radius:"sqrt",children:"Storage"}),m.source&&e.jsx(n,{variant:"heavy",radius:"sqrt",children:"Source"}),m.destination&&e.jsx(e.Fragment,{children:e.jsx(n,{variant:"heavy",radius:"sqrt",children:"Destination"})}),g.map(h=>e.jsx(n,{variant:"default",radius:"rounded",children:h},h))]}),e.jsx(l,{className:"text-secondary overflow-auto",children:p})]}),e.jsxs("div",{className:"mt-auto flex gap-2 text-center",children:[c&&e.jsx(o,{variant:"secondary",className:"flex-1",...c,children:"Read documentation"}),!c&&i==="not-installed"&&e.jsx(v,{status:i,onInstall:x,pending:d}),i==="installed"&&e.jsx(o,{variant:"tertiary",className:"flex-1",onPress:f,isDisabled:d,isPending:d,children:"Remove integration"})]})]})}function v({status:s,onInstall:a,pending:t}){return{installed:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(j,{type:"success-circle",size:"md",className:"text-accent"}),e.jsx(l,{weight:"medium",size:"sm",className:"text-accent",children:"Installed"})]}),"not-installed":e.jsx(o,{leftIcon:"download",isDisabled:!a||t,onPress:a,isPending:t,className:"w-full",children:"Install"}),"built-in":e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(j,{type:"success-circle",size:"md",className:"text-accent"}),e.jsx(l,{weight:"medium",size:"sm",className:"text-accent",children:"Built-in"})]})}[s]}function R({integration:s,installDisabled:a=!1,...t}){const r=y(),i=N();return e.jsx(A,{icon:s.icon,name:s.display_name,version:s.latest_version,stage:s.stage,installationStatus:s.installation.status,types:{source:s.types.source,destination:s.types.destination,storage:s.types.storage},tags:s.tags,description:s.description,onInstall:!a&&s.installation.available?()=>{r.mutate({integrationId:s.id,version:s.latest_version})}:void 0,onRemove:()=>{i.mutate({integrationId:s.id})},pending:r.isPending||i.isPending,...t},s.id)}function _(){return{isAuthenticated:w(b()).data!==null}}export{C as I,R as a,_ as u};
