1import{c as R,b as O,r,j as e,F as L,H,J as B,K as V,N as I,O as _,P as J,p as K,Q as T,R as S,I as $,V as W,i as p,W as Q,Y,u as Z,S as q,Z as E,_ as U,$ as X,a0 as ee,a1 as F,a2 as se,m as ae,a3 as le,a4 as ie,a5 as ne,a6 as te,a7 as re,a8 as ce,a9 as oe,aa as de,e as me}from"./index-CiJ62xMb.js";import{C as D,a as M,b as z,c as xe,d as he}from"./card-tXYvrq3S.js";import{D as A,u as ue,E as ge}from"./useDashboards-C-c92OsQ.js";import{T as G}from"./textarea-CBABdWKl.js";import{P as pe}from"./pencil-BBB0kO0X.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 je=R("Facebook",[["path",{d:"M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z",key:"1jg4f8"}]]);/** 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 fe=R("Music2",[["circle",{cx:"8",cy:"18",r:"4",key:"1fc0mg"}],["path",{d:"M12 18V2l7 4",key:"g04rme"}]]),Ne={meta:je,google:Y,tiktok:fe},ve=({open:f,onOpenChange:N,onCreate:u})=>{const{t:b}=O(),[i,o]=r.useState("select"),[x,j]=r.useState(null),[c,t]=r.useState(""),[h,g]=r.useState(""),[n,l]=r.useState(!1),d=x?A.find(s=>s.id===x):null,w=s=>{if(j(s),s){const m=A.find(v=>v.id===s);m&&(t(m.name),g(m.description))}else t(""),g("");o("details")},k=()=>{o("select")},P=async s=>{if(s.preventDefault(),!!c.trim()){l(!0);try{await u(c.trim(),h.trim()||void 0,x||void 0),C()}finally{l(!1)}}},C=()=>{o("select"),j(null),t(""),g("")},y=()=>{n||(C(),N(!1))},a=s=>{const m=Ne[s.icon];return e.jsx(m,{className:"h-6 w-6"})};return e.jsx(L,{open:f,onOpenChange:y,children:e.jsxs(H,{className:"sm:max-w-[600px] max-h-[85vh] flex flex-col",children:[e.jsxs(B,{className:"flex-shrink-0",children:[e.jsx(V,{children:i==="select"?"Crear nuevo panel":"Detalles del panel"}),e.jsx(I,{children:i==="select"?"Elige un template predefinido o crea un dashboard vacÃo.":x?`Basado en el template "${d==null?void 0:d.name}"`:"Crea un dashboard personalizado desde cero."})]}),i==="select"?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto py-4 space-y-4",children:[e.jsx(D,{className:"p-4 cursor-pointer transition-all hover:border-primary/50 hover:bg-accent/50",onClick:()=>w(null),children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-lg bg-muted",children:e.jsx(_,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Dashboard VacÃo"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Empieza desde cero y añade widgets manualmente"})]}),e.jsx(J,{className:"h-5 w-5 text-muted-foreground"})]})}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex-1 h-px bg-border"}),e.jsx("span",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"O usa un template"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:A.map(s=>e.jsx(D,{className:"p-4 cursor-pointer transition-all hover:border-primary/50 hover:bg-accent/50",onClick:()=>w(s.id),children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:K("p-2.5 rounded-lg",s.icon==="meta"&&"bg-blue-500/10 text-blue-600",s.icon==="google"&&"bg-red-500/10 text-red-600",s.icon==="tiktok"&&"bg-zinc-500/10 text-zinc-600"),children:a(s)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"flex items-center gap-2 mb-1",children:e.jsx("p",{className:"font-medium truncate",children:s.name})}),e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.description}),e.jsxs(T,{variant:"secondary",className:"mt-2",children:[s.widgets.length," widgets"]})]})]})},s.id))})]})}):e.jsxs("form",{onSubmit:P,className:"flex flex-col flex-1 min-h-0",children:[e.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto py-4 space-y-4 pb-6",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"name",children:"Nombre del panel"}),e.jsx($,{id:"name",value:c,onChange:s=>t(s.target.value),placeholder:"Mi panel de métricas",disabled:n})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"description",children:"Descripción (opcional)"}),e.jsx(G,{id:"description",value:h,onChange:s=>g(s.target.value),placeholder:b("widget.panelDescPlaceholder","Panel para monitorear el rendimiento de campañas..."),rows:3,disabled:n})]}),d&&e.jsxs("div",{className:"rounded-lg border bg-muted/50 p-4",children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Widgets incluidos:"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.widgets.map((s,m)=>e.jsx(T,{variant:"outline",children:s.title},m))})]})]}),e.jsxs(W,{className:"flex-shrink-0 border-t pt-4",children:[e.jsxs(p,{type:"button",variant:"ghost",onClick:k,disabled:n,className:"mr-auto",children:[e.jsx(Q,{className:"mr-2 h-4 w-4"}),"Atrás"]}),e.jsx(p,{type:"button",variant:"outline",onClick:y,disabled:n,children:"Cancelar"}),e.jsx(p,{type:"submit",disabled:!c.trim()||n,children:n?"Creando...":"Crear panel"})]})]})]})})},be=({open:f,onOpenChange:N,dashboard:u,onRename:b})=>{const{t:i}=O(),[o,x]=r.useState(""),[j,c]=r.useState(""),[t,h]=r.useState(!1);r.useEffect(()=>{u&&(x(u.name),c(u.description||""))},[u]);const g=async l=>{if(l.preventDefault(),!!o.trim()){h(!0);try{await b(o.trim(),j.trim()||void 0)}finally{h(!1)}}},n=()=>{t||N(!1)};
11return e.jsx(L,{open:f,onOpenChange:n,children:e.jsxs(H,{className:"sm:max-w-[425px]",children:[e.jsxs(B,{children:[e.jsx(V,{children:i("widget.editPanel")}),e.jsx(I,{children:i("widget.editPanelDesc")})]}),e.jsxs("form",{onSubmit:g,children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"rename-name",children:i("widget.panelName")}),e.jsx($,{id:"rename-name",value:o,onChange:l=>x(l.target.value),placeholder:i("widget.panelNamePlaceholder"),disabled:t})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(S,{htmlFor:"rename-description",children:i("widget.panelDescLabel")}),e.jsx(G,{id:"rename-description",value:j,onChange:l=>c(l.target.value),placeholder:i("widget.panelDescPlaceholder"),rows:3,disabled:t})]})]}),e.jsxs(W,{children:[e.jsx(p,{type:"button",variant:"outline",onClick:n,disabled:t,children:i("common.cancel")}),e.jsx(p,{type:"submit",disabled:!o.trim()||t,children:i(t?"common.saving":"common.saveChanges")})]})]})]})})},ke=()=>{const f=Z(),{dashboards:N,loading:u,createDashboard:b,createDashboardFromTemplate:i,updateDashboard:o,deleteDashboard:x}=ue(),[j,c]=r.useState(!1),[t,h]=r.useState(!1),[g,n]=r.useState(!1),[l,d]=r.useState(null),w=async(a,s,m)=>{let v;m?v=await i(a,s,m):v=await b(a,s),v&&(c(!1),f(`/dashboards/${v.id}`))},k=async(a,s)=>{l&&(await o(l.id,{name:a,description:s}),h(!1),d(null))},P=async()=>{l&&(await x(l.id),n(!1),d(null))},C=a=>{d(a),h(!0)},y=a=>{d(a),n(!0)};return e.jsxs("div",{className:"flex min-h-screen bg-background",children:[e.jsx(q,{}),e.jsxs("main",{className:"flex-1 p-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-10",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-semibold text-foreground tracking-tight",children:"Paneles"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Crea dashboards personalizados con métricas de tus campañas"})]}),e.jsxs(p,{onClick:()=>c(!0),className:"gap-2",children:[e.jsx(E,{size:18}),"Nuevo Panel"]})]}),u?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[1,2,3].map(a=>e.jsxs(D,{className:"glass animate-pulse",children:[e.jsxs(M,{children:[e.jsx("div",{className:"h-6 bg-muted rounded w-3/4"}),e.jsx("div",{className:"h-4 bg-muted rounded w-1/2 mt-2"})]}),e.jsx(z,{children:e.jsx("div",{className:"h-4 bg-muted rounded w-1/3"})})]},a))}):N.length===0?e.jsx(D,{className:"glass border-dashed border-white/[0.06]",children:e.jsxs(z,{className:"flex flex-col items-center justify-center py-16",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-muted flex items-center justify-center mb-4",children:e.jsx(_,{size:32,className:"text-muted-foreground"})}),e.jsx("h3",{className:"text-xl font-semibold text-foreground mb-2",children:"No tienes paneles aún"}),e.jsx("p",{className:"text-muted-foreground text-center max-w-md mb-6",children:"Crea tu primer panel personalizado para visualizar las métricas más importantes de tus campañas."}),e.jsxs(p,{onClick:()=>c(!0),className:"gap-2",children:[e.jsx(E,{size:18}),"Crear mi primer panel"]})]})}):e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:N.map(a=>e.jsxs(D,{className:"glass cursor-pointer hover:border-white/[0.12] transition-all duration-200 group",onClick:()=>f(`/dashboards/${a.id}`),children:[e.jsxs(M,{className:"flex flex-row items-start justify-between space-y-0",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx(xe,{className:"text-lg truncate",children:a.name}),a.description&&e.jsx(he,{className:"mt-1 line-clamp-2",children:a.description})]}),e.jsxs(U,{children:[e.jsx(X,{asChild:!0,onClick:s=>s.stopPropagation(),children:e.jsx(p,{variant:"ghost",size:"icon",className:"opacity-0 group-hover:opacity-100 transition-opacity h-8 w-8",children:e.jsx(ge,{size:16})})}),e.jsxs(ee,{align:"end",children:[e.jsxs(F,{onClick:s=>{s.stopPropagation(),C(a)},children:[e.jsx(pe,{size:14,className:"mr-2"}),"Renombrar"]}),e.jsxs(F,{onClick:s=>{s.stopPropagation(),y(a)},className:"text-destructive focus:text-destructive",children:[e.jsx(se,{size:14,className:"mr-2"}),"Eliminar"]})]})]})]}),e.jsx(z,{children:e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Creado"," ",ae(new Date(a.created_at),{addSuffix:!0,locale:me})]})})]},a.id))}),e.jsx(ve,{open:j,onOpenChange:c,onCreate:w}),e.jsx(be,{open:t,onOpenChange:h,dashboard:l,onRename:k}),e.jsx(le,{open:g,onOpenChange:n,children:e.jsxs(ie,{children:[e.jsxs(ne,{children:[e.jsx(te,{children:"¿Eliminar panel?"}),e.jsxs(re,{children:['Se eliminará "',l==null?void 0:l.name,'" y todos sus widgets. Esta acción no se puede deshacer.']})]}),e.jsxs(ce,{children:[e.jsx(oe,{children:"Cancelar"}),e.jsx(de,{onClick:P,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Eliminar"})]})]})})]})]})};export{ke 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.