1import{az as xe,r as x,u as H,v as $,j as e,k as D,h as b,d as be,q as X}from"./index-B6IjSzbS.js";import{H as ue}from"./Helmet-CN5HmP3L.js";import{a as T}from"./clerkAuthCompat-BqKaW5zj.js";import{p as je}from"./footerBadgeSnippet-BhhN279I.js";import{b as fe,F as ve}from"./footerBadgePrompt-DAkqi39h.js";import{A as ye}from"./AdminLayout-Lyy3mgbV.js";import{C as N,b as R,c as M,d as O,a as w}from"./card-CWmGXRr5.js";import{I as c}from"./input-BqW_EB-M.js";import{L as o}from"./label-6_Rv8CCf.js";import{u as ne}from"./use-toast-rC9HZ8yd.js";import{C as le}from"./chevron-left-N4n5feeA.js";import{C as de}from"./chevron-right-DgFj5aeb.js";import{C as Ne}from"./copyable-block-Bq2WWFsH.js";import{A as we,a as ze,b as Ce,c as Se,d as Ae,e as Ie,f as Ee,g as Fe}from"./alert-dialog-M_gdBJhT.js";import{B as ke}from"./badge-KLfy-OQo.js";import{S as De}from"./switch-DCaTAYxy.js";import{T as Pe}from"./textarea-CA1aXAc4.js";import{L as Le}from"./link-2--VzFFFPC.js";import{S as $e}from"./save-ChktZzMK.js";import{R as Te}from"./rotate-ccw-BKc2vdpz.js";import{P as Be,T as _e}from"./project-bookmark-button-c0_GoVOJ.js";import"./index-BKOoB7Mj.js";import"./index-CygqUEXr.js";import"./AuthenticatedApp-G4Xy2ifS.js";import"./user-profile-context-C07Hgz7o.js";import"./dialog-CWqm6uiq.js";import"./avatar-BPYJaHTR.js";import"./circle-alert-DB9qxBsc.js";import"./use-lighthouse-visibility-D5oWPW5g.js";import"./dropdown-menu-CyRl8HLd.js";import"./index-DYiEhNDv.js";import"./index-Cm3YmJDm.js";import"./index-D9EgYhml.js";import"./index-BC24ygWy.js";import"./check-DXeUfKTQ.js";import"./public-more-navigation-D4MwOVzo.js";import"./credits-checkout-analytics-BWsGFPpl.js";import"./circle-check-B7j2YiQg.js";import"./reply-CfSc8g0H.js";import"./arrow-left-CYD9a-Sw.js";import"./triangle-alert-BPm6id8e.js";import"./scroll-area-BPxxcVr0.js";import"./index-BdQq_4o_.js";import"./image-popup-modal-B2vioOHd.js";import"./waitForSession-CPWyU8Ap.js";import"./useMissionsFeatureFlag-DKHnWJTI.js";import"./useAiReviewFeatureFlag-NtPum-w_.js";import"./vibe-duel-Cidb3idU.js";import"./useBuilderStoriesFeatureFlag-BnXFgo1K.js";import"./useProjectPageFeatureFlags-CfDTW5EE.js";import"./ChatContext-BOW0J341.js";import"./user-yE6YPkvu.js";import"./external-link-Dz-JD35g.js";import"./award-cMrVIa8S.js";import"./folder-kanban-bjVmndYl.js";import"./popover-qs66ff-8.js";import"./formatDistanceToNow-BZCDZp8w.js";import"./en-US-4RaJY4CL.js";import"./download-Dcsn3I-F.js";import"./emoji-picker-BDAzwoGN.js";import"./search-Dxm3JS0s.js";import"./image-DF_6eEfa.js";import"./video-B-Tg-pnQ.js";import"./sparkles-CocyTOST.js";import"./star-BG1WDgyW.js";import"./database-CPdb1d3C.js";import"./newspaper-Cs4TR8WT.js";import"./copy-bi06ebrW.js";import"./index-DHhDC7BU.js";import"./login-dialog-DZ1OKTDA.js";import"./index-DyOj80ul.js";const k=20,Re=["active","needs_generic","broken","missing"],ee={active:"Active",needs_generic:"Needs a generic badge",broken:"Broken image",missing:"Missing a badge"},Me=["active","needs_generic","broken"];function Oe(n){const s=n.badge;return{imageSrc:(s==null?void 0:s.imageSrc)??"",href:(s==null?void 0:s.href)??`https://${n.domain}`,imageAlt:(s==null?void 0:s.imageAlt)??`Featured on ${n.name}`,label:(s==null?void 0:s.label)??`Featured on ${n.name}`,width:s!=null&&s.width?String(s.width):"",height:s!=null&&s.height?String(s.height):"",status:(s==null?void 0:s.status)??"active",note:(s==null?void 0:s.note)??""}}function te(n){const s=Number.parseInt(n,10);return Number.isInteger(s)&&s>0?s:null}const A="border-zinc-700 bg-zinc-950",ae="min-h-11 w-full rounded-md border border-zinc-700 bg-zinc-950 px-3 text-sm text-zinc-200";function Ue(){var j,F;const{toast:n}=ne(),s=xe(),[z,C]=x.useState("active"),[h,i]=x.useState(0),[I,p]=x.useState(null),[m,v]=x.useState(null),P=`/api/admin/directory-badges?limit=${k}&offset=${h}&status=${z}`,l=H({queryKey:[P]});x.useEffect(()=>{l.data&&h>0&&h>=l.data.total&&i(Math.max(0,Math.floor((l.data.total-1)/k)*k))},[l.data,h]);const E=T({mutationFn:async a=>(await $("PUT",`/api/admin/directory-badges/${a.directoryId}`,{imageSrc:a.form.imageSrc.trim(),href:a.form.href.trim(),imageAlt:a.form.imageAlt.trim(),label:a.form.label.trim(),width:te(a.form.width),height:te(a.form.height),status:a.form.status,note:a.form.note.trim()||null})).json(),onSuccess:async()=>{await s.invalidateQueries({predicate:a=>String(a.queryKey[0]).startsWith("/api/admin/directory-badges")}),p(null),v(null),n({title:"Badge saved"})},onError:a=>n({variant:"destructive",title:"Could not save badge",description:a instanceof Error?a.message:"Please try again."})}),g=((j=l.data)==null?void 0:j.total)??0,u=((F=l.data)==null?void 0:F.items.length)??0,B=g===0?0:h+1,U=Math.min(h+u,g);function S(){p(null),v(null)}function d(a,y){v(r=>r&&{...r,[a]:y})}return e.jsxs(N,{className:"border-zinc-800 bg-zinc-950",children:[e.jsxs(R,{children:[e.jsx(M,{className:"text-lg text-white",children:"Directory badges for the builder embed"}),e.jsx(O,{className:"text-zinc-400",children:"One generic badge per directory, shown to every builder who installs the directory badge wall. Only active badges render. This is separate from the footer wall above."})]}),e.jsxs(w,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"directory-badge-filter",className:"text-zinc-300",children:"Show"}),e.jsx("select",{id:"directory-badge-filter",value:z,onChange:a=>{C(a.target.value),i(0),S()},className:`${ae} sm:w-72`,children:Re.map(a=>e.jsxs("option",{value:a,children:[ee[a],l.data?` (${l.data.counts[a]})`:""]},a))})]}),l.isLoading?e.jsxs("div",{className:"flex items-center gap-2 py-8 text-sm text-zinc-400",children:[e.jsx(D,{className:"h-5 w-5 animate-spin"})," Loading directory badges"]}):l.isError?e.jsx("p",{role:"alert",className:"rounded-md border border-red-500/30 bg-red-950/20 p-4 text-sm text-red-200",children:"Could not load directory badges."}):u===0?e.jsx("p",{className:"rounded-md border border-dashed border-zinc-800 bg-black/30 py-12 text-center text-sm text-zinc-500",children:"Nothing here."}):e.jsx("ul",{className:"space-y-3",children:l.data.items.map(a=>{var y;return e.jsxs("li",{className:"rounded-md border border-zinc-800 p-4",children:[e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[a.badge?e.jsx("img",{src:a.badge.imageSrc,alt:a.badge.imageAlt,className:"h-10 w-auto rounded bg-zinc-700/60 p-1"}):e.jsx("span",{className:"text-xs text-zinc-500",children:"No badge"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm font-medium text-white",children:a.name}),e.jsxs("p",{className:"mt-1 truncate text-xs text-zinc-500",children:[a.domain,a.domainRating!==null?` - DR ${a.domainRating}`:"",(y=a.badge)!=null&&y.note?` - ${a.badge.note}`:""]})]}),e.jsx(b,{type:"button",variant:"outline",size:"sm","aria-label":`${a.badge?"Edit":"Add"} badge for ${a.domain}`,onClick:()=>{p(a.directoryId),v(Oe(a))},children:a.badge?"Edit":"Add badge"})]}),I===a.directoryId&&m?e.jsxs("form",{className:"mt-4 grid gap-4 sm:grid-cols-2",onSubmit:r=>{r.preventDefault(),E.mutate({directoryId:a.directoryId,form:m})},children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:`directory-badge-image-${a.directoryId}`,children:"Badge image URL"}),e.jsx(c,{id:`directory-badge-image-${a.directoryId}`,value:m.imageSrc,onChange:r=>d("imageSrc",r.target.value),className:A})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:`directory-badge-href-${a.directoryId}`,children:"Badge link URL"}),e.jsx(c,{id:`directory-badge-href-${a.directoryId}
1`,value:m.href,onChange:r=>d("href",r.target.value),className:A})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:`directory-badge-alt-${a.directoryId}`,children:"Badge alt text"}),e.jsx(c,{id:`directory-badge-alt-${a.directoryId}`,value:m.imageAlt,onChange:r=>d("imageAlt",r.target.value),className:A})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:`directory-badge-label-${a.directoryId}`,children:"Badge label"}),e.jsx(c,{id:`directory-badge-label-${a.directoryId}`,value:m.label,onChange:r=>d("label",r.target.value),className:A})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:`directory-badge-width-${a.directoryId}`,children:"Badge width"}),e.jsx(c,{id:`directory-badge-width-${a.directoryId}`,type:"number",min:1,value:m.width,onChange:r=>d("width",r.target.value),className:A})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:`directory-badge-height-${a.directoryId}`,children:"Badge height"}),e.jsx(c,{id:`directory-badge-height-${a.directoryId}`,type:"number",min:1,value:m.height,onChange:r=>d("height",r.target.value),className:A})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:`directory-badge-status-${a.directoryId}`,children:"Badge status"}),e.jsx("select",{id:`directory-badge-status-${a.directoryId}`,value:m.status,onChange:r=>d("status",r.target.value),className:ae,children:Me.map(r=>e.jsx("option",{value:r,children:ee[r]},r))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:`directory-badge-note-${a.directoryId}`,children:"Badge note"}),e.jsx(c,{id:`directory-badge-note-${a.directoryId}`,value:m.note,onChange:r=>d("note",r.target.value),className:A,maxLength:500})]}),e.jsxs("div",{className:"flex items-center gap-3 sm:col-span-2",children:[m.imageSrc?e.jsx("img",{src:m.imageSrc,alt:"",className:"h-10 w-auto rounded bg-zinc-700/60 p-1"}):null,e.jsx(b,{type:"submit",disabled:E.isPending,children:E.isPending?"Saving":"Save badge"}),e.jsx(b,{type:"button",variant:"ghost",onClick:S,children:"Cancel"})]})]}):null]},a.directoryId)})}),e.jsxs("div",{className:"flex items-center justify-between border-t border-zinc-800 pt-5",children:[e.jsxs(b,{variant:"outline",disabled:h===0,onClick:()=>{i(Math.max(0,h-k)),S()},children:[e.jsx(le,{className:"mr-2 h-4 w-4"})," Previous"]}),e.jsxs("span",{className:"text-sm text-zinc-500",children:[B,"-",U," of ",g]}),e.jsxs(b,{variant:"outline",disabled:h+k>=g,onClick:()=>{i(h+k),S()},children:["Next ",e.jsx(de,{className:"ml-2 h-4 w-4"})]})]})]})]})}const _=10,se="vibecodinglist.com",ie={listingId:"",href:"",label:"",title:"",imageSrc:"",imageAlt:"",rel:"noopener",width:"",height:"",linkDataAttributes:null,imageDataAttributes:null};function re(n){const s=Number.parseInt(n,10);return Number.isInteger(s)&&s>0?s:void 0}function qe(n){const s=n instanceof Error?n.message:"Please try again.",z=s.indexOf("{");if(z===-1)return{description:s,listingIdConflict:!1};try{const C=JSON.parse(s.slice(z));return{description:C.error||s,listingIdConflict:C.code==="footer_badge_listing_id_conflict"}}catch{return{description:s,listingIdConflict:!1}}}function la(){var Q,G,J,W,Z,V,Y;const{toast:n}=ne(),[s,z]=x.useState(0),[C,h]=x.useState(""),[i,I]=x.useState(ie),[p,m]=x.useState(null),[v,P]=x.useState(null),[l,E]=x.useState(null),g=H({queryKey:["/api/admin/directory-submissions/projects"]}),u=((Q=g.data)==null?void 0:Q.projects.find(t=>t.id===l))??null,B=(u==null?void 0:u.domain)===se;x.useEffect(()=>{var f;const t=(f=g.data)==null?void 0:f.projects[0];l===null&&t&&E(t.id)},[g.data,l]);const U=t=>{E(t),z(0)},S=`/api/admin/footer-badges?limit=${_}&offset=${s}${l?`&projectId=${l}`:""}`,d=H({queryKey:[S],enabled:l!==null});x.useEffect(()=>{d.data&&be("admin_footer_backlinks_viewed",{result_count:d.data.items.length,total_count:d.data.total})},[d.data]);const j=(t,f)=>{I(pe=>({...pe,[t]:f}))},F=()=>{I(ie),h(""),m(null)},a=()=>{const t=je(C);if(!t){n({variant:"destructive",title:"Could not parse snippet",description:"Expected an anchor wrapping an image with absolute http(s) URLs."});return}I({listingId:t.suggestedListingId,href:t.href,label:t.imageAlt,title:t.title??"",imageSrc:t.imageSrc,imageAlt:t.imageAlt,rel:t.rel??"noopener",width:t.width?String(t.width):"",he
1ight:t.height?String(t.height):"",linkDataAttributes:t.linkDataAttributes??null,imageDataAttributes:t.imageDataAttributes??null})},y=async()=>{await Promise.all([X.invalidateQueries({queryKey:[S]}),X.invalidateQueries({queryKey:["/api/footer-badges"]})])},r=T({mutationFn:async()=>{const t={...p?{}:{projectId:l??void 0},listingId:i.listingId.trim(),href:i.href.trim(),label:i.label.trim(),title:i.title.trim()?i.title.trim():void 0,imageSrc:i.imageSrc.trim(),imageAlt:i.imageAlt.trim(),rel:i.rel.trim()||"noopener",width:re(i.width),height:re(i.height),linkDataAttributes:i.linkDataAttributes??void 0,imageDataAttributes:i.imageDataAttributes??void 0};return(await $(p?"PATCH":"POST",p?`/api/admin/footer-badges/${p}`:"/api/admin/footer-badges",t)).json()},onSuccess:async()=>{n({title:p?"Badge updated":"Badge created"}),F(),await y()},onError:t=>{const f=qe(t);n({variant:"destructive",title:f.listingIdConflict?"Listing ID already used":"Could not save badge",description:f.description})}}),K=T({mutationFn:async t=>(await $("PATCH",`/api/admin/footer-badges/${t.id}`,{isActive:t.isActive})).json(),onSuccess:async()=>{await y()},onError:t=>n({variant:"destructive",title:"Could not update badge",description:t instanceof Error?t.message:"Please try again."})}),oe=T({mutationFn:async t=>(await $("DELETE",`/api/admin/footer-badges/${t}`)).json(),onSuccess:async(t,f)=>{n({title:"Badge deleted"}),P(null),p===f&&F(),await y()},onError:t=>n({variant:"destructive",title:"Could not delete badge",description:t instanceof Error?t.message:"Please try again."})}),q=T({mutationFn:async()=>(await $("POST","/api/admin/footer-badges/sync-defaults",{})).json(),onSuccess:async t=>{n({title:"Directory badges synced",description:`Imported ${t.inserted} of ${t.total} badges`}),await y()},onError:t=>n({variant:"destructive",title:"Could not sync badges",description:t instanceof Error?t.message:"Please try again."})}),ce=t=>{m(t.id),I({listingId:t.listingId,href:t.href,label:t.label,title:t.title??"",imageSrc:t.imageSrc,imageAlt:t.imageAlt,rel:t.rel,width:t.width?String(t.width):"",height:t.height?String(t.height):"",linkDataAttributes:t.linkDataAttributes,imageDataAttributes:t.imageDataAttributes})},L=((G=d.data)==null?void 0:G.total)??0,me=((J=d.data)==null?void 0:J.items.length)??0,ge=L===0?0:s+1,he=Math.min(s+me,L);return e.jsxs(e.Fragment,{children:[e.jsx(ue,{children:e.jsx("title",{children:"Footer Backlinks - VibeCodingList Admin"})}),e.jsxs(ye,{children:[e.jsxs("div",{className:"space-y-7",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-bold uppercase tracking-[0.18em] text-amber-200",children:[e.jsx(Le,{className:"h-4 w-4"})," Footer badge backlinks"]}),e.jsx("h1",{className:"mt-2 text-3xl font-bold text-white",children:"Footer Backlinks"}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm leading-6 text-zinc-400",children:`Manage the "Featured on" badges in the site footer. Paste a directory's embed snippet to prefill the form, then save to publish without a redeploy.`})]}),e.jsxs(N,{className:"border-zinc-800 bg-zinc-950",children:[e.jsxs(R,{children:[e.jsx(M,{className:"text-white",children:"Project"}),e.jsx(O,{children:"Badges belong to a project. Choose one to scope the list below, the create form, and the install prompt."})]}),e.jsx(w,{children:g.isLoading?e.jsxs("div",{className:"flex items-center gap-3 text-sm text-zinc-300",children:[e.jsx(D,{className:"h-4 w-4 animate-spin"})," Loading projects..."]}):g.isError?e.jsx("p",{className:"text-sm text-red-300",children:"Could not load projects."}):((W=g.data)==null?void 0:W.projects.length)===0?e.jsx("p",{className:"text-sm text-zinc-400",children:"No active projects found."}):e.jsxs("div",{className:"max-w-sm space-y-2",children:[e.jsx(o,{htmlFor:"badge-project",children:"Project"}),e.jsx("select",{id:"badge-project",value:l??"",onChange:t=>U(Number(t.target.value)),className:"min-h-11 w-full rounded-md border border-zinc-700 bg-zinc-950 px-3 text-sm text-zinc-200",children:(Z=g.data)==null?void 0:Z.projects.map(t=>e.jsx("option",{value:t.id,children:t.name},t.id))})]})})]}),e.jsxs(N,{className:"border-zinc-800 bg-zinc-950",children:[e.jsxs(R,{children:[e.jsx(M,{className:"text-white",children:p?`Edit badge #${p}`:"Add badge"}),e.jsx(O,{children:"Paste the embed HTML a directory gives you, or fill the fields manually."})]}),e.jsxs(w,{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"badge-snippet",children:"Paste badge embed HTML"}),e.jsx(Pe,{id:"badge-snippet",value:C,onChange:t=>h(t.target.value),placeholder:'<a href="https://example.com"><img src="https://example.com/badge.svg" alt="Featured on Example"></a>',className:"border-zinc-700 bg-zinc-950 font-mono text-xs"}),e.jsx(b,{type:"button",variant:"outline",onClick:a,className:"border-zinc-700 bg-zinc-950",children:"Parse snippet"})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"badge-listing-id",children:"Listing ID"}),e.jsx(c,{id:"badge-listing-id",value:i.listingId,onChange:t=>j("listingId",t.target.value),placeholder:"publishyoursaas","aria-describedby":"badge-listing-id-help",className:"border-zinc-700 bg-zinc-950"}),e.jsx("p",{id:"badge-listing-id-help",className:"text-xs leading-5 text-zinc-500",children:"Listing IDs must be unique. For same-name domains, append the domain suffix (for example: launchit_fast)."})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"badge-href",children:"Link URL"}
1),e.jsx(c,{id:"badge-href",value:i.href,onChange:t=>j("href",t.target.value),placeholder:"https://example.com",className:"border-zinc-700 bg-zinc-950"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"badge-label",children:"Label"}),e.jsx(c,{id:"badge-label",value:i.label,onChange:t=>j("label",t.target.value),placeholder:"Featured on Example",className:"border-zinc-700 bg-zinc-950"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"badge-image-src",children:"Image URL"}),e.jsx(c,{id:"badge-image-src",value:i.imageSrc,onChange:t=>j("imageSrc",t.target.value),placeholder:"https://example.com/badge.svg",className:"border-zinc-700 bg-zinc-950"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"badge-image-alt",children:"Image alt"}),e.jsx(c,{id:"badge-image-alt",value:i.imageAlt,onChange:t=>j("imageAlt",t.target.value),placeholder:"Featured on Example",className:"border-zinc-700 bg-zinc-950"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"badge-title",children:"Anchor title (optional)"}),e.jsx(c,{id:"badge-title",value:i.title,onChange:t=>j("title",t.target.value),className:"border-zinc-700 bg-zinc-950"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"badge-rel",children:"rel"}),e.jsx(c,{id:"badge-rel",value:i.rel,onChange:t=>j("rel",t.target.value),placeholder:"noopener",className:"border-zinc-700 bg-zinc-950"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"badge-width",children:"Width (optional)"}),e.jsx(c,{id:"badge-width",value:i.width,onChange:t=>j("width",t.target.value),inputMode:"numeric",className:"border-zinc-700 bg-zinc-950"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"badge-height",children:"Height (optional)"}),e.jsx(c,{id:"badge-height",value:i.height,onChange:t=>j("height",t.target.value),inputMode:"numeric",className:"border-zinc-700 bg-zinc-950"})]})]}),i.imageSrc?e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-xs font-bold uppercase tracking-[0.16em] text-zinc-500",children:"Preview"}),e.jsx("div",{className:"flex items-center rounded-md border border-zinc-600/80 bg-zinc-500/90 px-4 py-3",children:e.jsx("a",{href:i.href,target:"_blank",rel:"noopener noreferrer",children:e.jsx("img",{src:i.imageSrc,alt:i.imageAlt,className:"h-16 w-auto"})})})]}):null,e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(b,{onClick:()=>r.mutate(),disabled:r.isPending||l===null,className:"min-h-11 bg-white text-black hover:bg-zinc-200",children:[r.isPending?e.jsx(D,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx($e,{className:"mr-2 h-4 w-4"}),"Save badge"]}),p?e.jsx(b,{variant:"outline",onClick:F,className:"border-zinc-700 bg-zinc-950",children:"Cancel edit"}):null,l===null?e.jsx("span",{className:"text-xs text-zinc-500",children:"Select a project above before saving."}):null]})]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h2",{className:"text-lg font-semibold text-white",children:"Badges"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-zinc-500",children:[L," total"]}),e.jsxs(b,{variant:"outline",onClick:()=>q.mutate(),disabled:q.isPending||!B,className:"border-zinc-700 bg-zinc-950",children:[q.isPending?e.jsx(D,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(Te,{className:"mr-2 h-4 w-4"}),"Sync directory badges"]}),u&&!B?e.jsxs("span",{className:"text-xs text-zinc-500",children:["Sync only writes ",se,"'s badges; switch to that project to use it."]}):null]})]}),l===null?e.jsx(N,{className:"border-dashed border-zinc-800 bg-black/30",children:e.jsx(w,{className:"py-12 text-center text-sm text-zinc-500",children:g.isLoading?"Loading projects...":g.isError?"Could not load projects.":"No active projects to show badges for."})}):d.isLoading?e.jsx(N,{className:"border-zinc-800 bg-zinc-950",children:e.jsxs(w,{className:"flex items-center gap-3 py-10 text-zinc-300",children:[e.jsx(D,{className:"h-5 w-5 animate-spin"})," Loading badges..."]})}):d.isError?e.jsx(N,{className:"border-red-500/30 bg-red-950/20",children:e.jsx(w,{className:"py-8 text-red-100",children:"Could not load footer badges."})}):((V=d.data)==null?void 0:V.items.length)===0?e.jsx(N,{className:"border-dashed border-zinc-800 bg-black/30",children:e.jsx(w,{className:"py-12 text-center text-sm text-zinc-500",children:"No badges yet. Add one above."})}):e.jsx("div",{className:"space-y-3",children:(Y=d.data)==null?void 0:Y.items.map(t=>e.jsx(N,{className:"border-zinc-800 bg-zinc-950",children:e.jsxs(w,{className:"flex flex-col gap-4 p-4 sm:flex-row sm:items-center",children:[e.jsx("img",{src:t.imageSrc,alt:t.imageAlt,className:"h-10 w-auto rounded bg-zinc-700/60 p-1"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-white",children:t.label}),e.jsx(ke,{variant:"outline",className:"border-zinc-700 bg-zinc-900 text-zinc-300",children:t.rel})]}),e.jsxs("p",{className:"mt-1 truncate text-xs text-zinc-500",children:[t.listingId," - ",t.href]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(De,{checked:t.isActive,disabled:K.isPending,onCheckedChange:()=>K.mutate({id:t.id,isActive:!t.isActive}),"aria-label":`Toggle ${t.label}`}),e.jsxs(b,{variant:"outline",size:"sm",onClick:()=>ce(t),className:"border-zinc-700 bg-zinc-950",children:[e.jsx(Be,{className:"mr-2 h-4 w-4"})," Edit"]}),e.jsxs(b,{variant:"destructive",size:"sm",onClick:()=>P(t),children:[e.jsx(_e,{className:"mr-2 h-4 w-4"})," Delete"]})]})]})},t.id))}),e.jsxs("div",{className:"flex items-center justify-between border-t border-zinc-800 pt-5",children:[e.jsxs(b,{variant:"outline",disabled:s===0,onClick:()=>z(Math.max(0,s-_)),children:[e.jsx(le,{className:"mr-2 h-4 w-4"})," Previous"]}),e.jsxs("span",{className:"text-sm text-zinc-500",children:["Showing ",ge,"-",he," of ",L]}),e.jsxs(b,{variant:"outline",disabled:s+_>=L,onClick:()=>z(s+_),children:["Next ",e.jsx(de,{className:"ml-2 h-4 w-4"})]})]}),u&&d.isLoading?e.jsx(N,{className:"border-zinc-800 bg-zinc-950",children:e.jsxs(w,{className:"flex items-center gap-3 py-10 text-zinc-300",children:[e.jsx(D,{className:"h-5 w-5 animate-spin"})," Loading install prompt..."]})}):u&&d.data?e.jsxs(N,{className:"border-zinc-800 bg-zinc-950",children:[e.jsxs(R,{children:[e.jsxs(M,{className:"text-white",children:["Install prompt for ",u.domain]}),e.jsxs(O,{children:["Paste this into the coding agent for"," ",u.domain,". It installs every badge above and re-fetches them, so it stays correct as the wall changes."]})]}),e.jsx(w,{children:e.jsx(Ne,{value:fe({projectDomain:u.domain,baseUrl:ve,badgeCount:d.data.activeTotal}),label:"badge install prompt",actionLabel:"Copy install prompt",onCopy:t=>{navigator.clipboard.writeText(t),n({title:"Prompt copied"})}})})]}):null,e.jsx(Ue,{})]}),e.jsx(we,{open:!!v,onOpenChange:t=>!t&&P(null),children:e.jsxs(ze,{children:[e.jsxs(Ce,{children:[e.jsx(Se,{children:"Delete badge"}),e.jsxs(Ae,{children:['Are you sure you want to delete "',v==null?void 0:v.label,'"? The badge disappears from the footer once the cache expires. This action cannot be undone.']})]}),e.jsxs(Ie,{children:[e.jsx(Ee,{"data-testid":"button-cancel-delete",children:"Cancel"}),e.jsx(Fe,{onClick:()=>v&&oe.mutate(v.id),"data-testid":"button-confirm-delete",children:"Delete"})]})]})})]})]})}export{la 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.