1import{b as A,r as b,d as N,s as B,v as h,j as e,X as T}from"./index-IlT_z189.js";import{B as u}from"./button-Cacew5Rp.js";import{A as L}from"./AppLayout-jWKqpBck.js";import{A as S,a as z,b as P,c as V,d as q,e as O,f as I,g as M,h as H}from"./alert-dialog-CRfi3-OA.js";import{P as k}from"./plus-DMsnw8Bk.js";import{E as _}from"./eye-Beh_IxMj.js";import{E as F}from"./eye-off-BmPtmgDr.js";import{S as R}from"./square-pen-CkSc0SKw.js";import{T as U}from"./trash-2-DFOOjtAN.js";import{E as W}from"./external-link-KG-eHllU.js";import{C as X,a as G,b as J,c as K}from"./card-BY44-cGT.js";import{I as Q}from"./input-BGOvMOMm.js";import{L as j}from"./label-C9lIEQ9O.js";import{S as y,a as E,b as C,c as $,d as f}from"./select-ClqNG0Oq.js";import{B as D}from"./badge-Os8kKKF6.js";import{F as Y}from"./file-text-BDxV-iEh.js";import"./type-Cv4nDClX.js";import"./log-out-Z5CAULjL.js";import"./index-OVjkQOiQ.js";import"./Combination-EmHabfSa.js";import"./index-BeBtFS3-.js";import"./index-6fauBBVQ.js";import"./index-BWxHhxS9.js";import"./chevron-down-EYTpQ1VO.js";import"./chevron-up-BBr0wGAo.js";const Z=({filters:a,onStatsChange:n})=>{const d=A(),[x,i]=b.useState([]),[l,v]=b.useState(!0),{theme:m,isLight:r}=N();b.useEffect(()=>{g()},[a]);const g=async()=>{try{v(!0);let s=B.from("case_studies").select("*").order("created_at",{ascending:!1});a.client_name&&(s=s.ilike("client_name",`%${a.client_name}%`)),a.related_service&&(s=s.eq("related_service",a.related_service)),a.visible_on_site!=="all"&&(s=s.eq("visible_on_site",a.visible_on_site==="visible")),a.category_tags.length>0&&(s=s.overlaps("category_tags",a.category_tags));const{data:c,error:o}=await s;if(o){h.error("Failed to fetch case studies");return}i(c||[])}catch{h.error("An error occurred while fetching case studies")}finally{v(!1)}},p=async(s,c)=>{try{const{error:o}=await B.from("case_studies").update({visible_on_site:!c}).eq("id",s);if(o){h.error("Failed to update visibility");return}h.success(`Case study ${c?"hidden":"published"}`),g(),n==null||n()}catch{h.error("An error occurred while updating visibility")}},t=async s=>{try{const{error:c}=await B.from("case_studies").delete().eq("id",s);if(c){h.error("Failed to delete case study");return}h.success("Case study deleted successfully"),g(),n==null||n()}catch{h.error("An error occurred while deleting the case study")}};return l?e.jsx("div",{className:"flex justify-center items-center h-64",children:e.jsx("div",{className:`animate-spin rounded-full h-8 w-8 border-b-2 ${r?"border-amber-600":"border-[#FF6F0C]"}`})}):x.length===0?e.jsxs("div",{className:`rounded-xl p-12 text-center border ${r?"bg-white/80 border-neutral-200/40":"bg-neutral-900/40 backdrop-blur-md border-white/10"}`,children:[e.jsx("div",{className:"text-6xl mb-4",children:"ð"}),e.jsx("h3",{className:`text-xl font-semibold mb-2 ${r?"text-[#1B1B1B]":"text-white"}`,children:"No case studies yet"}),e.jsx("p",{className:`mb-6 ${r?"text-[#4B4B4B]":"text-gray-400"}`,children:"Create your first case study to showcase your work"}),e.jsxs(u,{onClick:()=>d("/case-studies/create"),className:"bg-gradient-to-r from-[#FF6F0C] to-[#FFD72F] hover:brightness-110 text-black font-medium shadow-[0_0_20px_rgba(253,186,79,0.3)] transition-all duration-300",children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),"Create Case Study"]})]}):e.jsx("div",{className:"grid gap-6",children:x.map(s=>{var c;return e.jsxs("div",{className:`rounded-xl p-6 border transition-all duration-300 ${r?"bg-white/80 border-neutral-200/40 hover:border-[#D4D4D1]":"bg-neutral-900/40 backdrop-blur-md border-white/10 hover:border-white/20"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("h3",{className:`text-xl font-semibold ${r?"text-[#1B1B1B]":"text-white"}`,children:s.title}),s.visible_on_site?e.jsxs("div",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${r?"bg-green-50 text-green-600":"bg-green-500/20 text-green-400"}`,children:[e.jsx(_,{className:"h-3 w-3"}),"Published"]}):e.jsxs("div",{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${r?"bg-neutral-100 text-neutral-600":"bg-neutral-700/50 text-neutral-400"}`,children:[e.jsx(F,{className:"h-3 w-3"}),"Draft"]})]}),s.client_name&&e.jsxs("p",{className:`text-sm ${r?"text-[#4B4B4B]":"text-gray-400"}`,children:["Client: ",s.client_name]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>d(`/case-studies/edit/${s.id}`),className:`h-8 w-8 p-0 ${r?"text-[#4B4B4B] hover:text-[#1B1B1B] hover:bg-[#F4F4F2]":"text-gray-400 hover:text-white"}`,children:e.jsx(R,{className:"h-4 w-4"})}),e.jsx(u,{variant:"ghost",size:"sm",onClick:()=>p(s.id,s.visible_on_site),className:`h-8 w-8 p-0 ${r?"text-[#4B4B4B] hover:text-[#1B1B1B] hover:bg-[#F4F4F2]":"text-gray-400 hover:text-white"}`,children:s.visible_on_site?e.jsx(F,{className:"h-4 w-4"}):e.jsx(_,{className:"h-4 w-4"})}),e.jsxs(S,{children:[e.jsx(z,{asChild:!0,children:e.jsx(u,{variant:"ghost",size:"sm",className:`h-8 w-8 p-0 ${r?"text-[#4B4B4B] hover:text-red-600 hover:bg-red-50":"text-gray-400 hover:text-red-400"}`,children:e.jsx(U,{className:"h-4 w-4"})})}
1),e.jsxs(P,{className:r?"bg-white border-[#E2E2DE]":"bg-neutral-800 border-white/10",children:[e.jsxs(V,{children:[e.jsx(q,{className:r?"text-[#1B1B1B]":"text-white",children:"Are you sure?"}),e.jsx(O,{className:r?"text-[#4B4B4B]":"text-gray-400",children:"This action cannot be undone. This will permanently delete the case study."})]}),e.jsxs(I,{children:[e.jsx(M,{className:r?"bg-[#F4F4F2] text-[#1B1B1B] border-[#E2E2DE] hover:bg-[#E2E2DE]":"bg-neutral-700 text-white border-white/10 hover:bg-neutral-600",children:"Cancel"}),e.jsx(H,{onClick:()=>t(s.id),className:"bg-red-600 text-white hover:bg-red-700",children:"Delete"})]})]})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:r?"text-[#1B1B1B]":"text-gray-300",children:s.short_description}),s.result_summary&&e.jsx("div",{className:`rounded px-3 py-2 border ${r?"bg-amber-50 border-amber-200":"bg-neutral-800/50 border-white/5"}`,children:e.jsx("p",{className:`text-sm font-medium ${r?"text-amber-600":"text-[#FF6F0C]"}`,children:s.result_summary})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[s.related_service&&e.jsx("div",{className:`px-2 py-1 rounded text-xs ${r?"bg-blue-50 text-blue-600":"bg-blue-500/20 text-blue-400"}`,children:s.related_service}),(c=s.category_tags)==null?void 0:c.map((o,w)=>e.jsx("div",{className:`px-2 py-1 rounded text-xs ${r?"bg-neutral-100 text-neutral-600":"bg-neutral-700/50 text-neutral-300"}`,children:o},w))]}),e.jsxs("div",{className:`flex justify-between items-center pt-4 border-t ${r?"border-[#E2E2DE]":"border-white/10"}`,children:[e.jsxs("span",{className:`text-sm ${r?"text-[#4B4B4B]":"text-gray-400"}`,children:["Created: ",new Date(s.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})]}),s.visible_on_site&&e.jsxs(u,{variant:"ghost",size:"sm",className:`h-8 ${r?"text-amber-600 hover:text-amber-700 hover:bg-amber-50":"text-[#FF6F0C] hover:text-[#FFD72F]"}`,children:[e.jsx(W,{className:"h-3 w-3 mr-1"}),"View Public"]})]})]})]},s.id)})})},ee=["Web Development","Mobile App Development","Digital Marketing","SEO Optimization","Brand Design","E-commerce","Consulting","Other"],se=({filters:a,onFiltersChange:n})=>{const[d,x]=b.useState([]),{theme:i,isLight:l}=N();b.useEffect(()=>{v()},[]);const v=async()=>{try{const{data:t,error:s}=await B.from("case_studies").select("category_tags");if(s)return;const c=new Set;t==null||t.forEach(o=>{o.category_tags&&o.category_tags.forEach(w=>c.add(w))}),x(Array.from(c).sort())}catch(t){console.error("Error fetching tags:",t)}},m=(t,s)=>{n({...a,[t]:s})},r=t=>{const s=a.category_tags,c=s.includes(t)?s.filter(o=>o!==t):[...s,t];m("category_tags",c)},g=()=>{n({client_name:"",related_service:"",visible_on_site:"all",category_tags:[]})},p=a.client_name||a.related_service||a.visible_on_site!=="all"||a.category_tags.length>0;return e.jsxs(X,{className:l?"bg-white border-neutral-200/40":"",children:[e.jsx(G,{children:e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(J,{className:`text-lg ${l?"text-[#1B1B1B]":""}`,children:"Filters"}),p&&e.jsx(u,{variant:"ghost",size:"sm",onClick:g,className:l?"text-[#4B4B4B] hover:text-[#1B1B1B] hover:bg-[#F4F4F2]":"",children:"Clear All"})]})}),e.jsxs(K,{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx(j,{htmlFor:"client_name",className:l?"text-[#1B1B1B]":"",children:"Client Name"}),e.jsx(Q,{id:"client_name",placeholder:"Search by client...",value:a.client_name,onChange:t=>m("client_name",t.target.value),className:l?"bg-white border-[#E2E2DE] text-[#1B1B1B] placeholder:text-[#737373]":""})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"related_service",className:l?"text-[#1B1B1B]":"",children:"Service"}),e.jsxs(y,{value:a.related_service,onValueChange:t=>m("related_service",t==="all"?"":t),children:[e.jsx(E,{className:l?"bg-white border-[#E2E2DE] text-[#1B1B1B]":"",children:e.jsx(C,{placeholder:"All services"})}),e.jsxs($,{className:l?"bg-white border-[#E2E2DE]":"",children:[e.jsx(f,{value:"all",className:l?"text-[#1B1B1B] focus:bg-[#F4F4F2]":"",children:"All services"}),ee.map(t=>e.jsx(f,{value:t,className:l?"text-[#1B1B1B] focus:bg-[#F4F4F2]":"",children:t},t))]})]})]}),e.jsxs("div",{children:[e.jsx(j,{htmlFor:"visibility",className:l?"text-[#1B1B1B]":"",children:"Visibility"}),e.jsxs(y,{value:a.visible_on_site,onValueChange:t=>m("visible_on_site",t),children:[e.jsx(E,{className:l?"bg-white border-[#
1E2E2DE] text-[#1B1B1B]":"",children:e.jsx(C,{})}),e.jsxs($,{className:l?"bg-white border-[#E2E2DE]":"",children:[e.jsx(f,{value:"all",className:l?"text-[#1B1B1B] focus:bg-[#F4F4F2]":"",children:"All case studies"}),e.jsx(f,{value:"visible",className:l?"text-[#1B1B1B] focus:bg-[#F4F4F2]":"",children:"Published only"}),e.jsx(f,{value:"hidden",className:l?"text-[#1B1B1B] focus:bg-[#F4F4F2]":"",children:"Drafts only"})]})]})]}),d.length>0&&e.jsxs("div",{children:[e.jsx(j,{className:l?"text-[#1B1B1B]":"",children:"Tags"}),e.jsxs("div",{className:"mt-2 space-y-2",children:[e.jsx("div",{className:"flex flex-wrap gap-2",children:d.map(t=>e.jsx(D,{variant:a.category_tags.includes(t)?"default":"outline",className:`cursor-pointer ${l?a.category_tags.includes(t)?"bg-amber-600 text-white hover:bg-amber-700":"border-[#E2E2DE] text-[#1B1B1B] hover:bg-[#F4F4F2]":""}`,onClick:()=>r(t),children:t},t))}),a.category_tags.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx(j,{className:`text-sm ${l?"text-[#1B1B1B]":""}`,children:"Active Tags:"}),e.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:a.category_tags.map(t=>e.jsxs(D,{variant:"default",className:`text-xs ${l?"bg-amber-600 text-white":""}`,children:[t,e.jsx(T,{className:"ml-1 h-3 w-3 cursor-pointer",onClick:()=>r(t)})]},t))})]})]})]})]})]})},te=({totalCaseStudies:a,publishedCount:n,draftCount:d})=>{const{theme:x,isLight:i}=N();return e.jsx("div",{className:`rounded-2xl border p-6 ${i?"bg-white/80 border-neutral-200/40 shadow-sm":"bg-neutral-900/80 backdrop-blur-md border-white/10 shadow-[0_8px_32px_rgba(0,0,0,0.3)]"}`,children:e.jsx("div",{className:"flex items-center justify-start md:justify-center overflow-x-auto scrollbar-none -mx-2 px-2",children:e.jsxs("div",{className:"flex gap-3 md:gap-6",children:[e.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border ${i?"bg-[#F4F4F2] border-neutral-200/40":"bg-neutral-800/50 border-white/10"}`,children:[e.jsx(Y,{className:`h-5 w-5 ${i?"text-amber-600":"text-[#FF6F0C]"}`}),e.jsxs("div",{children:[e.jsx("div",{className:`text-sm ${i?"text-[#4B4B4B]":"text-neutral-400"}`,children:"Total Studies"}),e.jsx("div",{className:`text-xl font-semibold ${i?"text-[#1B1B1B]":"text-white"}`,children:a})]})]}),e.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border ${i?"bg-[#F4F4F2] border-neutral-200/40":"bg-neutral-800/50 border-white/10"}`,children:[e.jsx(_,{className:`h-5 w-5 ${i?"text-green-600":"text-green-400"}`}),e.jsxs("div",{children:[e.jsx("div",{className:`text-sm ${i?"text-[#4B4B4B]":"text-neutral-400"}`,children:"Published"}),e.jsx("div",{className:`text-xl font-semibold ${i?"text-[#1B1B1B]":"text-white"}`,children:n})]})]}),e.jsxs("div",{className:`flex items-center gap-3 px-4 py-3 rounded-lg border ${i?"bg-[#F4F4F2] border-neutral-200/40":"bg-neutral-800/50 border-white/10"}`,children:[e.jsx(F,{className:`h-5 w-5 ${i?"text-[#737373]":"text-neutral-400"}`}),e.jsxs("div",{children:[e.jsx("div",{className:`text-sm ${i?"text-[#4B4B4B]":"text-neutral-400"}`,children:"Drafts"}),e.jsx("div",{className:`text-xl font-semibold ${i?"text-[#1B1B1B]":"text-white"}`,children:d})]})]})]})})})},Ce=()=>{const{theme:a,isLight:n}=N(),d=A(),[x,i]=b.useState({client_name:"",related_service:"",visible_on_site:"all",category_tags:[]}),[l,v]=b.useState({total:0,published:0,drafts:0});b.useEffect(()=>{m()},[]);const m=async()=>{try{const{data:r,error:g}=await B.from("case_studies").select("visible_on_site");if(g)return;const p=(r==null?void 0:r.length)||0,t=(r==null?void 0:r.filter(c=>c.visible_on_site).length)||0,s=p-t;v({total:p,published:t,drafts:s})}catch(r){console.error("Error fetching stats:",r)}};return e.jsx(L,{currentView:"case-studies",onViewChange:()=>{},children:e.jsxs("div",{className:`min-h-screen relative ${n?"bg-[#F4F4F2]":"bg-black/95"}`,children:[a==="dark"&&e.jsxs("div",{className:"absolute inset-0 overflow-hidden pointer-events-none",children:[e.jsx("div",{className:"absolute top-0 left-1/4 w-96 h-96 bg-amber-400/10 rounded-full blur-[100px] animate-pulse"}),e.jsx("div",{className:"absolute bottom-0 right-1/4 w-96 h-96 bg-yellow-500/8 rounded-full blur-[100px] animate-pulse",style:{animationDelay:"1s"}})]}),e.jsx("header",{className:`relative z-10 border-b backdrop-blur-xl ${n?"border-neutral-200/40 bg-white/80":"border-white/10 bg-gradient-to-b from-neutral-900/40 to-transparent"}`,children:e.jsxs("div",{className:"flex items-center justify-between px-6 py-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:`text-2xl md:text-3xl font-semibold mb-1 tracking-tight font-[Montserrat] ${n?"text-[#1A1A1A]":"text-white"}`,children:"Case Studies"}),e.jsx("p",{className:`text-sm font-[Inter] ${n?"text-[#666666]":"text-neutral-400"}`,children:"Manage your project case studies and publish them to your website"})]}),e.jsxs(u,{onClick:()=>d("/case-studies/create"),className:"bg-gradient-to-r from-amber-400 to-yellow-500 hover:brightness-110 text-black font-medium shadow-[0_0_20px_rgba(253,186,79,0.3)] transition-all duration-300",children:[e.jsx(k,{className:"h-4 w-4 mr-2"}),"Create Case Study"]})]})}),e.jsx("main",{className:"relative z-10 flex-1 overflow-hidden",children:e.jsxs("div",{className:"flex-1 flex flex-col h-full overflow-hidden",children:[e.jsx("div",{className:"px-4 py-3",children:e.jsx(te,{totalCaseStudies:l.total,publishedCount:l.published,draftCount:l.drafts})}),e.jsx("div",{className:"flex-1 flex flex-col px-4 py-3 gap-3 overflow-hidden",children:e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-6 h-full",children:[e.jsx("div",{className:"lg:col-span-1",children:e.jsx(se,{filters:x,onFiltersChange:i})}),e.jsx("div",{className:"lg:col-span-3 overflow-hidden",children:e.jsx(Z,{filters:x,onStatsChange:m})})]})})]})})]})})};export{Ce as CaseStudies};
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.