1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,81694,e=>{"use strict";var t=e.i(843476),a=e.i(271645),r=e.i(618566),s=e.i(217255),n=e.i(152727),l=e.i(90362),i=e.i(846932),o=e.i(387652),c=e.i(449492),d=e.i(887652),x=e.i(895420),u=e.i(591994),m=e.i(705766),g=e.i(39875),p=e.i(427217),h=e.i(372287),f=e.i(467415);let b=()=>(0,t.jsxs)("div",{className:"flex items-center p-4 rounded-xl mb-2 animate-pulse",children:[(0,t.jsx)("div",{className:"w-14 h-14 rounded-xl bg-gray-200 dark:bg-zinc-800 flex-shrink-0"}),(0,t.jsxs)("div",{className:"ml-4 flex-1 space-y-2",children:[(0,t.jsx)("div",{className:"h-4 bg-gray-200 dark:bg-zinc-800 rounded-full w-2/3"}),(0,t.jsx)("div",{className:"h-3 bg-gray-100 dark:bg-zinc-900 rounded-full w-1/3"})]})]}),v={creator:{label:"Creator",className:"bg-pink-50 text-pink-600 border border-pink-100"},campaign:{label:"Campaign",className:"bg-orange-50 text-orange-600 border border-orange-100"},organization:{label:"Org",className:"bg-purple-50 text-purple-600 border border-purple-100"}},y=({item:e,type:r,onSelect:s,className:n=""})=>
1{if(!e)return null;let[l,i]=(0,a.useState)(!1),o=v[r];return(0,t.jsxs)("div",{className:`group flex items-center cursor-pointer bg-white dark:bg-zinc-950 hover:bg-gradient-to-r hover:from-pink-50/60 hover:to-orange-50/60 p-4 border border-gray-100 dark:border-zinc-800 rounded-xl mb-2 transition-all duration-200 hover:-translate-y-0.5 hover:shadow-md hover:border-pink-100 focus-within:ring-2 focus-within:ring-pink-400/40 ${n}`,onClick:()=>s(r,e._id),onKeyDown:t=>{("Enter"===t.key||" "===t.key)&&(t.preventDefault(),s(r,e._id))},tabIndex:0,role:"button","aria-label":`Select ${r}: ${e.name}`,children:[(0,t.jsx)("div",{className:"relative flex-shrink-0",children:!l&&e.image?(0,t.jsx)("img",{src:e.image,alt:`${e.name} thumbnail`,className:"w-14 h-14 rounded-xl object-cover shadow-sm",loading:"lazy",onError:()=>i(!0)}):(0,t.jsx)("div",{className:"w-14 h-14 rounded-xl bg-gradient-to-br from-pink-400 to-orange-400 flex items-center justify-center shadow-sm",children:(0,t.jsx)("span",{className:"text-white text-xl font-semibold",children:e.name?.charAt(0).toUpperCase()})})}),(0,t.jsxs)("div",{className:"ml-4 flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100 truncate group-hover:text-pink-600 transition-colors duration-150",children:e.name}),o&&(0,t.jsx)("span",{className:`hidden sm:inline-flex items-center px-1.5 py-0.5 rounded-md text-[10px] font-medium flex-shrink-0 ${o.className}`,children:o.label})]}),"creator"===r&&e.socials&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-1.5",children:Object.entries(e.socials).slice(0,3).map(([e,a])=>{let r=h.default[e];return r?(0,t.jsxs)("span",{className:`inline-flex items-center px-2 py-0.5 rounded-md text-xs ${r.bg} ${"pinterest"===e?"text-black dark:text-black":"text-white"}`,children:[(0,t.jsx)("img",{src:r.icon,alt:r.displayName,className:"w-3 h-3 mr-1"}),(0,f.formatNumberReturn)(a.followers)]},e):null})})]}),(0,t.jsx)("div",{className:"ml-2 opacity-0 group-hover:opacity-100 transition-opacity duration-150 text-pink-400 flex-shrink-0",children:(0,t.jsx)("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})},k=({title:e,items:a,type:r,onSelect:s})=>a?.length?(0,t.jsxs)("div",{className:"mb-5",children:[(0,t.jsxs)("div",{className:"flex items-center mb-3 sticky top-0 backdrop-blur-sm bg-white/90 dark:bg-zinc-950/90 py-2 z-10",children:[(0,t.jsx)("div",{className:"h-3.5 w-0.5 rounded-full bg-gradient-to-b from-pink-500 to-orange-400 mr-2"}),(0,t.jsx)("h2",{className:"text-xs font-bold tracking-widest uppercase text-gray-400 dark:text-zinc-500",children:e}),(0,t.jsx)("div",{className:"ml-2 px-2 py-0.5 bg-gradient-to-r from-pink-500 to-orange-400 rounded-full text-[10px] font-semibold text-white",children:a.length})]}),(0,t.jsx)("div",{children:a.map(e=>(0,t.jsx)(y,{item:e,type:r,onSelect:s},e._id))})]}):null,j=function({router:e}){let r=(()=>{let[e,t]=(0,a.useState)(!0);return(0,a.useEffect)(()=>{t("u">typeof navigator&&/Mac|iPhone|iPad|iPod/.test(navigator.userAgent))},[]),e})(),{searchTerm:s,searchResults:n,isLoading:l,error:i,updateSearchTerm:o,clearSearch:c}=(()=>{var e;let t,r,[s,n]=(0,a.useState)(""),[l,i]=(0,a.useState)({creators:[],campaigns:[],organizations:[]}),[o,c]=(0,a.useState)(!1),[d,x]=(0,a.useState)(null),u=(0,a.useRef)(null),m=(e=(0,a.useCallback)(async e=>{if(u.current&&u.current.abort(),!e.trim()){i({creators:[],campaigns:[],organizations:[]}),c(!1);return}c(!0),x(null);try{u.current=new AbortController;let t=setTimeout(()=>u.current?.abort(),1e4),a=await fetch(`https://www.socialscout.ai/api/searchAutoCompleteAll?search=${encodeURIComponent(e)}`,{signal:u.current.signal,headers:{"Content-Type":"application/json"}});if(clearTimeout(t),!a.ok)throw Error(`Search failed: ${a.status}`);let r=await a.json();i({creators:(r.creators??[]).filter(Boolean),campaigns:(r.campaigns??[]).filter(Boolean),organizations:(r.organizations??[]).filter(
1Boolean)})}catch(e){"AbortError"!==e.name&&(x("Failed to fetch search results"),console.error("Search error:",e))}finally{c(!1)}},[]),t=(0,a.useRef)(null),r=(0,a.useCallback)((...a)=>{t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{e(...a)},300)},[e,300]),(0,a.useEffect)(()=>()=>{t.current&&clearTimeout(t.current)},[]),r),g=(0,a.useCallback)(e=>{n(e),m(e)},[m]),p=(0,a.useCallback)(()=>{u.current&&u.current.abort(),n(""),i({creators:[],campaigns:[],organizations:[]}),x(null),c(!1)},[]);return(0,a.useEffect)(()=>()=>{u.current&&u.current.abort()},[]),{searchTerm:s,searchResults:l,isLoading:o,error:d,updateSearchTerm:g,clearSearch:p}})(),d=(0,a.useCallback)((t,a)=>{let r={creator:`/dashboard/user/creator/${a}`,campaign:`/dashboard/user/campaign/${a}`,organization:`/dashboard/user/organization/${a}`}[t];r&&(e.push(r),c())},[e,c]),x=(0,a.useMemo)(()=>n.creators.length>0||n.campaigns.length>0||n.organizations.length>0,[n]),u=(0,a.useMemo)(()=>n.creators.length+n.campaigns.length+n.organizations.length,[n]);return(0,t.jsxs)("div",{className:"relative w-full max-w-2xl mx-auto",children:[x&&(0,t.jsx)("div",{className:"fixed inset-0 bg-black dark:bg-black bg-opacity-20 backdrop-blur-sm z-[60] transition-opacity duration-200",onClick:c,"aria-hidden":"true"}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:`p-[1.5px] rounded-2xl transition-all duration-200 ${s?"bg-gradient-to-r from-pink-500 to-orange-400":"bg-gray-200 dark:bg-zinc-800 hover:bg-gradient-to-r hover:from-pink-300 hover:to-orange-300"}`,children:(0,t.jsxs)("div",{className:"relative bg-white dark:bg-zinc-950 rounded-2xl",children:[(0,t.jsx)("input",{type:"text",value:s,onChange:e=>o(e.target.value),placeholder:"Search creators, campaigns, and organizations...",className:"w-full p-4 pl-12 pr-12 text-sm border-0 rounded-2xl bg-transparent focus:outline-none placeholder-gray-400 dark:placeholder-zinc-500 text-gray-900 dark:text-zinc-100","aria-label":"Search","aria-expanded":x,"aria-describedby":i?"search-error":void 0}),(0,t.jsx)("div",{className:"absolute left-4 top-1/2 transform -translate-y-1/2",children:s?(0,t.jsx)("button",{onClick:c,className:"p-1 rounded-full hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors duration-200 focus:outline-none","aria-label":"Clear search",children:(0,t.jsx)(p.XMarkIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"})}):(0,t.jsx)(g.MagnifyingGlassIcon,{className:"w-5 h-5 text-gray-400 dark:text-zinc-500"})}),(0,t.jsx)("div",{className:"absolute right-4 top-1/2 transform -translate-y-1/2",children:l?(0,t.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-pink-500 border-t-transparent"}):s?null:(0,t.jsxs)("kbd",{className:"hidden sm:inline-flex items-center gap-0.5 px-1.5 py-1 rounded-lg text-[11px] font-medium text-gray-400 dark:text-zinc-500 bg-gray-100/80 dark:bg-zinc-900/80 border border-gray-200/80 dark:border-zinc-800/80",children:[r?"â":"Ctrl+","K"]})})]})}),i&&(0,t.jsx)("div",{id:"search-error",className:"mt-2 p-3 bg-red-50 border border-red-200 rounded-lg text-red-700 text-sm",role:"alert",children:i})]}),(x||l)&&s&&(0,t.jsxs)("div",{className:"absolute top-full left-0 right-0 mt-2 bg-white/90 dark:bg-zinc-950/90 backdrop-blur-md rounded-2xl shadow-2xl border border-gray-100 dark:border-zinc-800 max-h-[70vh] overflow-y-auto z-[70]",children:[(0,t.jsx)("div",{className:"h-0.5 w-full bg-gradient-to-r from-pink-500 to-orange-400 rounded-t-2xl"}),(0,t.jsx)("div",{className:"p-4",children:l?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(b,{}),(0,t.jsx)(b,{}),(0,t.jsx)(b,{})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"mb-3 text-xs text-gray-400 dark:text-zinc-500 pb-2",children:[u," result",1!==u?"s":""," for"," ",(0,t.jsxs)("span",{className:"font-medium text-gray-600 dark:text-zinc-400",children:['"',s,'"']})]}),(0,t.jsx)(k,{title:"Creators",items:n.creators,type:"creator",onSelect:d}),(0,t.jsx)(k,{title:"Campaigns",items:n.campaigns,type:"campaign",onSelect:d}),(0,t.jsx)(k,{title:"Organizations",items:n.organizations,type:"organization",onSelect:d})]})})]}),s&&!x&&!l&&!i&&(0,t.jsxs)("div",{className:"absolute top-full left-0 right-0 mt-2 bg-white/90 dark:bg-zinc-950/90 backdrop-blur-md rounded-2xl shadow-2xl border border-gray-100 dark:border-zinc-800 z-[70]",children:[(0,t.jsx)("div",{className:"h-0.5 w-full bg-gradient-to-r from-pink-500 to-orange-400 rounded-t-2xl"}),(0,t.jsxs)("div",{className:"p-8 text-center",children:[(0,t.jsx)("div",{className:"w-12 h-12 rounded-full bg-gray-50 dark:bg-zinc-900 flex items-center justify-center mx-auto mb-4",children:(0,t.jsx)(g.MagnifyingGlassIcon,{className:"w-6 h-6 text-gray-300 dark:text-zinc-700"})}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-700 dark:text-zinc-300 mb-1",children:"No results found"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-zinc-500",children:"Try adjusting your search terms or browse our categories"})]})]})]})]})};var w=e.i(557587),N=e.i(248688),C=e.i(437902);let z={pink:{bg:"linear-gradient(135deg,rgba(236,72,153,0.18),rgba(249,115,22,0.12))",border:"rgba(236,72,153,0.35)",text:"#ec4899",glow:"rgba(236,72,153,0.4)"},blue:{bg:"linear-gradient(135deg,rgba(59,130,246,0.18),rgba(139,92,246,0.12))",border:"rgba(99,102,241,0.35)",text:"#6366f1",glow:"rgba(99,102,241,0.35)"},green:{bg:"linear-gradient(135deg,rgba(16,185,129,0.18),rgba(6,182,212,0.12))",border:"rgba(16,185,129,0.35)",text:"#10b981",glow:"rgba(16,185,129,0.35)"},amber:{bg:"linear-gradient(135deg,rgba(245,158,11,0.2),rgba(239,68,68,0.1))",border:"rgba(245,158,11,0.4)",text:"#f59e0b",glow:"rgba(245,158,11,0.35)"},red:{bg:"linear-gradient(135deg,rgba(239,68,68,0.18),rgba(236,72,153,0.1))",border:"rgba(239,68,68,0.4)",text:"#ef4444",glow:"rgba(239,68,68,0.35)"}},S={velocity:"Live Momentum",milestone:"Milestone",anomaly:"Signal",news:"Partner News",insight:"AI Insight"},E=()=>
1(0,t.jsxs)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-3 h-3",children:[(0,t.jsx)("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),(0,t.jsx)("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]}),P=()=>(0,t.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:"w-3 h-3",children:(0,t.jsx)("polygon",{points:"5,3 19,12 5,21"})}),$=({right:e})=>(0,t.jsx)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"w-3 h-3",style:{transform:e?"rotate(0deg)":"rotate(180deg)"},children:(0,t.jsx)("polyline",{points:"9 18 15 12 9 6"})}),M=()=>(0,t.jsxs)("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"w-3 h-3",children:[(0,t.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),(0,t.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,t.jsx)("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),F=()=>(0,t.jsxs)("span",{className:"relative flex h-2 w-2",children:[(0,t.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{background:"#ec4899"}}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2 w-2",style:{background:"#ec4899",boxShadow:"0 0 8px rgba(236,72,153,0.7)"}})]});function I(){return(0,t.jsxs)("div",{className:"flex items-center gap-3 h-full w-full",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl animate-pulse flex-shrink-0",style:{background:"var(--tint-softer)"}}),(0,t.jsxs)("div",{className:"flex-1 space-y-1.5",children:[(0,t.jsx)("div",{className:"h-2.5 rounded-full animate-pulse w-2/3",style:{background:"var(--tint-softer)"}}),(0,t.jsx)("div",{className:"h-2 rounded-full animate-pulse w-1/2",style:{background:"var(--tint-softer)"}})]})]})}function R({card:e,onClick:a,active:r}){let s=z[e.accent]||z.pink,n=S[e.type]||"Signal",l=!!e.href;return(0,t.jsxs)("div",{onClick:l?a:void 0,className:`flex items-center gap-3 w-full h-full ${l?"cursor-pointer":""}`,style:{transition:"all 0.4s cubic-bezier(0.4, 0, 0.2, 1)",opacity:+!!r,transform:r?"translateY(0)":"translateY(8px)"},children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center flex-shrink-0 text-lg relative",style:{background:s.bg,border:`1px solid ${s.border}`,boxShadow:`0 2px 12px ${s.glow}`},children:e.icon}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-0.5",children:[(0,t.jsx)("span",{className:"text-[9px] font-bold uppercase tracking-widest",style:{color:s.text,letterSpacing:"0.12em"},children:n}),(0,t.jsx)("span",{className:"text-[9px] font-medium",style:{color:"var(--scout-text-soft)"},children:"· live"})]}),(0,t.jsx)("p",{className:"text-sm font-semibold truncate",style:{color:"var(--scout-text-strong)"},children:e.headline}),e.subhead&&(0,t.jsx)("p",{className:"text-xs truncate mt-0.5",style:{color:"var(--scout-text-soft)"},children:e.subhead})]}),l&&(0,t.jsxs)("div",{className:"flex items-center gap-1 text-[10px] font-semibold uppercase tracking-widest flex-shrink-0",style:{color:s.text,letterSpacing:"0.1em"},children:[(0,t.jsx)("span",{className:"hidden md:inline",children:"View"}),(0,t.jsx)(M,{})]})]})}function T(){let e=(0,r.useRouter)(),[s,n]=(0,a.useState)([]),[l,i]=(0,a.useState)(!0),[o,c]=(0,a.useState)(null),[d,x]=(0,a.useState)(0),[u,m]=(0,a.useState)(!1),[g,p]=(0,a.useState)(!1),h=(0,a.useRef)(null),f=(0,a.useRef)(null),b=(0,a.useCallback)(async()=>{try{let e=await fetch("/api/ai/pulse",{method:"POST"});if(!e.ok)throw Error(`HTTP ${e.status}`);let{cards:t}=await e.json();Array.isArray(t)&&t.length?(n(t),x(0),c(null)):c("no_signals")}catch(e){console.error("[ScoutPulse]",e),c("fetch_failed")}finally{i(!1)}},[]);(0,a.useEffect)(()=>(b(),f.current=setInterval(b,216e5),()=>clearInterval(f.current)),[b]),(0,a.useEffect)(()=>{function e(){b()}return window.addEventListener("ss-sentiment-completed",e),()=>{window.removeEventListener("ss-sentiment-completed",e)}},[b]),(0,a.useEffect)(()=>{if(!u&&!(s.length<=1))return h.current=setTimeout(()=>{x(e=>(e+1)%s.length)},6e3),()=>clearTimeout(h.current)},[u,d,s.length]);let v=(0,a.useCallback)(()=>{clearTimeout(h.current),x(e=>(e+1)%Math.max(s.length,1))},[s.length]),y=(0,a.useCallback)(()=>{clearTimeout(h.current),x(e=>(e-1+s.length)%Math.max(s.length,1))},[s.length]),k=(0,a.useCallback)(t=>{t.href&&(t.href.startsWith("http")?window.open(t.href,"_blank","noopener,noreferrer"):e.push(t.href))},[e]);if(g||"no_signals"===o&&!l)return null;let j=s[d];return(0,t.jsxs)("div",{className:"jsx-5d9973da9a92b6a0 fixed bottom-16 md:bottom-4 left-0 right-0 z-40 px-3 pointer-events-none",children:[(0,t.jsx)("div",{className:"jsx-5d9973da9a92b6a0 max-w-5xl mx-auto pointer-events-auto",children:(0,t.jsxs)("div",{style:{borderRadius:16,background:"linear-gradient(160deg,rgba(14,10,22,0.88) 0%,rgba(20,14,30,0.88) 100%)",backdropFilter:"blur(40px) saturate(180%)",WebkitBackdropFilter:"blur(40px) saturate(180%)",border:"1px solid var(--tint-soft)",boxShadow:"0 20px 50px var(--shadow-ambient-2xl), inset 0 1px 0 var(--tint-softer)"},className:"jsx-5d9973da9a92b6a0 relative overflow-hidden",children:[(0,t.jsx)("div",{style:{background:"radial-gradient(circle,rgba(236,72,153,0.22) 0%,transparent 70%)",filter:"blur(30px)"},className:"jsx-5d9973da9a92b6a0 absolute -top-12 -right-12 w-40 h-40 pointer-events-none"}),(0,t.jsx)("div",{style:{background:"linear-gradient(90deg,#ec4899,#f97316)"},className:"jsx-5d9973da9a92b6a0 h-0.5 w-full"}),!u&&s.length>1&&!l&&(0,t.jsx)("div",{style:{background:"var(--tint-softer)"},className:"jsx-5d9973da9a92b6a0 h-0.5 w-full relative overflow-hidden",children:(0,t.jsx)("div",{style:{background:"linear-gradient(90deg,#ec4899,#f97316)",animation:"pulseProgress 6000ms linear forwards",width:"100%"},className:"jsx-5d9973da9a92b6a0 absolute top-0 left-0 h-full"},d)}),(0,t.jsxs)("div",{className:"jsx-5d9973da9a92b6a0 relative flex items-center gap-2 px-3 py-2.5",children:[(0,t.jsxs)("div",{style:{borderRight:"1px solid var(--tint-softer)"},className:"jsx-5d9973da9a92b6a0 hidden md:flex items-center gap-2 pr-3 flex-shrink-0",children:[(0,t.jsx)(F,{}),(0,t.jsx)("span",{style:{color:"var(--scout-text-strong)",letterSpacing:"0.14em"},className:"jsx-5d9973da9a92b6a0 text-[10px] font-bold tracking-widest uppercase",children:"Scout Pulse"})]}),(0,t.jsxs)("div",{className:"jsx-5d9973da9a92b6a0 flex-1 min-w-0 h-12 relative",children:[l&&(0,t.jsx)(I,{}),!l&&j&&(0,t.jsx)(R,{card:j,active:!0,onClick:()=>k(j)},d)]}),!l&&s.length>1&&(0,t.jsxs)("div",{className:"jsx-5d9973da9a92b6a0 flex items-center gap-1 flex-shrink-0",children:[(0,t.jsx)("button",{onClick:y,style:{color:"var(--scout-text-soft)"},onMouseEnter:e=>{e.currentTarget.style.color="rgba(255,255,255,0.95)",e.currentTarget.style.background="var(--tint-softer)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--scout-text-soft)",e.currentTarget.style.background="transparent"},title:"Previous",className:"jsx-5d9973da9a92b6a0 w-6 h-6 rounded-md flex items-center justify-center transition-all",children:(0,t.jsx)($,{})}),(0,t.jsx)("button",{onClick:()=>m(e=>!e),style:{color:u?"#ec4899":"var(--scout-text-soft)"},onMouseEnter:e=>{e.currentTarget.style.background="var(--tint-softer)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},title:u?"Resume":"Pause",className:"jsx-5d9973da9a92b6a0 w-6 h-6 rounded-md flex items-center justify-center transition-all",children:u?(0,t.jsx)(P,{}):(0,t.jsx)(E,{})}),(0,t.jsx)("button",{onClick:v,style:{color:"var(--scout-text-soft)"},onMouseEnter:e=>{e.currentTarget.style.color="rgba(255,255,255,0.95)",e.currentTarget.style.background="var(--tint-softer)"},onMouseLeave:e=>{e.currentTarget.style.color="var(--scout-text-soft)",e.currentTarget.style.background="transparent"},title:"Next",className:"jsx-5d9973da9a92b6a0 w-6 h-6 rounded-md flex items-center justify-center transition-all",children:(0,t.jsx)($,{right:!0})}),(0,t.jsx)("div",{style:{borderLeft:"1px solid var(--tint-softer)"},className:"jsx-5d9973da9a92b6a0 flex items-center gap-1 pl-2 ml-1",children:s.map((e,a)=>(0,t.jsx)("button",{onClick:()=>{clearTimeout(h.current),x(a)},style:{width:a===d?16:4,height:4,background:a===d?"linear-gradient(90deg,#ec4899,#f97316)":"var(--tint-soft)"},className:"jsx-5d9973da9a92b6a0 rounded-full transition-all"},a))})]})]})]})}),(0,t.jsx)(C.default,{id:"5d9973da9a92b6a0",children:"@keyframes pulseProgress{0%{transform:translate(-100%)}to{transform:translate(0)}}"})]})}var A=e.i(263150),D=e.i(370221),V=e.i(163858),L=e.i(521292),B=e.i(80843),O=e.i(586177),_=e.i(334152),U=e.i(482395),G=e.i(790806),H=e.i(879945),K=e.i(618969),W=e.i(136604);function q({value:e,color:r}){let[s,n]=(0,a.useState)(0),l=(0,a.useRef)(null),i=(0,o.useInView)(l,{once:!0,margin:"-40px"});return(0,a.useEffect)(()=>
1{if(!i||0===e)return;let t=performance.now();requestAnimationFrame(function a(r){let s=Math.min((r-t)/600,1);n(Math.round((1-Math.pow(1-s,3))*e)),s<1&&requestAnimationFrame(a)})},[i,e]),(0,t.jsx)("span",{ref:l,style:{color:r},children:s})}function Y({user:e}){return e?.image?(0,t.jsx)("img",{src:e.image,alt:e.name||"",className:"w-5 h-5 rounded-full object-cover ring-2 ring-white dark:ring-zinc-950 shadow-sm"}):(0,t.jsx)("div",{className:`w-5 h-5 rounded-full bg-gradient-to-br ${(0,W.getAvatarGradient)(e?.name)} flex items-center justify-center text-white text-[8px] font-bold ring-2 ring-white dark:ring-zinc-950 shadow-sm`,title:e?.name,children:(0,W.getInitials)(e?.name)})}let X={hidden:{},visible:{transition:{staggerChildren:.07,delayChildren:.1}}},Q={hidden:{opacity:0,y:20,scale:.96},visible:{opacity:1,y:0,scale:1,transition:{duration:.45,ease:[.25,.46,.45,.94]}}};function Z(){let{data:e}=(0,s.useSession)(),n=(0,r.useRouter)(),{resolvedTheme:l}=(0,H.useTheme)(),[o,c]=(0,a.useState)(null),[d,x]=(0,a.useState)([]),[u,m]=(0,a.useState)(!0),[g,p]=(0,a.useState)([]),[h,f]=(0,a.useState)(!0);function b(e,t){e.preventDefault(),e.stopPropagation(),n.push(t)}if((0,a.useEffect)(()=>{!async function(){if(e?.user)try{let e=await fetch("/api/tasks/my?limit=500");if(e.ok){let t=await e.json();c(t.summary);let a=t.tasks||[],r=e=>"Done"===e.status||"Complete"===e.status,s=e=>r(e)?2:+!e.dueDate,n=[...a].sort((e,t)=>{let a=s(e)-s(t);return 0!==a?a:0===s(e)?new Date(e.dueDate)-new Date(t.dueDate):2===s(e)?new Date(t.completedAt||t.updatedAt||0)-new Date(e.completedAt||e.updatedAt||0):new Date(t.createdAt||0)-new Date(e.createdAt||0)}),l=n.filter(e=>!r(e)),i=n.filter(r).slice(0,10);x([...l,...i])}}catch{}finally{m(!1)}}()},[e]),(0,a.useEffect)(()=>{!async function(){if(e?.user)try{let e=await fetch("/api/milestones/upcoming?days=14");if(e.ok){let t=await e.json();p(t.milestones||[])}}catch{}finally{f(!1)}}()},[e]),u)return(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-3xl p-6",style:{background:"var(--surface-panel)",backdropFilter:"blur(28px)",border:"1px solid var(--border-default)",boxShadow:"0 24px 60px -16px var(--shadow-ambient-xl), 0 4px 12px -4px var(--surface-softer)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-5",children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl bg-gray-100 dark:bg-zinc-900 animate-pulse"}),(0,t.jsx)("div",{className:"h-5 w-28 bg-gray-100 dark:bg-zinc-900 rounded-lg animate-pulse"})]}),(0,t.jsx)("div",{className:"grid grid-cols-3 gap-3",children:[1,2,3].map(e=>(0,t.jsx)("div",{className:"h-24 rounded-2xl bg-gray-50 dark:bg-zinc-900 animate-pulse"},e))})]});if(!o)return null;let v=[{label:"Overdue",value:o.overdue,icon:A.ExclamationTriangleIcon,accent:o.overdue>0?"#EF4444":"var(--text-disabled)",pulse:o.overdue>0},{label:"Due Today",value:o.dueToday,icon:D.ClockIcon,accent:o.dueToday>0?"#F59E0B":"var(--text-disabled)",pulse:!1},{label:"Active",value:o.totalActive,icon:O.BoltIcon,accent:"#6366F1",pulse:!1}];return(0,t.jsxs)(i.motion.div,{initial:"hidden",whileInView:"visible",viewport:{once:!0,margin:"-60px"},variants:X,className:"relative overflow-hidden rounded-3xl",style:{background:"var(--surface-panel)",backdropFilter:"blur(28px)",border:"1px solid var(--border-default)",boxShadow:"inset 0 1px 0 var(--inset-highlight), 0 1px 2px var(--shadow-ambient-sm), 0 24px 60px -18px var(--shadow-ambient-xl), 0 8px 22px -8px rgba(236,72,153,0.10)"},children:[(0,t.jsx)("div",{className:"absolute top-0 left-0 right-0 h-[3px] bg-gradient-to-r from-pink-500 via-rose-500 to-orange-400"}),(0,t.jsx)("div",{"aria-hidden":"true",className:"absolute -top-24 -right-24 w-72 h-72 rounded-full blur-3xl pointer-events-none animate-orb-drift-a",style:{background:"radial-gradient(circle, rgba(249,115,22,0.18), rgba(236,72,153,0.12) 55%, transparent 75%)",opacity:.7}}),(0,t.jsx)("div",{"aria-hidden":"true",className:"absolute -bottom-32 -left-20 w-80 h-80 rounded-full blur-3xl pointer-events-none animate-orb-drift-b",style:{background:"radial-gradient(circle, rgba(99,102,241,0.14), rgba(59,130,246,0.10) 55%, transparent 75%)",opacity:.65}}),(0,t.jsxs)("div",{className:"relative p-5 sm:p-6",children:[(0,t.jsx)(i.motion.div,{variants:Q,className:"flex items-center justify-between mb-5",children:(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center",style:{background:"linear-gradient(135deg, rgba(245,158,11,0.14), rgba(249,115,22,0.14))",border:"1px solid rgba(249,115,22,0.18)"},children:(0,t.jsx)(B.FireIcon,{className:"w-4 h-4 text-orange-500"})}),(0,t.jsx)("h3",{className:"text-[11px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"My Tasks"})]})}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-4",children:[v.map(e=>(0,t.jsx)(i.motion.div,{variants:Q,className:"lg:col-span-2",children:(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-2xl p-5 transition-all duration-500 hover:shadow-2xl hover:-translate-y-0.5 group h-full flex flex-col justify-between",style:{background:"var(--surface-frosted)",border:`1px solid ${e.accent}30`,boxShadow:`inset 0 1px 0 var(--inset-highlight), 0 1px 3px ${e.accent}10, 0 12px 28px -12px ${e.accent}25`,minHeight:110},children:[(0,t.jsx)("div",{className:"absolute -top-8 -right-8 w-24 h-24 rounded-full opacity-25 blur-2xl transition-opacity duration-500 group-hover:opacity-60 pointer-events-none",style:{background:e.accent}}),e.pulse&&e.value>0&&(0,t.jsx)("div",{className:"absolute top-3 right-3",children:(0,t.jsxs)("span",{className:"flex h-2.5 w-2.5",children:[(0,t.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full opacity-75",style:{backgroundColor:e.accent}}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5",style:{backgroundColor:e.accent}})]})}),(0,t.jsxs)("div",{className:"relative z-10 flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-auto",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center shrink-0",style:{background:`${e.accent}14`,boxShadow:`inset 0 0 0 1px ${e.accent}25`},children:(0,t.jsx)(e.icon,{className:"w-4 h-4",style:{color:e.accent}})}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-gray-400 dark:text-zinc-500 leading-tight",children:e.label})]}),(0,t.jsx)("div",{className:"text-3xl font-black tracking-tight leading-none mt-3 tabular-nums",children:(0,t.jsx)(q,{value:e.value,color:e.value>0?e.accent:"var(--text-disabled)"})})]})]})},e.label)),(0,t.jsx)(i.motion.div,{variants:Q,className:"lg:col-span-6",children:(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-2xl p-5 transition-all duration-500 h-full",style:{background:"var(--surface-frosted)",border:"1px solid var(--border-default)",boxShadow:"inset 0 1px 0 var(--inset-highlight), 0 12px 28px -12px var(--shadow-ambient-lg)"},children:[(0,t.jsx)("div",{className:"absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-pink-500/40 via-orange-400/40 to-violet-500/40"}),(0,t.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"Upcoming"}),(0,t.jsxs)("a",{href:"/?tab=tasks",className:"group flex items-center gap-1 text-[11px] font-semibold text-pink-600 dark:text-pink-400 hover:text-pink-700 dark:hover:text-pink-300 transition-colors",children:["View all",(0,t.jsx)(L.ArrowRightIcon,{className:"w-3 h-3 group-hover:translate-x-0.5 transition-transform"})]})]}),0===d.length?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-6 text-center",children:[(0,t.jsx)(V.CheckCircleIcon,{className:"w-8 h-8 text-gray-200 dark:text-zinc-700 mb-2"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-zinc-500",children:"All clear â no tasks yet"}),(0,t.jsx)("a",{href:"/?tab=tasks",className:"mt-2 text-[11px] font-semibold text-pink-600 dark:text-pink-400 hover:text-pink-700 dark:hover:text-pink-300",children:"Create your first task"})]}):(0,t.jsx)("div",{className:"space-y-1",children:d.map((e,a)=>{let r,s=e.dueDate&&new Date(e.dueDate)<new Date&&"Done"!==e.status&&"Complete"!==e.status,n="Done"===e.status||"Complete"===e.status;return(0,t.jsxs)(i.motion.a,{href:`/?tab=tasks&taskId=${e._id}`,initial:{opacity:0,x:-8}
1,animate:{opacity:1,x:0},transition:{delay:.15+.05*a},className:`flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 group ${n?"opacity-50 hover:opacity-80":"hover:bg-white/70 dark:hover:bg-zinc-950/60 hover:shadow-sm hover:-translate-y-px"}`,children:[(0,t.jsx)("div",{className:"relative flex-shrink-0",children:(r=(0,K.adjustStatusColor)(e.statusColor||"#c4c4c4",l),(0,t.jsx)("div",{className:"w-2.5 h-2.5 rounded-full",style:{backgroundColor:r,boxShadow:`0 0 0 2px var(--surface-frosted), 0 0 0 3px ${r}30`}}))}),(0,t.jsxs)("div",{className:"flex-1 min-w-0 flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("span",{className:`min-w-0 text-[13px] text-gray-700 dark:text-zinc-300 truncate font-medium group-hover:text-gray-900 dark:group-hover:text-zinc-100 transition-colors ${n?"line-through":""}`,children:e.title}),e.parentDeal&&(0,t.jsxs)("span",{onClick:t=>b(t,`/dashboard/user/sales/deal/${e.parentDeal._id}`),title:`Deal: ${e.parentDeal.name}`,className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[9px] font-bold flex-shrink-0 cursor-pointer hover:shadow-sm transition-all",style:{background:"rgba(249,115,22,0.08)",color:"#F97316",border:"1px solid rgba(249,115,22,0.18)"},children:[(0,t.jsx)(_.BriefcaseIcon,{className:"w-2.5 h-2.5"}),(0,t.jsx)("span",{className:"max-w-[90px] truncate",children:e.parentDeal.name})]}),e.milestone&&(0,t.jsxs)("span",{onClick:t=>b(t,`/dashboard/user/campaign/${e.linkedCampaign?._id||e.linkedCampaign}?tab=milestones`),title:`Milestone: ${e.milestone.title}`,className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[9px] font-bold flex-shrink-0 cursor-pointer hover:shadow-sm transition-all",style:{background:`${e.milestone.color||"#EC4899"}14`,color:e.milestone.color||"#EC4899",border:`1px solid ${e.milestone.color||"#EC4899"}25`},children:[(0,t.jsx)(U.FlagIcon,{className:"w-2.5 h-2.5"}),(0,t.jsx)("span",{className:"max-w-[90px] truncate",children:e.milestone.title})]}),e.linkedCampaign&&(0,t.jsx)(G.default,{type:"campaign",entity:e.linkedCampaign,size:"sm",showLabel:!1,nonInteractive:!0}),e.linkedCreator&&(0,t.jsx)(G.default,{type:"creator",entity:e.linkedCreator,size:"sm",showLabel:!1,nonInteractive:!0}),e.organization&&(0,t.jsx)(G.default,{type:"organization",entity:e.organization,size:"sm",showLabel:!1,nonInteractive:!0}),e.linkedPost&&(0,t.jsx)(G.default,{type:"post",entity:e.linkedPost,size:"sm",showLabel:!1,nonInteractive:!0})]}),"critical"===e.priority&&(0,t.jsx)("span",{className:"text-[9px] font-black uppercase tracking-wider px-1.5 py-0.5 rounded-md flex-shrink-0",style:{background:"rgba(239,68,68,0.12)",color:"#ef4444",border:"1px solid rgba(239,68,68,0.22)"},children:"!!!"}),"high"===e.priority&&(0,t.jsx)("span",{className:"text-[9px] font-black uppercase tracking-wider px-1.5 py-0.5 rounded-md flex-shrink-0",style:{background:"rgba(245,158,11,0.12)",color:"#f59e0b",border:"1px solid rgba(245,158,11,0.22)"},children:"!!"}),e.assignees?.length>0&&(0,t.jsx)("div",{className:"flex -space-x-1.5 flex-shrink-0",children:e.assignees.slice(0,2).map(e=>(0,t.jsx)(Y,{user:e},e._id||e))}),e.dueDate&&(0,t.jsx)("span",{className:"text-[10px] font-semibold flex-shrink-0 px-2 py-0.5 rounded-md",style:s?{color:"#ef4444",background:"rgba(239,68,68,0.12)",border:"1px solid rgba(239,68,68,0.22)"}:{color:"var(--text-tertiary)",background:"var(--surface-soft)",border:"1px solid var(--border-default)"},children:new Date(e.dueDate).toLocaleDateString("en-US",{month:"short",day:"numeric"})}),(0,t.jsx)(L.ArrowRightIcon,{className:"w-3 h-3 text-gray-300 dark:text-zinc-700 group-hover:text-pink-500 group-hover:translate-x-0.5 transition-all flex-shrink-0"})]},e._id)})})]})})]}),h?(0,t.jsx)(i.motion.div,{variants:Q,className:"mt-4",children:(0,t.jsx)("div",{className:"h-32 rounded-2xl bg-gray-50 dark:bg-zinc-900 animate-pulse"})}):g.length>0&&(0,t.jsx)(i.motion.div,{variants:Q,className:"mt-4",children:(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-2xl p-5",style:{background:"var(--surface-frosted)",border:"1px solid var(--border-default)",boxShadow:"inset 0 1px 0 var(--inset-highlight), 0 12px 28px -12px var(--shadow-ambient-lg)"},children:[(0,t.jsx)("div",{className:"absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-pink-500/40 via-orange-400/40 to-violet-500/40"}),(0,t.jsxs)("div",{className:"flex items-center gap-2.5 mb-4",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center",style:{background:"rgba(236,72,153,0.14)",border:"1px solid rgba(236,72,153,0.18)"},children:(0,t.jsx)(U.FlagIcon,{className:"w-4 h-4",style:{color:"#EC4899"}})}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"Milestones due soon"})]}),(0,t.jsx)("div",{className:"space-y-1",children:g.map((e,a)=>{let r=new Date(e.endDate),s=new Date,n=Math.ceil((r.setHours(0,0,0,0)-s.setHours(0,0,0,0))/864e5),l=n<0,o=e.color||"#EC4899";return(0,t.jsxs)(i.motion.a,{href:e.campaign?`/dashboard/user/campaign/${e.campaign?._id||e.campaign}?tab=milestones`:e.deal?`/dashboard/user/sales/deal/${e.deal?._id||e.deal}`:"#",initial:{opacity:0,x:-8}
1,animate:{opacity:1,x:0},transition:{delay:.1+.05*a},className:"flex items-center gap-3 px-3 py-2.5 rounded-xl transition-all duration-200 hover:bg-white/70 dark:hover:bg-zinc-950/60 hover:shadow-sm hover:-translate-y-px group",children:[(0,t.jsx)("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:o,boxShadow:`0 0 0 2px var(--surface-frosted), 0 0 0 3px ${o}30`}}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-[13px] font-medium text-gray-700 dark:text-zinc-300 truncate group-hover:text-gray-900 dark:group-hover:text-zinc-100 transition-colors",children:e.title}),(e.campaign?.name||e.deal?.name)&&(0,t.jsx)("div",{className:"text-[11px] text-gray-400 dark:text-zinc-500 truncate",children:e.campaign?.name||`Deal \xb7 ${e.deal.name}`})]}),(0,t.jsx)("span",{className:"text-[10px] font-semibold flex-shrink-0 px-2 py-0.5 rounded-md whitespace-nowrap",style:l?{color:"#ef4444",background:"rgba(239,68,68,0.12)",border:"1px solid rgba(239,68,68,0.22)"}:{color:"var(--text-tertiary)",background:"var(--surface-soft)",border:"1px solid var(--border-default)"},children:l?`overdue by ${Math.abs(n)}d`:0===n?"today":`in ${n}d`}),e.slipDays>0&&(0,t.jsxs)("span",{className:"text-[9px] font-black uppercase tracking-wider px-1.5 py-0.5 rounded-md flex-shrink-0",style:{background:"rgba(239,68,68,0.12)",color:"#ef4444",border:"1px solid rgba(239,68,68,0.22)"},children:["+",e.slipDays,"d"]}),(0,t.jsx)(L.ArrowRightIcon,{className:"w-3 h-3 text-gray-300 dark:text-zinc-700 group-hover:text-pink-500 group-hover:translate-x-0.5 transition-all flex-shrink-0"})]},e._id)})})]})})]})]})}var J=e.i(522016),ee=e.i(541179),et=e.i(847604),ea=e.i(639793),er=e.i(984174),es=e.i(725212),en=e.i(673130),el=e.i(259792),ei=e.i(389472);let eo=a.forwardRef(function({title:e,titleId:t,...r},s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},r),e?a.createElement("title",{id:t},e):null,a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 13.5h3.86a2.25 2.25 0 0 1 2.012 1.244l.256.512a2.25 2.25 0 0 0 2.013 1.244h3.218a2.25 2.25 0 0 0 2.013-1.244l.256-.512a2.25 2.25 0 0 1 2.013-1.244h3.859m-19.5.338V18a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18v-4.162c0-.224-.034-.447-.1-.661L19.24 5.338a2.25 2.25 0 0 0-2.15-1.588H6.911a2.25 2.25 0 0 0-2.15 1.588L2.35 13.177a2.25 2.25 0 0 0-.1.661Z"}))});var ec=e.i(817264),ed=e.i(779529);let ex=a.forwardRef(function({title:e,titleId:t,...r},s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},r),e?a.createElement("title",{id:t},e):null,a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 7.5h1.5m-1.5 3h1.5m-7.5 3h7.5m-7.5 3h7.5m3-9h3.375c.621 0 1.125.504 1.125 1.125V18a2.25 2.25 0 0 1-2.25 2.25M16.5 7.5V18a2.25 2.25 0 0 0 2.25 2.25M16.5 7.5V4.875c0-.621-.504-1.125-1.125-1.125H4.125C3.504 3.75 3 4.254 3 4.875V18a2.25 2.25 0 0 0 2.25 2.25h13.5M6 7.5h3v3H6v-3Z"}))});var eu=e.i(171387),em=e.i(142663);let eg={task:{Icon:ee.ClipboardDocumentListIcon,accent:"#f97316"},conversation:{Icon:et.ChatBubbleLeftRightIcon,accent:"#ec4899"},mention:{Icon:ea.AtSymbolIcon,accent:"#8b5cf6"},campaign:{Icon:es.MegaphoneIcon,accent:"#f97316"},news:{Icon:ex,accent:"#0ea5e9"}},ep={user:{accent:"#ec4899",FallbackIcon:en.UserCircleIcon},creator:{accent:"#10b981",FallbackIcon:en.UserCircleIcon},campaign:{accent:"#f97316",FallbackIcon:es.MegaphoneIcon},organization:{accent:"#8b5cf6",FallbackIcon:el.BuildingOffice2Icon}};function eh(){let e=new Date;return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}async function ef(e,t){if(!e.body)return;let a=e.body.getReader(),r=new TextDecoder,s="";for(;;){let e,{value:n,done:l}=await a.read();if(l)break;for(s+=r.decode(n,{stream:!0});-1!==(e=s.indexOf("\n\n"));){let a,r=s.slice(0,e);s=s.slice(e+2);let n="message",l=[];for(let e of r.split("\n"))e.startsWith("event:")?n=e.slice(6).trim():e.startsWith("data:")&&l.push(e.slice(5).trim());if(l.length){try{a=JSON.parse(l.join("\n"))}catch{continue}"init"===n?t({kind:"init",payload:a}):"delta"===n?t({kind:"delta",delta:a.text||""}):"reset"===n?t({kind:"reset"}):"done"===n?t({kind:"done",payload:a}):"error"===n&&t({kind:"error",payload:a})}}}}function eb(){let[e,r]=(0,a.useState)(null),[s,n]=(0,a.useState)(!0),[l,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(null),[,x]=(0,a.useState)(0),u=(0,a.useRef)(0),m=(0,a.useRef)(null),g=(0,a.useRef)(null),[p,h]=(0,a.useState)(""),[f,b]=(0,a.useState)(!1),v=(0,a.useRef)(""),y=(0,a.useRef)(null),k=(0,a.useRef)(0),j=(0,a.useRef)(0),w=(0,a.useRef)(!1),{openOrCreateDM:N}=(0,em.useConversation)();function C(){y.current&&cancelAnimationFrame(y.current),y.current=null,k.current=0,j.current=0,w.current=!1}async function z({force:e=!1}={}){return g.current||(e&&o(!0),g.current=(async()=>{try{let t=new URLSearchParams({h:String(new Date().getHours()),stream:"1"});e&&t.set("refresh","1");let a=await fetch(`/api/me/morning-briefing?${t.toString()}`,{cache:"no-store"});if(!a.ok)throw Error(`status ${a.status}`);if((a.headers.get("content-type")||"").includes("text/event-stream"))v.current="",w.current=!1,h(""),b(!0),function(){if(y.current)return;k.current=performance.now(),j.current=0;let e=t=>{let a=t-k.current;k.current=t;let r=v.current,s=90,n=r.length-0;n>40&&(s=Math.min(360,90+1.4*n)),j.current+=a/1e3*s;let l=Math.floor(j.current);j.current-=l,h(t=>{let a=v.current;if(t.length>=a.length)return w.current?(y.current=null,b(!1)):y.current=requestAnimationFrame(e),t;let r=a.slice(0,Math.min(a.length,t.length+Math.max(1,l)));return y.current=requestAnimationFrame(e),r})};y.current=requestAnimationFrame(e)}(),await ef(a,({kind:e,payload:t,delta:a})=>{"init"===e?r(e=>({...e||{},...t,summary:"",actions:[],fallback:!1})):"delta"===e?v.current+=a||"":"reset"===e?(v.current="",h("")):"done"===e&&("string"==typeof t?.summary&&(v.current=t.summary),w.current=!0,r(t))});else{let e=await a.json();C(),v.current=e?.summary||"",h(e?.summary||""),b(!1),r(e)}d(null),u.current=Date.now(),m.current=eh()}catch(e){d(e.message||"Failed to load")}finally{n(!1),o(!1),g.current=null}})()),g.current}if((0,a.useEffect)(()=>()=>C(),[]),(0,a.useEffect)(()=>{z()},[]),(0,a.useEffect)(()=>{function e(){"u"<typeof document||document.hidden||(Date.now()-u.current>=18e5||m.current!==eh())&&z()}return document.addEventListener("visibilitychange",e),window.addEventListener("focus",e),()=>{document.removeEventListener("visibilitychange",e),window.removeEventListener("focus",e)}},[]),(0,a.useEffect)(()=>{let e=setInterval(()=>x(e=>e+1),6e4);return()=>clearInterval(e)},[]),s&&!e)return(0,t.jsx)(eS,{});if(c&&!e||!e)return null;let S=(e.actions||[]).length>0,E=(e.entities||[]).length>0,P=(e.topTasks||[]).length>0,$=e.stats||{},M=$.subtasksTotal||0,F=$.subtasksDone||0,I=M>0?Math.round(F/M*100):0;return(0,t.jsxs)("div",{className:"rounded-2xl backdrop-blur-xl p-5 relative overflow-hidden",style:{background:"var(--surface-frosted)",border:"1px solid var(--border-default)",boxShadow:"0 4px 24px rgba(236,72,153,0.06)"},children:[(0,t.jsx)("div",{"aria-hidden":"true",className:"absolute -top-12 -right-12 w-40 h-40 rounded-full opacity-25 blur-3xl pointer-events-none",style:{background:"linear-gradient(135deg, rgba(236,72,153,0.6), rgba(249,115,22,0.4))"}}),(0,t.jsxs)("div",{className:"relative flex items-start gap-3",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"linear-gradient(135deg, rgba(236,72,153,0.14), rgba(249,115,22,0.14))",border:"1px solid rgba(236,72,153,0.25)"},children:(0,t.jsx)(er.SparklesIcon,{className:"w-4 h-4 text-pink-500"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-baseline justify-between gap-3 flex-wrap",children:[(0,t.jsx)("h3",{className:"text-[11px] font-bold uppercase tracking-[0.16em] text-gray-500 dark:text-zinc-400",children:"Briefing"}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-[10px] text-gray-400 dark:text-zinc-500",children:[(0,t.jsxs)("span",{children:[e.fallback?"Static · ":"",function(e){if(!e)return"";let t=Date.now()-new Date(e).getTime();if(t<3e4)return"just now";let a=Math.floor(t/1e3);if(a<60)return`${a}s ago`;let r=Math.floor(a/60);if(r<60)return`Updated ${r} min ago`;let s=Math.floor(r/60);return s<24?`Updated ${s}h ago`:`Updated ${Math.floor(s/24)}d ago`}(e.generatedAt)]}),(0,t.jsx)("button",{type:"button",onClick:()=>z({force:!0}),disabled:l,className:"inline-flex items-center justify-center w-6 h-6 rounded-md transition-colors hover:bg-gray-100 dark:hover:bg-zinc-900 disabled:opacity-60 disabled:cursor-not-allowed",title:l?"Refreshingâ¦":"Refresh briefing","aria-label":"Refresh briefing",children:(0,t.jsx)(ed.ArrowPathIcon,{className:`w-3.5 h-3.5 ${l?"animate-spin":""}`})})]})]}),(0,t.jsxs)(i.motion.p,{initial:{opacity:0,y:4}
1,animate:{opacity:1,y:0},transition:{duration:.4},className:"text-[15px] leading-relaxed text-gray-800 dark:text-zinc-200 mt-2",children:[f?p:e.summary,f&&(0,t.jsx)(ey,{})]},e.generatedAt),(0,t.jsx)(ev,{stats:$,subtasksDone:F,subtasksTotal:M,subtasksPct:I,dailyCompletions:e.recentActivity?.dailyCompletions||[]}),E&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.16em] text-gray-400 dark:text-zinc-500 mr-1",children:"In focus"}),(0,t.jsx)(i.motion.div,{initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:.03}}},className:"flex flex-wrap gap-1.5",children:e.entities.map(e=>(0,t.jsx)(ez,{entity:e,onUserClick:e=>N({otherUserId:e})},`${e.kind}-${e.id}`))})]}),P&&(0,t.jsx)(ej,{tasks:(e.topTasks||[]).slice(0,3)}),S&&(0,t.jsx)(i.motion.div,{initial:"hidden",animate:"visible",variants:{hidden:{},visible:{transition:{staggerChildren:.04}}},className:"flex flex-wrap gap-1.5 mt-3",children:e.actions.map((e,a)=>(0,t.jsx)(eN,{action:e},`${e.kind}-${a}-${e.href}`))})]})]})]})}function ev({stats:e,subtasksDone:a,subtasksTotal:r,subtasksPct:s,dailyCompletions:n}){let l=e.overdueCount||0,o=e.completedThisWeek||0,c=[{key:"active",Icon:O.BoltIcon,accent:"#f97316",value:e.openTasks||0,label:"active"},{key:"overdue",Icon:A.ExclamationTriangleIcon,accent:l>0?"#dc2626":"var(--text-tertiary)",value:l,label:"overdue"},{key:"today",Icon:ei.CalendarDaysIcon,accent:"#ec4899",value:e.dueTodayCount||0,label:"due today"},{key:"unread",Icon:eo,accent:"#8b5cf6",value:e.unreadNotifications||0,label:"unread"},...o>0?[{key:"done",Icon:ec.TrophyIcon,accent:"#10b981",value:o,label:"done this week",sparkline:n}]:[]];return(0,t.jsxs)("div",{className:"mt-3 flex items-center gap-x-3 gap-y-1.5 flex-wrap text-[12px] text-gray-600 dark:text-zinc-300",children:[c.map((e,a)=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 tabular-nums",children:[(0,t.jsx)(e.Icon,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:e.accent}}),(0,t.jsx)("span",{className:"font-bold",style:{color:"var(--text-primary)"},children:e.value}),(0,t.jsx)("span",{className:"text-gray-500 dark:text-zinc-400",children:e.label}),e.sparkline&&e.sparkline.length>0&&(0,t.jsx)(ek,{data:e.sparkline,accent:e.accent}),a<c.length-1&&(0,t.jsx)("span",{"aria-hidden":"true",className:"text-gray-300 dark:text-zinc-700 ml-2",children:"·"})]},e.key)),r>0&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-2 ml-auto min-w-[140px]",children:[(0,t.jsx)("span",{className:"text-[10px] uppercase tracking-wider font-bold text-gray-400 dark:text-zinc-500",children:"Subs"}),(0,t.jsx)("span",{className:"h-1.5 w-20 rounded-full overflow-hidden flex-shrink-0",style:{background:"var(--surface-softer)"},children:(0,t.jsx)(i.motion.span,{className:"block h-full rounded-full",initial:{width:0},animate:{width:`${s}%`},transition:{duration:.6,ease:[.22,1,.36,1]},style:{background:"linear-gradient(90deg, #ec4899, #f97316)"}})}),(0,t.jsxs)("span",{className:"tabular-nums text-[11px] text-gray-500 dark:text-zinc-400",children:[(0,t.jsx)("span",{className:"font-bold text-gray-900 dark:text-zinc-100",children:a}),"/",r]})]})]})}function ey(){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{"aria-hidden":"true",className:"jsx-f3814b8872b0ee24",children:" "}),(0,t.jsx)("span",{"aria-hidden":"true",style:{width:"0.5ch",height:"1.05em",background:"currentColor",borderRadius:1,marginLeft:-2,opacity:.7,animation:"briefingCaretBlink 1s steps(2, start) infinite"},className:"jsx-f3814b8872b0ee24 inline-block align-[-0.15em]"}),(0,t.jsx)(C.default,{id:"f3814b8872b0ee24",children:"@keyframes briefingCaretBlink{to{opacity:0}}"})]})}function ek({data:e,accent:a="#10b981"}){if(!Array.isArray(e)||0===e.length)return null;let r=Math.max(1,...e.map(e=>e.count||0)),s=(56-4*e.length)/(e.length-1||1);return(0,t.jsx)("svg",{width:56,height:14,viewBox:"0 0 56 14",className:"ml-0.5 flex-shrink-0","aria-hidden":"true",children:e.map((e,n)=>{let l=e.count||0,i=l>0?Math.max(2,Math.round(l/r*14)):1;return(0,t.jsx)("rect",{x:n*(4+s),y:14-i,width:4,height:i,rx:1,fill:a,opacity:l>0?.85:.25},e.date||n)})})}function ej({tasks:e}){return(0,t.jsx)("div",{className:"mt-3 flex flex-col gap-1.5",children:e.map(e=>(0,t.jsx)(ew,{task:e},e.id))})}function ew({task:e}){let a=e.subitems||{total:0,done:0,openCount:0},r=a.total>0,s=r?Math.round(a.done/a.total*100):0,n=e.overdue?"#dc2626":e.dueToday?"#ec4899":"#f97316";return(0,t.jsxs)(J.default,{href:e.href||"#",className:"group flex items-center gap-2.5 px-2.5 py-1.5 rounded-lg transition-all hover:-translate-y-0.5",style:{background:"var(--surface-soft)",border:`1px solid ${n}22`},children:[e.dueToday||e.overdue?(0,t.jsx)(A.ExclamationTriangleIcon,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:n}}):(0,t.jsx)(V.CheckCircleIcon,{className:"w-3.5 h-3.5 flex-shrink-0",style:{color:n}}),(0,t.jsx)("span",{className:"text-[12px] font-semibold text-gray-900 dark:text-zinc-100 truncate flex-shrink min-w-0",children:e.title}),e.dueLabel&&(0,t.jsx)("span",{className:"text-[9px] font-bold uppercase tracking-wider tabular-nums flex-shrink-0",style:{color:n},children:e.dueLabel}),r&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 ml-auto flex-shrink-0",children:[(0,t.jsx)("span",{className:"h-1 w-16 rounded-full overflow-hidden flex-shrink-0",style:{background:"var(--surface-softer)"},children:(0,t.jsx)("span",{className:"block h-full rounded-full transition-all",style:{width:`${s}%`,background:`linear-gradient(90deg, ${n}, ${n}cc)`}})}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 dark:text-zinc-500 tabular-nums",children:[a.done,"/",a.total]})]}),(0,t.jsx)(L.ArrowRightIcon,{className:"w-3 h-3 text-gray-300 dark:text-zinc-700 group-hover:text-gray-500 dark:group-hover:text-zinc-400 group-hover:translate-x-0.5 transition-all flex-shrink-0"})]})}function eN({action:e}){let a=eg[e.kind]||eg.task,r=a.Icon,s=e.avatar,n=(e.reason||"").trim(),l=e.href||"#",o=/^https?:\/\//i.test(l),c=o?(0,t.jsx)(eu.ArrowTopRightOnSquareIcon,{className:"w-3 h-3 text-gray-300 dark:text-zinc-700 group-hover:text-gray-500 dark:group-hover:text-zinc-400 group-hover:translate-x-0.5 transition-all flex-shrink-0"}):(0,t.jsx)(L.ArrowRightIcon,{className:"w-3 h-3 text-gray-300 dark:text-zinc-700 group-hover:text-gray-500 dark:group-hover:text-zinc-400 group-hover:translate-x-0.5 transition-all flex-shrink-0"}),d=(0,t.jsxs)(t.Fragment,{children:[s?(0,t.jsx)(eC,{name:s.name,image:s.image,accent:a.accent}):(0,t.jsx)("span",{className:"w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0",style:{background:`${a.accent}18`,color:a.accent},children:(0,t.jsx)(r,{className:"w-3 h-3"})}),(0,t.jsx)("span",{className:"text-[12px] font-semibold text-gray-900 dark:text-zinc-100 truncate max-w-[160px]",children:e.label}),n&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{"aria-hidden":"true",className:"text-[10px] text-gray-300 dark:text-zinc-700",children:"·"}),(0,t.jsx)("span",{className:"text-[11px] text-gray-500 dark:text-zinc-400 truncate max-w-[180px]",children:n})]}),c]}),x="group inline-flex items-center gap-2 pl-1.5 pr-2.5 py-1 rounded-full transition-all hover:-translate-y-0.5 max-w-full",u={background:"var(--surface-soft)",border:`1px solid ${a.accent}28`};return(0,t.jsx)(i.motion.div,{variants:{hidden:{opacity:0,y:6},visible:{opacity:1,y:0}},children:o?(0,t.jsx)("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:x,style:u,title:n,children:d}):(0,t.jsx)(J.default,{href:l,className:x,style:u,title:n,children:d})})}function eC({name:e,image:a,accent:r}){if(a)return(0,t.jsx)("img",{src:a,alt:e||"",className:"w-5 h-5 rounded-md object-cover flex-shrink-0"});let s=(e||"?").trim()[0]?.toUpperCase()||"?";return(0,t.jsx)("span",{className:"w-5 h-5 rounded-md flex items-center justify-center text-[9px] font-bold text-white flex-shrink-0",style:{background:`linear-gradient(135deg, ${r}, ${r}cc)`},children:s})}function ez({entity:e,onUserClick:a}){let r=ep[e.kind]||ep.user,s=r.FallbackIcon,n=e.image?(0,t.jsx)("img",{src:e.image,alt:e.name||"",className:"w-5 h-5 rounded-full object-cover flex-shrink-0"}):(0,t.jsx)("span",{className:"w-5 h-5 rounded-full flex items-center justify-center flex-shrink-0",style:{background:`${r.accent}18`},children:(0,t.jsx)(s,{className:"w-3 h-3",style:{color:r.accent}})}),l=(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 pl-1 pr-2.5 py-0.5 rounded-full text-[11px] font-semibold transition-all hover:-translate-y-0.5",style:{background:"var(--surface-soft)",border:`1px solid ${r.accent}25`,color:"var(--text-primary)"},title:`${e.kind} \xb7 ${e.name}`,children:[n,(0,t.jsx)("span",{className:"truncate max-w-[160px]",children:e.name})]});return"user"===e.kind?(0,t.jsx)(i.motion.button,{type:"button",onClick:()=>a?.(e.id),variants:{hidden:{opacity:0,scale:.96},visible:{opacity:1,scale:1}},children:l}):(0,t.jsx)(i.motion.div,{variants:{hidden:{opacity:0,scale:.96},visible:{opacity:1,scale:1}},children:(0,t.jsx)(J.default,{href:e.href||"#",children:l})})}function eS(){return(0,t.jsx)("div",{className:"rounded-2xl p-5 relative overflow-hidden animate-pulse",style:{background:"var(--surface-frosted)",border:"1px solid var(--border-default)"},children:(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex-shrink-0",style:{background:"var(--surface-softer)"}}),(0,t.jsxs)("div",{className:"flex-1 space-y-2",children:[(0,t.jsx)("div",{className:"h-3 w-24 rounded",style:{background:"var(--surface-softer)"}}),(0,t.jsx)("div",{className:"h-3 w-full rounded",style:{background:"var(--surface-softer)"}}),(0,t.jsx)("div",{className:"h-3 w-2/3 rounded",style:{background:"var(--surface-softer)"}})]})]})})}var eE=e.i(683512),eP=e.i(713691),e$=e.i(633576),eM=e.i(468094),eF=e.i(163341);function eI(e){if(null==e||isNaN(e))return"0";let t=Number(e);return t>=1e9?(t/1e9).toFixed(1)+"B":t>=1e6?(t/1e6).toFixed(1)+"M":t>
1=1e3?(t/1e3).toFixed(1)+"K":Math.round(t).toLocaleString()}function eR({value:e,formatFn:r=eI}){let[s,n]=(0,a.useState)(0),l=(0,a.useRef)(null),i=(0,o.useInView)(l,{margin:"-50px"}),d=(0,a.useRef)(0);return(0,a.useEffect)(()=>{if(!i||e===d.current)return;let t=d.current;return d.current=e,(0,c.animate)(t,e,{duration:1.8,ease:[.25,.46,.45,.94],onUpdate:e=>n(e)}).stop},[i,e]),(0,t.jsx)("span",{ref:l,children:r(s)})}function eT({children:e,className:r="",intensity:s=6}){let n=(0,a.useRef)(null),l=(0,d.useMotionValue)(0),o=(0,d.useMotionValue)(0),c=(0,u.useSpring)((0,x.useTransform)(o,[-.5,.5],[s,-s]),{stiffness:300,damping:30}),m=(0,u.useSpring)((0,x.useTransform)(l,[-.5,.5],[-s,s]),{stiffness:300,damping:30}),g=(0,a.useRef)(0),p=(0,a.useCallback)(e=>{if(!n.current||g.current)return;let{clientX:t,clientY:a}=e;g.current=requestAnimationFrame(()=>{if(g.current=0,!n.current)return;let e=n.current.getBoundingClientRect();l.set((t-e.left)/e.width-.5),o.set((a-e.top)/e.height-.5)})},[l,o]),h=(0,a.useCallback)(()=>{g.current&&(cancelAnimationFrame(g.current),g.current=0),l.set(0),o.set(0)},[l,o]);return(0,t.jsx)(i.motion.div,{ref:n,onMouseMove:p,onMouseLeave:h,style:{rotateX:c,rotateY:m,transformPerspective:800,transformStyle:"preserve-3d",backfaceVisibility:"hidden",willChange:"transform",isolation:"isolate"},className:r,children:e})}function eA({children:e,className:a="",delay:r=0}){return(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:40},whileInView:{opacity:1,y:0},viewport:{once:!0,margin:"-80px"},transition:{duration:.8,delay:r,ease:[.25,.46,.45,.94]},className:a,children:e})}let eD={hidden:{},visible:{transition:{staggerChildren:.08,delayChildren:.15}}},eV={hidden:{opacity:0,y:24,scale:.96},visible:{opacity:1,y:0,scale:1,transition:{duration:.5,ease:[.25,.46,.45,.94]}}};function eL({icon:e,label:a,value:r,formatFn:s,accent:n}){return(0,t.jsx)(i.motion.div,{variants:eV,className:"h-full",children:(0,t.jsx)(eT,{intensity:8,className:"h-full",children:(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border backdrop-blur-xl p-5 transition-all duration-500 hover:shadow-2xl group h-full flex flex-col justify-between",style:{background:"var(--surface-frosted)",borderColor:`${n}25`,boxShadow:`0 4px 24px ${n}08`,minHeight:120},children:[(0,t.jsx)("div",{className:"absolute -top-8 -right-8 w-24 h-24 rounded-full opacity-20 blur-2xl transition-opacity duration-500 group-hover:opacity-50 pointer-events-none",style:{background:n}}),(0,t.jsxs)("div",{className:"relative z-10 flex flex-col h-full",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-auto",children:[(0,t.jsx)("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center shrink-0",style:{background:`${n}14`},children:(0,t.jsx)(e,{className:"w-4 h-4",style:{color:n}})}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-gray-400 dark:text-zinc-500 leading-tight",children:a})]}),(0,t.jsx)("div",{className:"text-2xl md:text-3xl font-black tracking-tight text-gray-900 dark:text-zinc-100 leading-none mt-3",children:(0,t.jsx)(eR,{value:r,formatFn:s})})]})]})})})}function eB({icon:e,label:a,value:r,metric:s,color:n,onClick:l}){return(0,t.jsxs)(i.motion.button,{variants:eV,onClick:l,className:"group flex items-center gap-3 px-4 py-3 rounded-2xl border backdrop-blur-sm transition-all duration-300 hover:shadow-lg hover:-translate-y-0.5 shrink-0 text-left",style:{background:"var(--surface-panel)",borderColor:`${n}20`},whileHover:{scale:1.02},whileTap:{scale:.98},children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center shrink-0",style:{background:`${n}12`},children:(0,t.jsx)(e,{className:"w-4 h-4",style:{color:n}})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-[9px] font-bold uppercase tracking-[0.1em] text-gray-400 dark:text-zinc-500",children:a}),(0,t.jsx)("div",{className:"text-sm font-bold text-gray-900 dark:text-zinc-100 truncate max-w-[180px]",children:r}),(0,t.jsx)("div",{className:"text-[11px] font-semibold",style:{color:n},children:s})]}),(0,t.jsx)(L.ArrowRightIcon,{className:"w-3.5 h-3.5 text-gray-300 dark:text-zinc-700 group-hover:text-gray-500 dark:group-hover:text-zinc-400 transition-colors shrink-0 ml-1"})]})}function eO(){return(0,t.jsx)("div",{className:"mx-8 md:mx-32 my-2",children:(0,t.jsx)("div",{className:"h-px bg-gradient-to-r from-transparent via-gray-200 to-transparent dark:via-zinc-800"})})}let e_=function(){let e,[n,l]=(0,a.useState)([]),[o,c]=(0,a.useState)([]),[d,x]=(0,a.useState)([]),{data:u}
1=(0,s.useSession)(),g=(0,r.useRouter)();(0,a.useEffect)(()=>{!async function(){try{let[e,t,a]=await Promise.all([fetch("https://www.socialscout.ai/api/getFilteredCampaigns?status=Live&limit=10000"),fetch("https://www.socialscout.ai/api/TopCreators"),fetch("https://www.socialscout.ai/api/getPosts?monitored=true&limit=8")]);if(!e.ok)throw Error(`Campaigns: ${e.status}`);if(!t.ok)throw Error(`Creators: ${t.status}`);let[r,s]=await Promise.all([e.json(),t.json()]);if(l(r.campaigns||[]),c(s),a.ok){let e=await a.json();x(e.posts||[])}}catch(e){console.error(e),m.default.error(`Failed to fetch data: ${e.message}`)}}()},[]);let p=(0,a.useMemo)(()=>{let e=n.reduce((e,t)=>e+(t.totalViews||0),0),t=n.reduce((e,t)=>e+(t.totalEngagements||0),0),a=n.reduce((e,t)=>e+(t.totalClicks||0),0),r=new Set;return n.forEach(e=>{e.posts&&e.posts.forEach(e=>{e.creator&&r.add(String(e.creator))})}),{totalViews:e,totalEng:t,totalClicks:a,avgER:e>0?t/e*100:0,liveCreatorCount:r.size,liveCampaigns:n.length}},[n,o]),h=(0,a.useMemo)(()=>{if(0===n.length)return[];let e=[],t=[...n].sort((e,t)=>(t.totalViews||0)-(e.totalViews||0));t[0]?.totalViews>0&&e.push({icon:ec.TrophyIcon,label:"Top Campaign",value:t[0].name,metric:eI(t[0].totalViews)+" views",color:"#3b82f6",id:t[0]._id});let a=n.filter(e=>e.totalViews>0).map(e=>({...e,er:(e.totalEngagements||0)/e.totalViews*100})).sort((e,t)=>t.er-e.er);a[0]?.er>0&&e.push({icon:B.FireIcon,label:"Best Engagement",value:a[0].name,metric:a[0].er.toFixed(1)+"% ER",color:"#10b981",id:a[0]._id});let r=[...n].sort((e,t)=>(t.totalClicks||0)-(e.totalClicks||0));r[0]?.totalClicks>0&&e.push({icon:eP.CursorArrowRaysIcon,label:"Most Clicks",value:r[0].name,metric:eI(r[0].totalClicks)+" clicks",color:"#f59e0b",id:r[0]._id});let s=[...n].sort((e,t)=>(t.totalPaidViews||0)-(e.totalPaidViews||0));return s[0]?.totalPaidViews>0&&e.push({icon:eF.ChartBarIcon,label:"Top Paid",value:s[0].name,metric:eI(s[0].totalPaidViews)+" paid views",color:"#8b5cf6",id:s[0]._id}),e},[n]),f=u?.user?.name?.split(" ")[0]||"there",b=u?.user?.agency?.name;return(0,t.jsxs)("div",{className:"min-h-screen",children:[(0,t.jsx)("div",{className:"relative",children:(0,t.jsxs)("div",{className:"relative z-10 mx-8 md:mx-32 pt-8 pb-6",children:[(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.7,ease:[.25,.46,.45,.94]},children:(0,t.jsxs)("h1",{className:"text-4xl md:text-5xl font-black tracking-tight text-gray-900 dark:text-zinc-100 mb-2",children:[(e=new Date().getHours())<12?"Good morning":e<17?"Good afternoon":"Good evening",","," ",(0,t.jsx)("span",{className:"bg-gradient-to-r from-pink-500 via-rose-500 to-orange-400 bg-clip-text text-transparent",children:f})]})}),(0,t.jsxs)(i.motion.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.7,delay:.12},className:"text-gray-500 dark:text-zinc-400 text-base max-w-xl mb-5",children:[b?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-gray-700 dark:text-zinc-300",children:b})," ","command center"]}):"Your influencer marketing command center"," ","â real-time performance at a glance."]}),(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.7,delay:.18},className:"mb-8",children:(0,t.jsx)(eb,{})}),(0,t.jsxs)(i.motion.div,{variants:eD,initial:"hidden",animate:"visible",className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-3 mb-8",children:[(0,t.jsx)(eL,{icon:es.MegaphoneIcon,label:"Live Campaigns",value:p.liveCampaigns,formatFn:e=>Math.round(e).toString(),accent:"#ec4899"}),(0,t.jsx)(eL,{icon:eE.EyeIcon,label:"Total Views",value:p.totalViews,accent:"#3b82f6"}),(0,t.jsx)(eL,{icon:O.BoltIcon,label:"Engagements",value:p.totalEng,accent:"#8b5cf6"}),(0,t.jsx)(eL,{icon:eM.ArrowTrendingUpIcon,label:"Avg ER",value:p.avgER,formatFn:e=>e.toFixed(2)+"%",accent:"#10b981"}),(0,t.jsx)(eL,{icon:eP.CursorArrowRaysIcon,label:"Total Clicks",value:p.totalClicks,accent:"#f59e0b"}),(0,t.jsx)(eL,{icon:e$.UserGroupIcon,label:"Live Creators",value:p.liveCreatorCount,formatFn:e=>Math.round(e).toString(),accent:"#ef4444"})]}),(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:16}
1,animate:{opacity:1,y:0},transition:{duration:.6,delay:.45},className:"relative z-50",children:(0,t.jsx)(j,{router:g})})]})}),h.length>0&&(0,t.jsxs)(eA,{className:"mx-8 md:mx-32 mt-4 mb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(er.SparklesIcon,{className:"w-4 h-4 text-pink-400"}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"Quick Insights"}),(0,t.jsx)("div",{className:"flex-1 h-px bg-gradient-to-r from-gray-200 to-transparent ml-2 dark:from-zinc-800"})]}),(0,t.jsx)(i.motion.div,{variants:eD,initial:"hidden",whileInView:"visible",viewport:{once:!0},className:"flex gap-3 overflow-x-auto pb-2 scrollbar-hide",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:h.map(e=>(0,t.jsx)(eB,{...e,onClick:()=>g.push(`/dashboard/user/campaign/${e.id}`)},e.label))})]}),(0,t.jsx)(eO,{}),(0,t.jsxs)(eA,{className:"mx-8 md:mx-32 mt-6 mb-10",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,t.jsx)("div",{className:"h-6 w-1 rounded-full bg-gradient-to-b from-pink-500 to-orange-400"}),(0,t.jsx)("h2",{className:"text-lg font-bold text-gray-900 dark:text-zinc-100 tracking-tight",children:"Live Campaigns"}),(0,t.jsxs)("span",{className:"relative flex h-2.5 w-2.5 ml-0.5",children:[(0,t.jsx)("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),(0,t.jsx)("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-green-500"})]}),n.length>0&&(0,t.jsx)("span",{className:"px-2.5 py-0.5 rounded-full text-xs font-bold text-white bg-gradient-to-r from-green-500 to-emerald-500 shadow-sm shadow-green-200",children:n.length})]}),n.length>0?(0,t.jsx)("div",{className:"grid gap-6 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:n.map(e=>(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:24},whileInView:{opacity:1,y:0},viewport:{once:!0,margin:"-40px"},transition:{duration:.45},children:(0,t.jsx)(w.default,{campaign:e})},e._id))}):(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center border border-dashed border-gray-200 dark:border-zinc-800 rounded-3xl py-20 px-6 text-center bg-white/60 dark:bg-zinc-950/60 backdrop-blur-sm",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-gradient-to-br from-pink-100 to-orange-50 flex items-center justify-center mb-5",children:(0,t.jsx)(es.MegaphoneIcon,{className:"w-8 h-8 text-pink-300"})}),(0,t.jsx)("h3",{className:"text-lg font-bold text-gray-800 dark:text-zinc-100 mb-2",children:"No Campaigns Running Right Now"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-zinc-400 max-w-md",children:"Live campaigns will appear here once launched. In the meantime, explore creator highlights or view your dashboard insights below."})]})]}),(0,t.jsx)(eO,{}),d.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(eA,{className:"mx-8 md:mx-32 mt-6 mb-10",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"h-6 w-1 rounded-full bg-gradient-to-b from-pink-500 to-orange-400"}),(0,t.jsx)("h2",{className:"text-lg font-bold text-gray-900 dark:text-zinc-100 tracking-tight",children:"Monitored Posts"}),(0,t.jsx)("span",{className:"px-2.5 py-0.5 rounded-full text-xs font-bold text-white bg-gradient-to-r from-pink-500 to-orange-400 shadow-sm",children:d.length})]}),(0,t.jsxs)("button",{onClick:()=>window.dispatchEvent(new CustomEvent("navigate-tab",{detail:"posts"})),className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium text-gray-500 dark:text-zinc-400 hover:bg-gray-100 dark:hover:bg-zinc-900 transition-all shrink-0",children:["View all",(0,t.jsx)(L.ArrowRightIcon,{className:"w-3.5 h-3.5"})]})]}),(0,t.jsx)("div",{className:"grid gap-6 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4",children:d.map(e=>(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:24},whileInView:{opacity:1,y:0},viewport:{once:!0,margin:"-40px"},transition:{duration:.45},children:(0,t.jsx)(N.default,{post:e})},e._id))})]}),(0,t.jsx)(eO,{})]}),(0,t.jsx)(eA,{className:"mx-8 md:mx-32 mt-8 mb-10",delay:.03,children:(0,t.jsx)(Z,{})}),(0,t.jsx)(T,{})]})};var eU=e.i(88653),eG=e.i(760925);function eH({campaigns:e}){return(0,t.jsx)("div",{className:"grid gap-5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 mt-6 mx-4 md:mx-8",children:e.map(e=>(0,t.jsx)(w.default,{campaign:e},e._id))})}var eK=e.i(738932),eW=e.i(883015);let eq=[.25,.46,.45,.94];function eY({isOpen:e,onClose:r}){let{data:n}
1=(0,s.useSession)(),[l,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(null),[x,u]=(0,a.useState)(!1);(0,a.useEffect)(()=>{e&&(o(!1),d(null),u(!1))},[e]);let m=(0,a.useCallback)(()=>{l?u(!0):r?.()},[l,r]),g=(0,a.useCallback)(()=>{u(!1),r?.()},[r]);(0,a.useEffect)(()=>{if(!e)return;let t=e=>{"Escape"!==e.key||x||(e.preventDefault(),m())};return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[e,x,m]),(0,a.useEffect)(()=>{if(!e)return;let t=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.body.style.overflow=t}},[e]);let h=(0,a.useCallback)((e,t)=>{o(e),d(t||null)},[]);return(0,t.jsxs)(eU.AnimatePresence,{children:[e&&(0,t.jsx)(i.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"fixed inset-0 z-[100] flex items-center justify-center p-3 sm:p-6 bg-black/20 backdrop-blur-sm",onClick:m,children:(0,t.jsxs)(i.motion.div,{initial:{opacity:0,y:24,scale:.97},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.98},transition:{duration:.4,ease:eq},className:"relative w-full max-w-4xl rounded-3xl overflow-hidden flex flex-col",style:{height:"min(88vh, 860px)",background:"var(--surface-panel)",backdropFilter:"blur(40px)",border:"1px solid var(--border-default)",boxShadow:"0 30px 80px var(--shadow-ambient-xl), 0 4px 20px rgba(0,0,0,0.06)"},onClick:e=>e.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"create-campaign-title",children:[(0,t.jsx)("div",{className:"absolute top-0 inset-x-0 h-[3px] z-20 bg-gradient-to-r from-pink-500/60 via-orange-400/60 to-violet-500/60"}),(0,t.jsx)("div",{className:"absolute -top-24 -right-24 w-80 h-80 rounded-full blur-3xl pointer-events-none animate-orb-drift-a",style:{background:"radial-gradient(circle, rgba(236,72,153,0.20), rgba(249,115,22,0.10) 50%, transparent 70%)"}}),(0,t.jsx)("div",{className:"absolute -bottom-28 -left-24 w-80 h-80 rounded-full blur-3xl pointer-events-none animate-orb-drift-b",style:{background:"radial-gradient(circle, rgba(139,92,246,0.18), rgba(59,130,246,0.10) 50%, transparent 70%)"}}),(0,t.jsxs)("div",{className:"relative z-10 flex items-center justify-between gap-3 px-5 sm:px-7 pt-5 pb-4 flex-shrink-0",style:{background:"var(--surface-frosted)",backdropFilter:"blur(20px)",borderBottom:"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:"linear-gradient(135deg, rgba(236,72,153,0.15), rgba(249,115,22,0.15))",border:"1px solid rgba(236,72,153,0.2)"},children:(0,t.jsx)(es.MegaphoneIcon,{className:"w-4 h-4 text-pink-500"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("div",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"New campaign"}),(0,t.jsxs)("h2",{id:"create-campaign-title",className:"text-lg sm:text-xl font-black tracking-tight text-gray-900 dark:text-zinc-100 leading-tight truncate",children:["Create"," ",(0,t.jsx)("span",{className:"bg-gradient-to-r from-pink-500 via-rose-500 to-orange-400 bg-clip-text text-transparent",children:"Campaign"})]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[n?.user?.agency&&(0,t.jsxs)("div",{className:"hidden md:inline-flex items-center gap-2 px-3 py-1.5 rounded-full text-[11px] font-semibold tracking-wide",style:{background:"rgba(249,115,22,0.10)",border:"1px solid rgba(249,115,22,0.25)",color:"#f97316"},children:[(0,t.jsx)(el.BuildingOffice2Icon,{className:"w-3.5 h-3.5"}),n.user.agency.code," · ",n.user.agency.name]}),(0,t.jsx)("button",{type:"button",onClick:m,"aria-label":"Close",className:"w-8 h-8 rounded-xl flex items-center justify-center transition-colors hover:bg-gray-200/70 dark:hover:bg-zinc-800",style:{background:"var(--surface-softer)"},children:(0,t.jsx)(p.XMarkIcon,{className:"w-4 h-4 text-gray-500 dark:text-zinc-400"})})]})]}),(0,t.jsx)("div",{className:"relative z-10 flex-1 min-h-0 flex flex-col",children:(0,t.jsx)(eK.default,{embedded:!0,onDirtyChange:h,onCreated:r})})]},"create-campaign-panel")},"create-campaign-backdrop"),e&&x&&(0,t.jsx)(eW.default,{title:"Discard this campaign?",description:"Everything you've entered â brief, setup, goals, and overview â will be lost. This can't be und
1one.",summary:c,onKeepEditing:()=>u(!1),onDiscard:g,discardLabel:"Discard draft"},"discard-campaign-draft")]})}var eX=e.i(232579),eQ=e.i(518763),eZ=e.i(815328),eJ=e.i(882964),e0=e.i(913107),e1=e.i(27661),e2=e.i(980618),e5=e.i(844735);function e4(e){return e>=1e6?(e/1e6).toFixed(1).replace(/\.0$/,"")+"M":e>=1e3?(e/1e3).toFixed(1).replace(/\.0$/,"")+"K":e.toString()}let e3=["Created","In Progress","Live","Wrapped"],e6=eZ.LEGACY_FILTER_VERTICALS,e9=["views","engagements","clicks","posts","subscriber_reach","er","ctr"],e8={views:"Views",engagements:"Engagements",clicks:"Clicks",posts:"Posts",subscriber_reach:"Reach",er:"Engagement Rate",ctr:"Click-through Rate"};function e7({icon:e,label:a,value:r,accent:s,delay:n=0}){return(0,t.jsxs)(i.motion.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.5,delay:n},className:"relative group rounded-2xl backdrop-blur-xl border overflow-hidden",style:{background:"var(--surface-frosted)",borderColor:`${s}20`,boxShadow:`0 2px 16px ${s}06`},children:[(0,t.jsx)("div",{className:"absolute top-0 right-0 w-16 h-16 rounded-full opacity-[0.08] group-hover:opacity-[0.15] transition-opacity duration-300 -translate-y-4 translate-x-4",style:{background:s}}),(0,t.jsxs)("div",{className:"relative p-4 flex items-center gap-3",children:[(0,t.jsx)("div",{className:"flex-shrink-0 w-9 h-9 rounded-xl flex items-center justify-center",style:{background:`${s}14`},children:(0,t.jsx)(e,{className:"w-4 h-4",style:{color:s}})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-xl font-black text-gray-900 dark:text-zinc-100 leading-tight tabular-nums",children:r}),(0,t.jsx)("p",{className:"text-[10px] font-semibold uppercase tracking-[0.1em] text-gray-400 dark:text-zinc-500 mt-0.5",children:a})]})]})]})}function te({label:e,value:a,onChange:r,options:s,placeholder:n}){return(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-[10px] font-bold tracking-[0.14em] uppercase text-gray-400 dark:text-zinc-500 mb-2",children:e}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsxs)("select",{value:a,onChange:r,className:"w-full appearance-none pl-4 pr-10 py-2.5 text-sm bg-white dark:bg-zinc-950 border border-gray-200 dark:border-zinc-800 rounded-xl focus:outline-none focus:ring-2 focus:ring-pink-200 focus:border-pink-300 text-gray-700 dark:text-zinc-300 transition-all duration-200 cursor-pointer hover:border-pink-200",children:[(0,t.jsx)("option",{value:"",children:n}),s.map(e=>(0,t.jsx)("option",{value:"string"==typeof e?e:e.value,children:"string"==typeof e?e:e.label},"string"==typeof e?e:e.value))]}),(0,t.jsx)(e5.ChevronDownIcon,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-zinc-500 pointer-events-none"})]})]})}function tt({label:e,value:a,onChange:r}){return(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-[10px] font-bold tracking-[0.14em] uppercase text-gray-400 dark:text-zinc-500 mb-2",children:e}),(0,t.jsx)("div",{className:"relative",children:(0,t.jsx)("input",{type:"date",value:a,onChange:r,className:"w-full pl-4 pr-4 py-2.5 text-sm bg-white dark:bg-zinc-950 border border-gray-200 dark:border-zinc-800 rounded-xl focus:outline-none focus:ring-2 focus:ring-pink-200 focus:border-pink-300 text-gray-700 dark:text-zinc-300 transition-all duration-200 hover:border-pink-200"})})]})}function ta({selected:e,onSelect:r}){let[s,n]=(0,a.useState)(""),[l,i]=(0,a.useState)([]),[o,c]=(0,a.useState)(!1);return(0,a.useEffect)(()=>{if(s.length<2)return void i([]);let t=setTimeout(async()=>{try{let t=await fetch(`https://www.socialscout.ai/api/autocompleteOrg?search=${encodeURIComponent(s)}`);if(t.ok){let a=await t.json(),r=new Set(e.map(e=>e.id));i(a.filter(e=>!r.has(e._id)))}}catch(e){console.error("Org autocomplete error:",e)}},300);return()=>clearTimeout(t)},[s,e]),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-[10px] font-bold tracking-[0.14em] uppercase text-gray-400 dark:text-zinc-500 mb-2",children:"Organization"}),e.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mb-2",children:e.map(a=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-lg text-xs font-medium bg-yellow-50 text-yellow-700 border border-yellow-200",children:[a.name,(0,t.jsx)("button",{onClick:()=>r(e.filter(e=>e.id!==a.id)),className:"hover:opacity-70",children:(0,t.jsx)(p.XMarkIcon,{className:"w-3 h-3"})})]},a.id))}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("input",{type:"text",value:s,onChange:e=>{n(e.target.value),c(!0)},onFocus:()=>c(!0),onBlur:()=>setTimeout(()=>c(!1),200),placeholder:"Search organizations...",className:"w-full pl-4 pr-4 py-2.5 text-sm bg-white dark:bg-zinc-950 border border-gray-200 dark:border-zinc-800 rounded-xl focus:outline-none focus:ring-2 focus:ring-pink-200 focus:border-pink-300 text-gray-700 dark:text-zinc-300 transition-all duration-200 placeholder-gray-400 dark:placeholder-zinc-500 hover:border-pink-200"}),o&&l.length>0&&(0,t.jsx)("div",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-zinc-950 border border-gray-200 dark:border-zinc-800 rounded-xl shadow-lg z-10 max-h-48 overflow-y-auto",children:l.map(a=>(0,t.jsxs)("button",{onMouseDown:e=>e.preventDefault(),onClick:()=>{r([...e,{id:a._id,name:a.name}]),n(""),i([]),c(!1)},className:"w-full text-left px-4 py-2.5 text-sm text-gray-700 dark:text-zinc-300 hover:bg-pink-50 hover:text-pink-700 transition-colors flex items-center gap-2",children:[a.image&&(0,t.jsx)("img",{src:a.image,alt:"",className:"w-5 h-5 rounded-full object-cover"}),a.name]},a._id))})]})]})}let tr=[.25,.46,.45,.94];function ts({campaign:e,query:r,active:s,onPick:n,onHover:l}){var i;let o,c,d,x=(0,a.useRef)(null),[u,m]=(0,a.useState)(!1),g=eG.STATUS_CONFIG[e.status]||eG.STATUS_CONFIG.Created;return(0,a.useEffect)(()=>{s&&x.current?.scrollIntoView({block:"nearest"})},[s]),(0,t.jsxs)("li",{ref:x,role:"option","aria-selected":s,onMouseDown:e=>e.preventDefault(),onClick:()=>n(e),onMouseEnter:l,className:`flex items-center gap-3 min-h-[44px] px-3 py-2 mx-1.5 rounded-xl cursor-pointer transition-colors duration-150 ${s?"bg-gradient-to-r from-pink-50/80 to-orange-50/80 dark:from-pink-500/10 dark:to-orange-500/10 dark:ring-1 dark:ring-pink-500/20":"hover:bg-gray-50/80 dark:hover:bg-zinc-900/80"}`,children:[!u&&e.image?(0,t.jsx)("img",{src:e.image,alt:"",loading:"lazy",onError:()=>m(!0),className:"w-9 h-9 rounded-xl object-cover flex-shrink-0 shadow-sm"}):(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex-shrink-0 bg-gradient-to-br from-pink-400 to-orange-400 flex items-center justify-center",children:(0,t.jsx)("span",{className:"text-white text-sm font-semibold",children:(e.name||"?").charAt(0).toUpperCase()})}),(0,t.jsx)("span",{className:`flex-1 min-w-0 truncate text-sm font-medium ${s?"text-pink-600 dark:text-pink-400":"text-gray-900 dark:text-zinc-100"}`,children:(i=e.name,o=i||"",(d=(c=r.trim())?o.toLowerCase().indexOf(c.toLowerCase()):-1)<0?o:(0,t.jsxs)(t.Fragment,{children:[o.slice(0,d),(0,t.jsx)("span",{className:"font-bold text-pink-600 dark:text-pink-400",children:o.slice(d,d+c.length)}),o.slice(d+c.length)]}))}),(0,t.jsxs)("span",{className:"hidden sm:inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[10px] font-semibold flex-shrink-0",style:{color:g.color,background:g.bg,border:`1px solid ${g.border}`},children:[(0,t.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{background:g.color}}),g.label]})]})}
1function tn({value:e,onChange:s,onClear:n,onSubmit:l}){let o=(0,r.useRouter)(),c=(0,a.useRef)(null),d=(0,a.useRef)(0),[x,u]=(0,a.useState)([]),[m,h]=(0,a.useState)(!1),[f,b]=(0,a.useState)(!1),[v,y]=(0,a.useState)(-1),k=e.trim(),j=k.length>=2;(0,a.useEffect)(()=>{if(!j){u([]),h(!1),y(-1);return}let e=++d.current,t=new AbortController;h(!0);let a=setTimeout(async()=>{try{let a=await fetch(`https://www.socialscout.ai/api/searchAutoCompleteCampaigns?query=${encodeURIComponent(k)}`,{signal:t.signal});if(!a.ok||e!==d.current)return;let r=await a.json();if(e!==d.current)return;u(Array.isArray(r)?r.slice(0,8):[]),y(-1)}catch(e){"AbortError"!==e.name&&console.error("Campaign suggest error:",e)}finally{e===d.current&&h(!1)}},200);return()=>{clearTimeout(a),t.abort()}},[k,j]),(0,a.useEffect)(()=>{let e=e=>{c.current?.contains(e.target)||b(!1)};return document.addEventListener("mousedown",e),document.addEventListener("touchstart",e,{passive:!0}),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("touchstart",e)}},[]);let w=e=>{b(!1),o.push(`/dashboard/user/campaign/${e._id}`)},N=()=>{b(!1),l(e)},C=f&&j,z=m&&0===x.length;return(0,t.jsxs)("div",{ref:c,className:"flex-1 relative",children:[(0,t.jsx)("div",{className:`p-[1.5px] rounded-2xl transition-all duration-200 ${e?"bg-gradient-to-r from-pink-500 to-orange-400":"bg-gray-200 dark:bg-zinc-800 hover:bg-gradient-to-r hover:from-pink-300 hover:to-orange-300"}`,children:(0,t.jsxs)("div",{className:"relative bg-white dark:bg-zinc-950 rounded-2xl",children:[(0,t.jsx)("input",{type:"text",role:"combobox","aria-expanded":C,"aria-controls":"campaign-search-suggestions","aria-autocomplete":"list",autoComplete:"off",spellCheck:!1,placeholder:"Search campaigns by name...",value:e,onChange:e=>{s(e.target.value),b(!0)},onFocus:()=>b(!0),onKeyDown:e=>{if("Escape"===e.key){f&&(e.preventDefault(),b(!1));return}if("Enter"===e.key){e.preventDefault(),f&&v>=0&&x[v]?w(x[v]):N();return}x.length&&("ArrowDown"===e.key?(e.preventDefault(),b(!0),y(e=>e+1>=x.length?0:e+1)):"ArrowUp"===e.key&&(e.preventDefault(),b(!0),y(e=>e<=0?x.length-1:e-1)))},className:"w-full pl-11 pr-10 py-3 text-sm bg-transparent border-0 rounded-2xl focus:outline-none placeholder-gray-400 dark:placeholder-zinc-500 text-gray-900 dark:text-zinc-100"}),(0,t.jsx)("div",{className:"absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 dark:text-zinc-500",children:(0,t.jsx)(g.MagnifyingGlassIcon,{className:"w-[18px] h-[18px]"})}),e&&(0,t.jsx)("button",{type:"button","aria-label":"Clear search",onClick:()=>{n(),b(!1)},className:"absolute right-4 top-1/2 -translate-y-1/2 text-gray-400 dark:text-zinc-500 hover:text-gray-600 dark:hover:text-zinc-400 transition-colors",children:(0,t.jsx)(p.XMarkIcon,{className:"w-4 h-4"})})]})}),(0,t.jsx)(eU.AnimatePresence,{children:C&&(0,t.jsxs)(i.motion.div,{initial:{opacity:0,y:-6,scale:.99},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:-4,scale:.99},transition:{duration:.18,ease:tr},className:"absolute left-0 right-0 top-full mt-2 z-30 rounded-2xl overflow-hidden border border-gray-200/70 dark:border-zinc-800 backdrop-blur-xl shadow-[0_24px_64px_-16px_rgba(0,0,0,0.18)] dark:shadow-[0_24px_64px_-16px_rgba(0,0,0,0.6)]",style:{background:"var(--surface-panel)"},children:[(0,t.jsxs)("div",{className:"flex items-center px-4 pt-3 pb-1.5",children:[(0,t.jsx)("div",{className:"h-3.5 w-0.5 rounded-full bg-gradient-to-b from-pink-500 to-orange-400 mr-2"}),(0,t.jsx)("span",{className:"text-[10px] font-bold tracking-[0.14em] uppercase text-gray-400 dark:text-zinc-500",children:"Campaigns"}),x.length>0&&(0,t.jsx)("span",{className:"ml-2 px-1.5 py-0.5 rounded-full bg-gradient-to-r from-pink-500 to-orange-400 text-[10px] font-semibold text-white min-w-[18px] text-center",children:x.length}),(0,t.jsx)("span",{className:"hidden sm:inline ml-auto text-[10px] text-gray-400 dark:text-zinc-500",children:"ââ to move · âµ to open"})]}),(0,t.jsxs)("ul",{id:"campaign-search-suggestions",role:"listbox",className:"max-h-[50vh] overflow-y-auto pb-1.5",children:[z&&[0,1,2].map(e=>(0,t.jsxs)("li",{className:"flex items-center gap-3 min-h-[44px] px-3 py-2 mx-1.5 animate-pulse",style:{animationDelay:`${80*e}ms`},children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl bg-gray-100 dark:bg-zinc-900"}),(0,t.jsx)("div",{className:"h-3 rounded-full bg-gray-100 dark:bg-zinc-900",style:{width:`${55-12*e}%`}})]},`sk-${e}`)),!z&&x.map((e,a)=>(0,t.jsx)(ts,{campaign:e,query:k,active:v===a,onPick:w,onHover:()=>y(a)},e._id)),!m&&0===x.length&&(0,t.jsxs)("li",{className:"px-4 py-3 text-sm text-gray-500 dark:text-zinc-400",children:["No campaign names start with"," ",(0,t.jsxs)("span",{className:"font-semibold text-gray-700 dark:text-zinc-300",children:["â",k,"â"]}
1)]})]}),(0,t.jsxs)("button",{type:"button",onMouseDown:e=>e.preventDefault(),onClick:N,onMouseEnter:()=>y(-1),className:`w-full flex items-center gap-2.5 min-h-[44px] px-4 py-2.5 text-left text-sm border-t border-gray-100 dark:border-zinc-800 transition-colors ${-1===v?"bg-gray-50/80 dark:bg-zinc-900/60 text-gray-800 dark:text-zinc-200":"text-gray-600 dark:text-zinc-400 hover:bg-gray-50/80 dark:hover:bg-zinc-900/60"}`,children:[(0,t.jsx)("span",{className:"w-7 h-7 rounded-xl flex items-center justify-center flex-shrink-0 bg-[#ec489914] dark:bg-[#ec489925]",children:(0,t.jsx)(g.MagnifyingGlassIcon,{className:"w-3.5 h-3.5 text-pink-500"})}),(0,t.jsxs)("span",{className:"flex-1 min-w-0 truncate",children:["Filter the list by"," ",(0,t.jsxs)("span",{className:"font-semibold",children:["â",k,"â"]})]}),(0,t.jsx)("kbd",{className:"hidden sm:inline px-1.5 py-0.5 rounded-md text-[10px] font-medium bg-white dark:bg-zinc-950 border border-gray-200 dark:border-zinc-800 text-gray-500 dark:text-zinc-400",children:"âµ"})]})]},"suggest")})]})}function tl({open:e,onClose:a,filters:r,onFilterChange:s,onClear:n,activeCount:l,teamMembers:i}){return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:`fixed inset-0 bg-black/30 backdrop-blur-sm z-40 transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,onClick:a}),(0,t.jsxs)("div",{className:`fixed top-0 right-0 h-full w-[340px] bg-white dark:bg-zinc-950 z-50 shadow-2xl flex flex-col transition-transform duration-300 ease-out ${e?"translate-x-0":"translate-x-full"}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-6 py-5 border-b border-gray-100 dark:border-zinc-800",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,t.jsx)("div",{className:"p-1.5 rounded-lg bg-gradient-to-br from-pink-500 to-orange-400",children:(0,t.jsx)(e1.FunnelIcon,{className:"w-4 h-4 text-white"})}),(0,t.jsx)("h2",{className:"text-sm font-bold text-gray-900 dark:text-zinc-100",children:"Campaign Filters"}),l>0&&(0,t.jsx)("span",{className:"px-2 py-0.5 bg-gradient-to-r from-pink-500 to-orange-400 text-white text-[10px] font-semibold rounded-full",children:l})]}),(0,t.jsx)("button",{onClick:a,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors text-gray-400 dark:text-zinc-500",children:(0,t.jsx)(p.XMarkIcon,{className:"w-5 h-5"})})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 py-5 space-y-5",children:[(0,t.jsx)(te,{label:"Status",value:r.status,onChange:e=>s("status",e.target.value),options:e3,placeholder:"All statuses"}),(0,t.jsx)(te,{label:"Vertical",value:r.vertical,onChange:e=>s("vertical",e.target.value),options:e6,placeholder:"All verticals"}),(0,t.jsx)(te,{label:"Primary Goal",value:r.primaryGoal,onChange:e=>s("primaryGoal",e.target.value),options:e9.map(e=>({value:e,label:e8[e]})),placeholder:"All goals"}),(0,t.jsx)(te,{label:"Account Manager",value:r.accountManager,onChange:e=>s("accountManager",e.target.value),options:i,placeholder:"All account managers"}),(0,t.jsx)(te,{label:"Strategist",value:r.strategist,onChange:e=>s("strategist",e.target.value),options:i,placeholder:"All strategists"}),(0,t.jsx)(ta,{selected:r.organizations,onSelect:e=>s("organizations",e)}),(0,t.jsxs)("div",{className:"pt-2 border-t border-gray-100 dark:border-zinc-800",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-4",children:[(0,t.jsx)(ei.CalendarDaysIcon,{className:"w-3.5 h-3.5 text-gray-400 dark:text-zinc-500"}),(0,t.jsx)("span",{className:"text-[10px] font-bold tracking-[0.14em] uppercase text-gray-400 dark:text-zinc-500",children:"Date Ranges"})]}),(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsx)(tt,{label:"Start From",value:r.startDateFrom,onChange:e=>s("startDateFrom",e.target.value)}),(0,t.jsx)(tt,{label:"Start To",value:r.startDateTo,onChange:e=>s("startDateTo",e.target.value)})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,t.jsx)(tt,{label:"End From",value:r.endDateFrom,onChange:e=>s("endDateFrom",e.target.value)}),(0,t.jsx)(tt,{label:"End To",value:r.endDateTo,onChange:e=>s("endDateTo",e.target.value)})]})]})]})]}),l>0&&(0,t.jsx)("div",{className:"px-6 py-4 border-t border-gray-100 dark:border-zinc-800",children:(0,t.jsxs)("button",{onClick:n,className:"w-full flex items-center justify-center gap-2 px-4 py-2.5 text-sm font-medium text-gray-600 dark:text-zinc-400 border border-gray-200 dark:border-zinc-800 rounded-xl hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:[(0,t.jsx)(ed.ArrowPathIcon,{className:"w-4 h-4"}),"Clear all filters"]})})]})]})}let ti={status:"bg-green-50 text-green-700 border-green-100",vertical:"bg-purple-50 text-purple-700 border-purple-100",primaryGoal:"bg-blue-50 text-blue-700 border-blue-100",accountManager:"bg-orange-50 text-orange-700 border-orange-100",strategist:"bg-teal-50 text-teal-700 border-teal-100",organization:"bg-yellow-50 text-yellow-700 border-yellow-100",search:"bg-pink-50 text-pink-700 border-pink-100",startDateFrom:"bg-indigo-50 text-indigo-700 border-indigo-100",startDateTo:"bg-indigo-50 text-indigo-700 border-indigo-100",endD
1ateFrom:"bg-indigo-50 text-indigo-700 border-indigo-100",endDateTo:"bg-indigo-50 text-indigo-700 border-indigo-100"};function to({label:e,value:a,filterKey:r,onRemove:s}){return(0,t.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium border ${ti[r]||ti.search}`,children:[e,": ",(0,t.jsx)("strong",{children:a}),(0,t.jsx)("button",{onClick:s,className:"ml-0.5 hover:opacity-70 transition-opacity",children:(0,t.jsx)(p.XMarkIcon,{className:"w-3 h-3"})})]})}function tc({pagination:e,onPageChange:a}){if(!e||e.totalPages<=1)return null;let{currentPage:r,totalPages:s,hasPrevPage:n,hasNextPage:l,totalCampaigns:i}=e,o=Math.max(1,r-Math.floor(2.5)),c=Math.min(s,o+5-1);c-o<4&&(o=Math.max(1,c-5+1));let d=[];o>1&&(d.push({type:"page",value:1}),o>2&&d.push({type:"ellipsis",value:"s"}));for(let e=o;e<=c;e++)d.push({type:"page",value:e});return c<s&&(c<s-1&&d.push({type:"ellipsis",value:"e"}),d.push({type:"page",value:s})),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3 mt-10 mx-4 md:mx-8",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("button",{onClick:()=>a(r-1),disabled:!n,className:`px-3.5 py-2 text-sm font-medium rounded-xl border transition-all duration-200 ${!n?"bg-gray-50 dark:bg-zinc-900 text-gray-300 dark:text-zinc-700 border-gray-100 dark:border-zinc-800 cursor-not-allowed":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:"Previous"}),d.map(e=>"ellipsis"===e.type?(0,t.jsx)("span",{className:"px-2 text-gray-300 dark:text-zinc-700 text-sm",children:"..."},e.value):(0,t.jsx)("button",{onClick:()=>a(e.value),className:`w-9 h-9 text-sm font-medium rounded-xl border transition-all duration-200 ${e.value===r?"bg-gradient-to-r from-pink-500 to-orange-400 text-white border-transparent shadow-sm shadow-pink-200":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:e.value},e.value)),(0,t.jsx)("button",{onClick:()=>a(r+1),disabled:!l,className:`px-3.5 py-2 text-sm font-medium rounded-xl border transition-all duration-200 ${!l?"bg-gray-50 dark:bg-zinc-900 text-gray-300 dark:text-zinc-700 border-gray-100 dark:border-zinc-800 cursor-not-allowed":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:"Next"})]}),(0,t.jsxs)("p",{className:"text-xs text-gray-400 dark:text-zinc-500",children:["Page ",r," of ",s," · ",i," campaigns"]})]})}let td={status:"",vertical:"",primaryGoal:"",accountManager:"",strategist:"",organizations:[],startDateFrom:"",startDateTo:"",endDateFrom:"",endDateTo:""},tx=function(){let[e,r]=(0,a.useState)([]),[s,l]=(0,a.useState)(null),[i,o]=(0,a.useState)(!1),[c,d]=(0,a.useState)(!1),[x,u]=(0,a.useState)(td),[g,p]=(0,a.useState)(""),[h,f]=(0,a.useState)(""),[b,v]=(0,a.useState)(1),[y,k]=(0,a.useState)(null),[j,w]=(0,a.useState)(!1),[N,C]=(0,a.useState)([]),{can:z,loading:S}=(0,eX.usePermissions)(),{setFilterPanelOpen:E}=(0,eQ.useAI)();(0,a.useEffect)(()=>(E(c),()=>E(!1)),[c,E]),(0,a.useEffect)(()=>{!async function(){try{let e=await fetch("https://www.socialscout.ai/api/agency-team");if(e.ok){let t=await e.json();C((t.users||[]).map(e=>({value:e._id,label:e.name||e.email})))}}catch(e){console.error("Failed to fetch team:",e)}}()},[]),(0,a.useEffect)(()=>{let e=setTimeout(()=>{f(g),v(1)},500);return()=>clearTimeout(e)},[g]),(0,a.useEffect)(()=>{v(1)},[x.status,x.vertical,x.primaryGoal,x.accountManager,x.strategist,x.organizations,x.startDateFrom,x.startDateTo,x.endDateFrom,x.endDateTo]),(0,a.useEffect)(()=>{!async function(){w(!0);try{let e=new URLSearchParams({page:b.toString(),limit:"50"});x.status&&e.append("status",x.status),x.vertical&&e.append("vertical",x.vertical),x.primaryGoal&&e.append("primaryGoal",x.primaryGoal),x.accountManager&&e.append("accountManager",x.accountManager),x.strategist&&e.append("strategist",x.strategist),x.organizations.length>0&&x.organizations.forEach(t=>
1e.append("organizationId",t.id)),h&&e.append("query",h),x.startDateFrom&&e.append("startDateFrom",x.startDateFrom),x.startDateTo&&e.append("startDateTo",x.startDateTo),x.endDateFrom&&e.append("endDateFrom",x.endDateFrom),x.endDateTo&&e.append("endDateTo",x.endDateTo);let t=await fetch(`https://www.socialscout.ai/api/getFilteredCampaigns?${e.toString()}`);if(!t.ok)throw Error(`Fetch error: ${t.status}`);let a=await t.json();r(a.campaigns),k(a.pagination),a.aggregates&&l(a.aggregates)}catch(e){m.default.error(`Failed to fetch campaigns: ${e.message}`)}finally{w(!1)}}()},[x.status,x.vertical,x.primaryGoal,x.accountManager,x.strategist,x.organizations,h,x.startDateFrom,x.startDateTo,x.endDateFrom,x.endDateTo,b]);let P=(0,a.useCallback)((e,t)=>{u(a=>({...a,[e]:t}))},[]),$=(0,a.useCallback)(()=>{u(td),p(""),f(""),v(1)},[]),M=(0,a.useCallback)(e=>{f(e),v(1)},[]),F=()=>{p(""),f(""),v(1)},I=(0,a.useMemo)(()=>{let e=[];if(h&&e.push({key:"search",label:"Search",value:`"${h}"`,onRemove:F}),x.status&&e.push({key:"status",label:"Status",value:x.status,onRemove:()=>P("status","")}),x.vertical&&e.push({key:"vertical",label:"Vertical",value:x.vertical,onRemove:()=>P("vertical","")}),x.primaryGoal&&e.push({key:"primaryGoal",label:"Goal",value:e8[x.primaryGoal],onRemove:()=>P("primaryGoal","")}),x.accountManager){let t=N.find(e=>e.value===x.accountManager);e.push({key:"accountManager",label:"AM",value:t?.label||"Selected",onRemove:()=>P("accountManager","")})}if(x.strategist){let t=N.find(e=>e.value===x.strategist);e.push({key:"strategist",label:"Strategist",value:t?.label||"Selected",onRemove:()=>P("strategist","")})}return x.organizations.forEach(t=>{e.push({key:`org-${t.id}`,label:"Org",value:t.name,onRemove:()=>P("organizations",x.organizations.filter(e=>e.id!==t.id))})}),x.startDateFrom&&e.push({key:"startDateFrom",label:"Start from",value:x.startDateFrom,onRemove:()=>P("startDateFrom","")}),x.startDateTo&&e.push({key:"startDateTo",label:"Start to",value:x.startDateTo,onRemove:()=>P("startDateTo","")}),x.endDateFrom&&e.push({key:"endDateFrom",label:"End from",value:x.endDateFrom,onRemove:()=>P("endDateFrom","")}),x.endDateTo&&e.push({key:"endDateTo",label:"End to",value:x.endDateTo,onRemove:()=>P("endDateTo","")}),e},[h,x,N,P]),R=I.length;return(0,t.jsxs)("div",{className:"mt-6 mb-40",children:[(0,t.jsxs)("div",{className:"mx-4 md:mx-8 mb-6",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-5",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h2",{className:"text-2xl font-black text-gray-900 dark:text-zinc-100 tracking-tight",children:"Campaigns"}),(0,t.jsx)("p",{className:"text-sm text-gray-400 dark:text-zinc-500 mt-0.5",children:y?`${y.totalCampaigns} total across all pages`:"Loading..."})]}),!S&&z("campaigns","create")&&(0,t.jsxs)("button",{onClick:()=>o(!0),className:"flex items-center gap-2 px-5 py-2.5 text-sm font-semibold bg-gradient-to-r from-pink-500 to-orange-400 text-white rounded-xl shadow-sm shadow-pink-200 hover:shadow-md hover:shadow-pink-300 hover:-translate-y-0.5 transition-all duration-200",children:[(0,t.jsx)(e0.PlusIcon,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Create Campaign"}),(0,t.jsx)("span",{className:"sm:hidden",children:"New"})]})]}),s&&(0,t.jsxs)("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3 mb-6",children:[(0,t.jsx)(e7,{icon:es.MegaphoneIcon,label:"Campaigns",value:y?.totalCampaigns||0,accent:"#ec4899",delay:0}),(0,t.jsx)(e7,{icon:eE.EyeIcon,label:"Total Views",value:e4(s.totalViews),accent:"#3b82f6",delay:.05}),(0,t.jsx)(e7,{icon:O.BoltIcon,label:"Engagements",value:e4(s.totalEngagements),accent:"#8b5cf6",delay:.1}),(0,t.jsx)(e7,{icon:eP.CursorArrowRaysIcon,label:"Clicks",value:e4(s.totalClicks),accent:"#f59e0b",delay:.15}),(0,t.jsx)(e7,{icon:e$.UserGroupIcon,label:"Creators",value:s.uniqueCreators,accent:"#ef4444",delay:.2}),(0,t.jsx)(e7,{icon:e2.FilmIcon,label:"Posts",value:e4(s.totalPosts),accent:"#10b981",delay:.25})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)(tn,{value:g,onChange:p,onClear:F,onSubmit:M}),(0,t.jsxs)("button",{onClick:()=>d(!0),className:`relative flex items-center gap-2 px-4 py-3 text-sm font-medium rounded-2xl border transition-all duration-200 ${R>0?"bg-gradient-to-r from-pink-500 to-orange-400 text-white border-transparent shadow-sm shadow-pink-200":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:[(0,t.jsx)(eJ.AdjustmentsHorizontalIcon,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Filters"}),R>0&&(0,t.jsx)("span",{className:"w-5 h-5 rounded-full text-[10px] font-bold flex items-center justify-center bg-white/30 dark:bg-zinc-950/30 text-white",children:R})]})]})]}),I.length>0&&(0,t.jsxs)("div",{className:"mx-4 md:mx-8 mb-5 flex flex-wrap items-center gap-2",children:[I.map(e=>(0,t.jsx)(to,{label:e.label,value:e.value,filterKey:e.key,onRemove:e.onRemove},e.key)),(0,t.jsx)("button",{onClick:$,className:"text-xs text-gray-400 dark:text-zinc-500 hover:text-gray-600 dark:hover:text-zinc-400 underline underline-offset-2 transition-colors",children:"Clear all"})]}),(0,t.jsx)(tl,{open:c,onClose:()=>d(!1),filters:x,onFilterChange:P,onClear:$,activeCount:R,teamMembers:N}),(0,t.jsx)(eY,{isOpen:i,onClose:()=>o(!1)}
1),j&&(0,t.jsx)(n.InlineLoader,{message:"Loading campaignsâ¦"}),!j&&0===e.length&&(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center py-20 text-center mx-4 md:mx-8",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-gray-50 dark:bg-zinc-900 flex items-center justify-center mb-4",children:(0,t.jsx)(es.MegaphoneIcon,{className:"w-8 h-8 text-gray-300 dark:text-zinc-700"})}),(0,t.jsx)("p",{className:"text-sm font-semibold text-gray-700 dark:text-zinc-300 mb-1",children:"No campaigns found"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-zinc-500 mb-4",children:R>0?"Try adjusting your filters":"Create your first campaign to get started"}),R>0&&(0,t.jsx)("button",{onClick:$,className:"text-xs text-pink-500 hover:text-pink-600 underline underline-offset-2 transition-colors",children:"Clear all filters"})]}),!j&&e.length>0&&(0,t.jsx)(eH,{campaigns:e}),!j&&e.length>0&&(0,t.jsx)(tc,{pagination:y,onPageChange:e=>{v(e),window.scrollTo({top:0,behavior:"smooth"})}})]})};var tu=e.i(269519),tm=e.i(482514),tg=e.i(20271),tp=e.i(220316),th=e.i(657688),tf=e.i(112171);function tb({children:e,className:r=""}){let s=(0,a.useRef)(null),n=(0,d.useMotionValue)(0),l=(0,d.useMotionValue)(0),o=(0,u.useSpring)((0,x.useTransform)(l,[-.5,.5],[6,-6]),{stiffness:180,damping:22}),c=(0,u.useSpring)((0,x.useTransform)(n,[-.5,.5],[-6,6]),{stiffness:180,damping:22}),m=(0,u.useSpring)((0,x.useTransform)(n,[-.5,0,.5],[.1,0,.1]),{stiffness:180,damping:22}),g=(0,x.useTransform)(n,[-.5,.5],["-25%","25%"]),p=(0,x.useTransform)(l,[-.5,.5],["-25%","25%"]),h=(0,a.useRef)(0),f=(0,a.useCallback)(e=>{if(!s.current||h.current)return;let{clientX:t,clientY:a}=e;h.current=requestAnimationFrame(()=>{if(h.current=0,!s.current)return;let e=s.current.getBoundingClientRect();n.set((t-e.left)/e.width-.5),l.set((a-e.top)/e.height-.5)})},[n,l]),b=(0,a.useCallback)(()=>{h.current&&(cancelAnimationFrame(h.current),h.current=0),n.set(0),l.set(0)},[n,l]);return(0,t.jsxs)(i.motion.div,{ref:s,onMouseMove:f,onMouseLeave:b,style:{rotateX:o,rotateY:c,transformPerspective:900,transformStyle:"preserve-3d",backfaceVisibility:"hidden",willChange:"transform"},className:r,children:[e,(0,t.jsx)("div",{className:"absolute inset-0 rounded-2xl pointer-events-none z-30 overflow-hidden",children:(0,t.jsx)(i.motion.div,{className:"absolute",style:{inset:"-50%",opacity:m,x:g,y:p,background:"radial-gradient(ellipse at center, var(--inset-highlight) 0%, transparent 55%)",willChange:"transform, opacity"}})})]})}function tv({icon:e,label:a,value:r,color:s,active:n}){return(0,t.jsxs)("div",{className:"text-center",children:[(0,t.jsx)(e,{className:"w-3 h-3 mx-auto mb-1 transition-colors",style:{color:n?s:"var(--text-disabled)"}}),(0,t.jsx)("div",{className:"text-[13px] font-extrabold leading-none mb-0.5 transition-colors",style:{color:n?"var(--text-primary)":"var(--text-disabled)"},children:r}),(0,t.jsx)("div",{className:"text-[8px] font-bold uppercase tracking-[0.08em] text-gray-400 dark:text-zinc-500",children:a})]})}function ty({organization:e,index:a=0}){let s=(0,r.useRouter)(),n=e||{},l=n.campaignCount||0,o=n.postCount||0,c=n.uniqueCreatorCount||0,d=n.totalViews||0,x=n.totalEngagements||0,u=d>0?(x/d*100).toFixed(1):null,m=n.isParentCompany&&n.childCompanies?.length>0;return(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:24,scale:.97},animate:{opacity:1,y:0,scale:1},transition:{duration:.5,delay:Math.min(.04*a,.6),ease:[.25,.46,.45,.94]},className:"w-full max-w-sm mx-auto h-full",children:(0,t.jsx)(tb,{className:"relative group/card h-full",children:(0,t.jsxs)("div",{onClick:()=>{s.push(`/dashboard/user/organization/${n._id}`)},className:"relative bg-white dark:bg-zinc-950 rounded-2xl border border-gray-200/60 dark:border-zinc-800/60 overflow-hidden cursor-pointer transition-all duration-500 hover:shadow-[0_24px_64px_-16px_var(--shadow-ambient-xl)] hover:border-gray-300/80 dark:hover:border-zinc-700/80 h-full flex flex-col",children:[(0,t.jsxs)("div",{className:"relative h-32 w-full overflow-hidden bg-gray-50/50 dark:bg-zinc-200 border-b border-gray-100 dark:border-zinc-800 shrink-0",children:[(0,t.jsx)("div",{className:"absolute inset-0 opacity-[0.03]",style:{backgroundImage:"radial-gradient(circle at 1px 1px, var(--text-label) 1px, transparent 0)",backgroundSize:"20px 20px"}}),n.image?(0,t.jsx)("div",{className:"absolute inset-0 flex items-center justify-center p-6",children:(0,t.jsx)(th.default,{src:n.image,fill:!0,alt:n.name,sizes:"(max-width: 384px) 100vw, 384px",style:{objectFit:"contain"},className:"transition-transform duration-[900ms] ease-out group-hover/card:scale-[1.06] p-3"})}):(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center",children:(0,t.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-gradient-to-br from-gray-200 to-gray-300 flex items-center justify-center dark:from-zinc-800 dark:to-zinc-700",children:(0,t.jsx)("span",{className:"text-xl font-black text-white tracking-wider",children:n.name?.split(" ").slice(0,2).map(e=>e[0]).join("").toUpperCase()||"?"})})}),(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-pink-500/0 to-orange-400/0 group-hover/card:from-pink-500/[0.04] group-hover/card:to-orange-400/[0.04] transition-all duration-700"}),(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/60 to-transparent -skew-x-12 translate-x-[-200%] group-hover/card:translate-x-[200%] transition-transform duration-[1200ms] ease-out pointer-events-none"}),(0,t.jsxs)("div",{className:"absolute top-2.5 left-2.5 z-10 flex gap-1.5",children:[n.vertical&&(0,t.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-[9px] font-bold uppercase tracking-wider bg-gray-800 text-white shadow-sm dark:bg-zinc-200",children:n.vertical}),n.organizationType&&n.organizationType!==n.vertical&&(0,t.jsx)("span",{className:"inline-flex items-center px-2 py-0.5 rounded-md text-[9px] font-bold uppercase tracking-wider bg-gray-600 text-white shadow-sm dark:bg-zinc-400",children:n.organizationType})]}),m&&(0,t.jsx)("div",{className:"absolute top-2.5 right-2.5 z-10",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[9px] font-bold uppercase tracking-wider bg-blue-600 text-white shadow-sm",children:[(0,t.jsx)(tu.BuildingOfficeIcon,{className:"w-3 h-3"}),n.childCompanies.length," subs"]})})]}),(0,t.jsxs)("div",{className:"p-4 flex-1 flex flex-col",children:[(0,t.jsxs)("div",{className:"flex items-start gap-1.5 mb-3",children:[(0,t.jsx)("h3",{className:"text-[15px] font-bold text-gray-900 dark:text-zinc-100 leading-snug line-clamp-2 flex-1 min-w-0",children:n.name}),n.claim?.isClaimed&&(0,t.jsx)(tf.default,{domain:n.claim?.domain,size:"sm",className:"mt-0.5 flex-shrink-0"})]}),(0,t.jsxs)("div",{className:"flex items-center flex-wrap gap-1.5 mb-3",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-pink-50 text-pink-600 text-[10px] font-semibold",children:[(0,t.jsx)(tg.FolderIcon,{className:"w-2.5 h-2.5"}),l," campaign",1!==l?"s":""]}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-orange-50 text-orange-600 text-[10px] font-semibold",children:[(0,t.jsx)(e2.FilmIcon,{className:"w-2.5 h-2.5"}),o," post",1!==o?"s":""]}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md bg-purple-50 text-purple-600 text-[10px] font-semibold",children:[(0,t.jsx)(tp.UsersIcon,{className:"w-2.5 h-2.5"}),c," creator",1!==c?"s":""]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-1 bg-gray-50/80 dark:bg-zinc-900/80 rounded-xl p-2.5 mt-auto",children:[(0,t.jsx)(tv,{icon:eE.EyeIcon,label:"Views",value:d?(0,f.formatNumberReturn)(d):"â",color:"#3b82f6",active:d>0}),(0,t.jsx)(tv,{icon:tm.HeartIcon,label:"Engmts",value:x?(0,f.formatNumberReturn)(x):"â",color:"#ec4899",active:x>0}
1),(0,t.jsx)(tv,{icon:eF.ChartBarIcon,label:"ER",value:u?`${u}%`:"â",color:"#f59e0b",active:!!u})]})]}),(0,t.jsx)("div",{className:"h-[3px] w-full bg-gradient-to-r from-pink-500/0 via-transparent to-orange-400/0 group-hover/card:from-pink-500 group-hover/card:via-rose-400 group-hover/card:to-orange-400 transition-all duration-700 shrink-0"})]})})})}function tk({organizations:e}){return e&&0!==e.length?(0,t.jsx)("div",{className:"grid gap-5 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 mt-6 mx-4 md:mx-8",children:e.map((e,a)=>(0,t.jsx)(ty,{organization:e,index:a},e._id))}):(0,t.jsx)("div",{className:"mt-10 text-center text-gray-500 dark:text-zinc-400 text-lg",children:"No organizations found."})}var tj=e.i(144452),tw=e.i(687692);let tN=[{key:"name",label:"Organization",className:"text-left"},{key:"campaignCount",label:"Campaigns",className:"text-right"},{key:"postCount",label:"Posts",className:"text-right"},{key:"uniqueCreatorCount",label:"Creators",className:"text-right"},{key:"totalViews",label:"Views",className:"text-right"},{key:"totalEngagements",label:"Engagements",className:"text-right"},{key:"er",label:"ER",className:"text-right"}];function tC(e){let t=e.totalViews||0,a=e.totalEngagements||0;return t>0?a/t*100:null}function tz({org:e,size:a="w-9 h-9"}){var r;return(0,t.jsx)("div",{className:`${a} rounded-xl overflow-hidden flex-shrink-0 flex items-center justify-center border border-gray-100 dark:border-zinc-800 bg-gray-50 dark:bg-zinc-200 relative`,children:e.image?(0,t.jsx)(th.default,{src:e.image,alt:e.name||"",fill:!0,sizes:"40px",style:{objectFit:"contain"},className:"p-1"}):(0,t.jsx)("span",{className:"text-[11px] font-black text-gray-500 dark:text-zinc-600 tracking-wider",children:(r=e.name,r?.split(" ").slice(0,2).map(e=>e[0]).join("").toUpperCase()||"?")})})}function tS({org:e}){let a=e.isParentCompany&&e.childCompanies?.length>0;return e.vertical||e.organizationType||a?(0,t.jsxs)("div",{className:"flex items-center flex-wrap gap-1 mt-1",children:[e.vertical&&(0,t.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-md text-[9px] font-bold uppercase tracking-wider bg-gray-800 text-white dark:bg-zinc-200 dark:text-zinc-900",children:e.vertical}),e.organizationType&&e.organizationType!==e.vertical&&(0,t.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-md text-[9px] font-bold uppercase tracking-wider bg-gray-600 text-white dark:bg-zinc-400 dark:text-zinc-900",children:e.organizationType}),a&&(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md text-[9px] font-bold uppercase tracking-wider bg-blue-600 text-white",children:[(0,t.jsx)(tu.BuildingOfficeIcon,{className:"w-3 h-3"}),e.childCompanies.length," subs"]})]}):null}function tE({value:e,muted:a}){let r=e>0;return(0,t.jsx)("span",{className:`text-sm tabular-nums ${r?"font-bold text-gray-900 dark:text-zinc-100":"font-medium text-gray-300 dark:text-zinc-700"}`,children:r?(0,f.formatNumberReturn)(e):a||"â"})}function tP({org:e}){let a=tC(e);return null==a?(0,t.jsx)("span",{className:"text-sm font-medium text-gray-300 dark:text-zinc-700",children:"â"}):(0,t.jsxs)("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded-full tabular-nums",style:{color:"#f59e0b",background:"#f59e0b15",border:"1px solid #f59e0b30"},children:[a.toFixed(1),"%"]})}function t$({organizations:e}){let s=(0,r.useRouter)(),[n,l]=(0,a.useState)({key:"name",dir:"asc"}),i=(0,a.useMemo)(()=>{let t=[...e||[]],{key:a,dir:r}=n,s="asc"===r?1:-1;return t.sort((e,t)=>{if("name"===a)return s*String(e.name||"").localeCompare(String(t.name||""),"en",{sensitivity:"base"});let r="er"===a?tC(e)??-1:e[a]||0,n="er"===a?tC(t)??-1:t[a]||0;return r===n?String(e.name||"").localeCompare(String(t.name||"")):s*(r-n)}),t},[e,n]),o=e=>s.push(`/dashboard/user/organization/${e._id}`);return e&&0!==e.length?(0,t.jsxs)("div",{className:"mt-6 mx-4 md:mx-8 rounded-2xl overflow-hidden",style:{background:"var(--surface-panel)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"hidden md:block overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full text-sm",children:[(0,t.jsx)("thead",{children:(0,t.jsx)("tr",{className:"text-left",style:{background:"var(--surface-soft)"},children:tN.map(e=>{let a=n.key===e.key;return(0,t.jsx)("th",{className:`px-4 py-3 ${e.className}`,children:(0,t.jsxs)("button",{type:"button",onClick:()=>{var t;return t=e.key,void l(e=>e.key===t?{key:t,dir:"asc"===e.dir?"desc":"asc"}:{key:t,dir:"name"===t?"asc":"desc"})},className:`inline-flex items-center gap-1 text-[10px] font-bold uppercase tracking-[0.12em] transition-colors ${a?"text-pink-500":"text-gray-400 dark:text-zinc-500 hover:text-gray-700 dark:hover:text-zinc-200"}`,children:[e.label,a?"asc"===n.dir?(0,t.jsx)(tj.ChevronUpIcon,{className:"w-3 h-3"}):(0,t.jsx)(e5.ChevronDownIcon,{className:"w-3 h-3"}):(0,t.jsx)(tw.ChevronUpDownIcon,{className:"w-3 h-3 opacity-50"})]})},e.key)})})}),(0,t.jsx)("tbody",{className:"divide-y divide-black/5 dark:divide-white/5",children:i.map(e=>(0,t.jsxs)("tr",{onClick:()=>o(e),className:"cursor-pointer hover:bg-black/[0.02] dark:hover:bg-white/[0.03] transition-colors group/row",children:[(0,t.jsx)("td",{className:"px-4 py-3",children:(0,t.jsxs)("div",{className:"flex items-center gap-3 min-w-0",children:[(0,t.jsx)(tz,{org:e}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,t.jsx)("span",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100 truncate max-w-[320px] group-hover/row:text-pink-500 dark:group-hover/row:text-pink-400 transition-colors",children:e.name}),e.claim?.isClaimed&&(0,t.jsx)(tf.default,{domain:e.claim?.domain,size:"sm",className:"flex-shrink-0"})]}),(0,t.jsx)(tS,{org:e})]})]})}),(0,t.jsx)("td",{className:"px-4 py-3 text-right whitespace-nowrap",children:(0,t.jsx)(tE,{value:e.campaignCount,muted:"0"})}),(0,t.jsx)("td",{className:"px-4 py-3 text-right whitespace-nowrap",children:(0,t.jsx)(tE,{value:e.postCount,muted:"0"})}),(0,t.jsx)("td",{className:"px-4 py-3 text-right whitespace-nowrap",children:(0,t.jsx)(tE,{value:e.uniqueCreatorCount,muted:"0"})}),(0,t.jsx)("td",{className:"px-4 py-3 text-right whitespace-nowrap",children:(0,t.jsx)(tE,{value:e.totalViews})}),(0,t.jsx)("td",{className:"px-4 py-3 text-right whitespace-nowrap",children:(0,t.jsx)(tE,{value:e.totalEngagements})}),(0,t.jsx)("td",{className:"px-4 py-3 text-right whitespace-nowrap",children:(0,t.jsx)(tP,{org:e})})]},e._id))})]})}),(0,t.jsx)("div",{className:"md:hidden divide-y divide-black/5 dark:divide-white/5",children:i.map(e=>
1{let a=e.campaignCount||0,r=e.postCount||0,s=e.uniqueCreatorCount||0;return(0,t.jsxs)("div",{role:"link",tabIndex:0,onClick:()=>o(e),onKeyDown:t=>{"Enter"===t.key&&o(e)},className:"w-full text-left p-4 active:bg-black/[0.03] dark:active:bg-white/[0.04] transition-colors cursor-pointer",children:[(0,t.jsxs)("div",{className:"flex items-start gap-3",children:[(0,t.jsx)(tz,{org:e,size:"w-10 h-10"}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100 truncate",children:e.name}),e.claim?.isClaimed&&(0,t.jsx)(tf.default,{domain:e.claim?.domain,size:"sm",className:"flex-shrink-0"})]}),(0,t.jsxs)("p",{className:"text-[11px] text-gray-400 dark:text-zinc-500 truncate",children:[a," campaign",1!==a?"s":""," ·"," ",r," post",1!==r?"s":""," · ",s," ","creator",1!==s?"s":""]}),(0,t.jsx)(tS,{org:e})]}),(0,t.jsxs)("div",{className:"flex flex-col items-end gap-0.5 flex-shrink-0",children:[(0,t.jsx)(tE,{value:e.totalViews}),(0,t.jsx)("span",{className:"text-[9px] font-bold uppercase tracking-[0.08em] text-gray-400 dark:text-zinc-500",children:"Views"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 mt-2 pl-[52px]",children:[(0,t.jsxs)("span",{className:"text-[11px] text-gray-500 dark:text-zinc-400",children:[(0,t.jsx)(tE,{value:e.totalEngagements})," ",(0,t.jsx)("span",{className:"text-[9px] font-bold uppercase tracking-[0.08em] text-gray-400 dark:text-zinc-500",children:"Engmts"})]}),(0,t.jsx)("span",{className:"ml-auto",children:(0,t.jsx)(tP,{org:e})})]})]},e._id)})})]}):(0,t.jsx)("div",{className:"mt-10 text-center text-gray-500 dark:text-zinc-400 text-lg",children:"No organizations found."})}var tM=e.i(865654),tF=e.i(104903),tI=e.i(938712);let tR={hidden:{},show:{transition:{staggerChildren:.06}}},tT={hidden:{opacity:0,y:16},show:{opacity:1,y:0,transition:{duration:.45,ease:[.25,.46,.45,.94]}}};function tA({value:e}){let[r,s]=(0,a.useState)(0);return(0,a.useEffect)(()=>{if(!e)return void s(0);let t=performance.now();requestAnimationFrame(function a(r){let n=Math.min((r-t)/800,1);s(Math.round(0+(e-0)*(1-Math.pow(1-n,3)))),n<1&&requestAnimationFrame(a)})},[e]),(0,t.jsx)(t.Fragment,{children:(0,f.formatNumberReturn)(r)})}function tD({icon:e,label:a,value:r,color:s,gradient:n}){return(0,t.jsxs)(i.motion.div,{variants:tT,className:"relative overflow-hidden rounded-2xl bg-white dark:bg-zinc-950 border border-gray-100 dark:border-zinc-800 p-5 group hover:shadow-lg hover:-translate-y-0.5 transition-all duration-300",children:[(0,t.jsx)("div",{className:"absolute top-0 right-0 w-24 h-24 rounded-full opacity-[0.07] -translate-y-8 translate-x-8 transition-opacity group-hover:opacity-[0.12]",style:{background:n}}),(0,t.jsx)("div",{className:"flex items-start justify-between mb-3",children:(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{background:`${s}12`},children:(0,t.jsx)(e,{className:"w-5 h-5",style:{color:s}})})}),(0,t.jsx)("div",{className:"text-2xl font-black text-gray-900 dark:text-zinc-100 tracking-tight mb-0.5",children:(0,t.jsx)(tA,{value:r})}),(0,t.jsx)("div",{className:"text-[11px] font-semibold text-gray-400 dark:text-zinc-500 uppercase tracking-wider",children:a})]})}function tV({view:e,onToggle:a}){return(0,t.jsx)("div",{role:"group","aria-label":"Organizations view",className:"relative inline-flex rounded-full p-0.5 flex-shrink-0",style:{border:"1px solid var(--border-subtle)",zIndex:10},children:["cards","list"].map(r=>{let s=e===r;return(0,t.jsx)("button",{type:"button","aria-pressed":s,onClick:()=>a(r),className:`px-3 py-1 rounded-full text-[11px] font-semibold transition-colors duration-150 ${s?"bg-gradient-to-r from-pink-500 to-orange-400 text-white":"text-gray-500 dark:text-zinc-400"}`,style:s?{}:{background:"var(--surface-soft)"},children:"cards"===r?"Cards":"List"},r)})})}function tL({pagination:e,onPageChange:a}){if(!e||e.totalPages<=1)return null;let{currentPage:r,totalPages:s,hasPrevPage:n,hasNextPage:l}=e,i=[],o=Math.max(1,r-Math.floor(3.5)),c=Math.min(s,o+7-1);c-o<6&&(o=Math.max(1,c-7+1)),i.push((0,t.jsx)("button",{onClick:()=>a(r-1),disabled:!n,className:`px-3.5 py-2 rounded-xl text-sm font-medium transition-all duration-200 ${!n?"bg-gray-50 dark:bg-zinc-900 text-gray-300 dark:text-zinc-700 cursor-not-allowed":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:"Previous"},"prev")),o>1&&(i.push((0,t.jsx)("button",{onClick:()=>a(1),className:"px-3.5 py-2 rounded-xl text-sm font-medium bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600 transition-all duration-200",children:"1"},1)),o>2&&i.push((0,t.jsx)("span",{className:"px-2 text-gray-300 dark:text-zinc-700",children:"..."},"e1")));for(let e=o;e<=c;e++)i.push((0,t.jsx)("button",{onClick:()=>a(e),className:`px-3.5 py-2 rounded-xl text-sm font-medium transition-all duration-200 ${e===r?"bg-gradient-to-r from-pink-500 to-orange-400 text-white border border-transparent shadow-sm shadow-pink-200":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:e},e));return c<s&&(c<s-1&&i.push((0,t.jsx)("span",{className:"px-2 text-gray-300 dark:text-zinc-700",children:"..."},"e2")),i.push((0,t.jsx)("button",{onClick:()=>a(s),className:"px-3.5 py-2 rounded-xl text-sm font-medium bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600 transition-all duration-200",children:s},s))),i.push((0,t.jsx)("button",{onClick:()=>a(r+1),disabled:!l,className:`px-3.5 py-2 rounded-xl text-sm font-medium transition-all duration-200 ${!l?"bg-gray-50 dark:bg-zinc-900 text-gray-300 dark:text-zinc-700 cursor-not-allowed":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:"Next"},"next")),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3 mt-8",children:[(0,t.jsx)("div",{className:"flex gap-1.5 flex-wrap justify-center",children:i}),(0,t.jsxs)("p",{className:"text-xs text-gray-400 dark:text-zinc-500",children:["Page ",r," of ",s," ·"," ",e.totalOrganizations," organizations"]})]})}let tB=function({session:e}){let{params:r,setParams:s}=(0,tM.useHomeQuery)(),l="list"===r.get("orgsView")?"list":"cards",[o,c]=(0,a.useState)([]),[d,x]=(0,a.useState)(!1),[u,h]=(0,a.useState)(1),[f,b]=(0,a.useState)(null),[v,y]=(0,a.useState)(null),[k,j]=(0,a.useState)(!1),[w,N]=(0,a.useState)(""),[C,z]=(0,a.useState)(""),{can:S,loading:E}=(0,eX.usePermissions)();(0,a.useEffect)(()=>{let e=setTimeout(()=>{z(w),w!==C&&h(1)},500);return()=>clearTimeout(e)},[w]),(0,a.useEffect)(()=>{!async function(){j(!0);try{let e=new URLSearchParams({page:u.toString(),limit:"50"});C&&e.append("search",C);let t=await fetch(`https://www.socialscout.ai/api/getOrganizations?${e.toString()}`),a=await t.json();if(!t.ok)throw Error(a?.error||"Failed to load organizations");c(a.organizations),b(a.pagination),a.aggregates&&y(a.aggregates)}catch(e){console.error("Error fetching organizations:",e),m.default.error(`Failed to fetch organizations: ${e.message}`)}finally{j(!1)}}()},[u,C]);let P=()=>{N(""),z(""),h(1)},$=[{icon:tu.BuildingOfficeIcon,label:"Organizations",value:v?.totalOrganizations||0,color:"#ec4899",gradient:"radial-gradient(circle, #ec4899, #f97316)"},{icon:tg.FolderIcon,label:"Campaigns",value:v?.totalCampaigns||0,color:"#8b5cf6",gradient:"radial-gradient(circle, #8b5cf6, #6366f1)"},{icon:e2.FilmIcon,label:"Total Posts",value:v?.totalPosts||0,color:"#f97316",gradient:"radial-gradient(circle, #f97316, #ef4444)"},{icon:tp.UsersIcon,label:"Unique Creators",value:v?.uniqueCreators||0,color:"#06b6d4",gradient:"radial-gradient(circle, #06b6d4, #3b82f6)"},{icon:eE.EyeIcon,label:"Total Views",value:v?.totalViews||0,color:"#3b82f6",gradient:"radial-gradient(circle, #3b82f6, #8b5cf6)"},{icon:tm.HeartIcon,label:"Engagements",value:v?.totalEngagements||0,color:"#ef4444",gradient:"radial-gradient(circle, #ef4444, #ec4899)"}];return(0,t.jsxs)("div",{className:"mt-6 mb-40",children:[(0,t.jsx)("div",{className:"mx-4 md:mx-8 mb-6",children:(0,t.jsxs)(i.motion.div,{initial:{opacity:0,y:-10}
1,animate:{opacity:1,y:0},transition:{duration:.4},children:[(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 dark:text-zinc-100 tracking-tight",children:"Organizations"}),v&&(0,t.jsxs)("p",{className:"text-sm text-gray-400 dark:text-zinc-500 mt-1",children:[v.totalOrganizations," total ·"," ",v.totalCampaigns," campaigns across all organizations"]})]})}),v&&(0,t.jsx)(i.motion.div,{variants:tR,initial:"hidden",animate:"show",className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3 mx-4 md:mx-8 mb-8",children:$.map(e=>(0,t.jsx)(tD,{...e},e.label))}),(0,t.jsxs)(i.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.4,delay:.15},className:"mx-4 md:mx-8 mb-6 flex items-center gap-3",children:[(0,t.jsx)("div",{className:"flex-1 relative",children:(0,t.jsx)("div",{className:`p-[1.5px] rounded-2xl transition-all duration-300 ${w?"bg-gradient-to-r from-pink-500 to-orange-400 shadow-sm shadow-pink-200/50":"bg-gray-200 dark:bg-zinc-800 hover:bg-gray-300"}`,children:(0,t.jsxs)("div",{className:"relative bg-white dark:bg-zinc-950 rounded-2xl",children:[(0,t.jsx)("input",{type:"text",value:w,onChange:e=>N(e.target.value),placeholder:"Search organizations by name...",className:"w-full pl-10 pr-4 py-2.5 text-sm bg-transparent border-0 rounded-2xl focus:outline-none placeholder-gray-400 dark:placeholder-zinc-500 text-gray-900 dark:text-zinc-100"}),(0,t.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 dark:text-zinc-500",children:w?(0,t.jsx)("button",{onClick:P,className:"hover:text-gray-600 dark:hover:text-zinc-400 transition-colors",children:(0,t.jsx)(p.XMarkIcon,{className:"w-4 h-4"})}):(0,t.jsx)(g.MagnifyingGlassIcon,{className:"w-4 h-4"})})]})})}),(0,t.jsx)(tV,{view:l,onToggle:e=>{s({orgsView:"cards"===e?null:e})}}),!E&&S("organizations","create")&&(0,t.jsxs)(i.motion.button,{whileHover:{scale:1.03,y:-1},whileTap:{scale:.97},onClick:()=>x(!0),className:"flex items-center gap-2 px-4 py-2.5 text-sm font-medium bg-gradient-to-r from-pink-500 to-orange-400 text-white rounded-xl shadow-sm shadow-pink-200 hover:shadow-md hover:shadow-pink-300 transition-shadow duration-200",children:[(0,t.jsx)(e0.PlusIcon,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Create Organization"}),(0,t.jsx)("span",{className:"sm:hidden",children:"New"})]})]}),C&&(0,t.jsxs)(i.motion.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},exit:{opacity:0,x:-10},transition:{duration:.25},className:"mx-4 md:mx-8 mb-4 flex flex-wrap items-center gap-2",children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium bg-pink-50 text-pink-700 border border-pink-200",children:["Search",(0,t.jsxs)("span",{className:"font-semibold",children:["â",C,"â"]}),(0,t.jsx)("button",{onClick:P,className:"ml-0.5 hover:text-pink-900 transition-colors",children:(0,t.jsx)(p.XMarkIcon,{className:"w-3 h-3"})})]}),(0,t.jsx)("button",{onClick:P,className:"text-xs text-gray-400 dark:text-zinc-500 hover:text-gray-600 dark:hover:text-zinc-400 underline underline-offset-2 transition-colors",children:"Clear all"})]}),(0,t.jsx)(tI.default,{isOpen:d,onClose:()=>x(!1),children:(0,t.jsx)(tF.default,{})}),k&&(0,t.jsx)(n.InlineLoader,{message:"Loading organizationsâ¦"}),!k&&0===o.length&&C&&(0,t.jsxs)(i.motion.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.4},className:"flex flex-col items-center justify-center py-20 text-center",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-gray-50 dark:bg-zinc-900 flex items-center justify-center mb-4",children:(0,t.jsx)(tu.BuildingOfficeIcon,{className:"w-8 h-8 text-gray-300 dark:text-zinc-700"})}),(0,t.jsx)("p",{className:"text-sm font-semibold text-gray-700 dark:text-zinc-300 mb-1",children:"No organizations found"}),(0,t.jsxs)("p",{className:"text-xs text-gray-400 dark:text-zinc-500 mb-4",children:["No results matching â",C,"â"]}),(0,t.jsx)("button",{onClick:P,className:"text-xs text-pink-500 hover:text-pink-600 underline underline-offset-2 transition-colors",children:"Clear search"})]}),!k&&o.length>0&&"cards"===l&&(0,t.jsx)(tk,{organizations:o}),!k&&o.length>0&&"list"===l&&(0,t.jsx)(t$,{organizations:o}),!k&&o.length>0&&(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:12}
1,animate:{opacity:1,y:0},transition:{duration:.4,delay:.3},children:(0,t.jsx)(tL,{pagination:f,onPageChange:e=>{h(e),window.scrollTo({top:0,behavior:"smooth"})}})})]})};var tO=e.i(560539);let t_=e=>e?e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString():null,tU=()=>(0,t.jsx)("div",{className:"rounded-2xl overflow-hidden bg-gray-100 dark:bg-zinc-900 aspect-[3/4] animate-pulse"});function tG({creator:e,index:r=0}){let[s,n]=(0,a.useState)(!1),[l,o]=(0,a.useState)(!1);if(!e)return(0,t.jsx)(tU,{});let{_id:c,name:d,image:x,category:u,sub_category:m,city:g,state:p,country:f,socials:b,management_company:v}=e,y=[g,p,f].filter(Boolean).join(", "),k=!s&&x,j=Object.entries(b||{}).filter(([,e])=>e&&e.followers).sort((e,t)=>(t[1].followers||0)-(e[1].followers||0)),w=j.reduce((e,[,t])=>e+(t.followers||0),0);return j[0],(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:24,scale:.97},animate:{opacity:1,y:0,scale:1},transition:{duration:.5,delay:Math.min(.03*r,.5),ease:[.25,.46,.45,.94]},className:"h-full",children:(0,t.jsx)(J.default,{href:`/dashboard/user/creator/${c}`,className:"group block h-full",onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:(0,t.jsx)("div",{className:`p-[1.5px] rounded-2xl transition-all duration-500 h-full ${l?"bg-gradient-to-br from-pink-500 via-rose-400 to-orange-400 shadow-xl shadow-pink-500/20":"bg-gray-200/60 dark:bg-zinc-800/60"}`,children:(0,t.jsxs)("div",{className:"relative bg-white dark:bg-zinc-950 rounded-[14px] overflow-hidden h-full flex flex-col",children:[(0,t.jsxs)("div",{className:"relative aspect-[3/4] overflow-hidden",children:[k?(0,t.jsx)("img",{src:x,alt:d,className:"absolute inset-0 w-full h-full object-cover object-top transition-transform duration-[900ms] ease-out group-hover:scale-[1.08]",loading:"lazy",onError:()=>n(!0)}):(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-br from-gray-800 via-gray-900 to-gray-900 flex items-center justify-center dark:from-zinc-200 dark:to-zinc-100 dark:via-zinc-100",children:(0,t.jsx)("span",{className:"text-6xl font-black text-white/10 dark:text-zinc-900/10 select-none",children:d?.charAt(0)?.toUpperCase()??"?"})}),(0,t.jsx)("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/5 to-transparent"}),(0,t.jsx)("div",{className:"absolute inset-x-0 top-0 h-20 bg-gradient-to-b from-black/40 to-transparent"}),u&&(0,t.jsx)("div",{className:"absolute top-3 left-3 z-10",children:(0,t.jsx)("span",{className:"bg-gray-900/70 dark:bg-gray-900/70 backdrop-blur-md text-white text-[9px] font-bold uppercase tracking-wider px-2.5 py-1 rounded-md",children:u})}),v&&(0,t.jsxs)("div",{className:"absolute top-3 right-3 z-10 group/mgmt",children:[(0,t.jsx)("div",{className:"w-7 h-7 rounded-full ring-2 ring-white/40 overflow-hidden shadow-lg bg-white dark:bg-zinc-950 group-hover/mgmt:scale-110 transition-transform duration-200 dark:ring-zinc-700/40",children:v.image?(0,t.jsx)("img",{src:v.image,alt:v.name,className:"w-full h-full object-cover"}):(0,t.jsx)("div",{className:"w-full h-full bg-gray-200 dark:bg-zinc-800 flex items-center justify-center",children:(0,t.jsx)("span",{className:"text-[9px] font-bold text-gray-500 dark:text-zinc-400",children:v.name?.charAt(0)??"M"})})}),(0,t.jsx)("div",{className:"absolute top-full right-0 mt-1.5 opacity-0 group-hover/mgmt:opacity-100 transition-opacity duration-150 pointer-events-none z-20",children:(0,t.jsx)("div",{className:"bg-gray-900/90 dark:bg-gray-900/90 backdrop-blur-sm text-white text-[10px] font-medium rounded-lg px-2.5 py-1.5 whitespace-nowrap shadow-xl",children:v.name})})]}),(0,t.jsxs)("div",{className:"absolute bottom-0 left-0 right-0 p-3.5 z-10",children:[(0,t.jsx)("h3",{className:"text-white font-bold text-sm leading-tight drop-shadow-md line-clamp-1 mb-1",children:d??"Unknown Creator"}),y&&(0,t.jsxs)("div",{className:"flex items-center gap-1 mb-2.5",children:[(0,t.jsx)(tO.MapPinIcon,{className:"w-2.5 h-2.5 text-white/60 dark:text-white/60 flex-shrink-0"}),(0,t.jsx)("span",{className:"text-[10px] text-white/60 dark:text-white/60 truncate",children:y})]}),j.length>0&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[j.slice(0,3).map(([e,a])=>{let r=h.default[e];return r?(0,t.jsxs)("div",{className:"flex items-center gap-1 bg-white/15 dark:bg-zinc-950/15 backdrop-blur-md border border-white/10 rounded-md px-1.5 py-0.5 dark:border-zinc-800/10",children:[(0,t.jsx)("img",{src:r.icon,alt:e,className:"w-3 h-3 rounded-sm"}),(0,t.jsx)("span",{className:"text-[9px] font-bold text-white tabular-nums",children:t_(a.followers)})]},e):null}),j.length>3&&(0,t.jsx)("div",{className:"flex items-center justify-center bg-white/15 dark:bg-zinc-950/15 backdrop-blur-md border border-white/10 rounded-md px-1.5 py-0.5 dark:border-zinc-800/10",children:(0,t.jsxs)("span",{className:"text-[9px] font-bold text-white",children:["+",j.length-3]})})]})]})]}),(0,t.jsxs)("div",{className:"px-3.5 py-2.5 flex items-center justify-between bg-gray-50/80 dark:bg-zinc-900/80 mt-auto",children:[(0,t.jsx)("div",{className:"flex items-center gap-1.5",children:m&&(0,t.jsx)("span",{className:"text-[9px] font-semibold text-gray-500 dark:text-zinc-400 bg-gray-100 dark:bg-zinc-900 px-1.5 py-0.5 rounded",children:m})}),w>0&&(0,t.jsxs)("span",{className:"text-[10px] font-extrabold bg-gradient-to-r from-pink-500 to-orange-400 bg-clip-text text-transparent tabular-nums",children:[t_(w)," reach"]})]})]})})})})}function tH({creators:e}){return(0,t.jsx)("div",{className:"grid gap-5 grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 mx-4 md:mx-8",children:e.map((e,a)=>(0,t.jsx)(tG,{creator:e,index:a},e._id))})}var tK=e.i(231526),tW=e.i(641188),tq=e.i(691741);
1let tY=function({value:e,onChange:r}){let[s,n]=(0,a.useState)([]),[l,i]=(0,a.useState)(!0);return(0,a.useEffect)(()=>{!async function(){try{let e=await fetch("https://www.socialscout.ai/api/getManagementCompanies"),t=await e.json();n(t||[])}catch(e){console.error("Failed to fetch management companies:",e)}finally{i(!1)}}()},[]),(0,t.jsxs)("select",{value:e,onChange:r,className:"py-3 px-6 border border-gray-300 dark:border-zinc-700 rounded-md",disabled:l,children:[(0,t.jsx)("option",{value:"",children:l?"Loading...":"All Management Companies"}),s.map(e=>(0,t.jsx)("option",{value:e._id,children:e.name},e._id))]})},tX={hidden:{},show:{transition:{staggerChildren:.06}}},tQ={hidden:{opacity:0,y:16},show:{opacity:1,y:0,transition:{duration:.45,ease:[.25,.46,.45,.94]}}};function tZ({value:e}){let[r,s]=(0,a.useState)(0);return(0,a.useEffect)(()=>{if(!e)return void s(0);let t=performance.now();requestAnimationFrame(function a(r){let n=Math.min((r-t)/800,1);s(Math.round(e*(1-Math.pow(1-n,3)))),n<1&&requestAnimationFrame(a)})},[e]),(0,t.jsx)(t.Fragment,{children:(0,f.formatNumberReturn)(r)})}function tJ({icon:e,label:a,value:r,color:s,gradient:n}){return(0,t.jsxs)(i.motion.div,{variants:tQ,className:"relative overflow-hidden rounded-2xl bg-white dark:bg-zinc-950 border border-gray-100 dark:border-zinc-800 p-5 group hover:shadow-lg hover:-translate-y-0.5 transition-all duration-300",children:[(0,t.jsx)("div",{className:"absolute top-0 right-0 w-24 h-24 rounded-full opacity-[0.07] -translate-y-8 translate-x-8 transition-opacity group-hover:opacity-[0.12]",style:{background:n}}),(0,t.jsx)("div",{className:"flex items-start justify-between mb-3",children:(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{background:`${s}12`},children:(0,t.jsx)(e,{className:"w-5 h-5",style:{color:s}})})}),(0,t.jsx)("div",{className:"text-2xl font-black text-gray-900 dark:text-zinc-100 tracking-tight mb-0.5",children:(0,t.jsx)(tZ,{value:r})}),(0,t.jsx)("div",{className:"text-[11px] font-semibold text-gray-400 dark:text-zinc-500 uppercase tracking-wider",children:a})]})}let t0=({label:e,...a})=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-bold tracking-widest uppercase text-gray-400 dark:text-zinc-500 mb-2",children:e}),(0,t.jsx)("input",{className:"w-full px-3 py-2.5 text-sm border border-gray-200 dark:border-zinc-800 rounded-xl focus:outline-none focus:ring-2 focus:ring-pink-300 focus:border-transparent placeholder-gray-400 dark:placeholder-zinc-500",...a})]}),t1=({label:e,value:a,onChange:r,children:s})=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-bold tracking-widest uppercase text-gray-400 dark:text-zinc-500 mb-2",children:e}),(0,t.jsx)("select",{value:a,onChange:r,className:"w-full px-3 py-2.5 text-sm border border-gray-200 dark:border-zinc-800 rounded-xl focus:outline-none focus:ring-2 focus:ring-pink-300 focus:border-transparent bg-white dark:bg-zinc-950 text-gray-700 dark:text-zinc-300",children:s})]}),t2=({label:e,children:a})=>(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-xs font-bold tracking-widest uppercase text-gray-400 dark:text-zinc-500 mb-2",children:e}),a]}),t5=({open:e,onClose:a,category:r,subCategory:s,tiktokFollowers:n,instagramFollowers:l,locationFilter:i,managementCompany:o,sortField:c,sortOrder:d,onCategoryChange:x,onSubCategoryChange:u,onTiktokChange:m,onInstagramChange:g,onLocationChange:h,onManagementChange:f,onSortChange:b,onClear:v,activeCount:y})=>(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:`fixed inset-0 bg-black/30 backdrop-blur-sm z-40 transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,onClick:a}),(0,t.jsxs)("div",{className:`fixed top-0 right-0 h-full w-80 bg-white dark:bg-zinc-950 z-50 shadow-2xl flex flex-col transition-transform duration-300 ease-out ${e?"translate-x-0":"translate-x-full"}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-6 py-5 border-b border-gray-100 dark:border-zinc-800",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"p-1.5 rounded-lg bg-gradient-to-br from-pink-500 to-orange-400",children:(0,t.jsx)(e1.FunnelIcon,{className:"w-4 h-4 text-white"})}),(0,t.jsx)("h2",{className:"text-sm font-bold text-gray-900 dark:text-zinc-100",children:"Filters"}),y>0&&(0,t.jsx)("span",{className:"px-2 py-0.5 bg-gradient-to-r from-pink-500 to-orange-400 text-white text-[10px] font-semibold rounded-full",children:y})]}),(0,t.jsx)("button",{onClick:a,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors text-gray-400 dark:text-zinc-500",children:(0,t.jsx)(p.XMarkIcon,{className:"w-5 h-5"})})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 py-6 space-y-5",children:[(0,t.jsx)(t2,{label:"Category",children:(0,t.jsx)(tW.default,{value:r,onChange:x})}),(0,t.jsx)(t2,{label:"Sub-Category",children:(0,t.jsx)(tq.default,{value:s,onChange:u})}),(0,t.jsx)(t0,{label:"Min TikTok Followers",type:"number",placeholder:"e.g. 100000",value:n,onChange:m}),(0,t.jsx)(t0,{label:"Min Instagram Followers",type:"number",placeholder:"e.g. 50000",value:l,onCh
1ange:g}),(0,t.jsx)(t0,{label:"Location",type:"text",placeholder:"e.g. New York",value:i,onChange:h}),(0,t.jsx)(t2,{label:"Management",children:(0,t.jsx)(tY,{value:o,onChange:f})}),(0,t.jsxs)(t1,{label:"Sort By",value:`${c}-${1===d?"asc":"desc"}`,onChange:b,children:[(0,t.jsx)("option",{value:"name-asc",children:"Name (AâZ)"}),(0,t.jsx)("option",{value:"name-desc",children:"Name (ZâA)"}),(0,t.jsx)("option",{value:"socials.tiktok.followers-asc",children:"TikTok Followers (LowâHigh)"}),(0,t.jsx)("option",{value:"socials.tiktok.followers-desc",children:"TikTok Followers (HighâLow)"})]})]}),y>0&&(0,t.jsx)("div",{className:"px-6 py-4 border-t border-gray-100 dark:border-zinc-800",children:(0,t.jsx)("button",{onClick:v,className:"w-full px-4 py-2.5 text-sm font-medium text-gray-600 dark:text-zinc-400 border border-gray-200 dark:border-zinc-800 rounded-xl hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:"Clear all filters"})})]})]}),t4=({label:e,value:a,onRemove:r,color:s="pink"})=>(0,t.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border ${{pink:"bg-pink-50 text-pink-700 border-pink-100",green:"bg-green-50 text-green-700 border-green-100",purple:"bg-purple-50 text-purple-700 border-purple-100",orange:"bg-orange-50 text-orange-700 border-orange-100",yellow:"bg-yellow-50 text-yellow-700 border-yellow-100",teal:"bg-teal-50 text-teal-700 border-teal-100",blue:"bg-blue-50 text-blue-700 border-blue-100"}[s]}`,children:[e,": ",(0,t.jsx)("strong",{children:a}),(0,t.jsx)("button",{onClick:r,className:"ml-0.5 hover:opacity-70 transition-opacity",children:(0,t.jsx)(p.XMarkIcon,{className:"w-3 h-3"})})]}),t3=({pagination:e,onPageChange:a})=>{if(!e||e.totalPages<=1)return null;let{currentPage:r,totalPages:s,hasPrevPage:n,hasNextPage:l,totalCreators:i}=e,o=Math.max(1,r-Math.floor(3.5)),c=Math.min(s,o+7-1);c-o<6&&(o=Math.max(1,c-7+1));let d=[];o>1&&(d.push({type:"page",value:1}),o>2&&d.push({type:"ellipsis",value:"start"}));for(let e=o;e<=c;e++)d.push({type:"page",value:e});return c<s&&(c<s-1&&d.push({type:"ellipsis",value:"end"}),d.push({type:"page",value:s})),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3 mt-10 mx-4 md:mx-8",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap justify-center",children:[(0,t.jsx)("button",{onClick:()=>a(r-1),disabled:!n,className:`px-3.5 py-2 text-sm font-medium rounded-xl border transition-all ${!n?"bg-gray-50 dark:bg-zinc-900 text-gray-300 dark:text-zinc-700 border-gray-100 dark:border-zinc-800 cursor-not-allowed":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:"Previous"}),d.map(e=>"ellipsis"===e.type?(0,t.jsx)("span",{className:"px-2 text-gray-300 dark:text-zinc-700",children:"..."},e.value):(0,t.jsx)("button",{onClick:()=>a(e.value),className:`px-3.5 py-2 text-sm font-medium rounded-xl border transition-all ${e.value===r?"bg-gradient-to-r from-pink-500 to-orange-400 text-white border-transparent shadow-sm shadow-pink-200":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:e.value},e.value)),(0,t.jsx)("button",{onClick:()=>a(r+1),disabled:!l,className:`px-3.5 py-2 text-sm font-medium rounded-xl border transition-all ${!l?"bg-gray-50 dark:bg-zinc-900 text-gray-300 dark:text-zinc-700 border-gray-100 dark:border-zinc-800 cursor-not-allowed":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:"Next"})]}),(0,t.jsxs)("p",{className:"text-xs text-gray-400 dark:text-zinc-500",children:["Page ",r," of ",s," · ",i," creators"]})]})};function t6({className:e}){return(0,t.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:e,children:(0,t.jsx)("path",{d:"M19.59 6.69a4.83 4.83 0 01-3.77-4.25V2h-3.45v13.67a2.89 2.89 0 01-2.88 2.5 2.89 2.89 0 01-2.89-2.89 2.89 2.89 0 012.89-2.89c.28 0 .54.04.79.1V9.01a6.27 6.27 0 00-.79-.05 6.34 6.34 0 00-6.34 6.34 6.34 6.34 0 006.34 6.34 6.34 6.34 0 006.34-6.34V8.75a8.18 8.18 0 004.76 1.52V6.84a4.84 4.84 0 01-1-.15z"})})}function t9({className:e}
1){return(0,t.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:e,children:(0,t.jsx)("path",{d:"M12 2.163c3.204 0 3.584.012 4.85.07 3.252.148 4.771 1.691 4.919 4.919.058 1.265.069 1.645.069 4.849 0 3.205-.012 3.584-.069 4.849-.149 3.225-1.664 4.771-4.919 4.919-1.266.058-1.644.07-4.85.07-3.204 0-3.584-.012-4.849-.07-3.26-.149-4.771-1.699-4.919-4.92-.058-1.265-.07-1.644-.07-4.849 0-3.204.013-3.583.07-4.849.149-3.227 1.664-4.771 4.919-4.919 1.266-.057 1.645-.069 4.849-.069zM12 0C8.741 0 8.333.014 7.053.072 2.695.272.273 2.69.073 7.052.014 8.333 0 8.741 0 12c0 3.259.014 3.668.072 4.948.2 4.358 2.618 6.78 6.98 6.98C8.333 23.986 8.741 24 12 24c3.259 0 3.668-.014 4.948-.072 4.354-.2 6.782-2.618 6.979-6.98.059-1.28.073-1.689.073-4.948 0-3.259-.014-3.667-.072-4.947-.196-4.354-2.617-6.78-6.979-6.98C15.668.014 15.259 0 12 0zm0 5.838a6.162 6.162 0 100 12.324 6.162 6.162 0 000-12.324zM12 16a4 4 0 110-8 4 4 0 010 8zm6.406-11.845a1.44 1.44 0 100 2.881 1.44 1.44 0 000-2.881z"})})}function t8({className:e}){return(0,t.jsx)("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:e,children:(0,t.jsx)("path",{d:"M23.498 6.186a3.016 3.016 0 00-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 00.502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 002.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 002.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"})})}let t7=function({session:e}){let[s,l]=(0,a.useState)([]),[o,c]=(0,a.useState)(""),[d,x]=(0,a.useState)(""),[u,h]=(0,a.useState)(""),[b,v]=(0,a.useState)(""),[y,k]=(0,a.useState)(""),[j,w]=(0,a.useState)(""),[N,C]=(0,a.useState)("name"),[z,S]=(0,a.useState)(1),[E,P]=(0,a.useState)(!1),[$,M]=(0,a.useState)(!1),[F,I]=(0,a.useState)(""),[R,T]=(0,a.useState)(""),[A,D]=(0,a.useState)(""),[V,L]=(0,a.useState)(1),[B,O]=(0,a.useState)(null),[_,U]=(0,a.useState)(null),[G,H]=(0,a.useState)(!1),{can:K,loading:W}=(0,eX.usePermissions)(),q=(0,r.useRouter)(),{setFilterPanelOpen:Y}=(0,eQ.useAI)();(0,a.useEffect)(()=>(Y($),()=>Y(!1)),[$,Y]),(0,a.useEffect)(()=>{let e=setTimeout(()=>{D(R),R!==A&&L(1)},500);return()=>clearTimeout(e)},[R]),(0,a.useEffect)(()=>{L(1)},[u,b,y,j,F,o,N,z]),(0,a.useEffect)(()=>{!async function(){H(!0);try{let e=new URLSearchParams({page:V.toString(),limit:"50",sortField:N,sortOrder:z.toString()});u&&e.append("category",u),b&&e.append("subCategory",b),y&&e.append("tiktokFollowers",y),j&&e.append("instagramFollowers",j),F&&e.append("locationFilter",F),A&&e.append("search",A),o&&e.append("managementCompany",o);let t=await fetch(`https://www.socialscout.ai/api/getCreators?${e.toString()}`),a=await t.json();l(a.creators||[]),O(a.pagination),a.aggregates&&U(a.aggregates)}catch(e){console.error(e),m.default.error(`Failed to fetch creators: ${e.message}`)}finally{H(!1)}}()},[u,b,y,j,F,N,z,A,V,o]);let X=()=>{T(""),D(""),L(1)},Q=()=>{h(""),v(""),k(""),w(""),I(""),T(""),D(""),C("name"),S(1),L(1),c("")},Z=+!!u+ +!!b+ +!!y+ +!!j+ +!!F+ +!!o+ +!!A,J=Z>0,ee=[{icon:e$.UserGroupIcon,label:"Total Creators",value:_?.totalCreators||0,color:"#ec4899",gradient:"radial-gradient(circle, #ec4899, #f97316)"},{icon:tp.UsersIcon,label:"Total Followers",value:_?.totalFollowers||0,color:"#8b5cf6",gradient:"radial-gradient(circle, #8b5cf6, #6366f1)"},{icon:t6,label:"On TikTok",value:_?.withTikTok||0,color:"var(--text-primary)",gradient:"radial-gradient(circle, #111827, #374151)"},{icon:t9,label:"On Instagram",value:_?.withInstagram||0,color:"#c026d3",gradient:"radial-gradient(circle, #c026d3, #ec4899)"},{icon:t8,label:"On YouTube",value:_?.withYouTube||0,color:"#dc2626",gradient:"radial-gradient(circle, #dc2626, #ef4444)"}];return(0,t.jsxs)("div",{className:"mt-6 mb-40",children:[(0,t.jsx)("div",{className:"mx-4 md:mx-8 mb-6",children:(0,t.jsxs)(i.motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{duration:.4},children:[(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 dark:text-zinc-100 tracking-tight",children:"Creators"}),_&&(0,t.jsxs)("p",{className:"text-sm text-gray-400 dark:text-zinc-500 mt-1",children:[_.totalCreators," creators ·"," ",(0,f.formatNumberReturn)(_.totalFollowers)," combined reach"]})]})}),_&&(0,t.jsx)(i.motion.div,{variants:tX,initial:"hidden",animate:"show",className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 ga
1p-3 mx-4 md:mx-8 mb-8",children:ee.map(e=>(0,t.jsx)(tJ,{...e},e.label))}),(0,t.jsxs)(i.motion.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{duration:.4,delay:.15},className:"mx-4 md:mx-8 mb-6 flex items-center gap-3",children:[(0,t.jsx)("div",{className:"flex-1 relative",children:(0,t.jsx)("div",{className:`p-[1.5px] rounded-2xl transition-all duration-300 ${R?"bg-gradient-to-r from-pink-500 to-orange-400 shadow-sm shadow-pink-200/50":"bg-gray-200 dark:bg-zinc-800 hover:bg-gray-300"}`,children:(0,t.jsxs)("div",{className:"relative bg-white dark:bg-zinc-950 rounded-2xl",children:[(0,t.jsx)("input",{type:"text",placeholder:"Search creators by name, email, or handle...",value:R,onChange:e=>T(e.target.value),className:"w-full pl-10 pr-4 py-2.5 text-sm bg-transparent border-0 rounded-2xl focus:outline-none placeholder-gray-400 dark:placeholder-zinc-500 text-gray-900 dark:text-zinc-100"}),(0,t.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 dark:text-zinc-500",children:R?(0,t.jsx)("button",{onClick:X,className:"hover:text-gray-600 dark:hover:text-zinc-400 transition-colors",children:(0,t.jsx)(p.XMarkIcon,{className:"w-4 h-4"})}):(0,t.jsx)(g.MagnifyingGlassIcon,{className:"w-4 h-4"})})]})})}),(0,t.jsxs)(i.motion.button,{whileHover:{scale:1.03,y:-1},whileTap:{scale:.97},onClick:()=>M(!0),className:`relative flex items-center gap-2 px-4 py-2.5 text-sm font-medium rounded-xl border transition-all duration-200 ${J?"bg-gradient-to-r from-pink-500 to-orange-400 text-white border-transparent shadow-sm shadow-pink-200":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:[(0,t.jsx)(e1.FunnelIcon,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Filters"}),Z>0&&(0,t.jsx)("span",{className:`w-5 h-5 rounded-full text-[10px] font-bold flex items-center justify-center ${J?"bg-white/30 dark:bg-zinc-950/30 text-white":"bg-pink-100 text-pink-600"}`,children:Z})]}),!W&&K("campaigns","create")&&(0,t.jsxs)(i.motion.button,{whileHover:{scale:1.03,y:-1},whileTap:{scale:.97},onClick:()=>q.push("/dashboard/user/creatorTool"),className:"flex items-center gap-2 px-4 py-2.5 text-sm font-medium bg-gradient-to-r from-pink-500 to-orange-400 text-white rounded-xl shadow-sm shadow-pink-200 hover:shadow-md hover:shadow-pink-300 transition-shadow duration-200",children:[(0,t.jsx)(e0.PlusIcon,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Add Creator"}),(0,t.jsx)("span",{className:"sm:hidden",children:"Add"})]})]}),J&&(0,t.jsxs)(i.motion.div,{initial:{opacity:0,x:-10},animate:{opacity:1,x:0},transition:{duration:.25},className:"mx-4 md:mx-8 mb-4 flex flex-wrap items-center gap-2",children:[A&&(0,t.jsx)(t4,{label:"Search",value:`"${A}"`,onRemove:X,color:"pink"}),u&&(0,t.jsx)(t4,{label:"Category",value:u,onRemove:()=>h(""),color:"green"}),b&&(0,t.jsx)(t4,{label:"Sub-Category",value:b,onRemove:()=>v(""),color:"purple"}),y&&(0,t.jsx)(t4,{label:"Min TikTok",value:Number(y).toLocaleString(),onRemove:()=>k(""),color:"pink"}),j&&(0,t.jsx)(t4,{label:"Min Instagram",value:Number(j).toLocaleString(),onRemove:()=>w(""),color:"orange"}),F&&(0,t.jsx)(t4,{label:"Location",value:F,onRemove:()=>I(""),color:"yellow"}),o&&(0,t.jsx)(t4,{label:"Management",value:d||o,onRemove:()=>c(""),color:"teal"}),(0,t.jsx)("button",{onClick:Q,className:"text-xs text-gray-400 dark:text-zinc-500 hover:text-gray-600 dark:hover:text-zinc-400 underline underline-offset-2 transition-colors",children:"Clear all"})]}),(0,t.jsx)(t5,{open:$,onClose:()=>M(!1),category:u,subCategory:b,tiktokFollowers:y,instagramFollowers:j,locationFilter:F,managementCompany:o,sortField:N,sortOrder:z,onCategoryChange:e=>h(e.target.value),onSubCategoryChange:e=>v(e.target.value),onTiktokChange:e=>k(e.target.value),onInstagramChange:e=>w(e.target.value),onLocationChange:e=>I(e.target.value),onManagementChange:e=>{c(e.target.value),x(e.target.options[e.target.selectedIndex].text)},onSortChange:e=>
1{let[t,a]=e.target.value.split("-");C(t),S("asc"===a?1:-1)},onClear:Q,activeCount:Z}),(0,t.jsx)(tI.default,{isOpen:E,onClose:()=>P(!1),children:(0,t.jsx)(tK.default,{})}),G&&(0,t.jsx)(n.InlineLoader,{message:"Loading creatorsâ¦"}),!G&&0===s.length&&(0,t.jsxs)(i.motion.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.4},className:"flex flex-col items-center justify-center py-20 text-center",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-gray-50 dark:bg-zinc-900 flex items-center justify-center mb-4",children:(0,t.jsx)(e$.UserGroupIcon,{className:"w-8 h-8 text-gray-300 dark:text-zinc-700"})}),(0,t.jsx)("p",{className:"text-sm font-semibold text-gray-700 dark:text-zinc-300 mb-1",children:"No creators found"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-zinc-500 mb-4",children:J?"Try adjusting your filters":"Add your first creator to get started"}),J&&(0,t.jsx)("button",{onClick:Q,className:"text-xs text-pink-500 hover:text-pink-600 underline underline-offset-2 transition-colors",children:"Clear all filters"})]}),!G&&s.length>0&&(0,t.jsx)(tH,{creators:s}),!G&&s.length>0&&(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4,delay:.3},children:(0,t.jsx)(t3,{pagination:B,onPageChange:e=>{L(e),window.scrollTo({top:0,behavior:"smooth"})}})})]})},ae={hidden:{},show:{transition:{staggerChildren:.04}}},at={hidden:{opacity:0,y:16},show:{opacity:1,y:0,transition:{duration:.4,ease:[.25,.46,.45,.94]}}};function aa({posts:e}){return(0,t.jsx)(i.motion.div,{variants:ae,initial:"hidden",animate:"show",className:"grid gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 mx-4 md:mx-8",children:e.map(e=>(0,t.jsx)(i.motion.div,{variants:at,children:(0,t.jsx)(N.default,{post:e})},e._id))})}var ar=e.i(197299);e.i(954275);var as=e.i(526279),an=e.i(209428),al=e.i(211577),ai=e.i(8211),ao=e.i(410160),ac=e.i(392221),ad=e.i(343794);function ax(e){var t=a.useRef();return t.current=e,a.useCallback(function(){for(var e,a=arguments.length,r=Array(a),s=0;s<a;s++)r[s]=arguments[s];return null==(e=t.current)?void 0:e.call.apply(e,[t].concat(r))},[])}var au="u">typeof window&&window.document&&window.document.createElement?a.useLayoutEffect:a.useEffect,am=function(e,t){var r=a.useRef(!0);au(function(){return e(r.current)},t),au(function(){return r.current=!1,function(){r.current=!0}},[])},ag=function(e,t){am(function(t){if(!t)return e()},t)};function ap(e){var t=a.useRef(!1),r=a.useState(e),s=(0,ac.default)(r,2),n=s[0],l=s[1];return a.useEffect(function(){return t.current=!1,function(){t.current=!0}},[]),[n,function(e,a){a&&t.current||l(e)}]}function ah(e){return void 0!==e}var af={},ab=[];function av(e,t){}function ay(e,t){}function ak(e,t,a){t||af[a]||(e(!1,a),af[a]=!0)}function aj(e,t){ak(av,e,t)}aj.preMessage=function(e){ab.push(e)},aj.resetWarned=function(){af={}},aj.noteOnce=function(e,t){ak(ay,e,t)};let aw=function(e,t){var a=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=new Set;return function e(t,s){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,l=r.has(t);if(aj(!l,"Warning: There may be circular references"),l)return!1;if(t===s)return!0;if(a&&n>1)return!1;r.add(t);var i=n+1;if(Array.isArray(t)){if(!Array.isArray(s)||t.length!==s.length)return!1;for(var o=0;o<t.length;o++)if(!e(t[o],s[o],i))return!1;return!0}if(t&&s&&"object"===(0,ao.default)(t)&&"object"===(0,ao.default)(s)){var c=Object.keys(t);return c.length===Object.keys(s).length&&c.every(function(a){return e(t[a],s[a],i)})}return!1}(e,t)};var aN=e.i(931067),aC=e.i(703923),az=e.i(174080);function aS(e,t,a,r){var s=(t-a)/(r-a),n={};switch(e){case"rtl":n.right="".concat(100*s,"%"),n.transform="translateX(50%)";break;case"btt":n.bottom="".concat(100*s,"%"),n.transform="translateY(50%)";break;case"ttb":n.top="".concat(100*s,"%"),n.transform="translateY(-50%)";break;default:n.left="".concat(100*s,"%"),n.transform="translateX(-50%)"}return n}function aE(e,t){return Array.isArray(e)?e[t]:e}var aP={MAC_ENTER:3,BACKSPACE:8,TAB:9,NUM_CENTER:12,ENTER:13,SHIFT:16,CTRL:17,ALT:18,PAUSE:19,CAPS_LOCK:20,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,PRINT_SCREEN:44,INSERT:45,DELETE:46,ZERO:48,ONE:49,TWO:50,THREE:51,FOUR:52,FIVE:53,SIX:54,SEVEN:55,EIGHT:56,NINE:57,QUESTION_MARK:63,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,META:91,WIN_KEY_RIGHT:92,CONTEXT_MENU:93,NUM_ZERO:96,NUM_ONE:97,NUM_TWO:98,NUM_THREE:99,NUM_FOUR:100,NUM_FIVE:101,NUM_
1SIX:102,NUM_SEVEN:103,NUM_EIGHT:104,NUM_NINE:105,NUM_MULTIPLY:106,NUM_PLUS:107,NUM_MINUS:109,NUM_PERIOD:110,NUM_DIVISION:111,F1:112,F2:113,F3:114,F4:115,F5:116,F6:117,F7:118,F8:119,F9:120,F10:121,F11:122,F12:123,NUMLOCK:144,SEMICOLON:186,DASH:189,EQUALS:187,COMMA:188,PERIOD:190,SLASH:191,APOSTROPHE:192,SINGLE_QUOTE:222,OPEN_SQUARE_BRACKET:219,BACKSLASH:220,CLOSE_SQUARE_BRACKET:221,WIN_KEY:224,MAC_FF_META:224,WIN_IME:229,isTextModifyingKeyEvent:function(e){var t=e.keyCode;if(e.altKey&&!e.ctrlKey||e.metaKey||t>=aP.F1&&t<=aP.F12)return!1;switch(t){case aP.ALT:case aP.CAPS_LOCK:case aP.CONTEXT_MENU:case aP.CTRL:case aP.DOWN:case aP.END:case aP.ESC:case aP.HOME:case aP.INSERT:case aP.LEFT:case aP.MAC_FF_META:case aP.META:case aP.NUMLOCK:case aP.NUM_CENTER:case aP.PAGE_DOWN:case aP.PAGE_UP:case aP.PAUSE:case aP.PRINT_SCREEN:case aP.RIGHT:case aP.SHIFT:case aP.UP:case aP.WIN_KEY:case aP.WIN_KEY_RIGHT:return!1;default:return!0}},isCharacterKey:function(e){if(e>=aP.ZERO&&e<=aP.NINE||e>=aP.NUM_ZERO&&e<=aP.NUM_MULTIPLY||e>=aP.A&&e<=aP.Z||-1!==window.navigator.userAgent.indexOf("WebKit")&&0===e)return!0;switch(e){case aP.SPACE:case aP.QUESTION_MARK:case aP.NUM_PLUS:case aP.NUM_MINUS:case aP.NUM_PERIOD:case aP.NUM_DIVISION:case aP.SEMICOLON:case aP.DASH:case aP.EQUALS:case aP.COMMA:case aP.PERIOD:case aP.SLASH:case aP.APOSTROPHE:case aP.SINGLE_QUOTE:case aP.OPEN_SQUARE_BRACKET:case aP.BACKSLASH:case aP.CLOSE_SQUARE_BRACKET:return!0;default:return!1}}},a$=a.createContext({min:0,max:0,direction:"ltr",step:1,includedStart:0,includedEnd:0,tabIndex:0,keyboard:!0,styles:{},classNames:{}}),aM=a.createContext({}),aF=["prefixCls","value","valueIndex","onStartMove","onDelete","style","render","dragging","draggingDelete","onOffsetChange","onChangeComplete","onFocus","onMouseEnter"],aI=a.forwardRef(function(e,t){var r,s=e.prefixCls,n=e.value,l=e.valueIndex,i=e.onStartMove,o=e.onDelete,c=e.style,d=e.render,x=e.dragging,u=e.draggingDelete,m=e.onOffsetChange,g=e.onChangeComplete,p=e.onFocus,h=e.onMouseEnter,f=(0,aC.default)(e,aF),b=a.useContext(a$),v=b.min,y=b.max,k=b.direction,j=b.disabled,w=b.keyboard,N=b.range,C=b.tabIndex,z=b.ariaLabelForHandle,S=b.ariaLabelledByForHandle,E=b.ariaRequired,P=b.ariaValueTextFormatterForHandle,$=b.styles,M=b.classNames,F="".concat(s,"-handle"),I=function(e){j||i(e,l)},R=aS(k,n,v,y),T={};null!==l&&(T={tabIndex:j?null:aE(C,l),role:"slider","aria-valuemin":v,"aria-valuemax":y,"aria-valuenow":n,"aria-disabled":j,"aria-label":aE(z,l),"aria-labelledby":aE(S,l),"aria-required":aE(E,l),"aria-valuetext":null==(r=aE(P,l))?void 0:r(n),"aria-orientation":"ltr"===k||"rtl"===k?"horizontal":"vertical",onMouseDown:I,onTouchStart:I,onFocus:function(e){null==p||p(e,l)},onMouseEnter:function(e){h(e,l)},onKeyDown:function(e){if(!j&&w){var t=null;switch(e.which||e.keyCode){case aP.LEFT:t="ltr"===k||"btt"===k?-1:1;break;case aP.RIGHT:t="ltr"===k||"btt"===k?1:-1;break;case aP.UP:t="ttb"!==k?1:-1;break;case aP.DOWN:t="ttb"!==k?-1:1;break;case aP.HOME:t="min";break;case aP.END:t="max";break;case aP.PAGE_UP:t=2;break;case aP.PAGE_DOWN:t=-2;break;case aP.BACKSPACE:case aP.DELETE:null==o||o(l)}null!==t&&(e.preventDefault(),m(t,l))}},onKeyUp:function(e){switch(e.which||e.keyCode){case aP.LEFT:case aP.RIGHT:case aP.UP:case aP.DOWN:case aP.HOME:case aP.END:case aP.PAGE_UP:case aP.PAGE_DOWN:null==g||g()}}});var A=a.createElement("div",(0,aN.default)({ref:t,className:(0,ad.default)(F,(0,al.default)((0,al.default)((0,al.default)({},"".concat(F,"-").concat(l+1),null!==l&&N),"".concat(F,"-dragging"),x),"".concat(F,"-dragging-delete"),u),M.handle),style:(0,an.default)((0,an.default)((0,an.default)({},R),c),$.handle)},T,f));return d&&(A=d(A,{index:l,prefixCls:s,value:n,dragging:x,draggingDelete:u})),A}),aR=["prefixCls","style","onStartMove","onOffsetChange","values","handleRender","activeHandleRender","draggingIndex","draggingDelete","onF
1ocus"],aT=a.forwardRef(function(e,t){var r=e.prefixCls,s=e.style,n=e.onStartMove,l=e.onOffsetChange,i=e.values,o=e.handleRender,c=e.activeHandleRender,d=e.draggingIndex,x=e.draggingDelete,u=e.onFocus,m=(0,aC.default)(e,aR),g=a.useRef({}),p=a.useState(!1),h=(0,ac.default)(p,2),f=h[0],b=h[1],v=a.useState(-1),y=(0,ac.default)(v,2),k=y[0],j=y[1],w=function(e){j(e),b(!0)};a.useImperativeHandle(t,function(){return{focus:function(e){var t;null==(t=g.current[e])||t.focus()},hideHelp:function(){(0,az.flushSync)(function(){b(!1)})}}});var N=(0,an.default)({prefixCls:r,onStartMove:n,onOffsetChange:l,render:o,onFocus:function(e,t){w(t),null==u||u(e)},onMouseEnter:function(e,t){w(t)}},m);return a.createElement(a.Fragment,null,i.map(function(e,t){var r=d===t;return a.createElement(aI,(0,aN.default)({ref:function(e){e?g.current[t]=e:delete g.current[t]},dragging:r,draggingDelete:r&&x,style:aE(s,t),key:t,value:e,valueIndex:t},N))}),c&&f&&a.createElement(aI,(0,aN.default)({key:"a11y"},N,{value:i[k],valueIndex:null,dragging:-1!==d,draggingDelete:x,render:c,style:{pointerEvents:"none"},tabIndex:null,"aria-hidden":!0})))});let aA=function(e){var t=e.prefixCls,r=e.style,s=e.children,n=e.value,l=e.onClick,i=a.useContext(a$),o=i.min,c=i.max,d=i.direction,x=i.includedStart,u=i.includedEnd,m=i.included,g="".concat(t,"-text"),p=aS(d,n,o,c);return a.createElement("span",{className:(0,ad.default)(g,(0,al.default)({},"".concat(g,"-active"),m&&x<=n&&n<=u)),style:(0,an.default)((0,an.default)({},p),r),onMouseDown:function(e){e.stopPropagation()},onClick:function(){l(n)}},s)},aD=function(e){var t=e.prefixCls,r=e.marks,s=e.onClick,n="".concat(t,"-mark");return r.length?a.createElement("div",{className:n},r.map(function(e){var t=e.value,r=e.style,l=e.label;return a.createElement(aA,{key:t,prefixCls:n,style:r,value:t,onClick:s},l)})):null},aV=function(e){var t=e.prefixCls,r=e.value,s=e.style,n=e.activeStyle,l=a.useContext(a$),i=l.min,o=l.max,c=l.direction,d=l.included,x=l.includedStart,u=l.includedEnd,m="".concat(t,"-dot"),g=d&&x<=r&&r<=u,p=(0,an.default)((0,an.default)({},aS(c,r,i,o)),"function"==typeof s?s(r):s);return g&&(p=(0,an.default)((0,an.default)({},p),"function"==typeof n?n(r):n)),a.createElement("span",{className:(0,ad.default)(m,(0,al.default)({},"".concat(m,"-active"),g)),style:p})},aL=function(e){var t=e.prefixCls,r=e.marks,s=e.dots,n=e.style,l=e.activeStyle,i=a.useContext(a$),o=i.min,c=i.max,d=i.step,x=a.useMemo(function(){var e=new Set;if(r.forEach(function(t){e.add(t.value)}),s&&null!==d)for(var t=o;t<=c;)e.add(t),t+=d;return Array.from(e)},[o,c,d,s,r]);return a.createElement("div",{className:"".concat(t,"-step")},x.map(function(e){return a.createElement(aV,{prefixCls:t,key:e,value:e,style:n,activeStyle:l})}))},aB=function(e){var t=e.prefixCls,r=e.style,s=e.start,n=e.end,l=e.index,i=e.onStartMove,o=e.replaceCls,c=a.useContext(a$),d=c.direction,x=c.min,u=c.max,m=c.disabled,g=c.range,p=c.classNames,h="".concat(t,"-track"),f=(s-x)/(u-x),b=(n-x)/(u-x),v=function(e){!m&&i&&i(e,-1)},y={};switch(d){case"rtl":y.right="".concat(100*f,"%"),y.width="".concat(100*b-100*f,"%");break;case"btt":y.bottom="".concat(100*f,"%"),y.height="".concat(100*b-100*f,"%");break;case"ttb":y.top="".concat(100*f,"%"),y.height="".concat(100*b-100*f,"%");break;default:y.left="".concat(100*f,"%"),y.width="".concat(100*b-100*f,"%")}var k=o||(0,ad.default)(h,(0,al.default)((0,al.default)({},"".concat(h,"-").concat(l+1),null!==l&&g),"".concat(t,"-track-draggable"),i),p.track);return a.createElement("div",{className:k,style:(0,an.default)((0,an.default)({},y),r),onMouseDown:v,onTouchStart:v})},aO=function(e){var t=e.prefixCls,r=e.style,s=e.values,n=e.startPoint,l=e.onStartMove,i=a.useContext(a$),o=i.included,c=i.range,d=i.min,x=i.styles,u=i.classNames,m=a.useMemo(function(){if(!c){if(0===s.length)return[];var e=null!=n?n:d,t=s[0];return[{start:Math.min(e,t),end:Math.max(e,t)}]}for(var a=[],r=0;r<s.length-1;r+=1)a.push({start:s[r],end:s[r+1]});return a},[s,c,n,d]);if(!o)return null;var g=null!=m&&m.length&&(u.tracks||x.tracks)?a.createElement(aB,{index:null,prefixCls:t,start:m[0].start,end:m[m.length-1].end,replaceCls:(0,ad.default)(u.tracks,"".concat(t,"-tracks")),style:x.tracks}):null;return a.createElement(a.Fragment,null,g,m.map(function(e,s){var n=e.start,i=e.end;return a.createElement(aB,{index:s,prefixCls:t,style:(0,an.default)((0,an.default)({},aE(r,s)),x.track),start:n,end:i,key:s,onStartMove:l})}))};function a_(e){var t="targetTouches"in e?e.targetTouches[0]:e;return{pageX:t.pageX,pageY:t.pageY}}let aU=function(e,t,r,s,n,l,i,o,c,d,x){var u=a.useState(null),m=(0,ac.default)(u,2),g=m[0],p=m[1],h=a.useState(-1),f=(0,ac.default)(h,2),b=f[0],v=f[1],y=a.useState(!1),k=(0,ac.default)(y,2),j=k[0],w=k[1],N=a.useState(r),C=(0,ac.default)(N,2),z=C[0],S=C[1],E=a.useState(r),P=(0,ac.default)(E,2),$=P[0],M=P[1],F=a.useRef(null),I=a.useRef(null),R=a.useRef(null),T=a.useContext(aM),A=T.onDragStart,D=T.onDragChange;am(function(){-1===b&&S(r)},[r,b]),a.useEffect(function(){return function(){document.removeEventListener("mousemove",F.current),document.removeEventListener("mouseup",I.current),R.current&&(R.current.removeEventListener("touchmove",F.current),R.current.removeEventListener("touchend",I.current))}},[]);var V=function(e,t,a){void 0!==t&&p(t),S(e);var r=e;a&&(r=e.filter(function(e,t){return t!==b})),i(r),D&&D({rawValues:e,deleteIndex:a?b:-1,draggingIndex:b,draggingValue:t})},L=ax(function(e,t,a){if(-1===e){var r=$[0],i=$[$.length-1],o=t*(n-s);o=Math.min(o=Math.max(o,s-r),n-i),o=l(r+o)-r,V($.map(function(e){return e+o}))}else{var d=(0,ai.default)(z);d[e]=$[e];var x=c(d,(n-s)*t,e,"dist");V(x.values,x.value,a)}});return[b,g,j,a.useMemo(function(){var e=(0,ai.default)(r).sort(function(e,t){return e-t}),t=(0,ai.default)(z).sort(function(e,t){return e-t}),a={};t.forEach(function(e){a[e]=(a[e]||0)+1}),e.forEach(function(e){a[e]=(a[e]||0)-1});var s=+!!d;return Object.values(a).reduce(function(e,t){return e+Math.abs(t)},0)<=s?z:r},[r,z,d]),function(a,s,n){a.stopPropagation();var l=n||r,i=l[s];v(s),p(i),M(l),S(l),w(!1);var c=a_(a),u=c.pageX,m=c.pageY,g=!1;A&&A({rawValues:l,draggingIndex:s,draggingValue:i});var h=function(a){a.preventDefault();var r,n,l=a_(a),i=l.pageX,o=l.pageY,c=i-u,p=o-m,h=e.current.getBoundingClientRect(),f=h.width,b=h.height;switch(t){case"btt":r=-p/b,n=c;break;case"ttb":r=p/b,n=c;break;case"rtl":r=-c/f,n=p;break;default:r=c/f,n=p}w(g=!!d&&Math.abs(n)>130&&x<z.length),L(s,r,g)},f=function e(t){t.preventDefault(),document.removeEventListener("mouseup",e),document.removeEventListener("mousemove",h),R.current&&(R.current.removeEventListener("touchmove",F.current),R.current.removeEventListener("touchend",I.current)),F.current=null,I.current=null,R.current=null,o(g),v(-1),w(!1)};document.addEventListener("mouseup",f),document.addEventListener("mousemove",h),a.currentTarget.addEventListener("touchend",f),a.currentTarget.addEventListener("touchmove",h),F.current=h,I.current=f,R.current=a.currentTarget}]};var aG=a.forwardRef(function(e,t){var r,s,n,l,i,o,c,d,x,u,m,g,p,h,f,b,v,y,k,j,w,N,C,z=e.prefixCls,S=void 0===z?"rc-slider":z,E=e.className,P=e.style,$=e.classNames,M=e.styles,F=e.id,I=e.disabled,R=void 0!==I&&I,T=e.keyboard,A=void 0===T||T,D=e.autoFocus,V=e.onFocus,L=e.onBlur,B=e.min,O=void 0===B?0:B,_=e.max,U=void 0===_?100:_,G=e.step,H=void 0===G?1:G,K=e.value,W=e.defaultValue,q=e.range,Y=e.count,X=e.onCh
1ange,Q=e.onBeforeChange,Z=e.onAfterChange,J=e.onChangeComplete,ee=e.allowCross,et=e.pushable,ea=void 0!==et&&et,er=e.reverse,es=e.vertical,en=e.included,el=void 0===en||en,ei=e.startPoint,eo=e.trackStyle,ec=e.handleStyle,ed=e.railStyle,ex=e.dotStyle,eu=e.activeDotStyle,em=e.marks,eg=e.dots,ep=e.handleRender,eh=e.activeHandleRender,ef=e.track,eb=e.tabIndex,ev=void 0===eb?0:eb,ey=e.ariaLabelForHandle,ek=e.ariaLabelledByForHandle,ej=e.ariaRequired,ew=e.ariaValueTextFormatterForHandle,eN=a.useRef(null),eC=a.useRef(null),ez=a.useMemo(function(){return es?er?"ttb":"btt":er?"rtl":"ltr"},[er,es]),eS=(0,a.useMemo)(function(){if(!0===q||!q)return[!!q,!1,!1,0];var e=q.editable,t=q.draggableTrack;return[!0,e,!e&&t,q.minCount||0,q.maxCount]},[q]),eE=(0,ac.default)(eS,5),eP=eE[0],e$=eE[1],eM=eE[2],eF=eE[3],eI=eE[4],eR=a.useMemo(function(){return isFinite(O)?O:0},[O]),eT=a.useMemo(function(){return isFinite(U)?U:100},[U]),eA=a.useMemo(function(){return null!==H&&H<=0?1:H},[H]),eD=a.useMemo(function(){return"boolean"==typeof ea?!!ea&&eA:ea>=0&&ea},[ea,eA]),eV=a.useMemo(function(){return Object.keys(em||{}).map(function(e){var t=em[e],r={value:Number(e)};return t&&"object"===(0,ao.default)(t)&&!a.isValidElement(t)&&("label"in t||"style"in t)?(r.style=t.style,r.label=t.label):r.label=t,r}).filter(function(e){var t=e.label;return t||"number"==typeof t}).sort(function(e,t){return e.value-t.value})},[em]),eL=(r=void 0===ee||ee,s=a.useCallback(function(e){return Math.max(eR,Math.min(eT,e))},[eR,eT]),n=a.useCallback(function(e){if(null!==eA){var t=eR+Math.round((s(e)-eR)/eA)*eA,a=function(e){return(String(e).split(".")[1]||"").length},r=Math.max(a(eA),a(eT),a(eR)),n=Number(t.toFixed(r));return eR<=n&&n<=eT?n:null}return null},[eA,eR,eT,s]),l=a.useCallback(function(e){var t=s(e),a=eV.map(function(e){return e.value});null!==eA&&a.push(n(e)),a.push(eR,eT);var r=a[0],l=eT-eR;return a.forEach(function(e){var a=Math.abs(t-e);a<=l&&(r=e,l=a)}),r},[eR,eT,eV,eA,s,n]),i=function e(t,a,r){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit";if("number"==typeof a){var l,i=t[r],o=i+a,c=[];eV.forEach(function(e){c.push(e.value)}),c.push(eR,eT),c.push(n(i));var d=a>0?1:-1;"unit"===s?c.push(n(i+d*eA)):c.push(n(o)),c=c.filter(function(e){return null!==e}).filter(function(e){return a<0?e<=i:e>=i}),"unit"===s&&(c=c.filter(function(e){return e!==i}));var x="unit"===s?i:o,u=Math.abs((l=c[0])-x);if(c.forEach(function(e){var t=Math.abs(e-x);t<u&&(l=e,u=t)}),void 0===l)return a<0?eR:eT;if("dist"===s)return l;if(Math.abs(a)>1){var m=(0,ai.default)(t);return m[r]=l,e(m,a-d,r,s)}return l}return"min"===a?eR:"max"===a?eT:void 0},o=function(e,t,a){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit",s=e[a],n=i(e,t,a,r);return{value:n,changed:n!==s}},c=function(e){return null===eD&&0===e||"number"==typeof eD&&e<eD},[l,function(e,t,a){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"unit",n=e.map(l),d=n[a],x=i(n,t,a,s);if(n[a]=x,!1===r){var u=eD||0;a>0&&n[a-1]!==d&&(n[a]=Math.max(n[a],n[a-1]+u)),a<n.length-1&&n[a+1]!==d&&(n[a]=Math.min(n[a],n[a+1]-u))}else if("number"==typeof eD||null===eD){for(var m=a+1;m<n.length;m+=1)for(var g=!0;c(n[m]-n[m-1])&&g;){var p=o(n,1,m);n[m]=p.value,g=p.changed}for(var h=a;h>0;h-=1)for(var f=!0;c(n[h]-n[h-1])&&f;){var b=o(n,-1,h-1);n[h-1]=b.value,f=b.changed}for(var v=n.length-1;v>0;v-=1)for(var y=!0;c(n[v]-n[v-1])&&y;){var k=o(n,-1,v-1);n[v-1]=k.value,y=k.changed}for(var j=0;j<n.length-1;j+=1)for(var w=!0;c(n[j+1]-n[j])&&w;){var N=o(n,1,j+1);n[j+1]=N.value,w=N.changed}}return{value:n[a],values:n}}]),eB=(0,ac.default)(eL,2),eO=eB[0],e_=eB[1],eU=(x=(d={value:K}).defaultValue,u=d.value,m=d.onChange,g=d.postState,p=ap(function(){return ah(u)?u:ah(x)?"function"==typeof x?x():x:"function"==typeof W?W():W}),f=(h=(0,ac.default)(p,2))[0],b=h[1],v=void 0!==u?u:f,y=g?g(v):v,k=ax(m),j=ap([v]),N=(w=(0,ac.default)(j,2))[0],C=w[1],ag(function(){var e=N[0];f!==e&&k(f,e)},[N]),ag(function(){ah(u)||b(u)},[u]),[y,ax(function(e,t){b(e,t),C([v],t)})]),eG=(0,ac.default)(eU,2),eH=eG[0],eK=eG[1],eW=a.useMemo(function(){var e=null==eH?[]:Array.isArray(eH)?eH:[eH],t=(0,ac.default)(e,1)[0],a=void 0===t?eR:t,r=null===eH?[]:[a];if(eP){if(r=(0,ai.default)(e),Y||void 0===eH){var s,n=Y>=0?Y+1:2;for(r=r.slice(0,n);r.length<n;)r.push(null!=(s=r[r.length-1])?s:eR)}r.sort(function(e,t){return e-t})}return r.forEach(function(e,t){r[t]=eO(e)}),r},[eH,eP,eR,Y,eO]),eq=function(e){return eP?e:e[0]},eY=ax(function(e){var t=(0,ai.default)(e).sort(function(e,t){return e-t});X&&!aw(t,eW,!0)&&X(eq(t)),eK(t)}),eX=ax(function(e){e&&eN.current.hideHelp();var t=eq(eW);null==Z||Z(t),aj(!Z,"[rc-slider] `onAfterChange` is deprecated. Please use `onChangeComplete` instead."),null==J||J(t)}),eQ=aU(eC,ez,eW,eR,eT,eO,eY,eX,e_,e$,eF),eZ=(0,ac.default)(eQ,5),eJ=eZ[0],e0=eZ[1],e1=eZ[2],e2=eZ[3],e5=eZ[4],e4=function(e,t){if(!R){var a,r,s=(0,ai.default)(eW),n=0,l=0,i=eT-eR;eW.forEach(function(t,a){var r=Math.abs(e-t);r<=i&&(i=r,n=a),t<e&&(l=a)});var o=n;e$&&0!==i&&(!eI||eW.length<eI)?(s.splice(l+1,0,e),o=l+1):s[n]=e,eP&&!eW.length&&void 0===Y&&s.push(e);var c=eq(s);null==Q||Q(c),eY(s),t?(null==(a=document.activeElement)||null==(r=a.blur)||r.call(a),eN.current.focus(o),e5(t,o,s)):(null==Z||Z(c),aj(!Z,"[rc-slider] `onAfterChange` is deprecated. Please use `onChangeComplete` instead."),null==J||J(c))}},e3=a.useState(null),e6=(0,ac.default)(e3,2),e9=e6[0],e8=e6[1];a.useEffect(function(){if(null!==e9){var e=eW.indexOf(e9);e>=0&&eN.current.focus(e)}e8(null)},[e9]);var e7=a.useMemo(function(){return(!eM||null!==eA)&&eM},[eM,eA]),te=ax(function(e,t){e5(e,t),null==Q||Q(eq(eW))}),tt=-1!==eJ;a.useEffect(function(){if(!tt){var e=eW.lastIndexOf(e0);eN.current.focus(e)}},[tt]);var ta=a.useMemo(function(){return(0,ai.default)(e2).sort(function(e,t){return e-t})},[e2]),tr=a.useMemo(function(){return eP?[ta[0],ta[ta.length-1]]:[eR,ta[0]]},[ta,eP,eR]),ts=(0,ac.default)(tr,2),tn=ts[0],tl=ts[1];a.useImperativeHandle(t,function(){return{focus:function(){eN.current.focus(0)},blur:function(){var e,t=document.activeElement;null!=(e=eC.current)&&e.contains(t)&&(null==t||t.blur())}}}),a.useEffect(function(){D&&eN.current.focus(0)},[]);var ti=a.useMemo(function(){return{min:eR,max:eT,direction:ez,disabled:R,keyboard:A,step:eA,included:el,includedStart:tn,includedEnd:tl,range:eP,tabIndex:ev,ariaLabelForHandle:ey,ariaLabelledByForHandle:ek,ariaRequired:ej,ariaValueTextFormatterForHandle:ew,styles:M||{},classNames:$||{}}},[eR,eT,ez,R,A,eA,el,tn,tl,eP,ev,ey,ek,ej,ew,M,$]);return a.createElement(a$.Provider,{value:ti},a.createElement("div",{ref:eC,className:(0,ad.default)(S,E,(0,al.default)((0,al.default)((0,al.default)((0,al.default)({},"".concat(S,"-disabled"),R),"".concat(S,"-vertical"),es),"".concat(S,"-horizontal"),!es),"".concat(S,"-with-marks"),eV.length)),style:P,onMouseDown:function(e){e.preventDefault();var t,a=eC.current.getBoundingClientRect(),r=a.width,s=a.height,n=a.left,l=a.top,i=a.bottom,o=a.right,c=e.clientX,d=e.clientY;switch(ez){case"btt":t=(i-d)/s;break;case"ttb":t=(d-l)/s;break;case"rtl":t=(o-c)/r;break;default:t=(c-n)/r}e4(eO(eR+t*(eT-eR)),e)},id:F},a.createElement("div",{className:(0,ad.default)("".concat(S,"-rail"),null==$?void 0:$.rail),style:(0,an.default)((0,an.default)({},ed),null==M?void 0:M.rail)}),!1!==ef&&a.createElement(aO,{prefixCls:S,style:eo,values:eW,startPoint:ei,onStartMove:e7?te:void 0}),a.createElement(aL,{prefixCls:S,marks:eV,dots:eg,style:ex,activeStyle:eu}),a.createElement(aT,{ref:eN,prefixCls:S,style:ec,values:e2,draggingIndex:eJ,draggingDelete:e1,onStartMove:te,onOffsetChange:function(e,t){if(!R){var a=e_(eW,e,t);
1null==Q||Q(eq(eW)),eY(a.values),e8(a.value)}},onFocus:V,onBlur:L,handleRender:ep,activeHandleRender:eh,onChangeComplete:eX,onDelete:e$?function(e){if(!R&&e$&&!(eW.length<=eF)){var t=(0,ai.default)(eW);t.splice(e,1),null==Q||Q(eq(t)),eY(t);var a=Math.max(0,e-1);eN.current.hideHelp(),eN.current.focus(a)}}:void 0}),a.createElement(aD,{prefixCls:S,marks:eV,onClick:e4})))});let aH=({children:e})=>(0,t.jsx)("label",{className:"block text-xs font-bold tracking-widest uppercase text-gray-400 dark:text-zinc-500 mb-2",children:e}),aK=({children:e})=>(0,t.jsx)("div",{className:"space-y-1.5",children:e}),aW=({value:e,onChange:a,children:r})=>(0,t.jsx)("select",{value:e,onChange:a,className:"w-full px-3 py-2.5 text-sm border border-gray-200 dark:border-zinc-800 rounded-xl focus:outline-none focus:ring-2 focus:ring-pink-300 bg-white dark:bg-zinc-950 text-gray-700 dark:text-zinc-300",children:r});function aq({label:e,placeholder:a,searchTerm:r,onSearchChange:s,suggestions:n,onSelect:l,selected:i,onRemove:o,renderSuggestion:c,renderChip:d}){return(0,t.jsxs)(aK,{children:[(0,t.jsx)(aH,{children:e}),(0,t.jsxs)("div",{className:"relative",children:[(0,t.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none",children:(0,t.jsx)(g.MagnifyingGlassIcon,{className:"w-4 h-4 text-gray-400 dark:text-zinc-500"})}),(0,t.jsx)("input",{type:"text",value:r,onChange:e=>s(e.target.value),placeholder:a,className:"w-full pl-9 pr-4 py-2.5 text-sm border border-gray-200 dark:border-zinc-800 rounded-xl focus:outline-none focus:ring-2 focus:ring-pink-300 placeholder-gray-400 dark:placeholder-zinc-500"}),n.length>0&&(0,t.jsx)("ul",{className:"absolute top-full left-0 right-0 mt-1 bg-white dark:bg-zinc-950 border border-gray-100 dark:border-zinc-800 rounded-xl shadow-xl z-20 max-h-48 overflow-y-auto",children:n.map(e=>(0,t.jsx)("li",{onClick:()=>l(e),className:"px-3 py-2.5 hover:bg-pink-50 cursor-pointer text-sm text-gray-700 dark:text-zinc-300 transition-colors",children:c(e)},e._id))})]}),i.length>0&&(0,t.jsx)("div",{className:"flex flex-wrap gap-1.5 mt-2",children:i.map(e=>d(e))})]})}let aY=({label:e,onRemove:a,color:r="pink"})=>(0,t.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${{pink:"bg-pink-50 text-pink-700 border-pink-100",blue:"bg-blue-50 text-blue-700 border-blue-100",orange:"bg-orange-50 text-orange-700 border-orange-100"}[r]}`,children:[e,(0,t.jsx)("button",{onClick:a,className:"hover:opacity-70 transition-opacity",children:(0,t.jsx)(p.XMarkIcon,{className:"w-3 h-3"})})]}),aX=({platform:e,src:a,alt:r,isSelected:s,onClick:n})=>(0,t.jsxs)("button",{onClick:t=>{t.preventDefault(),n(e)},className:`relative flex flex-col items-center justify-center p-2 rounded-xl border-2 transition-all duration-150 hover:scale-105 focus:outline-none ${s?"border-pink-400 bg-pink-50 shadow-sm shadow-pink-100":"border-gray-100 dark:border-zinc-800 hover:border-gray-200 dark:hover:border-zinc-800 bg-white dark:bg-zinc-950"}`,children:[(0,t.jsx)("img",{src:a,alt:r,className:"w-7 h-7 object-contain"}),s&&(0,t.jsx)("span",{className:"absolute -top-1 -right-1 w-3.5 h-3.5 bg-gradient-to-br from-pink-500 to-orange-400 rounded-full flex items-center justify-center",children:(0,t.jsx)("svg",{className:"w-2 h-2 text-white",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,t.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:3,d:"M5 13l4 4L19 7"})})})]}),aQ=e=>e>=1e6?(e/1e6).toFixed(1)+"M":e>=1e3?(e/1e3).toFixed(0)+"K":e.toString(),aZ=({isOpen:e,onClose:r,onApplyFilter:s})=>{let{setFilterPanelOpen:n}=(0,eQ.useAI)();(0,a.useEffect)(()=>(n(e),()=>n(!1)),[e,n]);let[l,i]=(0,a.useState)(""),[o,c]=(0,a.useState)(!1),[d,x]=(0,a.useState)([]),[u,m]=(0,a.useState)({start:"",end:""}),[g,f]=(0,a.useState)(""),[b,v]=(0,a.useState)([0,600]),[y,k]=(0,a.useState)([0,1e8]),[j,w]=(0,a.useState)(""),[N,C]=(0,a.useState)(""),[z,S]=(0,a.useState)([]),[E,P]=(0,a.useState)([]),[$,M]=(0,a.useState)(""),[F,I]=(0,a.useState)([]),[R,T]=(0,a.useState)([]),[A,D]=(0,a.useState)(""),[V,L]=(0,a.useState)([]),[B,O]=(0,a.useState)([]);(0,a.useEffect)(()=>{N?fetch(`https://www.socialscout.ai/api/searchAutoCompleteCreators?query=${encodeURIComponent(N)}`).then(e=>e.ok?e.json():[]).then(S).catch(()=>S([])):S([])},[N]),(0,a.useEffect)(()=>{$?fetch(`https://www.socialscout.ai/api/searchAutoCompleteOrganizations?query=${encodeURIComponent($)}`).then(e=>e.ok?e.json():[]).then(I).catch(()=>I([])):I([])},[$]),(0,a.useEffect)(()=>{A?fetch(`https://www.socialscout.ai/api/searchAutoCompleteCampaigns?query=${encodeURIComponent(A)}`).then(e=>e.ok?e.json():[]).then(L).catch(()=>L([])):L([])},[A]);let _=e=>x(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),U=[l,g,j,d.length>0,E.length>0,R.length>0,B.length>0,o,u.start||u.end,y[0]>0||y[1]<1e8,b[0]>
10||b[1]<600].filter(Boolean).length;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:`fixed inset-0 bg-black/30 backdrop-blur-sm z-40 transition-opacity duration-300 ${e?"opacity-100":"opacity-0 pointer-events-none"}`,onClick:r}),(0,t.jsxs)("div",{className:`fixed top-0 right-0 h-full w-80 bg-white dark:bg-zinc-950 z-50 shadow-2xl flex flex-col transition-transform duration-300 ease-out ${e?"translate-x-0":"translate-x-full"}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between px-6 py-5 border-b border-gray-100 dark:border-zinc-800 flex-shrink-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)("div",{className:"p-1.5 rounded-lg bg-gradient-to-br from-pink-500 to-orange-400",children:(0,t.jsx)(e1.FunnelIcon,{className:"w-4 h-4 text-white"})}),(0,t.jsx)("h2",{className:"text-sm font-bold text-gray-900 dark:text-zinc-100",children:"Filter Posts"}),U>0&&(0,t.jsx)("span",{className:"px-2 py-0.5 bg-gradient-to-r from-pink-500 to-orange-400 text-white text-[10px] font-semibold rounded-full",children:U})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[U>0&&(0,t.jsx)("button",{onClick:()=>{i(""),c(!1),x([]),m({start:"",end:""}),f(""),w(""),C(""),S([]),P([]),M(""),I([]),T([]),D(""),L([]),O([]),k([0,1e8]),v([0,600]),s({})},className:"text-xs text-gray-400 dark:text-zinc-500 hover:text-gray-600 dark:hover:text-zinc-400 transition-colors",children:"Clear all"}),(0,t.jsx)("button",{onClick:r,className:"p-1.5 rounded-lg hover:bg-gray-100 dark:hover:bg-zinc-900 text-gray-400 dark:text-zinc-500 transition-colors",children:(0,t.jsx)(p.XMarkIcon,{className:"w-5 h-5"})})]})]}),(0,t.jsxs)("div",{className:"flex-1 overflow-y-auto px-6 py-6 space-y-6",children:[(0,t.jsxs)(aK,{children:[(0,t.jsx)(aH,{children:"Sort by Views"}),(0,t.jsxs)(aW,{value:j,onChange:e=>w(e.target.value),children:[(0,t.jsx)("option",{value:"",children:"None"}),(0,t.jsx)("option",{value:"asc",children:"Lowest to Highest"}),(0,t.jsx)("option",{value:"desc",children:"Highest to Lowest"})]})]}),(0,t.jsxs)(aK,{children:[(0,t.jsx)(aH,{children:"Options"}),(0,t.jsxs)("label",{className:"flex items-center gap-3 px-3 py-2.5 border border-gray-200 dark:border-zinc-800 rounded-xl cursor-pointer hover:border-pink-200 hover:bg-pink-50/30 transition-all",children:[(0,t.jsx)("div",{onClick:()=>c(e=>!e),className:`relative inline-flex h-5 w-9 items-center rounded-full transition-colors duration-200 cursor-pointer flex-shrink-0 ${o?"bg-gradient-to-r from-pink-500 to-orange-400":"bg-gray-200 dark:bg-zinc-800"}`,children:(0,t.jsx)("span",{className:`inline-block h-3.5 w-3.5 transform rounded-full bg-white dark:bg-zinc-950 shadow transition-transform duration-200 ${o?"translate-x-4.5":"translate-x-0.5"}`})}),(0,t.jsx)("span",{className:"text-sm text-gray-700 dark:text-zinc-300 font-medium",children:"Has Paid Media"})]})]}),(0,t.jsxs)(aK,{children:[(0,t.jsx)(aH,{children:"Campaign Vertical"}),(0,t.jsxs)(aW,{value:l,onChange:e=>i(e.target.value),children:[(0,t.jsx)("option",{value:"",children:"All Verticals"}),as.campaignVerticals.map((e,a)=>(0,t.jsx)("option",{value:e,children:e},a))]})]}),(0,t.jsxs)(aK,{children:[(0,t.jsx)(aH,{children:"Post Type"}),(0,t.jsxs)(aW,{value:g,onChange:e=>f(e.target.value),children:[(0,t.jsx)("option",{value:"",children:"All Types"}),ar.postTypes.map(e=>(0,t.jsx)("option",{value:e.value,children:e.label},e.value))]})]}),(0,t.jsxs)(aK,{children:[(0,t.jsxs)(aH,{children:["Platform",d.length>0?` \xb7 ${d.length} selected`:""]}),(0,t.jsx)("div",{className:"grid grid-cols-3 gap-2",children:Object.entries(h.default).map(([e,a])=>(0,t.jsx)(aX,{platform:e,src:a.icon,alt:a.displayName,isSelected:d.includes(e),onClick:_},e))})]}),(0,t.jsx)(aq,{label:"Client / Organization",placeholder:"Search organizationâ¦",searchTerm:$,onSearchChange:M,suggestions:F,onSelect:e=>{R.some(t=>t._id===e._id)||T(t=>[...t,e]),M(""),I([])},selected:R,renderSuggestion:e=>e.name,renderChip:e=>(0,t.jsx)(aY,{label:e.name,color:"blue",onRemove:()=>T(t=>t.filter(t=>t._id!==e._id))},e._id)}),(0,t.jsx)(aq,{label:"Campaign",placeholder:"Search campaignâ¦",searchTerm:A,onSearchChange:D,suggestions:V,onSelect:e=>{B.some(t=>t._id===e._id)||O(t=>[...t,e]),D(""),L([])},selected:B,renderSuggestion:e=>e.name,renderChip:e=>(0,t.jsx)(aY,{label:e.name,color:"orange",onRemove:()=>O(t=>t.filter(t=>t._id!==e._id))},e._id)}),(0,t.jsx)(aq,{label:"Creator",placeholder:"Search creatorâ¦",searchTerm:N,onSearchChange:C,suggestions:z,onSelect:e=>{E.some(t=>t._id===e._id)||P(t=>[...t,e]),C(""),S([])},selected:E,renderSuggestion:e=>(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[e.image&&(0,t.jsx)("img",{src:e.image,alt:e.name,className:"w-7 h-7 rounded-full object-cover flex-shrink-0"}),(0,t.jsx)("span",{children:e.name})]}),renderChip:e=>(0,t.jsx)(aY,{label:e.name,color:"pink",onRemove:()=>P(t=>t.filter(t=>t._id!==e._id))},e._id)}),(0,t.jsxs)(aK,{children:[(0,t.jsx)(aH,{children:"Date Range"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mb-1",children:"From"}
1),(0,t.jsx)("input",{type:"date",value:u.start,onChange:e=>m(t=>({...t,start:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-200 dark:border-zinc-800 rounded-xl focus:outline-none focus:ring-2 focus:ring-pink-300"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mb-1",children:"To"}),(0,t.jsx)("input",{type:"date",value:u.end,onChange:e=>m(t=>({...t,end:e.target.value})),className:"w-full px-3 py-2 text-sm border border-gray-200 dark:border-zinc-800 rounded-xl focus:outline-none focus:ring-2 focus:ring-pink-300"})]})]})]}),(0,t.jsxs)(aK,{children:[(0,t.jsx)(aH,{children:"Views"}),(0,t.jsx)("div",{className:"px-1 pt-1",children:(0,t.jsx)(aG,{range:!0,min:0,max:1e8,step:1e6,value:y,onChange:k,styles:{track:{background:"linear-gradient(to right, #ec4899, #f97316)"},handle:{borderColor:"#ec4899",boxShadow:"0 0 0 3px rgba(236,72,153,0.15)"},rail:{background:"#f3f4f6"}}})}),(0,t.jsxs)("div",{className:"flex justify-between mt-2",children:[(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-zinc-500",children:aQ(y[0])}),(0,t.jsxs)("span",{className:"text-xs font-medium text-gray-600 dark:text-zinc-400",children:[aQ(y[0])," â ",aQ(y[1])]}),(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-zinc-500",children:aQ(y[1])})]})]}),(0,t.jsxs)(aK,{children:[(0,t.jsx)(aH,{children:"Duration (seconds)"}),(0,t.jsx)("div",{className:"px-1 pt-1",children:(0,t.jsx)(aG,{range:!0,min:0,max:600,step:1,value:b,onChange:v,styles:{track:{background:"linear-gradient(to right, #ec4899, #f97316)"},handle:{borderColor:"#ec4899",boxShadow:"0 0 0 3px rgba(236,72,153,0.15)"},rail:{background:"#f3f4f6"}}})}),(0,t.jsxs)("div",{className:"flex justify-between mt-2",children:[(0,t.jsxs)("span",{className:"text-xs text-gray-400 dark:text-zinc-500",children:[b[0],"s"]}),(0,t.jsxs)("span",{className:"text-xs font-medium text-gray-600 dark:text-zinc-400",children:[b[0],"s â ",b[1],"s"]}),(0,t.jsxs)("span",{className:"text-xs text-gray-400 dark:text-zinc-500",children:[b[1],"s"]})]})]})]}),(0,t.jsxs)("div",{className:"flex gap-3 px-6 py-4 border-t border-gray-100 dark:border-zinc-800 flex-shrink-0",children:[(0,t.jsx)("button",{onClick:r,className:"flex-1 px-4 py-2.5 text-sm font-medium text-gray-600 dark:text-zinc-400 border border-gray-200 dark:border-zinc-800 rounded-xl hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:"Cancel"}),(0,t.jsx)("button",{onClick:()=>{s({vertical:l,client:R.map(e=>e._id).join(","),campaign:B.map(e=>e._id).join(","),platform:d.join(","),dateStart:u.start,dateEnd:u.end,postType:g,creatorName:E.map(e=>e.name).join(","),sortByViews:j,hasPaidMedia:o,...0!==y[0]||1e8!==y[1]?{views:y.join(",")}:{},...0!==b[0]||600!==b[1]?{duration:b.join(",")}:{}}),r()},className:"flex-1 px-4 py-2.5 text-sm font-medium bg-gradient-to-r from-pink-500 to-orange-400 text-white rounded-xl hover:shadow-md hover:shadow-pink-200 hover:-translate-y-0.5 transition-all duration-200",children:"Apply Filters"})]})]})]})};var aJ=e.i(867056),a0=e.i(158524),a1=e.i(341546),a2=e.i(635288),a5=e.i(456785);async function a4(e,t){let a=await fetch(`/api/proxyImage?imageUrl=${encodeURIComponent(e.assetUrl)}`);if(!a.ok)throw Error("Couldn't download the asset");let r=await a.blob(),s=URL.createObjectURL(r),n=document.createElement("a"),l=[String(t||"").replace(/[^a-z0-9]+/gi,"-").replace(/^-|-$/g,"").toLowerCase()||"post",e.platform,String(e._id).slice(-6)].filter(Boolean).join("-");n.href=s,n.download=`${l}.${function(e){try{let t=new URL(e.assetUrl).pathname.match(/\.([a-z0-9]{2,5})$/i);if(t)return t[1].toLowerCase()}catch{}return"video"===e.assetKind?"mp4":"jpg"}(e)}`,document.body.appendChild(n),n.click(),n.remove(),setTimeout(()=>URL.revokeObjectURL(s),1e4)}function a3({post:e,creatorName:r,showPlatformChip:s=!1}){let[n,l]=(0,a.useState)(!1),[i,o]=(0,a.useState)(!1),c=async t=>{if(t.preventDefault(),t.stopPropagation(),e.assetUrl&&!i){o(!0);try{await a4(e,r),m.default.success("Asset downloaded")}catch(e){m.default.error(e?.message||"Couldn't download the asset")}finally{o(!1)}}},d="flex-shrink-0 p-2 md:p-1.5 rounded-lg transition-colors text-gray-400 dark:text-zinc-500 hover:text-gray-700 dark:hover:text-zinc-200 hover:bg-gray-100 dark:hover:bg-zinc-900";return(0,t.jsxs)("div",{className:"py-1.5 first:pt-0 last:pb-0 min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1 min-w-0",children:[s&&(0,t.jsx)("span",{className:"flex-shrink-0 mr-1",children:(0,t.jsx)(a2.PlatformChip,{platform:e.platform})}),(0,t.jsx)(a5.PostFlagRowIndicator,{post:e,className:"flex-shrink-0"}),e.link?(0,t.jsx)("a",{href:e.link,target:"_blank",rel:"noopener noreferrer",title:e.link,onClick:e=>e.stopPropagation(),className:"text-[11px] text-gray-700 dark:text-zinc-300 underline-offset-2 hover:underline truncate flex-1 min-w-0",children:(0,a2.shortLink)(e.link)}):(0,t.jsx)("span",{className:"text-[11px] text-gray-400 dark:text-zinc-600 flex-1",children:"No link"}),e.link&&(0,t.jsxs)("button",{type:"button",title:"Copy link",onClick:t=>{t.preventDefault(),t.stopPropagation(),e.link&&(navigator.clipboard.writeText(e.link),l(!0),setTimeout(()=>l(!1),1500))},className:`relative ${d}`,children:[(0,t.jsx)(a0.Link2,{className:"h-4 w-4 md:h-3.5 md:w-3.5"}),n&&(0,t.jsx)("div",{className:"absolute -top-8 left-1/2 -translate-x-1/2 bg-gray-800 text-white text-[10px] rounded-md px-2 py-0.5 whitespace-nowrap shadow-lg dark:bg-zinc-200 dark:text-zinc-900 pointer-events-none",children:"Copied!"})]}),e.assetUrl&&(0,t.jsx)("button",{type:"button",title:"video"===e.assetKind?"Download video":"Download image",onClick:c,disabled:i,className:`${d} ${i?"animate-pulse":""}`,children:(0,t.jsx)(aJ.ArrowDownTrayIcon,{className:"h-4 w-4 md:h-3.5 md:w-3.5"})}),(0,t.jsx)(J.default,{href:`/dashboard/user/post/${e._id}`,onClick:e=>e.stopPropagation(),title:"Open post",className:d,children:(0,t.jsx)(eu.ArrowTopRightOnSquareIcon,{className:"w-4 h-4 md:w-3.5 md:h-3.5"})})]}),(0,t.jsxs)("div",{className:"mt-0.5 flex items-center gap-1.5 text-[10px] text-gray-400 dark:text-zinc-500 tabular-nums min-w-0",children:[(0,t.jsx)("span",{className:"whitespace-nowrap",children:(0,a1.formatDate)(e.createdAt)}),(0,t.jsx)(a2.DeliverableChip,{deliverable:e.deliverable}),null!=e.views&&(0,t.jsxs)("span",{className:"whitespace-nowrap hidden lg:inline",children:[(0,f.formatNumberReturn)(e.views)," views"]})]}),(0,t.jsx)(a5.PostFlagCaption,{post:e,className:"mt-1"})]})}function a6({creator:e,campaign:a}){let r=e?.name?.charAt(0)?.toUpperCase()||"?",s=a?.name?.charAt(0)?.toUpperCase()||"?";return(0,t.jsxs)("div",{className:"relative flex-shrink-0 w-9 h-7",children:[e?.image?(0,t.jsx)("img",{src:e.image,alt:e.name||"Creator",className:"absolute top-0 left-0 w-6 h-6 rounded-full object-cover",style:{border:"1.5px solid var(--border-subtle)",zIndex:1}}):(0,t.jsx)("div",{className:"absolute top-0 left-0 w-6 h-6 rounded-full flex items-center justify-center",style:{background:"rgba(236,72,153,0.10)",border:"1.5px solid rgba(236,72,153,0.22)",zIndex:1},children:(0,t.jsx)("span",{className:"text-pink-500 text-[9px] font-black leading-none",children:r})}),a?.image?(0,t.jsx)("img",{src:a.image,alt:a.name||"Campaign",className:"absolute bottom-0 right-0 w-5 h-5 rounded-md object-contain bg-white dark:bg-zinc-950",style:{border:"1.5px solid var(--border-subtle)",zIndex:2}}):(0,t.jsx)("div",{className:"absolute bottom-0 right-0 w-5 h-5 rounded-md flex items-center justify-center bg-white dark:bg-zinc-950",style:{border:"1.5px solid rgba(236,72,153,0.18)",zIndex:2},children:(0,t.jsx)("span",{className:"text-pink-500 text-[8px] font-black leading-none",children:s})})]})}function a9({rollup:e}){let{creator:a,campaign:r,postCount:s,totalViews:n,er:l,totalPaidSpend:i,postsFlaggedCount:o}=e,c=a?.name||"Unattached",d=r?.name||"Unassigned",x=r?.status==="Live",u=null!=l&&l>0?l.toFixed(2)+"%":"â",m=(0,a2.formatPaidSpend)(i);return(0,t.jsxs)("div",{className:"flex items-start gap-2.5 min-w-0",children:[(0,t.jsx)(a6,{creator:a,campaign:r}),(0,t.jsxs)("div",{className:"flex flex-col min-w-0 flex-1",children:[(0,t.jsx)("span",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100 truncate",children:c}),(0,t.jsxs)("span",{className:"text-[11px] text-gray-500 dark:text-zinc-400 truncate flex items-center gap-1.5",children:[x&&(0,t.jsx)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-green-500 dark:bg-green-400 shadow-[0_0_4px_rgba(34,197,94,0.6)] flex-shrink-0","aria-label":"Live campaign",title:"Campaign is live"}),(0,t.jsx)("span",{className:"truncate",children:d})]}),(0,t.jsxs)("span",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mt-0.5 tabular-nums truncate",children:[s," post",1!==s?"s":""," · ",(0,f.formatNumberReturn)(n)," views · ER ",u,"â"!==m&&` \xb7 ${m} paid`]}),(0,t.jsx)(a5.FlaggedCountChip,{count:o,className:"mt-1 self-start"})]})]})}function a8({rollup:e,columns:a}){let r=(0,a2.bucketPostsByColumn)(e.posts),s=e.creator?.name;return(0,t.jsxs)("div",{className:"flex items-start gap-4 px-4 py-3 transition-colors duration-150 hover:bg-black/[0.02] dark:hover:bg-white/[0.02]",children:[(0,t.jsx)("div",{className:"w-[240px] flex-shrink-0 min-w-0",children:(0,t.jsx)(a9,{rollup:e})}),a.map(e=>{let a=r[e.key];return(0,t.jsx)("div",{className:"flex-1 min-w-[200px]",children:0===a.length?(0,t.jsx)("span",{className:"text-[11px] text-gray-300 dark:text-zinc-700",children:"â"}):(0,t.jsx)("div",{className:"divide-y divide-black/5 dark:divide-white/5",children:a.map(a=>(0,t.jsx)(a3,{post:a,creatorName:s,showPlatformChip:"other"===e.key},a._id))})},e.key)})]})}function a7({rollup:e,columns:a}){let r=(0,a2.bucketPostsByColumn)(e.posts),s=e.creator?.name;return(0,t.jsxs)("div",{className:"px-4 py-3",children:[(0,t.jsx)(a9,{rollup:e}),(0,t.jsx)("div",{className:"mt-2 pl-1 flex flex-col gap-2",children:a.filter(e=>r[e.key].length>0).map(e=>(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-gray-400 dark:text-zinc-500 mb-1",children:e.label}),(0,t.jsx)("div",{className:"divide-y divide-black/5 dark:divide-white/5",children:r[e.key].map(a=>(0,t.jsx)(a3,{post:a,creatorName:s,showPlatformChip:"other"===e.key},a._id))})]},e.key))})]})}function re({totalMatchingPosts:e,totalContracted:a,totalAddedValue:r}){return(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-2 px-4 py-3",style:{borderTop:"1px solid var(--border-subtle)",background:"var(--surface-soft)"},children:[((e,a,r="")=>(0,t.jsxs)("span",{className:`inline-flex items-baseline gap-1.5 ${r}`,children:[(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-gray-400 dark:text-zinc-500",children:e}),(0,t.jsx)("span",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100 tabular-nums",children:(a||0).toLocaleStr
1ing()})]}))("Grand total",e),(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)(a2.DeliverableChip,{deliverable:"contracted"}),(0,t.jsx)("span",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100 tabular-nums",children:(a||0).toLocaleString()})]}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)(a2.DeliverableChip,{deliverable:"added_value"}),(0,t.jsx)("span",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100 tabular-nums",children:(r||0).toLocaleString()})]}),(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-zinc-500 ml-auto",children:"Based on the current filters, across all pages"})]})}function rt({rollups:e=[],capped:a=!1,totalMatchingGroups:r=0,totalMatchingPosts:s=0,totalContracted:n=0,totalAddedValue:l=0}){let i=e.some(e=>(0,a2.bucketPostsByColumn)(e.posts).other.length>0),o=a2.PLATFORM_COLUMNS.filter(e=>"other"!==e.key||i);return(0,t.jsxs)("div",{className:"mx-4 md:mx-8",children:[a&&(0,t.jsx)("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl mb-3 text-xs text-amber-700 dark:text-amber-400",style:{background:"var(--surface-soft)",border:"1px solid rgba(245,158,11,0.25)"},children:(0,t.jsxs)("span",{className:"font-semibold",children:["Showing the top 500 of ",(r||0).toLocaleString()," (creator à campaign) groups. Refine your filters to see complete totals."]})}),(0,t.jsxs)("div",{className:"rounded-2xl overflow-hidden",style:{background:"var(--surface-frosted)",border:"1px solid var(--border-subtle)",backdropFilter:"blur(12px)",WebkitBackdropFilter:"blur(12px)"},children:[(0,t.jsx)("div",{className:"h-0.5 bg-gradient-to-r from-pink-500/40 via-orange-400/40 to-violet-500/40"}),0===e.length?(0,t.jsx)("div",{className:"py-16 text-center",children:(0,t.jsx)("p",{className:"text-sm font-semibold text-gray-700 dark:text-zinc-300 mb-1",children:"No posts match these filters."})}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"hidden md:block overflow-x-auto",children:(0,t.jsxs)("div",{className:"min-w-[900px]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-4 px-4 py-2 text-[10px] font-bold uppercase tracking-[0.12em] text-gray-400 dark:text-zinc-500",style:{borderBottom:"1px solid var(--border-subtle)",background:"var(--surface-soft)"},children:[(0,t.jsx)("span",{className:"w-[240px] flex-shrink-0",children:"Creator · Campaign"}),o.map(e=>(0,t.jsx)("span",{className:"flex-1 min-w-[200px]",children:e.label},e.key))]}),(0,t.jsx)("div",{className:"divide-y divide-black/5 dark:divide-white/5",children:e.map(e=>(0,t.jsx)(a8,{rollup:e,columns:o},e.key))})]})}),(0,t.jsx)("div",{className:"md:hidden divide-y divide-black/5 dark:divide-white/5",children:e.map(e=>(0,t.jsx)(a7,{rollup:e,columns:o},e.key))})]}),(0,t.jsx)(re,{totalMatchingPosts:s,totalContracted:n,totalAddedValue:l})]})]})}let ra="contracted",rr="added_value",rs=/added[\s_-]*value/i;
1function rn(e){return e===rr?"Added Value":"Contracted"}var rl=e.i(820879),ri=e.i(562718),ro=e.i(573948);let rc={hidden:{},show:{transition:{staggerChildren:.06}}},rd={hidden:{opacity:0,y:16},show:{opacity:1,y:0,transition:{duration:.45,ease:[.25,.46,.45,.94]}}};function rx({value:e}){let[r,s]=(0,a.useState)(0);return(0,a.useEffect)(()=>{if(!e)return void s(0);let t=performance.now();requestAnimationFrame(function a(r){let n=Math.min((r-t)/800,1);s(Math.round(e*(1-Math.pow(1-n,3)))),n<1&&requestAnimationFrame(a)})},[e]),(0,t.jsx)(t.Fragment,{children:(0,f.formatNumberReturn)(r)})}function ru({icon:e,label:a,value:r,color:s,gradient:n}){return(0,t.jsxs)(i.motion.div,{variants:rd,className:"relative overflow-hidden rounded-2xl bg-white dark:bg-zinc-950 border border-gray-100 dark:border-zinc-800 p-5 group hover:shadow-lg hover:-translate-y-0.5 transition-all duration-300",children:[(0,t.jsx)("div",{className:"absolute top-0 right-0 w-24 h-24 rounded-full opacity-[0.07] -translate-y-8 translate-x-8 transition-opacity group-hover:opacity-[0.12]",style:{background:n}}),(0,t.jsx)("div",{className:"flex items-start justify-between mb-3",children:(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center",style:{background:`${s}12`},children:(0,t.jsx)(e,{className:"w-5 h-5",style:{color:s}})})}),(0,t.jsx)("div",{className:"text-2xl font-black text-gray-900 dark:text-zinc-100 tracking-tight mb-0.5",children:(0,t.jsx)(rx,{value:r})}),(0,t.jsx)("div",{className:"text-[11px] font-semibold text-gray-400 dark:text-zinc-500 uppercase tracking-wider",children:a})]})}let rm={vertical:"bg-purple-50 text-purple-700 border-purple-100",postType:"bg-pink-50 text-pink-700 border-pink-100",sortByViews:"bg-teal-50 text-teal-700 border-teal-100",platform:"bg-blue-50 text-blue-700 border-blue-100",creatorName:"bg-pink-50 text-pink-700 border-pink-100",client:"bg-orange-50 text-orange-700 border-orange-100",campaign:"bg-orange-50 text-orange-700 border-orange-100",hasPaidMedia:"bg-yellow-50 text-yellow-700 border-yellow-100",dateStart:"bg-indigo-50 text-indigo-700 border-indigo-100",dateEnd:"bg-indigo-50 text-indigo-700 border-indigo-100",search:"bg-pink-50 text-pink-700 border-pink-100"};function rg({label:e,value:a,filterKey:r,onRemove:s}){return(0,t.jsxs)("span",{className:`inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium border ${rm[r]||rm.search}`,children:[e,": ",(0,t.jsx)("strong",{children:a}),(0,t.jsx)("button",{onClick:s,className:"ml-0.5 hover:opacity-70 transition-opacity",children:(0,t.jsx)(p.XMarkIcon,{className:"w-3 h-3"})})]})}function rp({pagination:e,onPageChange:a}){if(!e||e.totalPages<=1)return null;let{currentPage:r,totalPages:s,hasPrevPage:n,hasNextPage:l,totalPosts:i}=e,o=Math.max(1,r-Math.floor(3.5)),c=Math.min(s,o+7-1);c-o<6&&(o=Math.max(1,c-7+1));let d=[];o>1&&(d.push({type:"page",value:1}),o>2&&d.push({type:"ellipsis",value:"s"}));for(let e=o;e<=c;e++)d.push({type:"page",value:e});return c<s&&(c<s-1&&d.push({type:"ellipsis",value:"e"}),d.push({type:"page",value:s})),(0,t.jsxs)("div",{className:"flex flex-col items-center gap-3 mt-10 mx-4 md:mx-8",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap justify-center",children:[(0,t.jsx)("button",{onClick:()=>a(r-1),disabled:!n,className:`px-3.5 py-2 text-sm font-medium rounded-xl border transition-all duration-200 ${!n?"bg-gray-50 dark:bg-zinc-900 text-gray-300 dark:text-zinc-700 border-gray-100 dark:border-zinc-800 cursor-not-allowed":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:"Previous"}),d.map(e=>"ellipsis"===e.type?(0,t.jsx)("span",{className:"px-2 text-gray-300 dark:text-zinc-700 text-sm",children:"..."},e.value):(0,t.jsx)("button",{onClick:()=>a(e.value),className:`w-9 h-9 text-sm font-medium rounded-xl border transition-all duration-200 ${e.value===r?"bg-gradient-to-r from-pink-500 to-orange-400 text-white border-transparent shadow-sm shadow-pink-200":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:e.value},e.value)),(0,t.jsx)("button",{onClick:()=>a(r+1),disabled:!l,className:`px-3.5 py-2 text-sm font-medium rounded-xl border transition-all duration-200 ${!l?"bg-gray-50 dark:bg-zinc-900 text-gray-300 dark:text-zinc-700 border-gray-100 dark:border-zinc-800 cursor-not-allowed":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:"Next"})]}),(0,t.jsxs)("p",{className:"text-xs text-gray-400 dark:text-zinc-500",children:["Page ",r," of ",s," · ",i," posts"]})]})}function rh({view:e,onToggle:a}){return(0,t.jsx)("div",{role:"group",className:"relative inline-flex rounded-full p-0.5 flex-shrink-0",style:{border:"1px solid var(--border-subtle)",zIndex:10},children:["cards","list"].map(r=>{let s=e===r;return(0,t.jsx)("button",{onClick:()=>a(r),className:`px-3 py-1 rounded-full text-[11px] font-semibold transition-colors duration-150 capitalize ${s?"bg-gradient-to-r from-pink-500 to-orange-400 text-white":"text-gray-500 dark:text-zinc-400"}`,style:s?{}:{background:"var(--surface-soft)"},children:"cards"===r?"Cards":"List"},r)})})}function rf(e,t){return t.map(e=>e.label).join(",")+"\n"+e.map(e=>t.map(t=>(e=>{if(null==e)return"";let t=String(e);return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t})(t.get(e))).join(",")).join("\n")}function rb(e,t){let a=new Blob(["\uFEFF"+t],{type:"text/csv;charset=utf-8"}),r=URL.createObjectURL(a),s=document.createElement("a");s.href=r,s.download=e,document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>URL.revokeObjectURL(r),1e3)}function rv({session:e,setFilterPanelBGIsOpen:r,filterPanelBGIsOpen:l}){let{params:o,setParams:c}=(0,tM.useHomeQuery)(),d="list"===o.get("postsView")?"list":"cards",x=parseInt(o.get("page")||"1",10),u=isNaN(x)||x<1?1:x,[h,f]=(0,a.useState)([]),[b,v]=(0,a.useState)({rollups:[],capped:!1,totalMatchingGroups:0,totalMatchingPosts:0,totalContracted:0,totalAddedValue:0,pagination:null}),[y,k]=(0,a.useState)(!1),[j,w]=(0,a.useState)(u),[N,C]=(0,a.useState)(null),[z,S]=(0,a.useState)(null),[E,P]=(0,a.useState)({capped:!1,totalMatching:0}),[$,M]=(0,a.useState)(!1),[F,I]=(0,a.useState)(!1),[R,T]=(0,a.useState)({}),[A,D]=(0,a.useState)(""),[V,L]=(0,a.useState)(""),[B,O]=(0,a.useState)(!1),[_,U]=(0,a.useState)(0),{data:G}
1=(0,s.useSession)(),H="true"===R.monitored||!0===R.monitored;(0,a.useEffect)(()=>{let e=setTimeout(()=>{L(A),w(1)},500);return()=>clearTimeout(e)},[A]);let K=(0,a.useMemo)(()=>{let e="";return Object.entries(R).forEach(([t,a])=>{""!==a&&!1!==a&&null!=a&&(e+=`&${t}=${encodeURIComponent(a)}`)}),V&&(e+=`&search=${encodeURIComponent(V)}`),e},[R,V]);(0,a.useEffect)(()=>{let e=!1;return async function(){M(!0),f([]);try{let t;t=("list"===d?`https://www.socialscout.ai/api/getPosts?rollup=creatorCampaign&page=${j}`:`https://www.socialscout.ai/api/getPosts?page=${j}&limit=50`)+K;let a=await fetch(t);if(!a.ok)throw Error(a.statusText);let r=await a.json();!e&&("list"===d?(v({rollups:r.rollups??[],capped:r.capped??!1,totalMatchingGroups:r.totalMatchingGroups??0,totalMatchingPosts:r.totalMatchingPosts??0,totalContracted:r.totalContracted??0,totalAddedValue:r.totalAddedValue??0,pagination:r.pagination?{...r.pagination,totalPosts:r.pagination.totalMatchingGroups??0}:null}),f([]),C(null)):(f(r.posts??[]),C(r.pagination??null)),P({capped:!1,totalMatching:0}),r.aggregates&&S(r.aggregates))}catch(t){console.error("Failed to fetch data:",t),e||m.default.error(`Failed to fetch data: ${t.message}`)}finally{e||M(!1)}}(),()=>{e=!0}},[d,j,K,_]);let W=(0,a.useCallback)(()=>{U(e=>e+1),O(!1)},[]),q=(0,a.useCallback)(()=>{c({page:null})},[c]),Y=(0,a.useCallback)(e=>{T(t=>{let a={...t};return delete a[e],a}),w(1),q()},[q]),X=(0,a.useCallback)(()=>{T({}),D(""),L(""),w(1),q()},[q]),Q=()=>{D(""),L(""),w(1),q()},Z=(0,a.useCallback)(()=>{T(e=>{let t={...e};return t.monitored?delete t.monitored:t.monitored="true",t}),w(1),q()},[q]),J=e=>{w(e),c({page:1===e?null:String(e)}),window.scrollTo({top:0,behavior:"smooth"})},ee=(0,a.useMemo)(()=>{let e=[];return V&&e.push({key:"search",label:"Search",value:`"${V}"`,onRemove:Q}),R.vertical&&e.push({key:"vertical",label:"Vertical",value:R.vertical,onRemove:()=>Y("vertical")}),R.postType&&e.push({key:"postType",label:"Post Type",value:R.postType,onRemove:()=>Y("postType")}),R.sortByViews&&e.push({key:"sortByViews",label:"Sort",value:"desc"===R.sortByViews?"Most Views":"Fewest Views",onRemove:()=>Y("sortByViews")}),R.platform&&e.push({key:"platform",label:"Platform",value:R.platform,onRemove:()=>Y("platform")}),R.creatorName&&e.push({key:"creatorName",label:"Creator",value:R.creatorName,onRemove:()=>Y("creatorName")}),R.client&&e.push({key:"client",label:"Client",value:"Selected",onRemove:()=>Y("client")}),R.campaign&&e.push({key:"campaign",label:"Campaign",value:"Selected",onRemove:()=>Y("campaign")}),R.hasPaidMedia&&e.push({key:"hasPaidMedia",label:"Paid Media",value:"Yes",onRemove:()=>Y("hasPaidMedia")}),R.dateStart&&e.push({key:"dateStart",label:"From",value:R.dateStart,onRemove:()=>Y("dateStart")}),R.dateEnd&&e.push({key:"dateEnd",label:"To",value:R.dateEnd,onRemove:()=>Y("dateEnd")}),e},[V,R,Y]),et=ee.length,ea="list"===d?b.totalMatchingPosts:N?.totalPosts||0,er=[{icon:ri.PhotoIcon,label:"Total Posts",value:ea,color:"#ec4899",gradient:"radial-gradient(circle, #ec4899, #f97316)"},{icon:eE.EyeIcon,label:"Total Views",value:z?.totalViews||0,color:"#3b82f6",gradient:"radial-gradient(circle, #3b82f6, #8b5cf6)"},{icon:tm.HeartIcon,label:"Likes",value:z?.totalLikes||0,color:"#ef4444",gradient:"radial-gradient(circle, #ef4444, #ec4899)"},{icon:ro.ChatBubbleOvalLeftIcon,label:"Comments",value:z?.totalComments||0,color:"#8b5cf6",gradient:"radial-gradient(circle, #8b5cf6, #6366f1)"},{icon:e$.UserGroupIcon,label:"Creators",value:z?.uniqueCreators||0,color:"#f97316",gradient:"radial-gradient(circle, #f97316, #ef4444)"},{icon:es.MegaphoneIcon,label:"Campaigns",value:z?.uniqueCampaigns||0,color:"#10b981",gradient:"radial-gradient(circle, #10b981, #06b6d4)"}];return(0,t.jsxs)("div",{className:"mt-6 mb-40",children:[(0,t.jsxs)("div",{className:"mx-4 md:mx-8 mb-6 flex items-start justify-between gap-3",children:[(0,t.jsxs)(i.motion.div,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{duration:.4},className:"min-w-0",children:[(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 dark:text-zinc-100 tracking-tight",children:"Posts"}),(0,t.jsx)("p",{className:"text-sm text-gray-400 dark:text-zinc-500 mt-1",children:"list"===d?b.totalMatchingPosts?`${b.totalMatchingPosts.toLocaleStr
1ing()} total posts`:$?"Loading...":"All posts":N?`${N.totalPosts} total across all pages`:"Loading..."})]}),(0,t.jsxs)(i.motion.button,{initial:{opacity:0,y:-10},animate:{opacity:1,y:0},transition:{duration:.4,delay:.05},whileHover:{scale:1.04},whileTap:{scale:.97},onClick:()=>O(!0),className:"flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-semibold text-white bg-gradient-to-r from-pink-500 to-orange-400 shadow-sm shadow-pink-200/50 dark:shadow-none flex-shrink-0",children:[(0,t.jsx)(e0.PlusIcon,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"New Post"})]})]}),(0,t.jsx)(tI.default,{isOpen:B,onClose:()=>O(!1),children:(0,t.jsx)(rl.default,{setRefetchTrigger:W})}),z&&(0,t.jsx)(i.motion.div,{variants:rc,initial:"hidden",animate:"show",className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-3 mx-4 md:mx-8 mb-8",children:er.map(e=>(0,t.jsx)(ru,{...e},e.label))}),(0,t.jsxs)(i.motion.div,{initial:!1,animate:{opacity:1,y:0},transition:{duration:.4,delay:.15},className:"mx-4 md:mx-8 mb-6 flex items-center gap-3 flex-wrap sm:flex-nowrap",children:[(0,t.jsx)("div",{className:"flex-1 relative min-w-0 w-full sm:w-auto",children:(0,t.jsx)("div",{className:`p-[1.5px] rounded-2xl transition-all duration-300 ${A?"bg-gradient-to-r from-pink-500 to-orange-400 shadow-sm shadow-pink-200/50":"bg-gray-200 dark:bg-zinc-800 hover:bg-gray-300"}`,children:(0,t.jsxs)("div",{className:"relative bg-white dark:bg-zinc-950 rounded-2xl",children:[(0,t.jsx)("input",{type:"text",placeholder:"Search by creator or campaign name...",value:A,onChange:e=>D(e.target.value),className:"w-full pl-10 pr-4 py-2.5 text-sm bg-transparent border-0 rounded-2xl focus:outline-none placeholder-gray-400 dark:placeholder-zinc-500 text-gray-900 dark:text-zinc-100"}),(0,t.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-gray-400 dark:text-zinc-500",children:A?(0,t.jsx)("button",{onClick:Q,className:"hover:text-gray-600 dark:hover:text-zinc-400 transition-colors",children:(0,t.jsx)(p.XMarkIcon,{className:"w-4 h-4"})}):(0,t.jsx)(g.MagnifyingGlassIcon,{className:"w-4 h-4"})})]})})}),(0,t.jsx)(rh,{view:d,onToggle:function(e){w(1),c({postsView:"cards"===e?null:e,page:null})}}),(()=>{let e="list"===d?b.totalMatchingPosts:h.length,a=y?"Exportingâ¦":e>0?`Export ${e.toLocaleString()} post${1!==e?"s":""}`:"Export",r=0===e||y;async function s(){let e=new Date().toISOString().slice(0,10);if("list"===d){k(!0);try{let t=`https://www.socialscout.ai/api/getPosts?rollup=creatorCampaign&flat=true${K}`,a=await fetch(t);if(!a.ok)throw Error(a.statusText);let r=await a.json(),s=r.posts??[],n=[{label:"Creator",get:e=>e.creatorName??""},{label:"Campaign",get:e=>e.campaignName??""},{label:"Campaign Status",get:e=>e.campaignStatus??""},{label:"Client",get:e=>e.organizationName??""},{label:"Deliverable",get:e=>rn(e.deliverable)},{label:"Post Date",get:e=>{let t;return(t=e.createdAt)?new Date(t).toISOString().slice(0,10):""}},...a2.PLATFORM_COLUMNS.map(e=>{let t;return{label:`${e.label} Link`,get:(t=e.key,e=>(0,a2.columnForPlatform)(e.platform)===t?e.link??"":"")}}),{label:"Platform",get:e=>e.platform??""},{label:"Views",get:e=>e.views??0},{label:"ER %",get:e=>null!=e.er?Number(e.er).toFixed(2):""},{label:"Paid Spend",get:e=>e.paidSpend??""},{label:"Asset URL",get:e=>e.assetUrl??""},{label:"Post ID",get:e=>e._id??""}],l=rf(s,n);rb(`posts-list-${e}.csv`,l),r.capped?(0,m.default)(`Export capped at ${s.length.toLocaleString()} posts â refine your filters for a complete file`,{icon:"â ï¸"}):m.default.success(`Exported ${s.length.toLocaleString()} posts`)}catch(e){console.error("Export failed:",e),m.default.error(`Export failed: ${e.message}`)}finally{k(!1)}}else rb(`posts-${e}-page${j}.csv`,rf(h,[{label:"Post ID",get:e=>e._id??""},{label:"Post Link",get:e=>e.link??""},{label:"Platform",get:e=>e.platform??""},{label:"Creator Name",get:e=>e.creatorDetails?.name??e.creator?.name??""},{label:"Campaign Name",get:e=>e.campaignDetails?.name??e.campaign?.name??""},{label:"Deliverable",get:e=>rn(e.deliverable??(e&&(e.deliverableType===rr||rs.test(String(e.postType||"")))?rr:ra))},{label:"Views",get:e=>e.lastSnapshot?.views??e.views??0},{label:"Likes",get:e=>e.lastSnapshot?.likes??e.likes??0},{label:"Comments",get:e=>e.lastSnapshot?.comments??e.comments??0},{label:"Shares",get:e=>e.lastSnapshot?.shares??e.shares??0},{label:"Saves",get:e=>e.lastSnapshot?.saves??e.saves??0},{label:"Paid Views",get:e=>e.lastPaidSnapshot?.paid_views??e.paidViews??0},{label:"Paid Spend",get:e=>e.lastPaidSnapshot?.cost??e.paidSpend??""},{label:"Created At",get:e=>e.createdAt??""}]))}return(0,t.jsxs)(i.motion.button,{whileHover:r?{}:{scale:1.03,y:-1},whileTap:r?{}:{scale:.97},onClick:r?void 0:s,disabled:r,title:"list"===d?"Export every post matching the current filters":"Export the current page's data",className:`relative flex items-center gap-2 px-4 py-2.5 text-sm font-medium rounded-xl border transition-all duration-200 flex-shrink-0 ${r?"bg-white dark:bg-zinc-950 text-gray-300 dark:text-zinc-700 border-gray-100 dark:border-zinc-800 cursor-not-allowed":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:[(0,t.jsx)(aJ.ArrowDownTrayIcon,{className:"w-4 h-4 flex-shrink-0"}),(0,t.jsx)("span",{className:"hidden sm:inline whitespace-nowrap",children:a})]})})(),(0,t.jsxs)(i.motion.button,{whileHover:{scale:1.03,y:-1},whileTap:{scale:.97},onClick:Z,title:"Show only monitored posts",className:`relative flex items-center gap-2 px-4 py-2.5 text-sm font-medium rounded-xl border transition-all duration-200 flex-shrink-0 ${H?"text-emerald-700 dark:text-emerald-300":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-emerald-200 hover:text-emerald-600"}`,style:H?{background:"rgba(16,185,129,0.10)",border:"1px solid rgba(16,185,129,0.25)"}:void 0,children:[(0,t.jsx)(eE.EyeIcon,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Monitored"})]}),(0,t.jsxs)(i.motion.button,{whileHover:{scale:1.03,y:-1},whileTap:{scale:.97},onClick:()=>{I(!0),r?.(!0)},className:`relative flex items-center gap-2 px-4 py-2.5 text-sm font-medium rounded-xl border transition-all duration-200 ${et>0?"bg-gradient-to-r from-pink-500 to-orange-400 text-white border-transparent shadow-sm shadow-pink-200":"bg-white dark:bg-zinc-950 text-gray-600 dark:text-zinc-400 border-gray-200 dark:border-zinc-800 hover:border-pink-200 hover:text-pink-600"}`,children:[(0,t.jsx)(eJ.AdjustmentsHorizontalIcon,{className:"w-4 h-4"}),(0,t.jsx)("span",{className:"hidden sm:inline",children:"Filters"}),et>0&&(0,t.jsx)("span",{className:"w-5 h-5 rounded-full text-[10px] font-bold flex items-center justify-center bg-white/30 dark:bg-zinc-950/30 text-white",children:et})]})]}),ee.length>0&&(0,t.jsxs)(i.motion.div,{initial:{opacity:0,x:-10}
1,animate:{opacity:1,x:0},transition:{duration:.25},className:"mx-4 md:mx-8 mb-5 flex flex-wrap items-center gap-2",children:[ee.map(({key:e,label:a,value:r,onRemove:s})=>(0,t.jsx)(rg,{label:a,value:r,filterKey:e,onRemove:s},e)),(0,t.jsx)("button",{onClick:X,className:"text-xs text-gray-400 dark:text-zinc-500 hover:text-gray-600 dark:hover:text-zinc-400 underline underline-offset-2 transition-colors",children:"Clear all"})]}),(0,t.jsx)(aZ,{isOpen:F,onClose:()=>{I(!1),r?.(!1)},onApplyFilter:e=>{T(Object.fromEntries(Object.entries(e).filter(([,e])=>""!==e&&!1!==e&&null!=e))),w(1),q()}}),$&&(0,t.jsx)(n.InlineLoader,{message:"Loading posts..."}),!$&&"list"===d&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(rt,{rollups:b.rollups,capped:b.capped,totalMatchingGroups:b.totalMatchingGroups,totalMatchingPosts:b.totalMatchingPosts,totalContracted:b.totalContracted,totalAddedValue:b.totalAddedValue}),b.rollups.length>0&&(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4,delay:.3},children:(0,t.jsx)(rp,{pagination:b.pagination,onPageChange:J})})]}),!$&&"cards"===d&&(0,t.jsxs)(t.Fragment,{children:[0===h.length&&(0,t.jsxs)(i.motion.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},transition:{duration:.4},className:"flex flex-col items-center justify-center py-20 text-center mx-4 md:mx-8",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-gray-50 dark:bg-zinc-900 flex items-center justify-center mb-4",children:(0,t.jsx)(ri.PhotoIcon,{className:"w-8 h-8 text-gray-300 dark:text-zinc-700"})}),(0,t.jsx)("p",{className:"text-sm font-semibold text-gray-700 dark:text-zinc-300 mb-1",children:"No posts found"}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-zinc-500 mb-4",children:et>0?"Try adjusting your filters":"Posts will appear here once added to campaigns"}),et>0&&(0,t.jsx)("button",{onClick:X,className:"text-xs text-pink-500 hover:text-pink-600 underline underline-offset-2 transition-colors",children:"Clear all filters"})]}),h.length>0&&(0,t.jsx)(aa,{posts:h},`${j}-${JSON.stringify(R)}-${V}`),h.length>0&&(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.4,delay:.3},children:(0,t.jsx)(rp,{pagination:N,onPageChange:J})})]})]})}let ry=function({session:e,setFilterPanelBGIsOpen:r,filterPanelBGIsOpen:s}){return(0,t.jsx)(a.Suspense,{fallback:(0,t.jsxs)("div",{className:"mt-6 mb-40",children:[(0,t.jsxs)("div",{className:"mx-4 md:mx-8 mb-6",children:[(0,t.jsx)("h1",{className:"text-2xl font-black text-gray-900 dark:text-zinc-100 tracking-tight",children:"Posts"}),(0,t.jsx)("p",{className:"text-sm text-gray-400 dark:text-zinc-500 mt-1",children:"Loading..."})]}),(0,t.jsx)(n.InlineLoader,{message:"Loading posts..."})]}),children:(0,t.jsx)(rv,{session:e,setFilterPanelBGIsOpen:r,filterPanelBGIsOpen:s})})};e.i(252422);let rk=a.default.createContext({});function rj({count:e=1,wrapper:t,className:r,containerClassName:s,containerTestId:n,circle:l=!1,style:i,...o}){var c,d,x;let u=a.default.useContext(rk),m={...o};for(let[e,t]of Object.entries(o))void 0===t&&delete m[e];let g={...u,...m,circle:l},p={...i,...function({baseColor:e,highlightColor:t,width:a,height:r,borderRadius:s,circle:n,direction:l,duration:i,enableAnimation:o=!0,customHighlightBackgroun
1d:c}){let d={};return"rtl"===l&&(d["--animation-direction"]="reverse"),"number"==typeof i&&(d["--animation-duration"]=`${i}s`),o||(d["--pseudo-element-display"]="none"),("string"==typeof a||"number"==typeof a)&&(d.width=a),("string"==typeof r||"number"==typeof r)&&(d.height=r),("string"==typeof s||"number"==typeof s)&&(d.borderRadius=s),n&&(d.borderRadius="50%"),void 0!==e&&(d["--base-color"]=e),void 0!==t&&(d["--highlight-color"]=t),"string"==typeof c&&(d["--custom-highlight-background"]=c),d}(g)},h="react-loading-skeleton";r&&(h+=` ${r}`);let f=null!=(c=g.inline)&&c,b=[],v=Math.ceil(e);for(let t=0;t<v;t++){let r=p;if(v>e&&t===v-1){let t=null!=(d=r.width)?d:"100%",a=e%1,s="number"==typeof t?t*a:`calc(${t} * ${a})`;r={...r,width:s}}let s=a.default.createElement("span",{className:h,style:r,key:t},"â");f?b.push(s):b.push(a.default.createElement(a.default.Fragment,{key:t},s,a.default.createElement("br",null)))}return a.default.createElement("span",{className:s,"data-testid":n,"aria-live":"polite","aria-busy":null==(x=g.enableAnimation)||x},t?b.map((e,r)=>a.default.createElement(t,{key:r},e)):b)}e.i(980084);var rw=e.i(189768),rN=e.i(405959),rC=e.i(982487),rz=e.i(792992),rS=e.i(800943),rE=e.i(625894),rP=e.i(109278),r$=e.i(937003),rM=e.i(570179);function rF({organizationId:e}){let[r,n]=(0,a.useState)(null),[l,i]=(0,a.useState)(null),[o,c]=(0,a.useState)(!1),[d,x]=(0,a.useState)("views"),[u,m]=(0,a.useState)(0),[g,p]=(0,a.useState)(0),[h,b]=(0,a.useState)(!1),{data:v}=(0,s.useSession)(),{can:y,loading:k}=(0,eX.usePermissions)();(0,a.useEffect)(()=>{!async function(){if(!e)return console.log("â ï¸ No organizationId provided, skipping fetch");try{console.log("Fetching organization data for ID:",e);let a=await fetch(`https://www.socialscout.ai/api/getOneOrganization?organizationId=${e}`);if(a.ok){let e=await a.json();if(console.log("Organization data fetched successfully:",e),n(e),e?.posts){var t;let a,r,s=(t=e.posts,a={},t.forEach(e=>{let t=e?.creator?._id;t&&(a[t]=!0)}),r=Object.keys(a),console.log("Unique Creator IDs:",r),r.length);p(s)}}else console.error("Failed to fetch organization data:",await a.text())}catch(e){console.error("Error fetching organization data:",e)}}()},[u,e]);let j=(0,rw.getSortedCreators)(r);return(0,t.jsxs)("div",{children:[(0,t.jsx)(rM.default,{isOpen:h,setIsOpen:b,organization:r?.id,setRefetchTrigger:m})," ",(0,t.jsxs)("div",{className:"flex items-center mt-10 mx-4",children:[r?.organization?.image?(0,t.jsx)("img",{src:r?.organization?.image,alt:"Organization Thumbnail",className:"w-48 h-48 rounded-full bg-white dark:bg-zinc-950 border-black border-2 object-cover shadow-2xl dark:border-zinc-700"}):(0,t.jsx)(rj,{height:100}),(0,t.jsxs)("div",{className:"text-2xl text-black sm:text-3xl lg:text-5xl font-bold mx-4 dark:text-zinc-100",children:[r?.name,(0,t.jsx)("div",{className:"flex mt-4 items-center justify-start",children:r?.organization?.vertical&&(0,t.jsx)("div",{className:"border-2 border-black text-center text-white bg-pink-500 justify-center text-xs font-bold rounded-full px-4 py-2 dark:border-zinc-700",children:r?.organization?.vertical})}),!k&&y("organizations","edit")&&(0,t.jsx)("button",{className:"bg-gradient-to-br font-normal text-sm w-36 h-12 from-pink-500 to-orange-400 text-white p-2 rounded-md mt-4",onClick:()=>b(!0),children:"Edit Organization"})]})]}),(0,t.jsx)("div",{className:"relative flex-auto items-center justify-between space-y-5 mx-4",children:(0,t.jsxs)("div",{className:"grid mt-10 md:grid-cols-4 gap-4",children:[(0,t.jsx)(rE.default,{value:g,description:g>1?"Creators":"Creator"}),(0,t.jsx)(rE.default,{value:r?.posts?r?.posts?.length:0,description:r?.posts?.length>1?"Posts":"Post"}),(0,t.jsx)(rE.default,{value:(0,f.formatNumberReturn)(r?.posts.reduce((e,t)=>(t.snapshot&&t.snapshot.length>0&&(e+=t.snapshot[t.snapshot.length-1].views),e),0)),description:"Views"}),(0,t.jsx)(rE.default,{value:(0,f.formatNumberReturn)(r?.posts.reduce((e,t)=>{let a=t.snapshot;if(t.snapshot&&t.snapshot.length>0){let t=a[a.length-1];e+=t.likes,e+=t.comments,e+=t.shares,e+=t.saves}return e},0)),description:"Engagements"})]})}),(0,t.jsxs)("div",{className:"mx-4 md:flex gap-2",children:[r?.posts[0]?.snapshot?.length>0&&(0,t.jsx)(rz.default,{campaign:r}),r?.posts[0]?.snapshot?.length>0&&(0,t.jsx)(rC.default,{campaign:r}),r?.posts[0]?.tik_tok_snapshot?.length>0&&(0,t.jsx)(rS.default,{campaign:r})]}),r&&r.campaigns&&r.campaigns.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"mt-4 mb-4 mx-4 text-lg md:text-4xl text-[#3e1eb1] items-center justify-center font-bold w-max",children:"Campaigns"}),(0,t.jsx)("div",{className:"mt-10 mx-8 md:mx-32 mb-10",children:(0,t.jsx)(r$.default,{campaigns:r.campaigns})})]}),r?.posts?.length>0&&(0,t.jsx)(rP.default,{sortedList:j}),(0,t.jsx)("div",{className:"mt-4 mb-4 mx-4 text-lg md:text-4xl text-[#3e1eb1] items-center justify-center font-bold w-max",children:"Posts"}),(0,t.jsxs)("div",{className:"text-left mx-4 my-6",children:[(0,t.jsx)("label",{htmlFor:"sort-metric",children:"Sort Posts By: "}
1),(0,t.jsxs)("select",{id:"sort-metric",value:d,onChange:e=>x(e.target.value),className:"border border-gray-300 dark:border-zinc-700 rounded px-2 py-1 ml-2",children:[(0,t.jsx)("option",{value:"views",children:"Views"}),(0,t.jsx)("option",{value:"organic views",children:"Organic Views"}),(0,t.jsx)("option",{value:"followers",children:"Followers"}),(0,t.jsx)("option",{value:"likes",children:"Likes"}),(0,t.jsx)("option",{value:"comments",children:"Comments"}),(0,t.jsx)("option",{value:"er",children:"ER"}),(0,t.jsx)("option",{value:"ctr",children:"CTR"})]})]}),r?.posts.sort((e,t)=>{let a=(e,t)=>{let a=(0,rw.getClicksFromLastTikTokSnapshot)(e),r=(0,rw.getPaidProfileVisitsFromLastTikTokSnapshot)(e),s=(0,rw.getPaidViewsFromLastTikTokSnapshot)(e),n=(0,rw.getTotalEngagementsForPost)(e)+a+r,l=(0,rw.getViewsFromLastSnapshot)(e),i=(n/l*100).toFixed(2),o=e?a/s:0;switch(t){case"views":return e.snapshot?.[e.snapshot.length-1]?.views||0;case"organic views":return l-s;case"followers":return e.creator.socials[e.platform]?.followers||0;case"ctr":return o||0;case"likes":return e.snapshot?.[e.snapshot.length-1]?.likes||0;case"comments":return e.snapshot?.[e.snapshot.length-1]?.comments||0;case"er":return i||0;default:return 0}};return a(t,d)-a(e,d)}).map(e=>{let a=e.snapshot?.length>0?e.snapshot[e.snapshot.length-1]:null,r=(0,rw.getClicksFromLastTikTokSnapshot)(e),s=(0,rw.getPaidProfileVisitsFromLastTikTokSnapshot)(e),n=(0,rw.getPaidViewsFromLastTikTokSnapshot)(e),l=(((0,rw.getTotalEngagementsForPost)(e)+r+s)/(0,rw.getViewsFromLastSnapshot)(e)*100).toFixed(2),i=e?(r/n*100).toFixed(2):0;return(0,t.jsx)("div",{className:"mb-10",children:(0,t.jsx)(rN.default,{post:e,snapshot:a,setRefetchTrigger:m,er:l,ctr:i})},e._id)})]})}let rI=()=>(0,t.jsxs)("div",{className:"relative min-h-screen bg-black dark:bg-black text-white",children:[(0,t.jsx)("div",{className:"absolute top-0 left-0 w-full h-full overflow-hidden z-0",children:(0,t.jsx)("div",{style:{padding:"56.25% 0 0 0",position:"relative"},children:(0,t.jsx)("iframe",{src:"https://player.vimeo.com/video/873047152?badge=0&autopause=0&player_id=0&app_id=58479&autoplay=1&loop=1&muted=1&background=1",frameBorder:"0",allow:"autoplay; fullscreen; picture-in-picture; clipboard-write",style:{position:"absolute",top:"0",left:"0",width:"100%",height:"100%"},title:"QYOU Studios - Capabilities Sizzle"})})}),(0,t.jsx)("div",{className:"absolute top-0 left-0 w-full h-full bg-black dark:bg-black opacity-80 z-10"}),(0,t.jsxs)("header",{className:"relative z-20 text-center py-20 px-4",children:[(0,t.jsx)("h1",{className:"text-4xl md:text-9xl font-bold uppercase bg-clip-text text-transparent bg-gradient-to-r from-red-500 via-orange-500 to-yellow-500",children:"TAKING INFLUENCER MARKETING TO THE NEXT LEVEL"}),(0,t.jsx)("p",{className:"mt-6 px-4 md:px-20 font-medium text-xl md:text-2xl",children:"Social Scout by The QYOU is a global pioneer transforming the way leading agencies and brands utilize data to optimize their creator and influencer marketing efforts."})]}),(0,t.jsx)("footer",{className:"absolute bottom-0 left-0 w-full z-20 py-6 text-center",children:(0,t.jsxs)("div",{className:"flex items-center justify-center gap-6 text-sm text-gray-400 dark:text-zinc-500",children:[(0,t.jsx)(J.default,{href:"/privacy-policy",className:"hover:text-white transition-colors",children:"Privacy Policy"}),(0,t.jsx)("span",{className:"text-gray-600 dark:text-zinc-400",children:"â¢"}),(0,t.jsx)(J.default,{href:"/terms-of-service",className:"hover:text-white transition-colors",children:"Terms of Service"})]})})]});var rR=e.i(700109);e.i(245368);var rT=e.i(6487),rA=e.i(208259),rD=e.i(922881),rV=e.i(303859),rL=e.i(662060),rB=e.i(399046),rO=e.i(933683),r_=e.i(307984);let rU={light:{organic:"#10b981",paid:"#8b5cf6"},dark:{organic:"#059669",paid:"#8b5cf6"}},rG={csv:"CSV import",mixed:"mixed sources"},rH=e=>(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-8",children:e}),rK={violet:["#8B5CF6","#6366F1"],amber:["#F59E0B","#F97316"]};function rW({rows:e,nameKey:r,limit:s=8,palette:n="violet"}){let l=(0,a.useRef)(null),i=r4(),o=(0,a.useMemo)(()=>{let t=e=>e[r],a=rK[n]||rK.violet;if(!e?.length)return null;let l=[...e].filter(e=>e.totalCost>0).sort((e,t)=>
1t.totalCost-e.totalCost).slice(0,s);if(!l.length)return null;let o=[...l].reverse();return{tooltip:{...r3(i),trigger:"axis",axisPointer:{type:"shadow"},formatter:e=>{let a=o[e[0].dataIndex];return`<div style="font-weight:600">${t(a)}</div><div style="color:#8B5CF6">${r8(a.totalCost)} spend</div><div>${r9(a.totalPaidViews)} paid views \xb7 ${a.costPerView>0?"$"+a.costPerView.toFixed(3)+"/view":"no view data"}</div><div style="opacity:.7">${a.boostedPosts} boosted post${1===a.boostedPosts?"":"s"}${a.totalCampaigns?` \xb7 ${a.totalCampaigns} campaign${1===a.totalCampaigns?"":"s"}`:""}</div>`}},grid:{top:4,right:64,bottom:4,left:0,containLabel:!0},xAxis:{type:"value",axisLabel:{fontSize:10,color:i.textDim,formatter:e=>r8(e)},splitLine:{lineStyle:{color:"var(--surface-softer)"}},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"category",data:o.map(e=>((e,t=22)=>e&&e.length>t?e.slice(0,t)+"â¦":e||"")(t(e))),axisLabel:{fontSize:10,color:i.text,width:110,overflow:"truncate"},axisLine:{show:!1},axisTick:{show:!1}},series:[{type:"bar",data:o.map(e=>e.totalCost),barMaxWidth:16,itemStyle:{borderRadius:[0,4,4,0],color:new rA.graphic.LinearGradient(0,0,1,0,[{offset:0,color:a[0]},{offset:1,color:a[1]}])},label:{show:!0,position:"right",fontSize:10,color:i.text,formatter:e=>{let t=o[e.dataIndex];return t.costPerView>0?`$${t.costPerView.toFixed(3)}/v`:r8(t.totalCost)}}}],animationDuration:800,animationEasing:"cubicOut"}},[e,i,r,s,n]);return(se(l,o,[o]),o)?(0,t.jsx)("div",{ref:l,style:{height:260}}):rH("No spend data")}function rq({rows:e}){let r=(0,a.useRef)(null),s=r4(),n=(0,a.useMemo)(()=>{if(!e?.length)return null;let t=e.filter(e=>e.totalCost>0);if(!t.length)return null;let a=t.map(e=>{let[t,a]=e.month.split("-");return new Date(Date.UTC(Number(t),Number(a)-1,1)).toLocaleDateString("en-US",{month:"short",year:"2-digit",timeZone:"UTC"})});return{tooltip:{...r3(s),trigger:"axis",axisPointer:{type:"shadow"},formatter:e=>{let a=t[e[0].dataIndex];return`<div style="font-weight:600">${e[0].name}</div><div style="color:#8B5CF6">${r8(a.totalCost)} spend</div><div>${r9(a.totalPaidViews)} paid views</div><div style="opacity:.7">${a.totalCampaigns} campaign${1===a.totalCampaigns?"":"s"} \xb7 ${a.boostedPosts} boosted post${1===a.boostedPosts?"":"s"}</div>`}},grid:{top:10,right:16,bottom:8,left:0,containLabel:!0},xAxis:{type:"category",data:a,axisLabel:{fontSize:10,color:s.text,interval:a.length>14?"auto":0,rotate:35*(a.length>10)},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",axisLabel:{fontSize:10,color:s.textDim,formatter:e=>r8(e)},splitLine:{lineStyle:{color:"var(--surface-softer)"}},axisLine:{show:!1},axisTick:{show:!1}},series:[{type:"bar",data:t.map(e=>e.totalCost),barMaxWidth:22,itemStyle:{borderRadius:[4,4,0,0],color:"#8B5CF6"}}],animationDuration:800,animationEasing:"cubicOut"}},[e,s]);return(se(r,n,[n]),n)?(0,t.jsx)("div",{ref:r,style:{height:260}}):rH("No dated spend")}function rY({platformBreakdown:e}){let r=(0,a.useRef)(null),s=r4(),{resolvedTheme:n}=(0,H.useTheme)(),l=rU["dark"===n?"dark":"light"],i=(0,a.useMemo)(()=>{if(!e)return null;let t=Object.entries(e).filter(([,e])=>(e.totalPaidViews||0)>0||(e.totalOrganicViews||0)>0);if(!t.length)return null;let a=t.map(([e])=>e.charAt(0).toUpperCase()+e.slice(1));return{tooltip:{...r3(s),trigger:"axis",axisPointer:{type:"shadow"},formatter:e=>{let t=e.reduce((e,t)=>e+(t.value||0),0);return`<div style="font-weight:600">${e[0].name}</div>`+e.map(e=>`<div><span style="color:${e.color}">â</span> ${e.seriesName}: ${r9(e.value)} (${t>0?(e.value/t*100).toFixed(1):0}%)</div>`).join("")}},legend:{bottom:0,textStyle:{fontSize:11,color:s.text},icon:"roundRect",itemWidth:10,itemHeight:10},grid:{top:10,right:16,bottom:36,left:0,containLabel:!0},xAxis:{type:"category",data:a,axisLabel:{fontSize:11,color:s.text},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",axisLabel:{fontSize:10,color:s.textDim,formatter:e=>r6(e)},splitLine:{lineStyle:{color:"var(--surface-softer)"}},axisLine:{show:!1},axisTick:{show:!1}},series:[{name:"Organic views",type:"bar",stack:"views",data:t.map(([,e])=>e.totalOrganicViews||0),barMaxWidth:36,itemStyle:{color:l.organic,borderColor:"transparent",borderWidth:1}},{name:"Paid views",type:"bar",stack:"views",data:t.map(([,e])=>e.totalPaidViews||0),barMaxWidth:36,itemStyle:{color:l.paid,borderRadius:[4,4,0,0],borderColor:"transparent",borderWidth:1}}],animationDuration:800,animationEasing:"cubicOut"}},[e,s,l]);
1return(se(r,i,[i]),i)?(0,t.jsx)("div",{ref:r,style:{height:260}}):rH("No view data")}function rX({campaigns:e}){let r=(0,a.useRef)(null),s=r4(),n=(0,a.useMemo)(()=>{let t=(e||[]).filter(e=>e.totalCost>0&&e.totalPaidViews>0);if(t.length<2)return null;let a=Math.max(...t.map(e=>e.boostedPosts||1));return{tooltip:{...r3(s),trigger:"item",formatter:e=>{let a=t[e.dataIndex];return`<div style="font-weight:600">${a.campaignName}</div><div style="opacity:.7">${a.organizationName||""}</div><div>${r8(a.totalCost)} â ${r9(a.totalPaidViews)} paid views</div><div>$${a.costPerView.toFixed(3)}/view \xb7 ${a.boostedPosts} boosted post${1===a.boostedPosts?"":"s"}</div>`}},grid:{top:16,right:20,bottom:8,left:0,containLabel:!0},xAxis:{type:"value",name:"Spend",nameTextStyle:{fontSize:10,color:s.textDim},axisLabel:{fontSize:10,color:s.textDim,formatter:e=>r8(e)},splitLine:{lineStyle:{color:"var(--surface-softer)"}},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",name:"Paid views",nameTextStyle:{fontSize:10,color:s.textDim},axisLabel:{fontSize:10,color:s.textDim,formatter:e=>r6(e)},splitLine:{lineStyle:{color:"var(--surface-softer)"}},axisLine:{show:!1},axisTick:{show:!1}},series:[{type:"scatter",data:t.map(e=>[e.totalCost,e.totalPaidViews]),symbolSize:(e,r)=>8+22*Math.sqrt((t[r.dataIndex].boostedPosts||1)/a),itemStyle:{color:"#8B5CF6",opacity:.75,borderColor:s.tooltipBg,borderWidth:2},emphasis:{itemStyle:{opacity:1}}}],animationDuration:800}},[e,s]);return(se(r,n,[n]),n)?(0,t.jsx)("div",{ref:r,style:{height:260}}):rH("Needs two or more campaigns with spend and paid views")}function rQ({rows:e}){let r=(0,a.useRef)(null),s=r4(),n=(0,a.useMemo)(()=>{if(!e?.length)return null;let t=[...e].filter(e=>e.totalCost>0).sort((e,t)=>t.totalCost-e.totalCost);if(!t.length)return null;let a=t.slice(0,8),r=t.slice(8).reduce((e,t)=>e+t.totalCost,0),n=a.map((e,t)=>({name:e.vertical,value:e.totalCost,itemStyle:{color:r2[t%r2.length]}}));r>0&&n.push({name:"Other",value:r,itemStyle:{color:"var(--text-disabled)"}});let l=n.reduce((e,t)=>e+t.value,0);return{tooltip:{...r3(s),trigger:"item",formatter:e=>`<div style="font-weight:600">${e.name}</div>${r8(e.value)} (${e.percent}%)`},legend:{bottom:0,type:"scroll",textStyle:{fontSize:10,color:s.text},icon:"circle",itemWidth:8,itemHeight:8},series:[{type:"pie",radius:["46%","68%"],center:["50%","44%"],data:n,label:{show:!1},emphasis:{itemStyle:{shadowBlur:10,shadowColor:"rgba(0,0,0,0.15)"}}}],graphic:[{type:"text",left:"center",top:"38%",style:{text:r8(l),fontSize:18,fontWeight:700,fill:s.textStrong,textAlign:"center"}},{type:"text",left:"center",top:"49%",style:{text:"lifetime spend",fontSize:10,fill:s.textDim,textAlign:"center"}}],animationDuration:1e3}},[e,s]);return(se(r,n,[n]),n)?(0,t.jsx)("div",{ref:r,style:{height:260}}):rH("No spend data")}function rZ({stats:e}){let r=e?.summary||{},s=e?.paidBreakdown,n=r.boostedPosts||0,l=(r.totalCost||0)>0||n>0,i=(0,a.useMemo)(()=>{let e=s?.audience;return e&&(e.byAgeGender?.length||e.byDma?.length||e.byDevice?.length)?[{_id:"rollup",paidAudience:{...e,source:"mixed"===e.source?null:e.source}}]:null},[s]);if(!l)return null;let o=Object.entries(r.paidSources||{}).sort((e,t)=>t[1].posts-e[1].posts).map(([e,t])=>`${rG[e]||(0,rB.sourceLabel)(e)||e} (${r9(t.posts)} post${1===t.posts?"":"s"})`),c=[{icon:rD.BanknotesIcon,label:"Lifetime Spend",value:r8(r.totalCost),fullValue:`$${r9(r.totalCost)}`,sub:`${r9(n)} boosted post${1===n?"":"s"}`,color:"#8B5CF6"},{icon:rV.PlayCircleIcon,label:"Paid Views",value:r6(r.totalPaidViews),fullValue:r9(r.totalPaidViews),sub:r.costPerView>0?`$${r.costPerView.toFixed(3)} per view`:"No view data",color:"#3B82F6"},{icon:eF.ChartBarIcon,label:"Impressions",value:r6(r.totalImpressions),fullValue:r.totalImpressions>0?r9(r.totalImpressions):null,sub:r.costPerThousandViews>0?`${r8(r.costPerThousandViews)} CPM`:"API captures only",color:"#6366F1"},{icon:eP.CursorArrowRaysIcon,label:"Paid CTR",value:r.paidClickThroughRate>0?`${r.paidClickThroughRate.toFixed(2)}%`:"â",sub:`${r6(r.totalClicks)} clicks${r.costPerClick>0?` \xb7 ${r8(r.costPerClick)} each`:""}`,color:"#F59E0B"},{icon:e$.UserGroupIcon,label:"People Reached",value:r.totalReach>0?r6(r.totalReach):"â",fullValue:r.totalReach>
10?r9(r.totalReach):null,sub:r.frequency>0?`${r.frequency.toFixed(2)}\xd7 avg frequency`:"API captures only",color:"#EC4899"},{icon:rL.UserPlusIcon,label:"Follows Gained",value:r.totalFollows>0?r6(r.totalFollows):"â",sub:r.costPerFollow>0?`${r8(r.costPerFollow)} per follow`:"API captures only",color:"#14B8A6"}];return(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsx)("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-2",children:(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5 flex-wrap",children:[(0,t.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0",style:{background:"rgba(139,92,246,0.08)"},children:(0,t.jsx)(O.BoltIcon,{className:"w-3.5 h-3.5",style:{color:"#8B5CF6"}})}),(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100",children:"Paid Media"}),(0,t.jsx)("span",{className:"text-[9px] font-bold uppercase tracking-widest px-2 py-0.5 rounded-full",style:{background:"rgba(139,92,246,0.08)",color:"#7C3AED",border:"1px solid rgba(139,92,246,0.15)"},children:"Spend Signals"})]}),(0,t.jsxs)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mt-1",children:["Lifetime spend and what it bought, across the current filters",o.length>0&&(0,t.jsxs)(t.Fragment,{children:[" · via ",o.join(" · ")]})]})]})}),(0,t.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 xl:grid-cols-6 gap-3",children:c.map(e=>(0,t.jsx)(sa,{...e},e.label))}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,t.jsx)(st,{title:"Spend by Campaign",subtitle:"Lifetime spend, top 8 · label is cost per paid view",children:(0,t.jsx)(rW,{rows:e.campaignBreakdown,nameKey:"campaignName"})}),(0,t.jsx)(st,{title:"Spend by Organization",subtitle:"Where the media budget went",children:(0,t.jsx)(rW,{rows:s?.byOrganization,nameKey:"organizationName",palette:"amber"})})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,t.jsx)(st,{title:"Spend by Month",subtitle:"Lifetime spend by campaign start month",children:(0,t.jsx)(rq,{rows:s?.byMonth})}),(0,t.jsx)(st,{title:"Paid vs Organic Views",subtitle:"Paid views carved out of the reported total, never added",children:(0,t.jsx)(rY,{platformBreakdown:e.platformBreakdown})})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,t.jsx)(st,{title:"Spend Efficiency",subtitle:"Spend vs paid views per campaign · dot size = boosted posts",children:(0,t.jsx)(rX,{campaigns:e.campaignBreakdown})}),(0,t.jsx)(st,{title:"Spend by Vertical",subtitle:"Share of lifetime spend",children:(0,t.jsx)(rQ,{rows:s?.byVertical})})]}),i&&(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 xl:grid-cols-3 gap-4",children:[(0,t.jsx)(rO.default,{posts:i}),(0,t.jsx)(r_.PaidMarketsCard,{posts:i,limit:8}),(0,t.jsx)(r_.PaidDeviceCard,{posts:i})]})]})}var rJ=e.i(247103),r0=e.i(787906),r1=e.i(951467);let r2=["#F59E0B","#6366F1","#10B981","#3B82F6","#EC4899","#8B5CF6","#06B6D4","#F97316","#14B8A6","#EF4444","#84CC16","#A855F7","#0EA5E9","#F43F5E","#22D3EE"],r5={tiktok:"#111827",instagram:"#E1306C",youtube:"#FF0000",twitter:"#1DA1F2",facebook:"#1877F2",snapchat:"#FFFC00"};function r4(){let{resolvedTheme:e}=(0,H.useTheme)();return(0,a.useMemo)(()=>{let t="dark"===e;return{text:t?"#a1a1aa":"var(--text-tertiary)",textDim:t?"#71717a":"var(--text-label)",textStrong:t?"#f4f4f5":"var(--text-primary)",tooltipBg:t?"rgba(20,20,24,0.95)":"rgba(255,255,255,0.95)",tooltipBorder:t?"rgba(255,255,255,0.1)":"rgba(0,0,0,0.1)",gridLine:t?"rgba(255,255,255,0.06)":"rgba(0,0,0,0.04)"}},[e])}let r3=e=>({backgroundColor:e.tooltipBg,borderColor:e.tooltipBorder,borderWidth:1,borderRadius:12,textStyle:{color:e.textStrong,fontSize:12,fontFamily:"Inter, system-ui, sans-serif"}}),r6=e=>{if(null==e||isNaN(e))return"â";let t=Number(e);return t>=1e9?(t/1e9).toFixed(2)+"B":t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toLocaleString()},r9=e=>null==e||isNaN(e)?"â":Math.round(Number(e)).toLocaleString(),r8=e=>{if(null==e||isNaN(e))return"â";let t=Number(e);return t>=1e6?"$"+(t/1e6).toFixed(2)+"M":t>=1e3?"$"+(t/1e3).toFixed(1)+"K":"$"+t.toFixed(2)},r7=e=>null==e||isNaN(e)?"â":Number(e).toFixed(2)+"%";function se(e,t,r=[]){let s=(0,a.useRef)(null);(0,a.useEffect)(()=>
1{if(!e.current)return;s.current||(s.current=rT.init(e.current)),t&&(s.current.setOption(t,!0),s.current.resize());let a=()=>s.current?.resize();return window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},r),(0,a.useEffect)(()=>()=>{s.current&&(s.current.dispose(),s.current=null)},[])}function st({title:e,subtitle:a,badge:r,children:s,className:n=""}){return(0,t.jsxs)("div",{className:`rounded-2xl overflow-hidden h-full flex flex-col ${n}`,style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("div",{className:"p-5 pb-0 flex-shrink-0",children:(0,t.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100",children:e}),a&&(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mt-0.5",children:a})]}),r&&(0,t.jsx)("span",{className:"text-[10px] font-bold px-2 py-0.5 rounded-full",style:{background:"rgba(245,158,11,0.08)",color:"#F59E0B",border:"1px solid rgba(245,158,11,0.15)"},children:r})]})}),(0,t.jsx)("div",{className:"flex-1 p-4 pt-2",children:s})]})}function sa({icon:e,label:a,value:r,fullValue:s,sub:n,color:l}){return(0,t.jsxs)("div",{className:"rounded-2xl p-5 relative overflow-hidden transition-all duration-200 hover:shadow-sm",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center",style:{background:`${l}14`},children:(0,t.jsx)(e,{className:"w-3.5 h-3.5",style:{color:l}})}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500",children:a})]}),(0,t.jsx)("div",{className:"text-2xl font-black text-gray-900 dark:text-zinc-100 tracking-tight leading-none mb-1",children:r}),s&&(0,t.jsx)("div",{className:"text-[10px] font-medium mb-1",style:{color:l,opacity:.7},children:s}),n&&(0,t.jsx)("div",{className:"text-[11px] text-gray-400 dark:text-zinc-500",children:n})]})}function sr({platformData:e}){let r=(0,a.useRef)(null),s=r4();return(se(r,(0,a.useMemo)(()=>{if(!e?.length)return null;let t=e.map(e=>e.name);return{tooltip:{...r3(s),trigger:"axis",axisPointer:{type:"shadow"}},legend:{bottom:0,textStyle:{fontSize:11,color:s.text},icon:"roundRect",itemWidth:10,itemHeight:10},grid:{top:10,right:16,bottom:36,left:0,containLabel:!0},xAxis:{type:"category",data:t,axisLabel:{fontSize:11,color:s.text},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"value",axisLabel:{fontSize:10,color:s.textDim,formatter:e=>r6(e)},splitLine:{lineStyle:{color:"var(--surface-softer)"}},axisLine:{show:!1},axisTick:{show:!1}},series:[{name:"Views",type:"bar",data:e.map(e=>e.views),barMaxWidth:28,itemStyle:{borderRadius:[4,4,0,0],color:"#3B82F6"}},{name:"Engagements",type:"bar",data:e.map(e=>e.engagements),barMaxWidth:28,itemStyle:{borderRadius:[4,4,0,0],color:"#10B981"}}],animationDuration:800,animationEasing:"cubicOut"}},[e,s]),[e,s]),e?.length)?(0,t.jsx)("div",{ref:r,style:{height:260}}):(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-8",children:"No platform data"})}function ss({campaignData:e}){let r=(0,a.useRef)(null),s=r4();return(se(r,(0,a.useMemo)(()=>{if(!e?.length)return null;let t=e.slice(0,8),a=[...t.map(e=>e.name)].reverse(),r=[...t.map(e=>e.views)].reverse();return{tooltip:{...r3(s),trigger:"axis",axisPointer:{type:"shadow"},formatter:e=>`<div style="font-weight:600">${e[0].name}</div><div style="color:#6366F1">${r9(e[0].value)} views</div>`},grid:{top:4,right:16,bottom:4,left:0,containLabel:!0},xAxis:{type:"value",axisLabel:{fontSize:10,color:s.textDim,formatter:e=>r6(e)},splitLine:{lineStyle:{color:"var(--surface-softer)"}},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"category",data:a,axisLabel:{fontSize:10,color:s.text,width:100,overflow:"truncate"},axisLine:{show:!1},axisTick:{show:!1}},series:[{type:"bar",data:r,barMaxWidth:16,itemStyle:{borderRadius:[0,4,4,0],color:new rA.graphic.LinearGradient(0,0,1,0,[{offset:0,color:"#6366F1"},{offset:1,color:"#8B5CF6"}])}}],animationDuration:800,animationEasing:"cubicOut"}}
1,[e,s]),[e,s]),e?.length)?(0,t.jsx)("div",{ref:r,style:{height:260}}):(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-8",children:"No campaign data"})}function sn({creators:e}){let r=(0,a.useRef)(null),s=r4();return(se(r,(0,a.useMemo)(()=>{if(!e?.length)return null;let t=e.slice(0,8),a=e.slice(8).reduce((e,t)=>e+t.totalViews,0),r=t.map((e,t)=>({name:e.creatorName,value:e.totalViews,itemStyle:{color:r2[t%r2.length]}}));a>0&&r.push({name:"Others",value:a,itemStyle:{color:"var(--text-disabled)"}});let n=r.reduce((e,t)=>e+t.value,0);return{tooltip:{...r3(s),trigger:"item",formatter:e=>`<div style="font-weight:600">${e.name}</div>${r9(e.value)} views (${e.percent}%)`},series:[{type:"pie",radius:["48%","72%"],center:["50%","50%"],data:r,label:{show:!1},emphasis:{itemStyle:{shadowBlur:10,shadowColor:"rgba(0,0,0,0.15)"}}}],graphic:[{type:"text",left:"center",top:"45%",style:{text:r6(n),fontSize:18,fontWeight:700,fill:s.textStrong,textAlign:"center"}},{type:"text",left:"center",top:"55%",style:{text:"total views",fontSize:10,fill:s.textDim,textAlign:"center"}}],animationDuration:1e3}},[e,s]),[e,s]),e?.length)?(0,t.jsx)("div",{ref:r,style:{height:260}}):(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-8",children:"No creator data"})}function sl({platformBreakdown:e}){let r=(0,a.useRef)(null),s=r4();return(se(r,(0,a.useMemo)(()=>{if(!e)return null;let t=Object.entries(e);if(!t.length)return null;let a=t.map(([e,t])=>({name:e.charAt(0).toUpperCase()+e.slice(1),value:t.totalEngagements,itemStyle:{color:r5[e]||r2[0]}})).filter(e=>e.value>0);if(!a.length)return null;let r=a.reduce((e,t)=>e+t.value,0);return{tooltip:{...r3(s),trigger:"item",formatter:e=>`<div style="font-weight:600">${e.name}</div>${r9(e.value)} engagements (${e.percent}%)`},series:[{type:"pie",radius:["48%","72%"],center:["50%","50%"],data:a,label:{show:!1},emphasis:{itemStyle:{shadowBlur:10,shadowColor:"rgba(0,0,0,0.15)"}}}],graphic:[{type:"text",left:"center",top:"45%",style:{text:r6(r),fontSize:18,fontWeight:700,fill:s.textStrong,textAlign:"center"}},{type:"text",left:"center",top:"55%",style:{text:"engagements",fontSize:10,fill:s.textDim,textAlign:"center"}}],animationDuration:1e3}},[e,s]),[e,s]),e&&Object.keys(e).length)?(0,t.jsx)("div",{ref:r,style:{height:260}}):(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-8",children:"No data"})}function si({campaigns:e}){let r=(0,a.useRef)(null),s=r4();return(se(r,(0,a.useMemo)(()=>{if(!e?.length)return null;let t=e.filter(e=>e.engagementRate>0).sort((e,t)=>t.engagementRate-e.engagementRate).slice(0,10);if(!t.length)return null;let a=[...t.map(e=>e.campaignName.length>20?e.campaignName.substring(0,20)+"â¦":e.campaignName)].reverse(),r=[...t.map(e=>e.engagementRate)].reverse();return{tooltip:{...r3(s),trigger:"axis",axisPointer:{type:"shadow"},formatter:e=>{let a=e[0],r=t[t.length-1-a.dataIndex];return`<div style="font-weight:600">${r?.campaignName||a.name}</div>ER: ${a.value.toFixed(2)}%`}},grid:{top:4,right:40,bottom:4,left:0,containLabel:!0},xAxis:{type:"value",axisLabel:{fontSize:10,color:s.textDim,formatter:e=>e.toFixed(1)+"%"},splitLine:{lineStyle:{color:"var(--surface-softer)"}},axisLine:{show:!1},axisTick:{show:!1}},yAxis:{type:"category",data:a,axisLabel:{fontSize:10,color:s.text,width:100,overflow:"truncate"},axisLine:{show:!1},axisTick:{show:!1}},series:[{type:"bar",data:r,barMaxWidth:14,itemStyle:{borderRadius:[0,4,4,0],color:new rA.graphic.LinearGradient(0,0,1,0,[{offset:0,color:"#10B981"},{offset:1,color:"#06B6D4"}])},label:{show:!0,position:"right",fontSize:10,color:s.text,formatter:e=>e.value.toFixed(2)+"%"}}],animationDuration:800}},[e,s]),[e,s]),e?.length)?(0,t.jsx)("div",{ref:r,style:{height:280}}):(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-8",children:"No data"})}function so({platformBreakdown:e}){let r=(0,a.useRef)(null),s=r4();return(se(r,(0,a.useMemo)(()=>{if(!e)return null;let t=Object.entries(e).filter(([,e])=>e.totalViews>0);if(!t.length)return null;let a=t.map(([e,t])=>({name:e.charAt(0).toUpperCase()+e.slice(1),value:t.totalViews,itemStyle:{color:r5[e]||r2[0]}})),r=a.reduce((e,t)=>
1e+t.value,0);return{tooltip:{...r3(s),trigger:"item",formatter:e=>`<div style="font-weight:600">${e.name}</div>${r9(e.value)} views (${e.percent}%)`},series:[{type:"pie",radius:["48%","72%"],center:["50%","50%"],data:a,label:{show:!0,position:"outside",fontSize:11,color:s.text,formatter:"{b}\n{d}%"},emphasis:{itemStyle:{shadowBlur:10,shadowColor:"rgba(0,0,0,0.15)"}}}],graphic:[{type:"text",left:"center",top:"45%",style:{text:r6(r),fontSize:18,fontWeight:700,fill:s.textStrong,textAlign:"center"}},{type:"text",left:"center",top:"55%",style:{text:"total views",fontSize:10,fill:s.textDim,textAlign:"center"}}],animationDuration:1e3}},[e,s]),[e,s]),e&&Object.keys(e).length)?(0,t.jsx)("div",{ref:r,style:{height:260}}):(0,t.jsx)("div",{className:"text-xs text-gray-400 dark:text-zinc-500 text-center py-8",children:"No data"})}function sc({label:e,placeholder:r,addPlaceholder:s,selectedItems:n,onChange:l,searchEndpoint:i,idField:o="_id",nameField:c="name",imageField:d="image",accentColor:x="#6366F1"}){let[u,m]=(0,a.useState)(""),[h,f]=(0,a.useState)([]),[b,v]=(0,a.useState)(!1),[y,k]=(0,a.useState)(!1),j=(0,a.useRef)(null),w=(0,a.useRef)(null),N=r4(),C=(0,a.useRef)(null);(0,a.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&v(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[N]);let z=(0,a.useCallback)(e=>{(clearTimeout(j.current),e)?(k(!0),j.current=setTimeout(async()=>{try{let t=await fetch(`${i}${encodeURIComponent(e)}`);
1if(!t.ok)throw Error();let a=await t.json(),r=new Set(n.map(e=>e.id));f((a||[]).filter(e=>!r.has((e[o]||e._id).toString())))}catch{f([])}finally{k(!1)}},280)):f([])},[n,i,o]),S=`${x}14`,E=`${x}26`;return(0,t.jsxs)("div",{ref:w,className:"relative",children:[(0,t.jsx)("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 mb-1.5",children:e}),(0,t.jsxs)("div",{onClick:()=>C.current?.focus(),className:"rounded-xl px-3 py-2 flex flex-wrap items-center gap-1.5 cursor-text min-h-[36px] transition-colors",style:{background:"var(--surface-section)",border:`1px solid ${b?`${x}66`:"var(--border-default)"}`},children:[n.map(e=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium",style:{background:S,color:x,border:`1px solid ${E}`},children:[e.image&&(0,t.jsx)("img",{src:e.image,alt:"",className:"w-3.5 h-3.5 rounded-sm object-cover"}),(0,t.jsx)("span",{className:"max-w-[120px] truncate",children:e.name}),(0,t.jsx)("button",{onClick:t=>{t.stopPropagation(),l(n.filter(t=>t.id!==e.id))},className:"opacity-60 hover:opacity-100",children:(0,t.jsx)(p.XMarkIcon,{className:"w-3 h-3"})})]},e.id)),(0,t.jsxs)("div",{className:"flex items-center flex-1 min-w-[100px] gap-1.5",children:[(0,t.jsx)(g.MagnifyingGlassIcon,{className:"w-3.5 h-3.5 text-gray-300 dark:text-zinc-700 flex-shrink-0"}),(0,t.jsx)("input",{ref:C,value:u,onChange:e=>{m(e.target.value),v(!0),z(e.target.value)},onFocus:()=>v(!0),placeholder:0===n.length?r:s,className:"bg-transparent border-none outline-none text-xs text-gray-900 dark:text-zinc-100 flex-1 min-w-0 p-0"}),y&&(0,t.jsx)(ed.ArrowPathIcon,{className:"w-3.5 h-3.5 text-gray-300 dark:text-zinc-700 animate-spin flex-shrink-0"})]})]}),b&&u&&(0,t.jsx)("div",{className:"absolute top-full mt-1 left-0 right-0 bg-white dark:bg-zinc-950 rounded-xl shadow-lg overflow-hidden z-50",style:{border:"1px solid var(--border-default)"},children:0!==h.length||y?(0,t.jsx)("div",{className:"max-h-[260px] overflow-y-auto",children:h.map(e=>{let a=(e[o]||e._id).toString(),r=e[c]||"Unknown",s=e[d]||null;return(0,t.jsxs)("button",{onClick:()=>{l([...n,{id:a,name:r,image:s}]),m(""),f(e=>e.filter(e=>(e[o]||e._id).toString()!==a)),C.current?.focus()},className:"flex items-center gap-2.5 w-full px-4 py-2.5 text-left hover:bg-gray-50 dark:hover:bg-zinc-900 transition-colors",children:[s?(0,t.jsx)("img",{src:s,alt:"",className:"w-7 h-7 rounded-lg object-cover flex-shrink-0",style:{border:"1px solid var(--border-subtle)"}}):(0,t.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0",style:{background:S},children:(0,t.jsx)("span",{className:"text-[10px] font-bold",style:{color:x},children:r?.[0]?.toUpperCase()||"?"})}),(0,t.jsx)("span",{className:"text-xs font-semibold text-gray-900 dark:text-zinc-100 truncate",children:r})]},a)})}):(0,t.jsxs)("div",{className:"px-4 py-3 text-xs text-gray-400 dark:text-zinc-500 text-center",children:["No results for â",u,"â"]})})]})}function sd({label:e,sortKey:a,currentSort:r,onSort:s,align:n="right"}){let l=r.key===a,i=l&&"asc"===r.dir;return(0,t.jsx)("th",{className:"px-4 py-2.5 text-[9px] font-bold uppercase tracking-wider whitespace-nowrap cursor-pointer select-none group transition-colors hover:bg-white/40 dark:hover:bg-zinc-950/40 dark:bg-zinc-950/40",style:{textAlign:n,borderBottom:"1px solid var(--border-subtle)",color:l?"#6366F1":"var(--text-label)"},onClick:()=>s(a),children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[e,(0,t.jsxs)("span",{className:"inline-flex flex-col -space-y-0.5",children:[(0,t.jsx)(tj.ChevronUpIcon,{className:`w-2 h-2 transition-colors ${l&&i?"text-indigo-500":"text-gray-300 dark:text-zinc-700 group-hover:text-gray-400 dark:group-hover:text-zinc-500"}`}),(0,t.jsx)(e5.ChevronDownIcon,{className:`w-2 h-2 transition-colors ${l&&!i?"text-indigo-500":"text-gray-300 dark:text-zinc-700 group-hover:text-gray-400 dark:group-hover:text-zinc-500"}`})]})]})})}let sx=[{id:"overview",label:"Overview",description:"Raw totals. Top creators by views, with engagement, reach, and boost spend."},{id:"mostValuable",label:"Most Valuable",description:"Best results for the money. Ranks creators 0â100 on views per follower, typical views per post, organic share, and cost per view, each compared against creators of similar size."},{id:"undervalued",label:"Undervalued",description:"Creators punching above their weight. Views per follower and organic share beat at least half of creators in the same follower tier, and cost per view is below the tier median
1when cost is known."},{id:"paidReady",label:"Paid-Ready",description:"Where boost dollars go furthest. Creators with boost spend, ranked by cheapest CPM, with cost per click, cost per follow, and organic views per dollar."}],su={overview:{minPosts:1,hasBoostSpend:!1,sort:{key:"totalViews",dir:"desc"},columns:["creator","totalPosts","totalViews","totalEngagements","totalFollowersReached","engagementRate","clickThroughRate","totalCost","costPerView","costPerFollow"]},mostValuable:{minPosts:3,hasBoostSpend:!1,sort:{key:"valueScore",dir:"desc"},columns:["creator","totalPosts","totalViews","medianViewsPerPost","reachMultiplier","organicShare","trueCost","trueCostPerView","valueScore"]},undervalued:{minPosts:3,hasBoostSpend:!1,sort:{key:"pct.reachMultiplier",dir:"desc"},columns:["creatorTier","totalPosts","followers","medianViewsPerPostPct","reachMultiplierPct","organicSharePct","campaignCount","trueCostPerViewPct"]},paidReady:{minPosts:3,hasBoostSpend:!0,sort:{key:"costPerThousandViews",dir:"asc"},columns:["creator","boostedPosts","totalCost","totalPaidViews","costPerThousandViews","costPerClick","costPerFollow","organicViewsPerDollar","engagementsPerDollar"]}};function sm(e){let t=e?.pct;if(!t)return!1;let{reachMultiplier:a,organicShare:r,trueCostPerView:s}=t;return null!=a&&null!=r&&!(a<50)&&!(r<50)&&(!((e.trueCost||0)>0)||null!=s&&!(s<50))}function sg(e,t){if(!t||-1===t.indexOf("."))return e?.[t];let[a,r]=t.split("."),s=e?.[a];return null==s?null:s[r]}function sp(e,t,a){return e.map((e,t)=>({row:e,i:t})).sort((e,r)=>{let s=sg(e.row,t),n=sg(r.row,t),l=null==s,i=null==n;return l&&i?e.i-r.i:l?1:i?-1:"string"==typeof s||"string"==typeof n?"asc"===a?String(s).localeCompare(String(n)):String(n).localeCompare(String(s)):"asc"===a?s-n:n-s}).map(e=>e.row)}let sh={nano:"Nano",micro:"Micro",mid:"Mid",macro:"Macro"},sf={nano:"#6B7280",micro:"#3B82F6",mid:"#8B5CF6",macro:"#F97316"};function sb({tier:e}){if(!e||!sh[e])return null;let a=sf[e];return(0,t.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full text-[9px] font-bold uppercase tracking-wide flex-shrink-0",style:{background:`${a}14`,border:`1px solid ${a}25`,color:a},children:sh[e]})}function sv({creator:e,showTier:a,hideFollowersSub:r}){return(0,t.jsxs)("div",{className:"flex items-center gap-2.5",children:[e.creatorImage?(0,t.jsx)("img",{src:e.creatorImage,alt:e.creatorName,className:"w-8 h-8 rounded-full object-cover flex-shrink-0",style:{border:"1px solid var(--border-subtle)"}}):(0,t.jsx)("div",{className:"w-8 h-8 rounded-full flex items-center justify-center flex-shrink-0",style:{background:"rgba(236,72,153,0.08)",border:"1px solid rgba(236,72,153,0.15)"},children:(0,t.jsx)("span",{className:"text-[10px] font-bold text-pink-500",children:e.creatorName?.[0]?.toUpperCase()||"?"})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5 flex-wrap",children:[(0,t.jsx)("span",{className:"text-xs font-semibold text-gray-900 dark:text-zinc-100 truncate",children:e.creatorName}),a&&(0,t.jsx)(sb,{tier:e.followerTier})]}),!r&&e.followers>0&&(0,t.jsxs)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500",children:[r6(e.followers)," followers"]})]})]})}function sy({value:e}){if(null==e)return(0,t.jsx)("span",{className:"text-xs text-gray-300 dark:text-zinc-700",children:"â"});let a=Math.max(0,Math.min(100,e)),r=a>=66?"#10B981":a>=33?"#F59E0B":"#EF4444";return(0,t.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,t.jsx)("div",{className:"w-12 h-1.5 rounded-full overflow-hidden flex-shrink-0",style:{background:"var(--surface-softer)"},children:(0,t.jsx)("div",{className:"h-full rounded-full",style:{width:`${a}%`,background:r}})}),(0,t.jsx)("span",{className:"text-xs font-bold tabular-nums",style:{color:r},children:a.toFixed(1)})]})}let sk=(0,t.jsx)("span",{className:"text-xs text-gray-300 dark:text-zinc-700",children:"â"});function sj(e,a="#3B82F6"){return e>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"text-xs font-bold",style:{color:a},children:r6(e)}),(0,t.jsx)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500",children:r9(e)})]}):sk}function sw(e,a){return e>0?(0,t.jsx)("span",{className:"text-xs font-bold tabular-nums",style:{color:a},children:r8(e)}
1):sk}function sN(e,a){return e>0?(0,t.jsxs)("span",{className:"text-xs font-medium tabular-nums",style:{color:a},children:["$",e.toFixed(3)]}):sk}function sC(e,a=""){return e>0?(0,t.jsxs)("span",{className:"text-xs font-semibold tabular-nums text-gray-700 dark:text-zinc-300",children:[e.toFixed(1),a]}):sk}let sz={creator:{label:"Creator",sortKey:"creatorName",align:"left",cell:e=>(0,t.jsx)(sv,{creator:e})},creatorTier:{label:"Creator",sortKey:"creatorName",align:"left",cell:e=>(0,t.jsx)(sv,{creator:e,showTier:!0,hideFollowersSub:!0})},totalPosts:{label:"Posts",sortKey:"totalPosts",align:"right",cell:e=>(0,t.jsx)("span",{className:"text-xs font-medium text-gray-500 dark:text-zinc-400",children:e.totalPosts})},boostedPosts:{label:"Boosted Posts",sortKey:"boostedPosts",align:"right",cell:e=>(0,t.jsx)("span",{className:"text-xs font-medium text-gray-500 dark:text-zinc-400",children:e.boostedPosts||0})},campaignCount:{label:"Campaigns",sortKey:"campaignCount",align:"right",cell:e=>(0,t.jsx)("span",{className:"text-xs font-medium text-gray-500 dark:text-zinc-400",children:e.campaignCount||0})},followers:{label:"Followers",sortKey:"followers",align:"right",cell:e=>(0,t.jsx)("span",{className:"text-xs font-semibold text-gray-700 dark:text-zinc-300",children:r6(e.followers)})},totalViews:{label:"Views",sortKey:"totalViews",align:"right",cell:e=>sj(e.totalViews,"#3B82F6")},medianViewsPerPost:{label:"Median Views",sortKey:"medianViewsPerPost",align:"right",cell:e=>sj(e.medianViewsPerPost,"#3B82F6")},medianViewsPerPostPct:{label:"Median Views",sortKey:"pct.medianViewsPerPost",align:"right",cell:e=>sj(e.medianViewsPerPost,"#3B82F6")},totalEngagements:{label:"Engagements",sortKey:"totalEngagements",align:"right",cell:e=>(0,t.jsx)("span",{className:"text-xs font-bold text-gray-700 dark:text-zinc-300",children:r6(e.totalEngagements)})},totalFollowersReached:{label:"Followers Reached",sortKey:"totalFollowersReached",align:"right",cell:e=>(0,t.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,t.jsx)(e$.UserGroupIcon,{className:"w-3 h-3 text-pink-400"}),(0,t.jsx)("span",{className:"text-xs font-bold",style:{color:"#EC4899"},children:r6(e.totalFollowersReached)})]})},engagementRate:{label:"Eng. Rate",sortKey:"engagementRate",align:"right",cell:e=>(0,t.jsx)("span",{className:"text-xs font-medium",style:{color:"#10B981"},children:r7(e.engagementRate)})},clickThroughRate:{label:"CTR",sortKey:"clickThroughRate",align:"right",cell:e=>(0,t.jsx)("span",{className:"text-xs font-medium",style:{color:"#8B5CF6"},children:r7(e.clickThroughRate)})},reachMultiplier:{label:"Reach Ã",sortKey:"reachMultiplier",align:"right",cell:e=>sC(e.reachMultiplier,"Ã")},reachMultiplierPct:{label:"Reach Ã",sortKey:"pct.reachMultiplier",align:"right",cell:e=>sC(e.reachMultiplier,"Ã")},organicShare:{label:"Organic Share",sortKey:"organicShare",align:"right",cell:e=>e.organicShare>0?(0,t.jsx)("span",{className:"text-xs font-medium",style:{color:"#F59E0B"},children:r7(e.organicShare)}):sk},organicSharePct:{label:"Organic Share",sortKey:"pct.organicShare",align:"right",cell:e=>e.organicShare>0?(0,t.jsx)("span",{className:"text-xs font-medium",style:{color:"#F59E0B"},children:r7(e.organicShare)}):sk},organicViewsPerDollar:{label:"Organic Views / $",sortKey:"organicViewsPerDollar",align:"right",cell:e=>sC(e.organicViewsPerDollar)},engagementsPerDollar:{label:"Eng. / $",sortKey:"engagementsPerDollar",align:"right",cell:e=>sC(e.engagementsPerDollar)},totalPaidViews:{label:"Paid Views",sortKey:"totalPaidViews",align:"right",cell:e=>e.totalPaidViews>0?(0,t.jsx)("span",{className:"text-xs font-semibold",style:{color:"#8B5CF6"},children:r6(e.totalPaidViews)}):sk}
1,costPerThousandViews:{label:"CPM",sortKey:"costPerThousandViews",align:"right",cell:e=>sw(e.costPerThousandViews,"#F59E0B")},costPerClick:{label:"Cost / Click",sortKey:"costPerClick",align:"right",cell:e=>sw(e.costPerClick,"#F97316")},totalCost:{label:"Boost Spend",sortKey:"totalCost",align:"right",cell:e=>e.totalCost>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"text-xs font-bold text-gray-700 dark:text-zinc-300 tabular-nums",children:r8(e.totalCost)}),(0,t.jsxs)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500",children:[e.boostedPosts," boosted"]})]}):sk},costPerView:{label:"Cost / View",sortKey:"costPerView",align:"right",cell:e=>sN(e.costPerView,"#06B6D4")},costPerFollow:{label:"Cost / Follow",sortKey:"costPerFollow",align:"right",cell:e=>sw(e.costPerFollow,"#14B8A6")},trueCost:{label:"True Cost",sortKey:"trueCost",align:"right",cell:e=>e.trueCost>0?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"text-xs font-bold text-gray-700 dark:text-zinc-300 tabular-nums",children:r8(e.trueCost)}),"none"===e.bookingCostSource&&(0,t.jsx)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500",children:"boost only"})]}):sk},trueCostPerView:{label:"True Cost / View",sortKey:"trueCostPerView",align:"right",cell:e=>sN(e.trueCostPerView,"#06B6D4")},trueCostPerViewPct:{label:"True Cost / View",sortKey:"pct.trueCostPerView",align:"right",cell:e=>sN(e.trueCostPerView,"#06B6D4")},valueScore:{label:"Value Score",sortKey:"valueScore",align:"right",cell:e=>(0,t.jsx)(sy,{value:e.valueScore})}},sS=()=>{let[e,s]=(0,a.useState)(null),[n,l]=(0,a.useState)(!0),[i,o]=(0,a.useState)(null),[c,d]=(0,a.useState)(!1),x=(0,r.useRouter)(),u=r4(),[m,g]=(0,a.useState)({platform:"",organization:"",vertical:"",status:"",primaryGoal:"",tag:"",startDate:"",endDate:""}),[h,f]=(0,a.useState)([]),[b,v]=(0,a.useState)([]),[y,k]=(0,a.useState)({key:"totalViews",dir:"desc"}),[j,w]=(0,a.useState)({key:"totalViews",dir:"desc"}),[N,C]=(0,a.useState)("overview"),[z,S]=(0,a.useState)(su.overview.minPosts),[E,P]=(0,a.useState)("all"),[$,M]=(0,a.useState)(su.overview.hasBoostSpend),F=e=>{k(t=>({key:e,dir:t.key===e&&"desc"===t.dir?"asc":"desc"}))},I=(0,a.useMemo)(()=>{if(!e?.creatorBreakdown)return[];let t=e.creatorBreakdown.filter(e=>(e.totalPosts||0)>=z);return"all"!==E&&(t=t.filter(e=>e.followerTier===E)),$&&(t=t.filter(e=>(e.boostCost||0)>0)),"undervalued"===N&&(t=t.filter(sm)),t},[e,z,E,$,N]),R=(0,a.useMemo)(()=>{let{key:e,dir:t}=y;if("overview"===N){let a=sp(I,"totalViews","desc").slice(0,10);return sp(a,e,t)}return sp(I,e,t)},[I,y,N]),T=e?.creatorBreakdown?.length||0,A=I.length,D=(0,a.useMemo)(()=>I.filter(e=>(e.trueCost||0)>0).length,[I]),V=su[N]?.columns||su.overview.columns,L=(0,a.useMemo)(()=>{if(!e?.campaignBreakdown)return[];let t=[...e.campaignBreakdown],{key:a,dir:r}=j;return t.sort((e,t)=>{let s=e[a]??0,n=t[a]??0;return"string"==typeof s?"asc"===r?s.localeCompare(n):n.localeCompare(s):"asc"===r?s-n:n-s}),t},[e,j]),B=(0,a.useMemo)(()=>{if(!e?.campaignBreakdown)return[];let t=new Map;return e.campaignBreakdown.forEach(e=>{e.organizationId&&e.organizationName&&!t.has(e.organizationId)&&t.set(e.organizationId,e.organizationName)}),Array.from(t.entries()).map(([e,t])=>({id:e,name:t})).sort((e,t)=>e.name.localeCompare(t.name))},[e]),O=async()=>{l(!0),o(null);try{let e=new URLSearchParams;Object.entries(m).forEach(([t,a])=>{a&&e.append(t,a)}),h.length>0&&e.append("campaigns",h.map(e=>e.id).join(",")),b.length>0&&e.append("creators",b.map(e=>e.id).join(","));let t=await fetch(`https://www.socialscout.ai/api/homeHeroStats?${e.toString()}`);if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||"Failed to fetch campaign statistics")}s(await t.json())}catch(e){o(e.message||"An error occurred")}finally{l(!1)}};(0,a.useEffect)(()=>{O()},[]);let _=e=>{let{name:t,value:a}=e.target;g(e=>({...e,[t]:a}))},U=()=>{g({platform:"",organization:"",vertical:"",status:"",primaryGoal:"",tag:"",startDate:"",endDate:""}),f([]),v([])},G=Object.values(m).filter(Boolean).length+h.length+b.length;if(n&&!e)return(0,t.jsxs)("div",{className:"flex items-center justify-center gap-3 rounded-2xl h-[300px]",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)(ed.ArrowPathIcon,{className:"w-5 h-5 text-gray-300 dark:text-zinc-700 animate-spin"}),(0,t.jsx)("span",{className:"text-xs font-medium text-gray-400 dark:text-zinc-500",children:"Fetching campaign dataâ¦"})]});if(i&&!e)return(0,t.jsxs)("div",{className:"rounded-2xl p-8",style:{background:"rgba(239,68,68,0.04)",border:"1px solid rgba(239,68,68,0.12)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,t.jsx)(r1.ExclamationCircleIcon,{className:"w-4 h-4 text-red-500"}),(0,t.jsx)("span",{className:"text-sm font-semibold text-red-600",children:"Error loading statistics"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-500 dark:text-zinc-400 mb-4",children:i}),(0,t.jsxs)("button",{onClick:O,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-semibold text-gray-600 dark:text-zinc-400 transition-colors hover:bg-gray-100 dark:hover:bg-zinc-900",style:{background:"var(--surface-softer)",border:"1px solid var(--border-default)"},children:[(0,t.jsx)(ed.ArrowPathIcon,{className:"w-3.5 h-3.5"})," Retry"]})]});let H=e?.summary||{},K=e?e?.platformBreakdown?Object.entries(e.platformBreakdown).map(([e,t])=>({name:e.charAt(0).toUpperCase()+e.slice(1),views:t.totalViews,engagements:t.totalEngagements})):[]:[],W=e?e?.campaignBreakdown?e.campaignBreakdown.slice(0,8).map(e=>({name:e.campaignName.length>22?e.campaignName.substring(0,22)+"â¦":e.campaignName,views:e.totalViews})):[]:[],q="w-full rounded-xl px-3 py-2 text-xs text-gray-700 dark:text-zinc-300 outline-none transition-colors appearance-none cursor-pointer",Y={background:"var(--surface-section)",border:"1px solid var(--border-default)"},X=[...h.map(e=>({label:e.name,type:"campaign",id:e.id})),...b.map(e=>({label:e.name,type:"creator",id:e.id})),...m.platform?[{label:m.platform,type:"filter",key:"platform"}]:[],...m.status?[{label:m.status,type:"filter",key:"status"}]:[],...m.vertical?[{label:m.vertical,type:"filter",key:"vertical"}]:[],...m.organization?[{label:B.find(e=>e.id===m.organization)?.name||"Org",type:"filter",key:"organization"}]:[],...m.primaryGoal?[{label:m.primaryGoal,type:"filter",key:"primaryGoal"}]:[],...m.startDate?[{label:`From ${m.startDate}`,type:"filter",key:"startDate"}
1]:[],...m.endDate?[{label:`Until ${m.endDate}`,type:"filter",key:"endDate"}]:[]];return(0,t.jsxs)("div",{className:"rounded-2xl overflow-hidden",style:{background:"var(--surface-section)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"px-6 py-5 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",style:{borderBottom:"1px solid var(--border-subtle)",background:"linear-gradient(135deg, rgba(245,158,11,0.03) 0%, transparent 60%)"},children:[(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5 mb-1",children:[(0,t.jsxs)("div",{className:"relative flex h-2.5 w-2.5",children:[(0,t.jsx)("span",{className:"absolute inline-flex h-full w-full rounded-full opacity-75 animate-ping",style:{background:"#10B981"}}),(0,t.jsx)("span",{className:"relative inline-flex h-2.5 w-2.5 rounded-full",style:{background:"#10B981"}})]}),(0,t.jsx)("h2",{className:"text-base font-bold text-gray-900 dark:text-zinc-100 tracking-tight",children:"Campaign Intelligence"}),(0,t.jsx)("span",{className:"text-[9px] font-bold uppercase tracking-widest px-2 py-0.5 rounded-full",style:{background:"linear-gradient(135deg, rgba(245,158,11,0.08), rgba(249,115,22,0.08))",color:"#D97706",border:"1px solid rgba(245,158,11,0.15)"},children:"Live"})]}),(0,t.jsx)("p",{className:"text-xs text-gray-400 dark:text-zinc-500 ml-5",children:G>0?`${G} filter${G>1?"s":""} active \xb7 ${H.totalPosts||0} posts across ${H.totalCampaigns||0} campaigns`:"Real-time performance across all campaigns"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[G>0&&(0,t.jsx)("span",{className:"w-5 h-5 rounded-full flex items-center justify-center text-[10px] font-bold text-white",style:{background:"#6366F1"},children:G}),(0,t.jsxs)("button",{onClick:()=>d(!c),className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold transition-colors",style:c?{background:"rgba(99,102,241,0.08)",color:"#6366F1",border:"1px solid rgba(99,102,241,0.15)"}:{background:"var(--surface-softer)",color:u.text,border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)(e1.FunnelIcon,{className:"w-3.5 h-3.5"})," Filters"]}),(0,t.jsxs)("button",{onClick:()=>(function(e){if(!e)return;let t=e.summary,a=[];a.push("CAMPAIGN INTELLIGENCE REPORT"),a.push(`Generated,${new Date().toLocaleDateString()}`),a.push(""),a.push("SUMMARY"),a.push(`Total Posts,${t.totalPosts}`),a.push(`Total Views,${t.totalViews}`),a.push(`Total Engagements,${t.totalEngagements}`),a.push(`Total Clicks,${t.totalClicks}`),a.push(`Followers Reached,${t.totalFollowersReached}`),a.push(`Unique Creators,${t.totalUniqueCreators}`),a.push(`Total Campaigns,${t.totalCampaigns}`),a.push(`Engagement Rate,${t.engagementRate}%`),a.push(`Click-Through Rate,${t.clickThroughRate}%`),a.push(""),a.push("PAID MEDIA"),a.push(`Lifetime Spend,${t.totalCost||0}`),a.push(`Boosted Posts,${t.boostedPosts||0}`),a.push(`Paid Views,${t.totalPaidViews||0}`),a.push(`Impressions,${t.totalImpressions||0}`),a.push(`Reach,${t.totalReach||0}`),a.push(`Follows,${t.totalFollows||0}`),a.push(`Cost Per View,${t.costPerView||0}`),a.push(`CPM,${t.costPerThousandViews||0}`),a.push(`Cost Per Follow,${t.costPerFollow||0}`),e.platformBreakdown&&(a.push(""),a.push("PLATFORM BREAKDOWN"),a.push("Platform,Posts,Views,Engagements,Clicks,Followers Reached,ER%,CTR%,Spend,Paid Views,Cost Per View"),Object.entries(e.platformBreakdown).forEach(([e,t])=>{a.push(`${e},${t.totalPosts},${t.totalViews},${t.totalEngagements},${t.totalClicks},${t.totalFollowersReached},${t.engagementRate},${t.clickThroughRate},${t.totalCost||0},${t.totalPaidViews||0},${t.costPerView||0}`)})),e.campaignBreakdown?.length&&(a.push(""),a.push("CAMPAIGN BREAKDOWN"),a.push("Campaign,Organization,Vertical,Posts,Views,Engagements,Clicks,Followers Reached,ER%,CTR%,Spend,Paid Views,Cost Per View,Reach,Follows"),e.campaignBreakdown.forEach(e=>{a.push(`"${e.campaignName}","${e.organizationName||""}","${e.organizationVertical||""}",${e.totalPosts},${e.totalViews},${e.totalEngagements},${e.totalClicks},${e.totalFollowersReached||0},${e.engagementRate},${e.clickThroughRate},${e.totalCost||0},${e.totalPaidViews||0},${e.costPerView||0},${e.totalReach||0},${e.totalFollows||0}`)})),e.creatorBreakdown?.length&&(a.push(""),a.push("CREATOR BREAKDOWN"),a.push("Creator,Category,Posts,Views,Engagements,Clicks,Followers,Followers Reached,ER%,CTR%,Spend,Cost Per View,Cost Per Follow,Follower Tier,Campaigns,Organizations,Median Views Per Post,Reach Multiplier,Organic Share %,Organic Views Per $,Engagements Per $,Boost Cost,Booking Cost,Booking Cost Source,True Cost,True Cost Per View,True Cost Per Engagement,Value Score"),e.creatorBreakdown.forEach(e
1=>{a.push(`"${e.creatorName}","${e.creatorCategory||""}",${e.totalPosts},${e.totalViews},${e.totalEngagements},${e.totalClicks},${e.followers},${e.totalFollowersReached||0},${e.engagementRate},${e.clickThroughRate},${e.totalCost||0},${e.costPerView||0},${e.costPerFollow||0},${e.followerTier||""},${e.campaignCount||0},${e.organizationCount||0},${e.medianViewsPerPost||0},${e.reachMultiplier||0},${e.organicShare||0},${e.organicViewsPerDollar||0},${e.engagementsPerDollar||0},${e.boostCost||0},${e.bookingCost||0},${e.bookingCostSource||"none"},${e.trueCost||0},${e.trueCostPerView||0},${e.trueCostPerEngagement||0},${null!=e.valueScore?e.valueScore:""}`)})),e.paidBreakdown?.byOrganization?.length&&(a.push(""),a.push("SPEND BY ORGANIZATION"),a.push("Organization,Vertical,Campaigns,Boosted Posts,Spend,Paid Views,Cost Per View"),e.paidBreakdown.byOrganization.forEach(e=>{a.push(`"${e.organizationName}","${e.organizationVertical||""}",${e.totalCampaigns},${e.boostedPosts},${e.totalCost},${e.totalPaidViews},${e.costPerView}`)})),e.paidBreakdown?.byMonth?.length&&(a.push(""),a.push("SPEND BY CAMPAIGN START MONTH"),a.push("Month,Campaigns,Boosted Posts,Spend,Paid Views"),e.paidBreakdown.byMonth.forEach(e=>{a.push(`${e.month},${e.totalCampaigns},${e.boostedPosts},${e.totalCost},${e.totalPaidViews}`)})),e.filters&&(a.push(""),a.push("ACTIVE FILTERS"),Object.entries(e.filters).forEach(([e,t])=>{t&&"null"!==t&&a.push(`${e},"${"object"==typeof t?JSON.stringify(t):t}"`)}));let r=new Blob([a.join("\n")],{type:"text/csv;charset=utf-8;"}),s=URL.createObjectURL(r),n=document.createElement("a");n.href=s,n.download=`campaign_intelligence_report_${new Date().toISOString().split("T")[0]}.csv`,n.style.visibility="hidden",document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)})(e),disabled:!e,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold text-gray-500 dark:text-zinc-400 transition-colors hover:bg-gray-100 dark:hover:bg-zinc-900 disabled:opacity-40",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)(aJ.ArrowDownTrayIcon,{className:"w-3.5 h-3.5"})," Export"]}),(0,t.jsxs)("button",{onClick:O,disabled:n,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-semibold text-gray-500 dark:text-zinc-400 transition-colors hover:bg-gray-100 dark:hover:bg-zinc-900 disabled:opacity-40",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)(ed.ArrowPathIcon,{className:`w-3.5 h-3.5 ${n?"animate-spin":""}`})," Refresh"]})]})]}),X.length>0&&!c&&(0,t.jsxs)("div",{className:"px-6 py-2.5 flex items-center gap-2 flex-wrap",style:{background:"var(--surface-frosted)",borderBottom:"1px solid var(--surface-softer)"},children:[(0,t.jsx)("span",{className:"text-[9px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 flex-shrink-0",children:"Active:"}),X.map((e,a)=>(0,t.jsxs)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[11px] font-medium",style:"creator"===e.type?{background:"rgba(236,72,153,0.08)",color:"#EC4899",border:"1px solid rgba(236,72,153,0.15)"}:"campaign"===e.type?{background:"rgba(99,102,241,0.08)",color:"#6366F1",border:"1px solid rgba(99,102,241,0.15)"}:{background:"var(--surface-softer)",color:u.text,border:"1px solid var(--border-subtle)"},children:[e.label,(0,t.jsx)("button",{onClick:()=>{"campaign"===e.type?f(t=>t.filter(t=>t.id!==e.id)):"creator"===e.type?v(t=>t.filter(t=>t.id!==e.id)):g(t=>({...t,[e.key]:""}))},className:"opacity-50 hover:opacity-100",children:(0,t.jsx)(p.XMarkIcon,{className:"w-3 h-3"})})]},`${e.type}-${e.id||e.key}-${a}`)),(0,t.jsx)("button",{onClick:()=>{U(),setTimeout(O,0)},className:"text-[11px] text-gray-400 dark:text-zinc-500 hover:text-gray-600 dark:hover:text-zinc-400 transition-colors",children:"Clear all"})]}),c&&(0,t.jsx)("div",{className:"px-6 py-5",style:{background:"var(--surface-frosted)",borderBottom:"1px solid var(--border-subtle)"},children:(0,t.jsxs)("form",{onSubmit:e=>{e.preventDefault(),O()},children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 mb-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 mb-1.5",children:"Platform"}),(0,t.jsxs)("select",{name:"platform",value:m.platform,onChange:_,className:q,style:Y,children:[(0,t.jsx)("option",{value:"",children:"All Platforms"}),(0,t.jsx)("option",{value:"tiktok",children:"TikTok"}),(0,t.jsx)("option",{value:"youtube",children:"YouTube"}),(0,t.jsx)("option",{value:"instagram",children:"Instagram"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 mb-1.5",children:"Status"}),(0,t.jsxs)("select",{name:"status",value:m.status,onChange:_,className:q,style:Y,children:[(0,t.jsx)("option",{value:"",children:"All Statuses"}),(0,t.jsx)("option",{value:"Live",children:"Live"}),(0,t.jsx)("option",{value:"Wrapped",children:"Wrapped"}),(0,t.jsx)("option",{value:"Created",children:"Created"}),(0,t.jsx)("option",{value:"In Progress",children:"In Progress"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 mb-1.5",children:"Vertical"}
1),(0,t.jsxs)("select",{name:"vertical",value:m.vertical,onChange:_,className:q,style:Y,children:[(0,t.jsx)("option",{value:"",children:"All Verticals"}),as.campaignVerticals.map(e=>(0,t.jsx)("option",{value:e,children:e},e))]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 mb-1.5",children:"Organization"}),(0,t.jsxs)("select",{name:"organization",value:m.organization,onChange:_,className:q,style:Y,children:[(0,t.jsx)("option",{value:"",children:"All Organizations"}),B.map(e=>(0,t.jsx)("option",{value:e.id,children:e.name},e.id))]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 mb-1.5",children:"Primary Goal"}),(0,t.jsxs)("select",{name:"primaryGoal",value:m.primaryGoal,onChange:_,className:q,style:Y,children:[(0,t.jsx)("option",{value:"",children:"All Goals"}),(0,t.jsx)("option",{value:"views",children:"Views"}),(0,t.jsx)("option",{value:"engagements",children:"Engagements"}),(0,t.jsx)("option",{value:"clicks",children:"Clicks"}),(0,t.jsx)("option",{value:"posts",children:"Posts"}),(0,t.jsx)("option",{value:"subscriber_reach",children:"Subscriber Reach"}),(0,t.jsx)("option",{value:"er",children:"Engagement Rate"}),(0,t.jsx)("option",{value:"ctr",children:"Click-Through Rate"})]})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 mb-1.5",children:"Start Date"}),(0,t.jsx)("input",{type:"date",value:m.startDate,onChange:e=>g(t=>({...t,startDate:e.target.value})),className:q,style:Y})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("label",{className:"block text-[10px] font-bold uppercase tracking-wider text-gray-400 dark:text-zinc-500 mb-1.5",children:"End Date"}),(0,t.jsx)("input",{type:"date",value:m.endDate,onChange:e=>g(t=>({...t,endDate:e.target.value})),className:q,style:Y})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mb-4",children:[(0,t.jsx)(sc,{label:"Campaigns",placeholder:"Search campaignsâ¦",addPlaceholder:"Add moreâ¦",selectedItems:h,onChange:f,searchEndpoint:"https://www.socialscout.ai/api/searchAutoCompleteCampaigns?query=",accentColor:"#6366F1"}),(0,t.jsx)(sc,{label:"Creators",placeholder:"Search creatorsâ¦",addPlaceholder:"Add moreâ¦",selectedItems:b,onChange:v,searchEndpoint:"https://www.socialscout.ai/api/searchAutoCompleteCreators?query=",accentColor:"#EC4899"})]}),(0,t.jsxs)("div",{className:"flex gap-2 justify-end",children:[(0,t.jsx)("button",{type:"button",onClick:U,className:"px-3 py-1.5 rounded-full text-xs font-semibold text-gray-400 dark:text-zinc-500 transition-colors hover:bg-gray-100 dark:hover:bg-zinc-900",style:{border:"1px solid var(--border-subtle)"},children:"Clear all"}),(0,t.jsxs)("button",{type:"submit",className:"flex items-center gap-1.5 px-4 py-1.5 rounded-full text-xs font-semibold text-white transition-all hover:scale-105",style:{background:"linear-gradient(135deg, #6366F1, #8B5CF6)"},children:[(0,t.jsx)(r0.CheckIcon,{className:"w-3.5 h-3.5"})," Apply",G>0?` \xb7 ${G} filter${G>1?"s":""}`:""]})]})]})}),e&&(0,t.jsxs)("div",{className:"p-6 space-y-6",children:[(0,t.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3",children:[(0,t.jsx)(sa,{icon:eE.EyeIcon,label:"Total Views",value:r6(H.totalViews),fullValue:r9(H.totalViews),sub:`Across ${r9(H.totalPosts)} posts`,color:"#3B82F6"}),(0,t.jsx)(sa,{icon:eM.ArrowTrendingUpIcon,label:"Engagement Rate",value:r7(H.engagementRate),sub:`${r6(H.totalEngagements)} engagements`,color:"#10B981"}),(0,t.jsx)(sa,{icon:eP.CursorArrowRaysIcon,label:"Click-Through Rate",value:r7(H.clickThroughRate),sub:`${r6(H.totalClicks)} clicks \xb7 ${r6(H.totalProfileVisits)} visits`,color:"#8B5CF6"}),(0,t.jsx)(sa,{icon:es.MegaphoneIcon,label:"Creators",value:(H.totalUniqueCreators||0).toLocaleString(),sub:`Across ${H.totalCampaigns??0} campaigns`,color:"#F59E0B"}),(0,t.jsx)(sa,{icon:e$.UserGroupIcon,label:"Followers Reached",value:r6(H.totalFollowersReached),fullValue:r9(H.totalFollowersReached),sub:"Combined audie
1nce per post",color:"#EC4899"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,t.jsx)(st,{title:"Platform Performance",subtitle:"Views vs Engagements by platform",children:(0,t.jsx)(sr,{platformData:K})}),(0,t.jsx)(st,{title:"Top Campaigns",subtitle:"Ranked by total views",children:(0,t.jsx)(ss,{campaignData:W})})]}),(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[(0,t.jsx)(st,{title:"Views by Creator",subtitle:"Top creators by view contribution",children:(0,t.jsx)(sn,{creators:e.creatorBreakdown.slice(0,10)})}),(0,t.jsx)(st,{title:"Platform Share",subtitle:"View distribution across platforms",children:(0,t.jsx)(so,{platformBreakdown:e.platformBreakdown})}),(0,t.jsx)(st,{title:"Engagement by Platform",subtitle:"Engagement distribution",children:(0,t.jsx)(sl,{platformBreakdown:e.platformBreakdown})})]}),(0,t.jsx)(st,{title:"Campaign ER Ranking",subtitle:"Engagement rate comparison across campaigns",children:(0,t.jsx)(si,{campaigns:e.campaignBreakdown})}),(0,t.jsx)(rZ,{stats:e}),(0,t.jsxs)("div",{className:"rounded-2xl overflow-hidden",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"p-5 pb-3",style:{borderBottom:"1px solid var(--surface-softer)"},children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 flex-wrap mb-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100",children:"Creator Performance"}),(0,t.jsx)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mt-0.5",children:"Click headers to sort · Click rows to view profile"})]}),(0,t.jsxs)("span",{className:"text-[10px] font-medium text-gray-400 dark:text-zinc-500",children:[R.length," creator",1!==R.length?"s":""]})]}),(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-1.5 mb-3 -mx-1 px-1 overflow-x-auto scrollbar-hide",children:sx.map(e=>(0,t.jsx)("button",{type:"button",onClick:()=>{var t;let a;(a=su[t=e.id])&&(C(t),S(a.minPosts),M(a.hasBoostSpend),P("all"),k(a.sort))},className:"px-3 py-1.5 rounded-full text-xs font-semibold transition-colors flex-shrink-0",style:N===e.id?{background:"rgba(99,102,241,0.10)",border:"1px solid rgba(99,102,241,0.28)",color:"#6366F1"}:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)",color:"var(--text-tertiary)"},children:e.label},e.id))}),(0,t.jsx)("p",{className:"text-[11px] leading-snug text-gray-500 dark:text-zinc-400 mb-3 max-w-2xl",children:sx.find(e=>e.id===N)?.description}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2 mb-2",children:[(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] font-medium text-gray-500 dark:text-zinc-400",children:["Min posts",(0,t.jsxs)("select",{value:z,onChange:e=>S(Number(e.target.value)),className:"rounded-full px-2.5 py-1.5 text-[10px] font-semibold text-gray-600 dark:text-zinc-400 appearance-none cursor-pointer outline-none",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("option",{value:1,children:"1+"}),(0,t.jsx)("option",{value:3,children:"3+"}),(0,t.jsx)("option",{value:5,children:"5+"})]})]}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-[10px] font-medium text-gray-500 dark:text-zinc-400",children:["Tier",(0,t.jsxs)("select",{value:E,onChange:e=>P(e.target.value),className:"rounded-full px-2.5 py-1.5 text-[10px] font-semibold text-gray-600 dark:text-zinc-400 appearance-none cursor-pointer outline-none",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("option",{value:"all",children:"All"}),(0,t.jsx)("option",{value:"nano",children:"Nano"}),(0,t.jsx)("option",{value:"micro",children:"Micro"}),(0,t.jsx)("option",{value:"mid",children:"Mid"}),(0,t.jsx)("option",{value:"macro",children:"Macro"})]})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>M(e=>!e),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-full text-[10px] font-semibold transition-colors",style:$?{background:"rgba(16,185,129,0.10)",border:"1px solid rgba(16,185,129,0.28)",color:"#059669"}:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)",color:"var(--text-tertiary)"},children:[(0,t.jsx)("span",{className:"w-3 h-3 rounded-full flex items-center justify-center flex-shrink-0",style:{background:$?"#10B981":"var(--border-subtle)"},children:$&&(0,t.jsx)(r0.CheckIcon,{className:"w-2 h-2 text-white"})}),"Has boost spend"]})]}),(0,t.jsxs)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500",children:[A," of ",T," creators match · ",D," have cost data"]})]}),(0,t.jsx)("div",{className:"overflow-x-auto",children:(0,t.jsxs)("table",{className:"w-full",children:[(0,t.jsx)("thead",{children:(0,t.jsx)("tr",{style:{background:"var(--surface-soft)"},children:V.map(e=>{let a=sz[e];return a?(0,t.jsx)(sd,{label:a.label,sortKey:a.sortKey,currentSort:y,onSort:F,al
1ign:a.align},e):null})})}),(0,t.jsx)("tbody",{children:0===R.length?(0,t.jsx)("tr",{children:(0,t.jsx)("td",{colSpan:V.length,className:"px-4 py-10 text-center text-xs text-gray-400 dark:text-zinc-500",children:"No creators match this lens â lower the minimum posts or widen the filters."})}):R.map(e=>(0,t.jsx)("tr",{onClick:()=>x.push(`/dashboard/user/creator/${e.creatorId}`),className:"cursor-pointer transition-colors hover:bg-white/60 dark:hover:bg-zinc-950/60 dark:bg-zinc-950/60",children:V.map(a=>{let r=sz[a];return r?(0,t.jsx)("td",{className:`px-4 py-3 ${"left"===r.align?"text-left":"text-right"}`,style:{borderBottom:"1px solid var(--surface-softer)"},children:r.cell(e)},a):null})},e.creatorId))})]})})]}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("h3",{className:"text-sm font-semibold text-gray-900 dark:text-zinc-100",children:"Organizations & Campaigns"}),(0,t.jsxs)("p",{className:"text-[10px] text-gray-400 dark:text-zinc-500 mt-0.5",children:[L.length," campaigns"]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)("span",{className:"text-[10px] text-gray-400 dark:text-zinc-500",children:"Sort by"}),(0,t.jsxs)("select",{value:j.key,onChange:e=>w({key:e.target.value,dir:"desc"}),className:"rounded-full px-2.5 py-1 text-[10px] font-semibold text-gray-600 dark:text-zinc-400 appearance-none cursor-pointer outline-none",style:{background:"var(--surface-softer)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsx)("option",{value:"totalViews",children:"Views"}),(0,t.jsx)("option",{value:"totalEngagements",children:"Engagements"}),(0,t.jsx)("option",{value:"engagementRate",children:"ER%"}),(0,t.jsx)("option",{value:"totalClicks",children:"Clicks"}),(0,t.jsx)("option",{value:"totalFollowersReached",children:"Followers"}),(0,t.jsx)("option",{value:"totalCost",children:"Spend"}),(0,t.jsx)("option",{value:"costPerView",children:"Cost / View"}),(0,t.jsx)("option",{value:"totalPosts",children:"Posts"}),(0,t.jsx)("option",{value:"campaignName",children:"Name"})]})]})]}),(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:L.slice(0,8).map(e=>(0,t.jsxs)("div",{onClick:()=>x.push(`/dashboard/user/campaign/${e.campaignId}`),className:"rounded-2xl p-4 cursor-pointer transition-all duration-200 hover:shadow-md hover:-translate-y-0.5 group",style:{background:"var(--surface-soft)",border:"1px solid var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2.5 mb-3",children:[e.organizationImage?(0,t.jsx)("img",{src:e.organizationImage,alt:e.organizationName,className:"w-8 h-8 rounded-lg object-contain bg-white dark:bg-zinc-950 p-0.5 flex-shrink-0",style:{border:"1px solid var(--border-subtle)"}}):(0,t.jsx)("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0",style:{background:"rgba(245,158,11,0.08)"},children:(0,t.jsx)("span",{className:"text-[10px] font-bold text-amber-500",children:e.organizationName?.[0]?.toUpperCase()||"?"})}),(0,t.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,t.jsx)("div",{className:"text-xs font-semibold text-gray-900 dark:text-zinc-100 truncate",children:e.campaignName}),(0,t.jsx)("div",{className:"text-[10px] text-gray-400 dark:text-zinc-500 truncate",children:e.organizationName})]}),(0,t.jsx)(rJ.ChevronRightIcon,{className:"w-3.5 h-3.5 text-gray-300 dark:text-zinc-700 group-hover:text-gray-500 dark:group-hover:text-zinc-400 transition-colors flex-shrink-0"})]}),(0,t.jsx)("div",{className:`grid gap-2 ${e.totalCost>0?"grid-cols-3":"grid-cols-2"}`,children:[{label:"Views",value:r6(e.totalViews),color:"#3B82F6"},{label:"ER",value:r7(e.engagementRate),color:"#10B981"},{label:"Clicks",value:r6(e.totalClicks),color:"#8B5CF6"},{label:"Reach",value:r6(e.totalFollowersReached||0),color:"#EC4899"},...e.totalCost>0?[{label:"Spend",value:r8(e.totalCost),color:"#8B5CF6"},{label:"CPV",value:e.costPerView>0?`$${e.costPerView.toFixed(3)}`:"â",color:"#06B6D4"}]:[]].map(({label:e,value:a,color:r})=>(0,t.jsxs)("div",{className:"rounded-lg p-2 text-center",style:{background:"var(--surface-soft)"},children:[(0,t.jsx)("div",{className:"text-xs font-bold",style:{color:r},children:a}),(0,t.jsx)("div",{className:"text-[9px] font-medium uppercase tracking-wider text-gray-400 dark:text-zinc-500 mt-0.5",children:e})]},e))})]},e.campaignId))})]})]})]})};var sE=e.i(300420),sP=e.i(921991);let s$=a.forwardRef(function({title:e,titleId:t,...r},s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},r),e?a.createElement("title",{id:t},e):null,a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 6a7.5 7.5 0 1 0 7.5 7.5h-7.5V6Z"}),a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M13.5 10.5H21A7.5 7.5 0 0 0 13.5 3v7.5Z"}))}),sM=a.forwardRef(function({title:e,titleId:t,...r},s){return a.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor","aria-hidden":"true","data-slot":"icon",ref:s,"aria-labelledby":t},r),e?a.createElement("title",{id:t},e):null,a.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 3.75H6.912a2.25 2.25 0 0 0-2.15 1.588L2.35 13.177a2.25 2.25 0 0 0-.1.661V18a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18v-4.162c0-.224-.034-.447-.1-.661L19.24 5.338a2.25 2.25 0 0 0-2.15-1.588H1
15M2.25 13.5h3.86a2.25 2.25 0 0 1 2.012 1.244l.256.512a2.25 2.25 0 0 0 2.013 1.244h3.218a2.25 2.25 0 0 0 2.013-1.244l.256-.512a2.25 2.25 0 0 1 2.013-1.244h3.859M12 3v8.25m0 0-3-3m3 3 3-3"}))});var sF=e.i(107657),sI=e.i(99508),sR=e.i(87107);let sT=[.25,.46,.45,.94];function sA(e,t,a){return t?"#10b981":a?"#ef4444":e>=75?"#3b82f6":e>=25?"#f59e0b":"#6366f1"}function sD({value:e,formatFn:r}){let[s,n]=(0,a.useState)(0),l=(0,a.useRef)(null),i=(0,o.useInView)(l,{margin:"-50px"}),d=(0,a.useRef)(0);return(0,a.useEffect)(()=>{if(!i||e===d.current)return;let t=d.current;return d.current=e,(0,c.animate)(t,e,{duration:1.4,ease:sT,onUpdate:e=>n(e)}).stop},[i,e]),(0,t.jsx)("span",{ref:l,children:r(s)})}function sV({children:e,className:a="",delay:r=0}){return(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:40},whileInView:{opacity:1,y:0},viewport:{once:!0,margin:"-80px"},transition:{duration:.8,delay:r,ease:sT},className:a,children:e})}function sL(){return(0,t.jsx)("div",{className:"mx-4 sm:mx-8 md:mx-32 my-2",children:(0,t.jsx)("div",{className:"h-px bg-gradient-to-r from-transparent via-gray-200 to-transparent dark:via-zinc-800"})})}function sB({children:e,accentIcon:a}){return(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,t.jsx)("div",{className:"h-6 w-1 rounded-full bg-gradient-to-b from-pink-500 to-orange-400"}),(0,t.jsx)("h2",{className:"text-lg font-bold text-gray-900 dark:text-zinc-100 tracking-tight",children:e}),a&&(0,t.jsx)(a,{className:"w-4 h-4 text-gray-300 dark:text-zinc-700"})]})}function sO({icon:e,label:a,value:r,formatFn:s,accent:n,sub:l}){return(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border backdrop-blur-xl p-4 sm:p-5 flex flex-col justify-between",style:{background:"var(--surface-frosted)",borderColor:`${n}25`,boxShadow:`0 4px 24px ${n}08`,minHeight:118},children:[(0,t.jsx)("div",{className:"absolute -top-8 -right-8 w-24 h-24 rounded-full opacity-20 blur-2xl pointer-events-none",style:{background:n}}),(0,t.jsxs)("div",{className:"relative z-10 flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center shrink-0",style:{background:`${n}14`},children:(0,t.jsx)(e,{className:"w-4 h-4",style:{color:n}})}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-gray-400 dark:text-zinc-500 leading-tight",children:a})]}),(0,t.jsxs)("div",{className:"relative z-10 mt-3",children:[(0,t.jsx)("div",{className:"text-2xl md:text-3xl font-black tracking-tight text-gray-900 dark:text-zinc-100 leading-none tabular-nums",children:(0,t.jsx)(sD,{value:r,formatFn:s})}),l&&(0,t.jsx)("div",{className:"text-[11px] font-semibold text-gray-400 dark:text-zinc-500 mt-1.5",children:l})]})]})}function s_(){let e,{data:n}=(0,s.useSession)(),l=(0,r.useRouter)(),[o,c]=(0,a.useState)(null),[d,x]=(0,a.useState)([]),[u,m]=(0,a.useState)([]),[g,p]=(0,a.useState)(null),[h,f]=(0,a.useState)([]),[b,v]=(0,a.useState)(!0),[y,k]=(0,a.useState)(!1);(0,a.useEffect)(()=>{let e=!1;return(async()=>{v(!0);try{let[t,a,r,s,n]=await Promise.all([fetch("/api/pipelines"),fetch("/api/deals?limit=250"),fetch("/api/deals?withStageSummary=1"),fetch("/api/sales/analytics"),fetch("/api/approvals/inbox")]);if(e)return;if((403===t.status||403===a.status||403===r.status||403===s.status)&&k(!0),t.ok){let{pipelines:e}=await t.json(),a=e||[];c(a.find(e=>e.isDefault)||a[0]||null)}if(a.ok){let{deals:e}=await a.json();x(e||[])}if(r.ok){let{stageSummary:e}=await r.json();m(e||[])}if(s.ok&&p(await s.json()),n.ok){let{approvals:e}=await n.json();f(e||[])}}catch(e){console.error("[SalesHome] fetch failed:",e)}finally{e||v(!1)}})(),()=>{e=!0}},[]);let j=n?.user?.name?.split(" ")[0]||"there",w=(0,a.useMemo)(()=>{let e=g?.summary;return{openCount:e?.open?.count??0,pipelineValue:e?.open?.value??0,weightedForecast:e?.open?.weightedValue??0,wonCount:e?.won?.count??0,wonRevenue:e?.won?.value??0,winRate:e?.winRate??null,totalClosed:e?.totalClosed??0}},[g]),N=(0,a.useMemo)(()=>{let e=o?.stages||[],t=new Map(u.map(e=>[e.stage,e]));return e.map(e=>{let a=t.get(e.key);return{key:e.key,label:e.label,probability:e.probability||0,isWon:!!e.isClosedWon,isLost:!!e.isClosedLost,count:a?.count||0,value:a?.sum||0}})},[o,u]),C=(0,a.useMemo)(()=>d.slice(0,6),[d]);return(0,t.jsxs)("div",{className:"min-h-screen",children:[(0,t.jsxs)("div",{className:"relative z-10 mx-4 sm:mx-8 md:mx-32 pt-8 pb-6",children:[(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:20}
1,animate:{opacity:1,y:0},transition:{duration:.7,ease:sT},children:(0,t.jsxs)("h1",{className:"text-4xl md:text-5xl font-black tracking-tight text-gray-900 dark:text-zinc-100 mb-2",children:[(e=new Date().getHours())<12?"Good morning":e<17?"Good afternoon":"Good evening",","," ",(0,t.jsx)("span",{className:"bg-gradient-to-r from-pink-500 via-rose-500 to-orange-400 bg-clip-text text-transparent",children:j})]})}),(0,t.jsx)(i.motion.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.7,delay:.12},className:"text-gray-500 dark:text-zinc-400 text-base max-w-xl mb-6",children:"Your sales command center â pipeline health, approvals, and momentum at a glance."}),(0,t.jsx)(sR.default,{className:"mb-6"}),y&&(0,t.jsxs)("div",{className:"flex items-start gap-3 rounded-2xl border p-4 mb-6",style:{background:"rgba(99,102,241,0.06)",borderColor:"rgba(99,102,241,0.25)"},children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center shrink-0",style:{background:"#6366f114"},children:(0,t.jsx)(sF.LockClosedIcon,{className:"w-4 h-4",style:{color:"#6366f1"}})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-bold text-gray-900 dark:text-zinc-100",children:"CRM access not enabled"}),(0,t.jsx)("p",{className:"text-[13px] text-gray-500 dark:text-zinc-400 mt-0.5",children:"Your sales home is ready, but pipeline data is gated on your agency role permissions. Ask an admin to grant deal access."})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 xl:grid-cols-4 gap-3",children:[(0,t.jsx)(sO,{icon:sP.RectangleStackIcon,label:"Open Deals",value:w.openCount,formatFn:e=>Math.round(e).toString(),accent:"#6366f1"}),(0,t.jsx)(sO,{icon:rD.BanknotesIcon,label:"Pipeline Value",value:w.pipelineValue,formatFn:e=>(0,sI.formatCurrencyCompact)(e,"USD"),accent:"#3b82f6"}),(0,t.jsx)(sO,{icon:sE.ScaleIcon,label:"Weighted Forecast",value:w.weightedForecast,formatFn:e=>(0,sI.formatCurrencyCompact)(e,"USD"),accent:"#f59e0b"}),(0,t.jsx)(sO,{icon:ec.TrophyIcon,label:"Won Revenue",value:w.wonRevenue,formatFn:e=>(0,sI.formatCurrencyCompact)(e,"USD"),accent:"#10b981",sub:`${w.wonCount} deal${1===w.wonCount?"":"s"} won`})]})]}),(0,t.jsx)(sL,{}),(0,t.jsxs)(sV,{className:"mx-4 sm:mx-8 md:mx-32 mt-6 mb-2",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-6",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("div",{className:"h-6 w-1 rounded-full bg-gradient-to-b from-pink-500 to-orange-400"}),(0,t.jsx)("h2",{className:"text-lg font-bold text-gray-900 dark:text-zinc-100 tracking-tight",children:"Pipeline Overview"}),o?.name&&(0,t.jsx)("span",{className:"text-[11px] font-semibold text-gray-400 dark:text-zinc-500 truncate max-w-[40vw]",children:o.name})]}),(0,t.jsxs)("button",{onClick:()=>l.push("/dashboard/user/sales/pipeline"),className:"hidden sm:inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium text-gray-500 dark:text-zinc-400 hover:bg-gray-100 dark:hover:bg-zinc-900 transition-all shrink-0",children:["Open board",(0,t.jsx)(L.ArrowRightIcon,{className:"w-3.5 h-3.5"})]})]}),b?(0,t.jsx)("div",{className:"flex gap-3 overflow-x-auto pb-2 scrollbar-hide",children:[0,1,2,3,4].map(e=>(0,t.jsx)("div",{className:"h-28 w-40 shrink-0 rounded-2xl border animate-pulse",style:{background:"var(--surface-soft)",borderColor:"var(--border-subtle)"}},e))}):N.length>0?(0,t.jsx)("div",{className:"flex gap-3 overflow-x-auto pb-2 scrollbar-hide",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:N.map(e=>{let a=sA(e.probability,e.isWon,e.isLost);return(0,t.jsxs)("button",{onClick:()=>l.push("/dashboard/user/sales/pipeline"),className:"group relative overflow-hidden rounded-2xl border backdrop-blur-xl p-4 text-left shrink-0 w-40 transition-all duration-300 hover:-translate-y-0.5 hover:shadow-lg",style:{background:"var(--surface-frosted)",borderColor:`${a}25`},children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{background:a}}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.1em] text-gray-400 dark:text-zinc-500 truncate",children:e.label})]}),(0,t.jsx)("div",{className:"text-2xl font-black tracking-tight text-gray-900 dark:text-zinc-100 leading-none tabular-nums",children:e.count}),(0,t.jsx)("div",{className:"text-[11px] font-semibold mt-1.5 tabular-nums",style:{color:a},children:(0,sI.formatCurrencyCompact)(e.value,"USD")})]},e.key)})}):(0,t.jsx)(sU,{icon:s$,title:"No pipeline yet",body:"Once a pipeline and deals exist for your agency, the stage funnel appears here."})]}),(0,t.jsx)(sL,{}),(0,t.jsx)(sV,{className:"mx-4 sm:mx-8 md:mx-32 mt-6 mb-2",children:(0,t.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,t.jsxs)("div",{className:"lg:col-span-2",children:[(0,t.jsx)(sB,{accentIcon:sM,children:"Approvals Waiting"}),b?(0,t.jsx)("div",{className:"space-y-3",children:[0,1].map(e=>(0,t.jsx)("div",{className:"h-16 rounded-2xl border animate-pulse",style:{background:"var(--surface-soft)",borderColor:"var(--border-subtle)"}},e))}):h.length>0?(0,t.jsx)("div",{className:"space-y-3",children:h.map(e=>(0,t.jsxs)("button",{onClick:()=>e.deal?._id&&l.push(`/dashboard/user/sales/deal/${e.deal._id}`),className:"group w-full flex items-center gap-3 rounded-2xl border backdrop-blur-xl p-4 text-left transition-all duration-300 hover:-translate-y-0.5 hover:shadow-lg",style:{background:"var(--surface-frosted)",borderColor:"rgba(245,158,11,0.25)"},children:[(0,t.jsx)("div",{className:"w-10 h-10 rounded-xl flex items-center justify-center shrink-0",style:{background:"#f59e0b14"},children:(0,t.jsx)(D.ClockIcon,{className:"w-5 h-5",style:{color:"#f59e0b"}})}),(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"text-sm font-bold text-gray-900 dark:text-zinc-100 truncate",children:e.deal?.name||"Deal approval"}),(0,t.jsx)("p",{className:"text-[12px] text-gray-500 dark:text-zinc-400 truncate flex items-center gap-1.5 mt-0.5",children:e.deal?.organization?.name&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(el.BuildingOffice2Icon,{className:"w-3.5 h-3.5 shrink-0"}),e.deal.organization.name]})})]}),(0,t.jsx)("div",{className:"shrink-0 text-right",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-[11px] font-semibold tabular-nums",style:{background:"rgba(245,158,11,0.08)",border:"1px solid rgba(245,158,11,0.33)",color:"#B45309"},children:["Step ",(e._priorApprovedCount??0)+1,"/",e._totalSteps??1]})}),(0,t.jsx)(L.ArrowRightIcon,{className:"w-4 h-4 text-gray-300 dark:text-zinc-700 group-hover:text-gray-500 dark:group-hover:text-zinc-400 transition-colors shrink-0"})]},e._id))}):(0,t.jsx)(sU,{icon:V.CheckCircleIcon,title:"All caught up",body:"No deals are waiting on your approval right now.",accent:"#10b981"})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)(sB,{children:"Close Rate"}),b?(0,t.jsx)("div",{className:"h-[calc(100%-2.5rem)] min-h-[160px] rounded-2xl border animate-pulse",style:{background:"var(--surface-soft)",borderColor:"var(--border-subtle)"}}):(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border backdrop-blur-xl p-5 h-[calc(100%-2.5rem)] min-h-[160px] flex flex-col justify-between",style:{background:"var(--surface-frosted)",borderColor:"rgba(139,92,246,0.25)"},children:[(0,t.jsx)("div",{className:"absolute -top-10 -right-10 w-28 h-28 rounded-full opacity-20 blur-2xl pointer-events-none",style:{background:"#8b5cf6"}}),(0,t.jsxs)("div",{className:"relative z-10 flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center shrink-0",style:{background:"#8b5cf614"},children:(0,t.jsx)(s$,{className:"w-4 h-4",style:{color:"#8b5cf6"}})}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-gray-400 dark:text-zinc-500 leading-tight",children:"Win Rate"})]}),w.totalClosed>0?(0,t.jsxs)("div",{className:"relative z-10",children:[(0,t.jsx)("div",{className:"text-3xl font-black tracking-tight text-gray-900 dark:text-zinc-100 leading-none tabular-nums",children:(0,t.jsx)(sD,{value:100*w.winRate,formatFn:e=>`${e.toFixed(1)}%`})}),(0,t.jsxs)("p",{className:"text-[12px] text-gray-500 dark:text-zinc-400 mt-2 leading-relaxed",children:[w.wonCount," won of ",w.totalClosed," closed deal",1===w.totalClosed?"":"s"]})]}):(0,t.jsxs)("div",{className:"relative z-10",children:[(0,t.jsx)("div",{className:"text-3xl font-black tracking-tight text-gray-300 dark:text-zinc-700 leading-none",children:"â"}),(0,t.jsx)("p",{className:"text-[12px] text-gray-500 dark:text-zinc-400 mt-2 leading-relaxed",children:"No closed deals yet â win rate appears once your first deal closes."})]}),(0,t.jsxs)("button",{onClick:()=>l.push("/dashboard/user/sales/analytics"),className:"relative z-10 mt-3 inline-flex items-center gap-1.5 self-start px-3 py-1.5 rounded-full text-xs font-medium text-gray-500 dark:text-zinc-400 hover:bg-gray-100 dark:hover:bg-zinc-900 transition-all",children:["View full analytics",(0,t.jsx)(L.ArrowRightIcon,{className:"w-3.5 h-3.5"})]})]})]})]})}),(0,t.jsx)(sL,{}),(0,t.jsxs)(sV,{className:"mx-4 sm:mx-8 md:mx-32 mt-6 mb-10",children:[(0,t.jsx)(sB,{accentIcon:O.BoltIcon,children:"Recent Deal Activity"}),b?(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:[0,1,2].map(e=>(0,t.jsx)("div",{className:"h-20 rounded-2xl border animate-pulse",style:{background:"var(--surface-soft)",borderColor:"var(--border-subtle)"}},e))}):C.length>0?(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3",children:C.map(e=>{let a,r,{label:s,accent:n}=(a=(o?.stages||[]).find(t=>t.key===e.stage),r=sA(a?.probability??e.probability??0,!!a?.isClosedWon,!!a?.isClosedLost),{label:a?.label||e.stage,accent:r});return(0,t.jsxs)("button",{onClick:()=>l.push(`/dashboard/user/sales/deal/${e._id}`),className:"group flex items-center gap-3 rounded-2xl border backdrop-blur-xl p-4 text-left transition-all duration-300 hover:-translate-y-0.5 hover:shadow-lg",style:{background:"var(--surface-frosted)",borderColor:"var(--border-subtle)"},children:[(0,t.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,t.jsx)("p",{className:"text-sm font-bold text-gray-900 dark:text-zinc-100 truncate",children:e.name}),(0,t.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,t.jsx)("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-[10px] font-semibold shrink-0",style:{background:`${n}14`,color:n},children:s}),(0,t.jsx)("span",{className:"text-[11px] text-gray-400 dark:text-zinc-500 truncate",children:e.organization?.name||"â"})]})]}),(0,t.jsxs)("div",{className:"shrink-0 text-right",children:[(0,t.jsx)("div",{className:"text-[13px] font-extrabold text-gray-900 dark:text-zinc-100 tabular-nums leading-none",children:(0,sI.formatCurrencyCompact)(e.amount||0,e.currency||"USD")}),(0,t.jsx)("div",{className:"text-[10px] font-medium text-gray-400 dark:text-zinc-500 mt-1",children:function(e){if(!e)return null;let t=new Date,a=new Date(e),r=t-a,s=Math.floor(r/6e4),n=Math.floor(r/36e5),l=Math.floor(r/864e5);return s<1?"Just now":s<60?`${s}m ago`:n<24?`${n}h ago`:l<7?`${l}d ago`:a.toLocaleDateString("en-US",{month:"short",day:"numeric"})}(e.createdAt)})]})]},e._id)})}):(0,t.jsx)(sU,{icon:sP.RectangleStackIcon,title:"No deals yet",body:"New deals will show up here as your team creates them."})]})]})}function sU({icon:e,title:a,body:r,accent:s="#ec4899"}){return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center border border-dashed border-gray-200 dark:border-zinc-800 rounded-3xl py-14 px-6 text-center bg-white/60 dark:bg-zinc-950/60 backdrop-blur-sm",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center mb-5",style:{background:`${s}14`},children:(0,t.jsx)(e,{className:"w-8 h-8",style:{color:s}})}),(0,t.jsx)("h3",{className:"text-lg font-bold text-gray-800 dark:text-zinc-100 mb-2",children:a}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-zinc-400 max-w-md",children:r})]})}var sG=e.i(996874),sH=e.i(915027);let sK=[.25,.46,.45,.94];function sW(e){if(null==e||isNaN(e))return"0";let t=Number(e);return t>=1e9?(t/1e9).toFixed(1)+"B":t>=1e6?(t/1e6).toFixed(1)+"M":t>
1=1e3?(t/1e3).toFixed(1)+"K":Math.round(t).toLocaleString()}function sq({value:e,formatFn:r}){let[s,n]=(0,a.useState)(0),l=(0,a.useRef)(null),i=(0,o.useInView)(l,{margin:"-50px"}),d=(0,a.useRef)(0);return(0,a.useEffect)(()=>{if(!i||e===d.current)return;let t=d.current;return d.current=e,(0,c.animate)(t,e,{duration:1.4,ease:sK,onUpdate:e=>n(e)}).stop},[i,e]),(0,t.jsx)("span",{ref:l,children:r(s)})}function sY({children:e,className:a="",delay:r=0}){return(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:40},whileInView:{opacity:1,y:0},viewport:{once:!0,margin:"-80px"},transition:{duration:.8,delay:r,ease:sK},className:a,children:e})}function sX(){return(0,t.jsx)("div",{className:"mx-4 sm:mx-8 md:mx-32 my-2",children:(0,t.jsx)("div",{className:"h-px bg-gradient-to-r from-transparent via-gray-200 to-transparent dark:via-zinc-800"})})}function sQ({children:e,accentIcon:a}){return(0,t.jsxs)("div",{className:"flex items-center gap-3 mb-6",children:[(0,t.jsx)("div",{className:"h-6 w-1 rounded-full bg-gradient-to-b from-pink-500 to-orange-400"}),(0,t.jsx)("h2",{className:"text-lg font-bold text-gray-900 dark:text-zinc-100 tracking-tight",children:e}),a&&(0,t.jsx)(a,{className:"w-4 h-4 text-gray-300 dark:text-zinc-700"})]})}function sZ({icon:e,label:a,value:r,formatFn:s,accent:n,sub:l}){return(0,t.jsxs)("div",{className:"relative overflow-hidden rounded-2xl border backdrop-blur-xl p-4 sm:p-5 flex flex-col justify-between",style:{background:"var(--surface-frosted)",borderColor:`${n}25`,boxShadow:`0 4px 24px ${n}08`,minHeight:118},children:[(0,t.jsx)("div",{className:"absolute -top-8 -right-8 w-24 h-24 rounded-full opacity-20 blur-2xl pointer-events-none",style:{background:n}}),(0,t.jsxs)("div",{className:"relative z-10 flex items-center gap-2",children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center shrink-0",style:{background:`${n}14`},children:(0,t.jsx)(e,{className:"w-4 h-4",style:{color:n}})}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.12em] text-gray-400 dark:text-zinc-500 leading-tight",children:a})]}),(0,t.jsxs)("div",{className:"relative z-10 mt-3",children:[(0,t.jsx)("div",{className:"text-2xl md:text-3xl font-black tracking-tight text-gray-900 dark:text-zinc-100 leading-none tabular-nums",children:(0,t.jsx)(sq,{value:r,formatFn:s})}),l&&(0,t.jsx)("div",{className:"text-[11px] font-semibold text-gray-400 dark:text-zinc-500 mt-1.5",children:l})]})]})}function sJ({icon:e,label:a,onClick:r}){return(0,t.jsxs)("button",{onClick:r,className:"flex items-center gap-1.5 px-4 py-2 rounded-full text-sm font-semibold text-gray-700 dark:text-zinc-300 bg-[rgba(0,0,0,0.04)] dark:bg-[rgba(255,255,255,0.06)] border border-[rgba(0,0,0,0.06)] dark:border-[rgba(255,255,255,0.10)] hover:bg-gray-100 dark:hover:bg-zinc-900 transition-colors",children:[(0,t.jsx)(e,{className:"w-4 h-4"}),a]})}function s0({icon:e,title:a,body:r,accent:s="#ec4899"}){return(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center border border-dashed border-gray-200 dark:border-zinc-800 rounded-3xl py-14 px-6 text-center bg-white/60 dark:bg-zinc-950/60 backdrop-blur-sm",children:[(0,t.jsx)("div",{className:"w-16 h-16 rounded-2xl flex items-center justify-center mb-5",style:{background:`${s}14`},children:(0,t.jsx)(e,{className:"w-8 h-8",style:{color:s}})}),(0,t.jsx)("h3",{className:"text-lg font-bold text-gray-800 dark:text-zinc-100 mb-2",children:a}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-zinc-400 max-w-md",children:r})]})}var s1=e.i(165608);let s2={sales:s_,sales_pipeline:s_,talent_management:function(){let e,{data:n}=(0,s.useSession)(),l=(0,r.useRouter)(),[o,c]=(0,a.useState)([]),[d,x]=(0,a.useState)(0),[u,m]=(0,a.useState)(null),[g,p]=(0,a.useState)(!0),[h,f]=(0,a.useState)(!1),[b,v]=(0,a.useState)(!1),[y,k]=(0,a.useState)(!1),j=(0,a.useCallback)(async()=>{p(!0);try{let e=await fetch("/api/getPosts?monitored=true&limit=24");if((403===e.status||401===e.status)&&f(!0),e.ok){let t=await e.json();c(t.posts||[]),x(t.totalCount??0),m(t.aggregates||null)}}catch(e){console.error("[TalentHome] fetch failed:",e)}finally{p(!1)}},[]);(0,a.useEffect)(()=>{j()},[j]);let w=n?.user?.name?.split(" ")[0]||"there",C=(0,a.useMemo)(()=>{let e=u?.totalViews||0;return{postCount:d,totalViews:e,totalEngagements:(u?.totalLikes||0)+(u?.totalComments||0)+(u?.totalShares||0),creatorsTracked:u?.uniqueCreators||0}},[u,d]),z=(0,a.useMemo)(()=>o.slice(0,8),[o]),S=(0,a.useCallback)(()=>{j(),v(!1)},[j]),E=(0,a.useCallback)(()=>
1{j(),k(!1)},[j]),P=o.length>0;return(0,t.jsxs)("div",{className:"min-h-screen",children:[(0,t.jsxs)("div",{className:"relative z-10 mx-4 sm:mx-8 md:mx-32 pt-8 pb-6",children:[(0,t.jsxs)("div",{className:"flex flex-col md:flex-row md:items-start md:justify-between gap-4",children:[(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.7,ease:sK},children:(0,t.jsxs)("h1",{className:"text-4xl md:text-5xl font-black tracking-tight text-gray-900 dark:text-zinc-100 mb-2",children:[(e=new Date().getHours())<12?"Good morning":e<17?"Good afternoon":"Good evening",","," ",(0,t.jsx)("span",{className:"bg-gradient-to-r from-pink-500 via-rose-500 to-orange-400 bg-clip-text text-transparent",children:w})]})}),(0,t.jsx)(i.motion.p,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.7,delay:.12},className:"text-gray-500 dark:text-zinc-400 text-base max-w-xl",children:"Your talent command center â every monitored post and its momentum at a glance."})]}),(0,t.jsxs)(i.motion.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.7,delay:.18},className:"flex flex-wrap items-center gap-2 shrink-0",children:[(0,t.jsx)(sJ,{icon:e0.PlusIcon,label:"New Post",onClick:()=>v(!0)}),(0,t.jsx)(sJ,{icon:sG.ArrowUpTrayIcon,label:"Import posts",onClick:()=>k(!0)})]})]}),h&&(0,t.jsxs)("div",{className:"flex items-start gap-3 rounded-2xl border p-4 mt-6",style:{background:"rgba(99,102,241,0.06)",borderColor:"rgba(99,102,241,0.25)"},children:[(0,t.jsx)("div",{className:"w-9 h-9 rounded-xl flex items-center justify-center shrink-0",style:{background:"#6366f114"},children:(0,t.jsx)(sF.LockClosedIcon,{className:"w-4 h-4",style:{color:"#6366f1"}})}),(0,t.jsxs)("div",{className:"min-w-0",children:[(0,t.jsx)("p",{className:"text-sm font-bold text-gray-900 dark:text-zinc-100",children:"Monitored posts not enabled"}),(0,t.jsx)("p",{className:"text-[13px] text-gray-500 dark:text-zinc-400 mt-0.5",children:"Your talent home is ready, but post data is gated on your agency role permissions. Ask an admin to grant access."})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 xl:grid-cols-4 gap-3 mt-6",children:[(0,t.jsx)(sZ,{icon:sP.RectangleStackIcon,label:"Monitored Posts",value:C.postCount,formatFn:e=>Math.round(e).toString(),accent:"#6366f1"}),(0,t.jsx)(sZ,{icon:eE.EyeIcon,label:"Total Views",value:C.totalViews,formatFn:sW,accent:"#3b82f6"}),(0,t.jsx)(sZ,{icon:O.BoltIcon,label:"Engagements",value:C.totalEngagements,formatFn:sW,accent:"#8b5cf6"}),(0,t.jsx)(sZ,{icon:e$.UserGroupIcon,label:"Creators Tracked",value:C.creatorsTracked,formatFn:e=>Math.round(e).toString(),accent:"#f97316"})]})]}),(0,t.jsx)(sX,{}),(g||P)&&(0,t.jsxs)(sY,{className:"mx-4 sm:mx-8 md:mx-32 mt-6 mb-2",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-3",children:[(0,t.jsx)(D.ClockIcon,{className:"w-4 h-4 text-pink-400"}),(0,t.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-[0.14em] text-gray-400 dark:text-zinc-500",children:"Recently Added"}),(0,t.jsx)("div",{className:"flex-1 h-px bg-gradient-to-r from-gray-200 to-transparent ml-2 dark:from-zinc-800"})]}),g?(0,t.jsx)("div",{className:"flex gap-4 overflow-x-auto pb-2 scrollbar-hide",children:[0,1,2,3].map(e=>(0,t.jsx)("div",{className:"h-72 w-[280px] shrink-0 rounded-2xl border animate-pulse",style:{background:"var(--surface-soft)",borderColor:"var(--border-subtle)"}},e))}):(0,t.jsx)("div",{className:"flex gap-4 overflow-x-auto pb-2 scrollbar-hide",style:{scrollbarWidth:"none",msOverflowStyle:"none"},children:z.map(e=>(0,t.jsx)("div",{className:"w-[280px] shrink-0",children:(0,t.jsx)(N.default,{post:e})},e._id))})]}),(0,t.jsx)(sX,{}),(0,t.jsxs)(sY,{className:"mx-4 sm:mx-8 md:mx-32 mt-6 mb-10",children:[(0,t.jsxs)("div",{className:"flex items-center justify-between gap-3 mb-6",children:[(0,t.jsx)(sQ,{accentIcon:er.SparklesIcon,children:"Monitored Posts"}),(0,t.jsxs)("button",{onClick:()=>l.push("/?tab=posts"),className:"hidden sm:inline-flex items-center gap-1.5 px-3 py-1.5 rounded-full text-xs font-medium text-gray-500 dark:text-zinc-400 hover:bg-gray-100 dark:hover:bg-zinc-900 transition-all shrink-0 -mt-4",children:["View all",(0,t.jsx)(L.ArrowRightIcon,{className:"w-3.5 h-3.5"})]})]}),g?(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:[0,1,2,3].map(e=>(0,t.jsx)("div",{className:"h-96 rounded-2xl border animate-pulse",style:{background:"var(--surface-soft)",borderColor:"var(--border-subtle)"}},e))}):P?(0,t.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6",children:o.map(e=>(0,t.jsx)(i.motion.div,{initial:{opacity:0,y:24},whileInView:{opacity:1,y:0},viewport:{once:!0,margin:"-40px"},transition:{duration:.45},children:(0,t.jsx)(N.default,{post:e})},e._id))}):(0,t.jsx)(s0,{icon:sP.RectangleStackIcon,title:h?"No posts to show":"No monitored posts yet",body:h?"Monitored posts will appear here once access is granted.":"Create a standalone post or pin a campaign post to start tracking it here."})]}),(0,t.jsx)(tI.default,{isOpen:b,onClose:()=>v(!1),children:(0,t.jsx)(rl.default,{setRefetchTrigger:S})}),(0,t.jsx)(tI.default,{isOpen:y,onClose:()=>k(!1),children:(0,t.jsxs)("div",{className:"w-[min(90vw,32rem)]",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-2 px-1",children:[(0,t.jsx)(sG.ArrowUpTrayIcon,{className:"w-5 h-5 text-pink-500"}),(0,t.jsx)("h2",{className:"text-lg font-bold text-gray-900 dark:text-zinc-100 tracking-tight",children:"Import monitored posts"})]}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-zinc-400 px-1 mb-2",children:"Upload a CSV to create standalone monitored posts â no campaign required."}),(0,t.jsx)(sH.default,{setRefetchTrigger:E})]})})]})}};function s5(){let{params:e,setParams:i}=(0,tM.useHomeQuery)(),o=(0,r.useSearchParams)(),c=(0,r.useRouter)(),d=e.get("tab")||"home",[x,u]=(0,a.useState)(d),[m,g]=(0,a.useState)(!1),[p,h]=(0,a.useState)(!1),{data:f,status:b}
1=(0,s.useSession)(),v=f?.user?.organization,y=f?.user?.creator,k=!!f?.user?.agency,j=k||!v?.id,w=!!y,N=f?.user?.agencyRole?.homeView||f?.user?.userType?.homeView||s1.DEFAULT_HOME_VIEW,C=(0,s1.getHomeView)(N),z=s2[N]||e_,S="authenticated"===b&&k&&!w&&!!C.href&&!e.get("tab");(0,a.useEffect)(()=>{S&&c.replace(C.href)},[S,C.href,c]),(0,a.useEffect)(()=>{if(console.log("[creator-redirect] check",{status:b,isCreatorUser:w,creator:y,creatorId:y?.id,role:f?.user?.role,email:f?.user?.email}),"authenticated"===b&&w&&y?.id){h(!0);try{c.push(`/dashboard/user/creator/${y.id}`)}catch(e){console.error("router.push failed:",e),window.location.href=`/dashboard/user/creator/${y.id}`}}},[b,w,y,c,f]);let E=e=>{w||(u(e),i({tab:e}))};return((0,a.useEffect)(()=>{let e=e=>{let t=e.detail;["home","campaigns","organizations","creators","posts","tasks","intelligence"].includes(t)&&E(t)};return window.addEventListener("navigate-tab",e),()=>window.removeEventListener("navigate-tab",e)},[]),"loading"===b)?(0,t.jsx)(n.default,{message:"Initializing your session"}):"unauthenticated"===b?(0,t.jsx)(rI,{}):S?(0,t.jsx)(n.default,{message:"Taking you to your home"}):w&&p?(0,t.jsx)(n.default,{message:"Heading to your creator profile"}):w&&!p?(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-screen",children:[(0,t.jsx)("p",{className:"text-red-500",children:"Redirect failed. Please click below:"}),(0,t.jsx)("a",{href:`/dashboard/user/creator/${y.id}`,className:"mt-4 px-4 py-2 bg-blue-500 text-white rounded",children:"Go to Creator Profile"})]}):(0,t.jsxs)("div",{children:[j&&(0,t.jsx)(l.default,{setActiveTab:E,activeTab:x}),"home"===x&&(0,t.jsx)(t.Fragment,{children:j?(0,t.jsx)(z,{}):(0,t.jsx)(rF,{organizationId:v.id})}),"campaigns"===x&&(0,t.jsx)(tx,{session:f}),"organizations"===x&&(0,t.jsx)(tB,{session:f}),"creators"===x&&(0,t.jsx)(t7,{session:f}),"posts"===x&&(0,t.jsx)(ry,{session:f,setFilterPanelBGIsOpen:g,filterPanelBGIsOpen:m}),"tasks"===x&&(0,t.jsxs)("div",{className:"mx-8 md:mx-32 mt-8 mb-10",children:[(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsx)("h1",{className:"text-3xl font-black tracking-tight text-gray-900 dark:text-zinc-100",children:"Tasks"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-zinc-400 mt-1",children:"Manage and track all your work in one place"})]}),(0,t.jsx)(rR.default,{showBoardSelector:!0,context:"home",boardId:o.get("board")||void 0})]}),"intelligence"===x&&(0,t.jsxs)("div",{className:"mx-8 md:mx-32 mt-8 mb-10",children:[(0,t.jsxs)("div",{className:"mb-6",children:[(0,t.jsx)("h1",{className:"text-3xl font-black tracking-tight text-gray-900 dark:text-zinc-100",children:"Campaign Intelligence"}),(0,t.jsx)("p",{className:"text-sm text-gray-500 dark:text-zinc-400 mt-1",children:"Real-time performance, creator value lenses, and filters across every campaign"})]}),(0,t.jsx)(sS,{})]})]})}function s4(){return(0,t.jsxs)("div",{className:"fixed inset-0 z-[100] flex flex-col items-center justify-center bg-white dark:bg-zinc-950",children:[(0,t.jsx)("div",{className:"absolute bottom-0 right-0 w-[60vw] h-[40vh] opacity-[0.07] pointer-events-none",style:{background:"radial-gradient(ellipse at 80% 90%, rgba(249,115,22,0.8), transparent 70%)"}}),(0,t.jsxs)("h1",{className:"text-2xl font-black tracking-tight text-gray-900 dark:text-zinc-100 mb-10",children:["Social",(0,t.jsx)("span",{style:{background:"linear-gradient(to right, #ec4899, #f97316)",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent"},children:"Scout"})]}),(0,t.jsx)("div",{className:"flex items-end gap-[5px] h-12 mb-8",children:[0,1,2,3,4].map(e=>(0,t.jsx)("div",{className:"w-[4px] rounded-full bg-gradient-to-t from-orange-500 to-amber-400 animate-pulse",style:{height:16+5*e,animationDelay:`${100*e}ms`,animationDuration:"0.8s"}},e))}),(0,t.jsx)("p",{className:"text-[13px] font-medium text-gray-400 dark:text-zinc-500 tracking-wide",children:"Loading your dashboard"}),(0,t.jsx)("div",{className:"absolute bottom-0 left-0 right-0 h-[2px] bg-gray-100 dark:bg-zinc-900 overflow-hidden",children:(0,t.jsx)("div",{className:"h-full w-1/3 bg-gradient-to-r from-transparent via-orange-400/60 to-transparent",style:{animation:"shimmerSlide 1.8s ease-in-out infinite"}})}),(0,t.jsx)("style",{children:` 2 @keyframes shimmerSlide { 3 0% { transform: translateX(-100%); } 4 100% { transform: translateX(400%); } 5 } 6 `})]})}e.s(["default",0,function(){return(0,t.jsx)(a.Suspense,{fallback:(0,t.jsx)(s4,{}),children:(0,t.jsx)(s5,{})})}],81694)},343794,(e,t,a)=>{!function(){"use strict";var a={}.hasOwnProperty;function r(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];
6n&&(e=s(e,function(e){if("string"==typeof e||"number"==typeof e)return e;if("object"!=typeof e)return"";if(Array.isArray(e))return r.apply(null,e);if(e.toString!==Object.prototype.toString&&!e.toString.toString().includes("[native code]"))return e.toString();var t="";for(var n in e)a.call(e,n)&&e[n]&&(t=s(t,n));return t}(n)))}return e}function s(e,t){return t?e?e+" "+t:e+t:e}if(t.exports)r.default=r,t.exports=r;else if("function"==typeof define&&"object"==typeof define.amd&&define.amd)void 0!==r&&e.v(r);else window.classNames=r}()}]);
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.