1import{c as S,h as p,z as ae,a3 as ie,o as e,B as o,C as W,w as u}from"./index-D-GBr4OT.js";import{u as oe}from"./useQuery-BQqi4bll.js";import{u as M,A as te,T as ne}from"./AdminLayout-DPVaJfs7.js";import{C as R,b as V,c as q,d as O,a as D}from"./card-xgnto5D_.js";import{B as b}from"./badge-u3waVycK.js";import{T as le,a as ce,b as U,c,d as de,e as d}from"./table-ISi2tFx3.js";import{D as F,b as B,c as H,d as J,e as X}from"./dialog-BrYf6emB.js";import{I as v}from"./input-D6LAVBj1.js";import{L as l}from"./label-znFVWv-D.js";import{S as me,a as xe,b as he,c as pe,d as ue}from"./select-c7EgGzNU.js";import{T as je}from"./textarea-CeNghESl.js";import{S as ve}from"./switch-D_ArcsQM.js";import{A as ge,a as C,b as P,c as k}from"./accordion-BPpoAvab.js";import{S as K}from"./server-BreT6a2k.js";import{P as Q}from"./plus-DcPx_ap3.js";import{L as fe}from"./loader-circle-COluazb2.js";import{W as ye}from"./wifi-09jpmHQe.js";import{P as Ne}from"./pencil-DMkrNA1j.js";import{E as be}from"./external-link-BFoulwV1.js";import{H as G}from"./hard-drive-cU2UDrlK.js";import{M as Z}from"./monitor-DyRFLJ7U.js";import"./sidebar-DGkNvcst.js";import"./gamepad-2-Cq3c7WUI.js";import"./shopping-cart-sVwxESaO.js";import"./mail-VfMeEExt.js";import"./tag-Dzb1TaB-.js";import"./ThemeToggle-CpFdVCpJ.js";import"./index-Ch4cfzOk.js";import"./index-BdQq_4o_.js";import"./search-CPnmhyre.js";import"./index-BCaDnGsR.js";import"./chevron-down-Dx4NE3AC.js";import"./check-B7suo32t.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Ce=S("BookOpen",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const Pe=S("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const ke=S("Power",[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]]),w=[{value:"proxmox",label:"Proxmox VE",icon:G},{value:"virtualizor",label:"Virtualizor",icon:W},{value:"vmware",label:"VMware ESXi",icon:Z}],I={name:"",type:"proxmox",api_url:"",token_id:"",token_secret:"",is_active:!0,notes:""};function ts(){const[Y,m]=p.useState(!1),[x,g]=p.useState(null),[r,i]=p.useState(I),[f,j]=p.useState(null),[A,T]=p.useState(null),{toast:n}=ae(),L=ie(),{data:_=[],isLoading:$}=oe({queryKey:["hypervisor-providers"],queryFn:async()=>{const{data:s,error:a}=await u.from("hypervisor_providers").select("*").order("created_at",{ascending:!0});if(a)throw a;return s}}),y=M({mutationFn:async s=>{const{id:a,...h}=s;if(a){const{error:t}=await u.from("hypervisor_providers").update(h).eq("id",a);if(t)throw t}else{const{error:t}=await u.from("hypervisor_providers").insert(h);if(t)throw t}},onSuccess:()=>{L.invalidateQueries({queryKey:["hypervisor-providers"]}),m(!1),g(null),i(I),n({title:x?"Provedor atualizado":"Provedor adicionado"})},onError:s=>n({title:"Erro",description:s.message,variant:"destructive"})}),N=M({mutationFn:async s=>{const{error:a}=await u.from("hypervisor_providers").delete().eq("id",s);if(a)throw a},onSuccess:()=>{L.invalidateQueries({queryKey:["hypervisor-providers"]}),j(null),n({title:"Provedor removido"})},onError:s=>n({title:"Erro",description:s.message,variant:"destructive"})}),ee=s=>{g(s.id),i({name:s.name,type:s.type,api_url:s.api_url,token_id:s.token_id,token_secret:s.token_secret,is_active:s.is_active,notes:s.notes||""}),m(!0)},z=()=>{g(null),i(I),m(!0)},se=async s=>{T(s);try{const{data:{session:a}}=await u.auth.getSession(),t=await(await fetch("https://rrihdzmgfblieriotrpc.supabase.co/functions/v1/virtualizor?action=test_c
16onnection",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a==null?void 0:a.access_token}`,apikey:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InJyaWhkem1nZmJsaWVyaW90cnBjIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzA3NTM5OTIsImV4cCI6MjA4NjMyOTk5Mn0.5ul_L0-Hbw_1k1dvBLuRhe271G13mkkgL9mI-cxv0ME"},body:JSON.stringify({action:"test_connection",provider_id:s})})).json();t.success?n({title:"â
Conexão OK!",description:t.message}):n({title:"â Falha na conexão",description:t.error,variant:"destructive"})}catch(a){n({title:"Erro",description:a.message,variant:"destructive"})}finally{T(null)}},re=s=>w.find(a=>a.value===s)||w[0],E=(s=>{switch(s){case"proxmox":return{idLabel:"Token ID (ex: user@pam!token)",secretLabel:"Token Secret"};case"virtualizor":return{idLabel:"API Key",secretLabel:"API Pass"};case"vmware":return{idLabel:"Usuário (ex: root)",secretLabel:"Senha"};default:return{idLabel:"Token ID",secretLabel:"Token Secret"}}})(r.type);return e.jsx(te,{children:e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold text-foreground flex items-center gap-2",children:[e.jsx(K,{className:"w-6 h-6 text-primary"}),"Máquinas Dedicadas"]}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Gerencie seus provedores de virtualização (Proxmox, Virtualizor, VMware, etc.)"})]}),e.jsxs(o,{onClick:z,className:"gap-2",children:[e.jsx(Q,{className:"w-4 h-4"})," Adicionar Provedor"]})]}),e.jsxs(R,{children:[e.jsxs(V,{children:[e.jsx(q,{children:"Provedores Configurados"}),e.jsx(O,{children:"Adicione quantos servidores de virtualização precisar. Cada um pode ser de um tipo diferente."})]}),e.jsx(D,{children:$?e.jsx("p",{className:"text-muted-foreground text-center py-8",children:"Carregando..."}):_.length===0?e.jsxs("div",{className:"text-center py-12 space-y-3",children:[e.jsx(K,{className:"w-12 h-12 mx-auto text-muted-foreground/50"}),e.jsx("p",{className:"text-muted-foreground",children:"Nenhum provedor configurado ainda."}),e.jsxs(o,{variant:"outline",onClick:z,className:"gap-2",children:[e.jsx(Q,{className:"w-4 h-4"})," Adicionar primeiro provedor"]})]}):e.jsxs(le,{children:[e.jsx(ce,{children:e.jsxs(U,{children:[e.jsx(c,{children:"Nome"}),e.jsx(c,{children:"Tipo"}),e.jsx(c,{children:"URL da API"}),e.jsx(c,{children:"Status"}),e.jsx(c,{children:"Notas"}),e.jsx(c,{className:"text-right",children:"Ações"})]})}),e.jsx(de,{children:_.map(s=>{const a=re(s.type),h=a.icon;return e.jsxs(U,{children:[e.jsxs(d,{className:"font-medium flex items-center gap-2",children:[e.jsx(h,{className:"w-4 h-4 text-primary"}),s.name]}),e.jsx(d,{children:e.jsx(b,{variant:"secondary",children:a.label})}),e.jsx(d,{className:"text-muted-foreground text-sm max-w-[200px] truncate",children:s.api_url||"â"}),e.jsx(d,{children:s.is_active?e.jsxs(b,{className:"bg-emerald-500/10 text-emerald-500 border-emerald-500/20",children:[e.jsx(ke,{className:"w-3 h-3 mr-1"})," Ativo"]}):e.jsxs(b,{variant:"outline",className:"text-muted-foreground",children:[e.jsx(Pe,{className:"w-3 h-3 mr-1"})," Inativo"]})}),e.jsx(d,{className:"text-muted-foreground text-sm max-w-[150px] truncate",children:s.notes||"â"}),e.jsxs(d,{className:"text-right space-x-1",children:[e.jsx(o,{size:"sm",variant:"ghost",title:"Testar Conexão",disabled:A===s.id,onClick:()=>se(s.id),children:A===s.id?e.jsx(fe,{className:"w-4 h-4 animate-spin"}):e.jsx(ye,{className:"w-4 h-4"})}),e.jsx(o,{size:"sm",variant:"ghost",onClick:()=>ee(s),children:e.jsx(Ne,{className:"w-4 h-4"})}),e.jsx(o,{size:"sm",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>j(s.id),children:e.jsx(ne,{className:"w-4 h-4"})}),s.type==="proxmox"&&e.jsx(o,{size:"sm",variant:"ghost",asChild:!0,children:e.jsx("a",{href:"/admin/proxmox",className:"inline-flex items-center",children:e.jsx(be,{className:"w-4 h-4"})})})]})]},s.id)})})]})})]}),e.jsxs(R,{children:[e.jsxs(V,{children:[e.jsxs(q,{className:"flex items-center gap-2",children:[e.jsx(Ce,{className:"w-5 h-5 text-primary"}),"Como obter as credenciais"]}),e.jsx(O,{children:"Tutoriais passo a passo para cada tipo de virtualizador"})]}),e.jsx(D,{children:e.jsxs(ge,{type:"single",collapsible:!0,className:"w-full",children:[e.jsxs(C,{value:"proxmox",children:[e.jsx(P,{className:"text-base",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(G,{className:"w-4 h-4 text-primary"}),"Proxmox VE"]})}),e.jsxs(k,{className:"space-y-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"1. URL da API"}),e.jsx("p",{children:"Acesse seu painel Proxmox pelo navegador. A URL será algo como:"}),e.jsx("code",{className:"block bg-muted px-3 py-2 rounded text-xs",children:"https://seu-servidor.com:8006"}
16),e.jsxs("p",{children:["Use exatamente essa URL (com a porta ",e.jsx("strong",{children:"8006"}),")."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"2. Criar Token de API"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-2",children:[e.jsxs("li",{children:["No painel Proxmox, vá em ",e.jsx("strong",{children:"Datacenter â Permissions â API Tokens"})]}),e.jsxs("li",{children:["Clique em ",e.jsx("strong",{children:"Add"})]}),e.jsxs("li",{children:["Selecione o ",e.jsx("strong",{children:"User"})," (ex: ",e.jsx("code",{children:"root@pam"}),")"]}),e.jsxs("li",{children:["Dê um nome ao token (ex: ",e.jsx("code",{children:"lovable"}),")"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Desmarque"}),' a opção "Privilege Separation" para acesso total']}),e.jsxs("li",{children:["Clique em ",e.jsx("strong",{children:"Add"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"3. Copiar as credenciais"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-2",children:[e.jsxs("li",{children:[e.jsx("strong",{children:"Token ID:"})," Formato ",e.jsx("code",{children:"usuario@pam!nometoken"})," (ex: ",e.jsx("code",{children:"root@pam!lovable"}),")"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Token Secret:"})," Uma string UUID exibida ",e.jsx("strong",{children:"apenas uma vez"})," ao criar. Copie e guarde!"]})]}),e.jsx("div",{className:"bg-accent/50 border border-accent rounded-md p-3 mt-2",children:e.jsx("p",{className:"text-xs font-medium text-accent-foreground",children:"â ï¸ O Token Secret só é mostrado uma vez. Se perder, será necessário criar um novo token."})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"4. Requisitos"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-2",children:[e.jsxs("li",{children:["Proxmox VE versão ",e.jsx("strong",{children:"7.0 ou superior"})]}),e.jsx("li",{children:"Certificado SSL válido (Let's Encrypt recomendado)"}),e.jsx("li",{children:"Porta 8006 acessÃvel externamente"})]})]})]})]}),e.jsxs(C,{value:"virtualizor",children:[e.jsx(P,{className:"text-base",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"w-4 h-4 text-primary"}),"Virtualizor"]})}),e.jsxs(k,{className:"space-y-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"1. URL da API"}),e.jsx("p",{children:"à a URL do painel administrativo do Virtualizor:"}),e.jsx("code",{className:"block bg-muted px-3 py-2 rounded text-xs",children:"https://seu-servidor.com:4085"}),e.jsxs("p",{children:["A porta padrão do painel admin é ",e.jsx("strong",{children:"4085"})," (HTTPS) ou ",e.jsx("strong",{children:"4084"})," (HTTP)."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"2. Obter API Key e API Pass"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-2",children:[e.jsx("li",{children:"Acesse o painel admin do Virtualizor"}),e.jsxs("li",{children:["Vá em ",e.jsx("strong",{children:"Configuration â Master Settings"})]}),e.jsxs("li",{children:["Procure a seção ",e.jsx("strong",{children:"API Credentials"})]}),e.jsxs("li",{children:["Copie o ",e.jsx("strong",{children:"API Key"})," e o ",e.jsx("strong",{children:"API Pass"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"3. Alternativa via arquivo"}),e.jsx("p",{children:"As credenciais também podem ser encontradas no servidor via SSH:"}),e.jsx("code",{className:"block bg-muted px-3 py-2 rounded text-xs",children:"cat /usr/local/virtualizor/conf.php"}),e.jsxs("p",{children:["Procure pelas chaves ",e.jsx("code",{children:"key"})," e ",e.jsx("code",{children:"pass"})," no arquivo."]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"4. Requisitos"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-2",children:[e.jsxs("li",{children:["Virtualizor com ",e.jsx("strong",{children:"SSL válido"})," (Let's Encrypt)"]}),e.jsx("li",{children:"API habilitada nas configurações"}),e.jsx("li",{children:"IP do servidor Lovable liberado no firewall (se houver)"})]})]})]})]}),e.jsxs(C,{value:"vmware",children:[e.jsx(P,{className:"text-base",children:e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4 text-primary"}),"VMware ESXi"]})}),e.jsxs(k,{className:"space-y-4 text-sm text-muted-foreground",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"1. URL da API"}),e.jsx("p",{children:"à o endereço do seu host ESXi ou vCenter:"}),e.jsx("code",{className:"block bg-muted px-3 py-2 rounded text-xs",children:"https://esxi.seu-servidor.com"}),e.jsx("p",{children:"Para vCenter, use a URL do vCenter Server."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"2. Credenciais de acesso"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-2",children:[e.jsx("li",{children:"Use as credenciais de login do ESXi/vCenter"}),e.jsxs("li",{children:[e.jsx("strong",{children:"Usuário:"})," Geralmente ",e.jsx("code",{children:"root"})," (ESXi) ou ",e.jsx("code",{children:"[email protected]"})," (vCenter)"]}),e.jsxs("li",{children:[e.jsx("strong",{children:"Senha:"})," A senha definida na instalação"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"3. Habilitar API REST"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 ml-2",children:[e.jsx("li",{children:"No ESXi 7+, a API REST já vem habilitada por padrão"}),e.jsxs("li",{children:["Para vCenter, verifique se o serviço ",e.jsx("strong",{children:"vmware-vapi-endpoint"})," está ativo"]}),e.jsxs("li",{children:["Teste acessando: ",e.jsx("code",{children:"https://seu-servidor.com/api"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"font-semibold text-foreground",children:"4. Recomendações de segurança"}),e.jsxs("ul",{className:"list-disc list-inside space-y-1 ml-2",children:[e.jsxs("li",{children:["Crie um ",e.jsx("strong",{children:"usuário dedicado"})," com permissões limitadas em vez de usar root"]}),e.jsxs("li",{children:["ESXi versão ",e.jsx("strong",{children:"7.0 ou superior"})," recomendado"]}),e.jsx("li",{children:"Certificado SSL válido necessário"}),e.jsx("li",{children:"Firewall configurado para permitir acesso à API"})]})]}),e.jsx("div",{className:"bg-accent/50 border border-accent rounded-md p-3 mt-2",children:e.jsx("p",{className:"text-xs font-medium text-accent-foreground",children:"â¹ï¸ A integração com VMware ainda está em fase experimental. Funcionalidades podem ser limitadas."})})]})]})]})})]}),e.jsx(F,{open:Y,onOpenChange:m,children:e.jsxs(B,{className:"max-w-lg",children:[e.jsx(H,{children:e.jsx(J,{children:x?"Editar Provedor":"Adicionar Provedor"})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Nome do servidor"}),e.jsx(v,{placeholder:"Ex: Proxmox Principal",value:r.name,onChange:s=>i({...r,name:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Tipo de virtualização"}),e.jsxs(me,{value:r.type,onValueChange:s=>i({...r,type:s}),children:[e.jsx(xe,{children:e.jsx(he,{})}),e.jsx(pe,{children:w.map(s=>e.jsx(ue,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"URL da API"}),e.jsx(v,{placeholder:r.type==="proxmox"?"https://proxmox.exemplo.com:8006":r.type==="virtualizor"?"https://vps.exemplo.com":"https://esxi.exemplo.com",value:r.api_url,onChange:s=>i({...r,api_url:s.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:E.idLabel}),e.jsx(v,{value:r.token_id,onChange:s=>i({...r,token_id:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:E.secretLabel}),e.jsx(v,{type:"password",value:r.token_secret,onChange:s=>i({...r,token_secret:s.target.value})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{children:"Observações"}),e.jsx(je,{placeholder:"Notas internas sobre este servidor...",value:r.notes,onChange:s=>i({...r,notes:s.target.value})})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ve,{checked:r.is_active,onCheckedChange:s=>i({...r,is_active:s})}),e.jsx(l,{children:"Ativo"})]})]}),e.jsxs(X,{children:[e.jsx(o,{variant:"outline",onClick:()=>m(!1),children:"Cancelar"}),e.jsx(o,{onClick:()=>y.mutate({...r,...x?{id:x}:{}}),disabled:y.isPending||!r.name||!r.api_url,children:y.isPending?"Salvando...":x?"Atualizar":"Adicionar"})]})]})}),e.jsx(F,{open:!!f,onOpenChange:()=>j(null),children:e.jsxs(B,{children:[e.jsx(H,{children:e.jsx(J,{children:"Confirmar exclusão"})}),e.jsx("p",{className:"text-muted-foreground",children:"Tem certeza que deseja remover este provedor? Esta ação não pode ser desfeita."}),e.jsxs(X,{children:[e.jsx(o,{variant:"outline",onClick:()=>j(null),children:"Cancelar"}),e.jsx(o,{variant:"destructive",onClick:()=>f&&N.mutate(f),disabled:N.isPending,children:N.isPending?"Removendo...":"Remover"})]})]})})]})})}export{ts as default};
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.