1import{r as d,j as e}from"./query-vendor-CqOtiPNe.js";import{a as D}from"./useMarketerGuides-UOK2XUWn.js";import{x as T,D as k,O as A,B as a,p as G,q as S,r as _,b as E,f as M}from"./index-CgiuONvO.js";import{I as P}from"./input-oPoHA7Fw.js";import{B as z}from"./badge-CSzvBtO5.js";import{T as B,a as I,b as p,c as t,d as L,e as i}from"./table-CUs_AvL6.js";import{A as O,a as $,b as H,c as R,d as U,e as q,f as F,g as K}from"./alert-dialog-3FMVIuPP.js";import{S as h}from"./skeleton-B97PTBMn.js";import{a as V}from"./react-vendor-Oyj1q24G.js";import{P as f}from"./plus-DhJDBkeB.js";import{C as Y}from"./copy-B3hQhSgM.js";import{E as J}from"./external-link-DLbL3mEn.js";import{f as Q}from"./format-Ch7dQtBq.js";import{S as W}from"./square-pen-Cd8FE6iD.js";import{T as X}from"./trash-2-XdlKjO4t.js";import"./ui-vendor-C92kXd7i.js";import"./chart-vendor-De-uRwFm.js";import"./en-US-5rFTtd83.js";function fe(){const m=V(),{toast:g}=T(),{guides:x,isLoading:N,createGuide:r,deleteGuide:w}=D(),[l,u]=d.useState(""),[b,n]=d.useState(!1),[c,o]=d.useState(null),j=async()=>{if(!l.trim())return;const s=await r.mutateAsync(l);u(""),n(!1),m(`/site-admin/guides/${s.id}`)},C=s=>{const v=`https://jhasolutions.com/${s}`;navigator.clipboard.writeText(v),g({title:"URL copied to clipboard"})},y=async()=>{c&&(await w.mutateAsync(c),o(null))};return N?e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(h,{className:"h-8 w-48"}),e.jsx(h,{className:"h-10 w-32"})]}),e.jsx(h,{className:"h-64 w-full"})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Marketer Guides"}),e.jsx("p",{className:"text-muted-foreground",children:"Create guides for marketers with structured content blocks"})]}),e.jsxs(k,{open:b,onOpenChange:n,children:[e.jsx(A,{asChild:!0,children:e.jsxs(a,{children:[e.jsx(f,{className:"h-4 w-4 mr-2"}),"New Guide"]})}),e.jsxs(G,{children:[e.jsx(S,{children:e.jsx(_,{children:"Create New Guide"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsx(P,{placeholder:"Guide title...",value:l,onChange:s=>u(s.target.value),onKeyDown:s=>s.key==="Enter"&&j()}),e.jsxs(a,{onClick:j,disabled:!l.trim()||r.isPending,className:"w-full",children:[r.isPending&&e.jsx(E,{className:"h-4 w-4 mr-2 animate-spin"}),"Create Guide"]})]})]})]})]}),x.length===0?e.jsxs("div",{className:"border rounded-lg p-12 text-center",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"No guides created yet"}),e.jsxs(a,{onClick:()=>n(!0),children:[e.jsx(f,{className:"h-4 w-4 mr-2"}),"Create Your First Guide"]})]}):e.jsx("div",{className:"border rounded-lg",children:e.jsxs(B,{children:[e.jsx(I,{children:e.jsxs(p,{children:[e.jsx(t,{children:"Title"}),e.jsx(t,{children:"Status"}),e.jsx(t,{children:"Views"}),e.jsx(t,{children:"Public URL"}),e.jsx(t,{children:"Created"}),e.jsx(t,{className:"text-right",children:"Actions"})]})}),e.jsx(L,{children:x.map(s=>e.jsxs(p,{children:[e.jsx(i,{className:"font-medium",children:s.title}),e.jsx(i,{children:e.jsx(z,{variant:s.status==="published"?"default":"secondary",children:s.status})}),e.jsx(i,{children:s.views_count}),e.jsx(i,{children:s.status==="published"?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"text-xs bg-muted px-2 py-1 rounded",children:["jhasolutions.com/",s.public_code]}),e.jsx(a,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>C(s.public_code),children:e.jsx(Y,{className:"h-3 w-3"})}),e.jsx(a,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>window.open(`/${s.public_code}`,"_blank"),children:e.jsx(J,{className:"h-3 w-3"})})]}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Not published"})}),e.jsx(i,{className:"text-muted-foreground text-sm",children:Q(new Date(s.created_at),"MMM d, yyyy")}),e.jsx(i,{className:"text-right",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx(a,{variant:"ghost",size:"icon",onClick:()=>window.open(`/${s.public_code}`,"_blank"),disabled:s.status!=="published",children:e.jsx(M,{className:"h-4 w-4"})}),e.jsx(a,{variant:"ghost",size:"icon",onClick:()=>m(`/site-admin/guides/${s.id}`),children:e.jsx(W,{className:"h-4 w-4"})}),e.jsx(a,{variant:"ghost",size:"icon",onClick:()=>
1o(s.id),children:e.jsx(X,{className:"h-4 w-4"})})]})})]},s.id))})]})}),e.jsx(O,{open:!!c,onOpenChange:()=>o(null),children:e.jsxs($,{children:[e.jsxs(H,{children:[e.jsx(R,{children:"Delete Guide"}),e.jsx(U,{children:"Are you sure you want to delete this guide? This action cannot be undone."})]}),e.jsxs(q,{children:[e.jsx(F,{children:"Cancel"}),e.jsx(K,{onClick:y,children:"Delete"})]})]})})]})}export{fe as GuidesManager};
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.