1import{j as e,a3 as H,V as S,B as M,$ as J,t as x,c as g,h as Q,k as O,C as N,l as C,m as w,n as F,d as k,a1 as W,I as Y,L as D,F as Z,J as o}from"./index-JdcCQ3sc.js";import{u as _,C as q,a as X,b as P,D as ee,c as se,S as te,v as ae,d as ce,s as ne,K as ie,P as oe}from"./sortable.esm-Sx6935Df.js";import{S as $}from"./switch-m_ZptmEK.js";import{G as re}from"./grip-vertical-CWnyDXD1.js";import{A as le}from"./arrow-left-BGv2wG4i.js";function de({coin:s,onToggleFeatured:u,onToggleActive:p,onRemove:v,isRemoving:A}){const{attributes:j,listeners:f,setNodeRef:l,transform:b,transition:n,isDragging:r}=_({id:s.coinId}),h={transform:q.Transform.toString(b),transition:n,opacity:r?.5:1};return e.jsxs("div",{"data-loc":"client/src/components/SortableMemecoinItem.tsx:48",ref:l,style:h,className:"flex items-center gap-4 p-4 rounded-lg border border-border/50 bg-card/50",children:[e.jsx("div",{"data-loc":"client/src/components/SortableMemecoinItem.tsx:53",...j,...f,className:"cursor-grab active:cursor-grabbing",children:e.jsx(re,{"data-loc":"client/src/components/SortableMemecoinItem.tsx:58",className:"h-5 w-5 text-muted-foreground"})}),s.imageUrl&&e.jsx("img",{"data-loc":"client/src/components/SortableMemecoinItem.tsx:62",src:s.imageUrl,alt:s.coinName,className:"h-10 w-10 rounded-full object-cover"}),e.jsxs("div",{"data-loc":"client/src/components/SortableMemecoinItem.tsx:69",className:"flex-1 min-w-0",children:[e.jsxs("div",{"data-loc":"client/src/components/SortableMemecoinItem.tsx:70",className:"flex items-center gap-2",children:[e.jsx("h3",{"data-loc":"client/src/components/SortableMemecoinItem.tsx:71",className:"font-semibold",children:s.coinName}),e.jsx("span",{"data-loc":"client/src/components/SortableMemecoinItem.tsx:72",className:"text-sm text-muted-foreground",children:s.symbol}),s.isFeatured===1&&e.jsx(H,{"data-loc":"client/src/components/SortableMemecoinItem.tsx:74",className:"h-4 w-4 text-yellow-500 fill-yellow-500"})]}),e.jsx("p",{"data-loc":"client/src/components/SortableMemecoinItem.tsx:77",className:"text-sm text-muted-foreground truncate",children:s.contractAddress})]}),e.jsxs("div",{"data-loc":"client/src/components/SortableMemecoinItem.tsx:82",className:"flex items-center gap-4",onClick:d=>d.stopPropagation(),children:[e.jsxs("div",{"data-loc":"client/src/components/SortableMemecoinItem.tsx:83",className:"flex items-center gap-2",children:[e.jsx(S,{"data-loc":"client/src/components/SortableMemecoinItem.tsx:84",htmlFor:`featured-${s.coinId}`,className:"text-sm",children:"Featured"}),e.jsx($,{"data-loc":"client/src/components/SortableMemecoinItem.tsx:87",id:`featured-${s.coinId}`,checked:s.isFeatured===1,onCheckedChange:()=>u(s.coinId,s.isFeatured===1?1:0)})]}),e.jsxs("div",{"data-loc":"client/src/components/SortableMemecoinItem.tsx:96",className:"flex items-center gap-2",children:[e.jsx(S,{"data-loc":"client/src/components/SortableMemecoinItem.tsx:97",htmlFor:`active-${s.coinId}`,className:"text-sm",children:"Active"}),e.jsx($,{"data-loc":"client/src/components/SortableMemecoinItem.tsx:100",id:`active-${s.coinId}`,checked:s.isActive===1,onCheckedChange:()=>p(s.coinId,s.isActive===1?1:0)})]}),e.jsx(M,{"data-loc":"client/src/components/SortableMemecoinItem.tsx:109",variant:"destructive",size:"sm",onClick:d=>{d.stopPropagation(),v(s.coinId,s.coinName)},disabled:A,children:e.jsx(J,{"data-loc":"client/src/components/SortableMemecoinItem.tsx:118",className:"h-4 w-4"})})]})]})}function Ae(){const s=x.useUtils(),[u,p]=g.useState(""),[v,A]=g.useState(!1),[j,f]=g.useState(null),{data:l,isLoading:b}=x.memecoins.getAllAdmin.useQuery(void 0),[n,r]=g.useState([]),h=g.useRef(!1);g.useEffect(()=>{l&&!h.current&&r(l)},[l]);const d=x.memecoins.addMemecoin.useMutation({onSuccess:()=>{s.memecoins.getAllAdmin.invalidate()}}),L=x.memecoins.removeMemecoin.useMutation({onSuccess:()=>{s.memecoins.getAllAdmin.invalidate()}}),R=x.memecoins.toggleFeatured.useMutation({onSuccess:()=>{s.memecoins.getAllAdmin.invalidate()}}),T=x.memecoins.toggleActive.useMutation({onSuccess:()=>{s.memecoins.getAllAdmin.invalidate()}}),E=x.memecoins.reorderAll.useMutation(),G=X(P(oe),P(ie,{coordinateGetter:ne})),V=async t=>{const{active:i,over:a}=t;if(!a||i.id===a.id||!n)return;const c=n.findIndex(m=>m.coinId===i.id),y=n.findIndex(m=>m.coinId===a.id);if(c===-1||y===-1)return;const I=ce(n,c,y);h.current=!0,r(I),s.memecoins.getAllAdmin.setData(void 0,I);try{await E.mutateAsync({coinIds:I.map(m=>m.coinId)}),o.success("Volgorde opgeslagen")}catch(m){o.error(`Failed to reorder: ${m.message||"An error occurred"}`),s.memecoins.getAllAdmin.setData(void 0,l),r(l||[])}finally{h.current=!1}},B=async()=>
1{if(!u.trim()){o.error("Please provide a contract address");return}try{await d.mutateAsync({contractAddress:u}),o.success("Memecoin added successfully"),p(""),A(!1)}catch(t){o.error(`Failed to add memecoin: ${t.message||"An error occurred"}`)}},K=async(t,i)=>{if(confirm(`Are you sure you want to remove ${i}?`)){r(a=>a.filter(c=>c.coinId!==t)),f(t);try{await L.mutateAsync({coinId:t}),o.success(`${i} removed`)}catch(a){o.error(`Failed to remove: ${a.message||"An error occurred"}`),s.memecoins.getAllAdmin.invalidate()}finally{f(null)}}},U=async(t,i)=>{r(a=>a.map(c=>c.coinId===t?{...c,isFeatured:i===0?1:0}:c));try{await R.mutateAsync({coinId:t,isFeatured:i===0})}catch(a){o.error(`Failed to update featured status: ${a.message||"An error occurred"}`),s.memecoins.getAllAdmin.invalidate()}},z=async(t,i)=>{r(a=>a.map(c=>c.coinId===t?{...c,isActive:i===0?1:0}:c));try{await T.mutateAsync({coinId:t,isActive:i===0})}catch(a){o.error(`Failed to update active status: ${a.message||"An error occurred"}`),s.memecoins.getAllAdmin.invalidate()}};return e.jsxs("div",{"data-loc":"client/src/pages/AdminMemecoins.tsx:169",className:"min-h-screen bg-background flex flex-col",children:[e.jsx(Q,{"data-loc":"client/src/pages/AdminMemecoins.tsx:170"}),e.jsx("main",{"data-loc":"client/src/pages/AdminMemecoins.tsx:172",className:"flex-1",children:e.jsxs("div",{"data-loc":"client/src/pages/AdminMemecoins.tsx:173",className:"container py-8",children:[e.jsxs("div",{"data-loc":"client/src/pages/AdminMemecoins.tsx:174",className:"mb-8",children:[e.jsx(O,{"data-loc":"client/src/pages/AdminMemecoins.tsx:175",href:"/admin",children:e.jsxs(M,{"data-loc":"client/src/pages/AdminMemecoins.tsx:176",variant:"ghost",size:"sm",className:"mb-2",children:[e.jsx(le,{"data-loc":"client/src/pages/AdminMemecoins.tsx:177",className:"w-4 h-4 mr-2"}),"Back to Admin"]})}),e.jsx("h1",{"data-loc":"client/src/pages/AdminMemecoins.tsx:181",className:"text-4xl font-bold mb-2",children:"Memecoin Management"}),e.jsx("p",{"data-loc":"client/src/pages/AdminMemecoins.tsx:182",className:"text-muted-foreground",children:"Add, remove, and manage memecoins displayed on the platform"})]}),e.jsxs(N,{"data-loc":"client/src/pages/AdminMemecoins.tsx:188",className:"mb-8",children:[e.jsxs(C,{"data-loc":"client/src/pages/AdminMemecoins.tsx:189",children:[e.jsx(w,{"data-loc":"client/src/pages/AdminMemecoins.tsx:190",children:"Add New Memecoin"}),e.jsx(F,{"data-loc":"client/src/pages/AdminMemecoins.tsx:191",children:"Enter the contract address. All data will be fetched automatically from DexScreener."})]}),e.jsx(k,{"data-loc":"client/src/pages/AdminMemecoins.tsx:195",children:v?e.jsxs("div",{"data-loc":"client/src/pages/AdminMemecoins.tsx:202",className:"space-y-4",children:[e.jsxs("div",{"data-loc":"client/src/pages/AdminMemecoins.tsx:203",children:[e.jsx(S,{"data-loc":"client/src/pages/AdminMemecoins.tsx:204",htmlFor:"contractAddress",children:"Contract Address"}),e.jsx(Y,{"data-loc":"client/src/pages/AdminMemecoins.tsx:205",id:"contractAddress",placeholder:"e.g., 3oQwNvAfZMuPWjVPC12ukY7RPA9JiGwLod6Pr4Lkpump",value:u,onChange:t=>p(t.target.value)}),e.jsx("p",{"data-loc":"client/src/pages/AdminMemecoins.tsx:211",className:"text-xs text-muted-foreground mt-1",children:"Coin name and details will be automatically fetched from DexScreener"})]}),e.jsxs("div",{"data-loc":"client/src/pages/AdminMemecoins.tsx:215",className:"flex gap-2",children:[e.jsxs(M,{"data-loc":"client/src/pages/AdminMemecoins.tsx:216",onClick:B,disabled:d.isPending,className:"flex-1",children:[d.isPending&&e.jsx(D,{"data-loc":"client/src/pages/AdminMemecoins.tsx:221",className:"h-4 w-4 mr-2 animate-spin"}),"Add Memecoin"]}),e.jsx(M,{"data-loc":"client/src/pages/AdminMemecoins.tsx:224",variant:"outline",onClick:()=>{A(!1),p("")},children:"Cancel"})]})]}):e.jsxs(M,{"data-loc":"client/src/pages/AdminMemecoins.tsx:197",onClick:()=>A(!0),className:"w-full",children:[e.jsx(W,{"data-loc":"client/src/pages/AdminMemecoins.tsx:198",className:"h-4 w-4 mr-2"}),"Add Memecoin"]})})]}),e.jsxs(N,{"data-loc":"client/src/pages/AdminMemecoins.tsx:240",children:[e.jsxs(C,{"data-loc":"client/src/pages/AdminMemecoins.tsx:241",children:[e.jsxs(w,{"data-loc":"client/src/pages/AdminMemecoins.tsx:242",children:["Current Memecoins (",n?.length||0,")"]}),e.jsx(F,{"data-loc":"client/src/pages/AdminMemecoins.tsx:243",children:"Drag to reorder. Toggle featured/active status or remove coins."})]}),e.jsx(k,{"data-loc":"client/src/pages/AdminMemecoins.tsx:247",children:b?e.jsx("div",{"data-loc":"client/src/pages/AdminMemecoins.tsx:249",className:"flex items-center justify-center py-12",children:e.jsx(D,{"data-loc":"client/src/pages/AdminMemecoins.tsx:250",className:"h-8 w-8 animate-spin text-primary"})}):n&&n.length>0?e.jsx(ee,{"data-loc":"client/src/pages/AdminMemecoins.tsx:253",sensors:G,collisionDetection:se,onDragEnd:V,children:e.jsx(te,{"data-loc":"client/src/pages/AdminMemecoins.tsx:258",items:n.map(t=>t.coinId),strategy:ae,children:e.jsx("div",{"data-loc":"client/src/pages/AdminMemecoins.tsx:262",className:"space-y-3",children:n.map(t=>e.jsx(de,{"data-loc":"client/src/pages/AdminMemecoins.tsx:264",coin:t,onToggleFeatured:U,onToggleActive:z,onRemove:K,isRemoving:j===t.coinId},t.coinId))})})}):e.jsx("div",{"data-loc":"client/src/pages/AdminMemecoins.tsx:277",className:"text-center py-12 text-muted-foreground",children:'No memecoins added yet. Click "Add Memecoin" to get started.'})})]})]})}),e.jsx(Z,{"data-loc":"client/src/pages/AdminMemecoins.tsx:286",onFeedbackClick:()=>window.open("https://help.manus.im","_blank")})]})}export{Ae 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.