import{c as j}from"./createLucideIcon-BASx8f0E.js";import{r as d,j as e}from"./app-BwDemWQz.js";import{P as k}from"./PlatformIcon-BoGOJKWv.js";import{a as V,b as U,c as G,S as ee,P as q}from"./AppLayout-3zbhnyYw.js";import{C as v,s as B}from"./index-CkDmAPFS.js";import{S as H}from"./search-sQ0SJSXK.js";import{F as re}from"./funnel-BGG8ZS5h.js";import{E as ae}from"./ellipsis-vertical-MSJbXZp-.js";import{E as se}from"./eye-C30qcgue.js";import{L as te}from"./link-BuvjkyeI.js";import{T as le}from"./trash-2-DJCIoKoz.js";/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const de=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]],ke=j("ellipsis",de);/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ie=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],ve=j("message-circle",ie);/**
 * @license lucide-react v0.539.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ne=[["path",{d:"M12 2v13",key:"1km8f5"}],["path",{d:"m16 6-4-4-4 4",key:"13yo43"}],["path",{d:"M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8",key:"1b2hhj"}]],je=j("share",ne),Ne=({t:i,onSelectedAccountsChange:N,onActivePlatformChange:w,accounts:n,selectedAccountIds:h,socialPlatforms:y=[],mode:C="full",showAllPlatforms:J=!1})=>{var _;const[c,A]=d.useState([]),[o,z]=d.useState(""),[u,K]=d.useState("facebook"),[Q,p]=d.useState({}),[S,T]=d.useState(!1),[l,E]=d.useState({accountType:"all",status:"all"}),g=d.useRef({}),b=d.useRef(null);d.useEffect(()=>{h&&A(h)},[h]);const F={accountType:[{value:"all",label:"All Types"},{value:"profile",label:"Profile"},{value:"page",label:"Page"},{value:"group",label:"Group"},{value:"channel",label:"Channel"}],status:[{value:"all",label:"All Status"},{value:"connected",label:"Connected"},{value:"disconnected",label:"Disconnected"}]},x=C==="simple"?n:n.filter(r=>{var $,D,O,R;const a=(($=r==null?void 0:r.name)==null?void 0:$.toLowerCase().includes(o.toLowerCase()))||((O=(D=r==null?void 0:r.platform)==null?void 0:D.name)==null?void 0:O.toLowerCase().includes(o.toLowerCase())),s=((R=r==null?void 0:r.platform)==null?void 0:R.slug)===u,t=l.accountType==="all"||r.accountType===l.accountType,I=l.status==="all"||l.status==="connected";return a&&s&&t&&I}),f=J?y:y.filter(r=>n.some(a=>{var s;return((s=a.platform)==null?void 0:s.slug)===r.slug})),L=r=>{n.find(t=>t.id===r);let a;c.includes(r)?a=c.filter(t=>t!==r):a=[...c,r],A(a);const s=n.filter(t=>a.includes(t.id));N&&N(s)},W=r=>{z(r.target.value)},X=r=>{p(a=>({...a,[r]:!a[r]}))},m=(r,a)=>{p(s=>({...s,[r]:!1}))},M=(r,a)=>{E(s=>({...s,[r]:a}))},Y=()=>{E({accountType:"all",status:"all"}),z("")},Z=r=>{K(r),w&&w(r)};d.useEffect(()=>{const r=a=>{b.current&&!b.current.contains(a.target)&&T(!1),Object.keys(g.current).forEach(s=>{g.current[s]&&!g.current[s].contains(a.target)&&p(t=>({...t,[s]:!1}))})};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[]);const P=((_=y.find(r=>r.slug===u))==null?void 0:_.id)||null;return C==="simple"?e.jsx("div",{className:"w-full",children:e.jsxs("div",{className:"space-y-2 min-h-[120px]",children:[x.map(r=>{var a,s;return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-all duration-200 group",children:[e.jsx("input",{type:"checkbox",checked:c.includes(r.id),onChange:()=>L(r.id),className:"w-4 h-4 text-primary bg-gray-100 border-gray-300 rounded focus:ring-primary dark:focus:ring-primary dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsxs(V,{className:"h-10 w-10",children:[e.jsx(U,{src:r.avatar,alt:"User Avatar"}),e.jsx(G,{children:"AV"})]}),e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-5 h-5 rounded-full bg-white dark:bg-zinc-900 flex items-center justify-center border-2 border-white dark:border-gray-900",children:e.jsx(k,{slug:(a=r.platform)==null?void 0:a.slug,size:12,round:!0})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-white text-sm truncate",children:r.label||r.name}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 capitalize truncate",children:[(s=r.platform)==null?void 0:s.name," • ",r.accountType||"Account"]})]}),e.jsx("div",{className:"flex-shrink-0",children:e.jsx("div",{className:`w-2 h-2 rounded-full ${r.is_connected?"bg-green-500":"bg-gray-400"}`})})]},r.id)}),x.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-gray-800 rounded-lg flex items-center justify-center mb-3",children:e.jsx(v,{className:"w-6 h-6 text-gray-400"})}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm",children:i?i("No accounts available"):"No accounts available"})]})]})}):e.jsxs("div",{className:"w-full bg-white dark:bg-zinc-900 rounded-lg border border-gray-200 dark:border-zinc-800",children:[e.jsxs("div",{className:"p-4 border-b border-gray-200 dark:border-zinc-800",children:[e.jsx("div",{className:"flex items-center gap-1 mb-4 bg-gray-100 dark:bg-gray-800 p-1 rounded-lg overflow-x-auto",children:f==null?void 0:f.map(r=>{const a=n.filter(s=>{var t;return((t=s.platform)==null?void 0:t.slug)===r.slug}).length;return e.jsxs("button",{onClick:()=>Z(r.slug),className:`whitespace-nowrap px-3 py-2 text-sm font-medium rounded-md transition-all flex items-center gap-2 ${u===r.slug?"bg-white dark:bg-zinc-800 text-gray-900 dark:text-white shadow-sm":"text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white"}`,children:[e.jsx(k,{slug:r.slug,size:16}),e.jsx("span",{children:r.name}),a>0&&e.jsx("span",{className:"ml-1 text-xs bg-gray-200 dark:bg-gray-600 px-1.5 py-0.5 rounded-full",children:a})]},r.slug)})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(H,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",placeholder:i?i("Search accounts..."):"Search accounts...",value:o,onChange:W,className:"w-full pl-10 pr-4 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-zinc-900 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]}),e.jsxs("div",{className:"relative",ref:b,children:[e.jsx("button",{onClick:()=>T(!S),className:`p-2 border border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors ${l.accountType!=="all"||l.status!=="all"?"bg-primary/10 dark:bg-primary/20 border-primary/30 dark:border-primary/60 text-primary dark:text-primary":"bg-white dark:bg-zinc-900 hover:bg-gray-50 dark:hover:bg-gray-700"}`,children:e.jsx(re,{className:"w-4 h-4"})}),S&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white dark:bg-zinc-900 border border-gray-200 dark:border-zinc-800 rounded-lg shadow-lg z-20 min-w-[200px] py-2",children:[e.jsxs("div",{className:"px-3 py-2",children:[e.jsx("h4",{className:"text-xs font-medium text-gray-900 dark:text-white mb-2",children:"Account Type"}),F.accountType.map(r=>e.jsxs("button",{onClick:()=>M("accountType",r.value),className:"w-full flex items-center justify-between px-2 py-1.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:[r.label,l.accountType===r.value&&e.jsx(v,{className:"w-3 h-3 text-primary dark:text-primary"})]},r.value))]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-zinc-800"}),e.jsxs("div",{className:"px-3 py-2",children:[e.jsx("h4",{className:"text-xs font-medium text-gray-900 dark:text-white mb-2",children:"Status"}),F.status.map(r=>e.jsxs("button",{onClick:()=>M("status",r.value),className:"w-full flex items-center justify-between px-2 py-1.5 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded",children:[r.label,l.status===r.value&&e.jsx(v,{className:"w-3 h-3 text-primary dark:text-primary"})]},r.value))]}),(l.accountType!=="all"||l.status!=="all")&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"border-t border-gray-200 dark:border-zinc-800"}),e.jsx("div",{className:"px-3 py-2",children:e.jsx("button",{onClick:Y,className:"w-full px-2 py-1.5 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20 rounded",children:"Clear Filters"})})]})]})]})]})]}),e.jsxs("div",{className:"p-4 space-y-2 min-h-[120px]",children:[x.map(r=>{var a,s;return e.jsxs("div",{className:"flex items-center gap-3 p-3 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-800 transition-all duration-200 group",children:[e.jsx("input",{type:"checkbox",checked:c.includes(r.id),onChange:()=>L(r.id),className:"w-4 h-4 text-primary bg-gray-100 border-gray-300 rounded focus:ring-primary dark:focus:ring-primary dark:ring-offset-gray-800 focus:ring-2 dark:bg-gray-700 dark:border-gray-600"}),e.jsxs("div",{className:"relative flex-shrink-0",children:[e.jsxs(V,{className:"h-10 w-10",children:[e.jsx(U,{src:r.avatar,alt:"User Avatar"}),e.jsx(G,{children:"AV"})]}),e.jsx("div",{className:"absolute -bottom-0.5 -right-0.5 w-5 h-5 rounded-full bg-white dark:bg-zinc-900 flex items-center justify-center border-2 border-white dark:border-gray-900",children:e.jsx(k,{slug:(a=r.platform)==null?void 0:a.slug,size:12,round:!0})})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium text-gray-900 dark:text-white text-sm truncate",children:r.label}),e.jsxs("p",{className:"text-xs text-gray-500 dark:text-gray-400 capitalize truncate",children:[r.name," ",(s=r.platform)==null?void 0:s.name," ",r.accountType]})]}),e.jsxs("div",{className:"relative flex-shrink-0",ref:t=>g.current[r.id]=t,children:[e.jsx("button",{onClick:()=>X(r.id),className:"p-1.5 hover:bg-gray-200 dark:hover:bg-gray-700 rounded-lg transition-colors opacity-0 group-hover:opacity-100",children:e.jsx(ae,{className:"w-4 h-4 text-gray-400"})}),Q[r.id]&&e.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white dark:bg-zinc-900 border border-gray-200 dark:border-zinc-800 rounded-lg shadow-lg z-10 min-w-[140px] py-1",children:[e.jsxs("button",{onClick:()=>m(r.id),className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:[e.jsx(se,{className:"w-4 h-4"}),"View"]}),e.jsxs("button",{onClick:()=>m(r.id),className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:[e.jsx(te,{className:"w-4 h-4"}),"Share"]}),e.jsxs("button",{onClick:()=>m(r.id),className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700",children:[e.jsx(ee,{className:"w-4 h-4"}),"Settings"]}),e.jsx("div",{className:"border-t border-gray-200 dark:border-zinc-800 my-1"}),e.jsxs("button",{onClick:()=>m(r.id),className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 dark:text-red-400 hover:bg-red-50 dark:hover:bg-red-900/20",children:[e.jsx(le,{className:"w-4 h-4"}),"Delete"]})]})]})]},r.id)}),x.length===0&&e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-gray-100 dark:bg-gray-800 rounded-lg flex items-center justify-center mb-3",children:e.jsx(H,{className:"w-6 h-6 text-gray-400"})}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400 text-sm",children:o?`No accounts found matching "${o}"`:"No accounts found"})]})]}),e.jsx("div",{className:"p-4 pt-0",children:P?e.jsxs("a",{href:B("user.platform.accounts",P),className:"w-full py-3 px-4 border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:border-primary/50 dark:hover:border-primary/60 hover:text-primary dark:hover:text-primary hover:bg-primary/5 dark:hover:bg-primary/10 transition-all flex items-center justify-center gap-2 text-sm font-medium",children:[e.jsx(q,{className:"w-4 h-4"}),i?i("Add Account"):"Add Account"]}):e.jsxs("a",{href:B("user.platform.index"),className:"w-full py-3 px-4 border-2 border-dashed border-gray-300 dark:border-gray-600 rounded-lg text-gray-600 dark:text-gray-400 hover:border-primary/50 dark:hover:border-primary/60 hover:text-primary dark:hover:text-primary hover:bg-primary/5 dark:hover:bg-primary/10 transition-all flex items-center justify-center gap-2 text-sm font-medium",children:[e.jsx(q,{className:"w-4 h-4"}),i?i("Connect Account"):"Connect Account"]})})]})};export{Ne as A,ke as E,ve as M,je as S};
