1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5188],{3460:(a,t,e)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/almost-famous/campaigns",function(){return e(7997)}])},4358:(a,t,e)=>{"use strict";e.d(t,{A:()=>s});let s=(0,e(86346).A)("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]])},7997:(a,t,e)=>{"use strict";e.r(t),e.d(t,{__N_SSP:()=>P,default:()=>L});var s=e(6029),i=e(71541),l=e(55729),n=e(81278),r=e(82203),o=e.n(r),c=e(47374),d=e(30126),m=e(22259),u=e(4358),p=e(11482),g=e(98197),h=e(61242),f=e(58995),y=e(89708),x=e(28826),v=e(59688),j=e(14117),b=e(50129),w=e(81984),A=e(51540),k=e(29674),C=e(67363),N=e(77096);let T=[{value:"all",label:"All Platforms"},{value:"meta",label:"Meta"},{value:"google",label:"Google"},{value:"spotify",label:"Spotify"},{value:"tiktok",label:"TikTok"}],D=a=>"object"==typeof a&&null!==a&&!Array.isArray(a);var P=!0;let L=(0,i.X3)(function(){var a,t;let[e,i]=(0,l.useState)({query:"",status:"ALL",platform:"all"}),[r,P]=(0,l.useState)(1),[L,F]=(0,l.useState)("grid"),M=(0,n.useRouter)(),{selectedChannelId:E,channels:I,isWhitelabel:S,isLoading:_}=(0,w.G3)(),q=(()=>{switch(e.platform){case"meta":return"META";case"google":return"GOOGLE";case"spotify":return"SPOTIFY";case"tiktok":return"TIKTOK";default:return}})(),{data:O,isLoading:z,isError:R,refetch:$}=x.id.almostFamous.campaigns.list.useQuery({channelId:E||"",page:r,limit:20,status:"ALL"!==e.status?e.status:void 0,platform:q,search:e.query.trim()||void 0},{enabled:!!E,keepPreviousData:!0}),G=null==O?void 0:O.meta,Q={channelId:E||"",page:1,limit:1,search:e.query.trim()||void 0,platform:q},X={enabled:!!E,keepPreviousData:!0,staleTime:3e4},V=x.id.almostFamous.campaigns.list.useQuery({...Q,status:"ACTIVE"},X),U=x.id.almostFamous.campaigns.list.useQuery({...Q,status:"PAUSED"},X),K=x.id.almostFamous.campaigns.list.useQuery({...Q,status:"COMPLETED"},X),Y=x.id.almostFamous.campaigns.list.useQuery({...Q,status:"DRAFT"},X),B=a=>{var t,e;return"number"==typeof(null==(e=a.data)||null==(t=e.meta)?void 0:t.total)?String(a.data.meta.total):"â"},{data:H}=x.id.almostFamous.campaigns.listPayments.useQuery({channelId:E||""},{enabled:!!E}),W=(0,l.useMemo)(()=>{let a=new Map;if(!H)return a;for(let t of H)a.set(t.campaignId,t.status);return a},[H]),Z=(0,l.useMemo)(()=>(null==O?void 0:O.data)||[],[null==O?void 0:O.data]),J=x.id.almostFamous.campaigns.create.useMutation({onSuccess:a=>{M.push("/almost-famous/campaigns/".concat(a.id))}}),aa=x.id.useContext(),{runChain:at}=(0,k.F)(),ae=x.id.almostFamous.campaigns.duplicate.useMutation({onError:a=>{v.oR.error("Failed to duplicate: ".concat(a.message))}}),as=async(a,t)=>{if(a.preventDefault(),a.stopPropagation(),!E)return;let e=null;try{if(await at([async()=>{e=(await ae.mutateAsync({channelId:E,id:t})).id},async()=>{await aa.almostFamous.campaigns.list.invalidate(),$()}],{loadingToast:"Duplicating campaignâ¦",successToast:"Campaign duplicated",errorToast:"Failed to duplicate campaign"}),e){let a=e;M.push("/almost-famous/campaigns/".concat(a))}}catch(a){}},ai=a=>{if(!(a||E))return void v.oR.error("Please select a channel first");M.push("/almost-famous/campaign-creation")},al=(0,l.useMemo)(()=>{var a;let t=(null==O?void 0:O.data)||[];return{total:"number"==typeof(null==O||null==(a=O.meta)?void 0:a.total)?O.meta.total:t.length}},[null==O?void 0:O.data,null==O||null==(a=O.meta)?void 0:a.total]),an=a=>{let t,e=D(t=a.config)?t.platformDistribution:void 0;if(!D(e))return{};let s={};for(let[a,t]of Object.entries(e))"number"==typeof t&&(s[a]=t);return s},ar=(0,s.jsxs)(j.$n,{variant:"primary",size:"sm",onClick:()=>ai(),disabled:J.isLoading,"data-testid":"af-campaigns-new",children:[(0,s.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"New Campaign"]});return S||_||void 0===I||0!==I.length?(0,s.jsxs)(N.b,{eyebrow:"Campaign Management",title:"Campaigns",sub:"Manage your marketing campaigns across all platforms",actions:ar,testId:"af-campaigns-page",children:[(0,s.jsx)(b.
1wn,{className:"!py-0","data-testid":"af-campaigns-stats",children:(0,s.jsx)("div",{className:"grid grid-cols-2 gap-4 sm:grid-cols-3 lg:grid-cols-5",children:[{status:"ALL",label:"Total",value:al.total,testId:"all"},{status:"ACTIVE",label:"Active",value:B(V),testId:"active"},{status:"PAUSED",label:"Paused",value:B(U),testId:"paused"},{status:"COMPLETED",label:"Completed",value:B(K),testId:"completed"},{status:"DRAFT",label:"Draft",value:B(Y),testId:"draft"}].map(a=>{let{status:t,label:l,value:n,testId:r}=a,o=e.status===t;return(0,s.jsx)("button",{onClick:()=>{i({...e,status:t}),P(1)},className:"text-left","aria-pressed":o,"aria-label":"".concat(l," campaigns filter"),"data-testid":"af-campaigns-stat-".concat(r),children:(0,s.jsx)(j.$5,{label:l,value:n,animate:"ALL"===t,className:(0,A.cn)("h-full",o&&"border-accent")})},t)})})}),(0,s.jsxs)(b.wn,{className:"!py-0",children:[(0,s.jsx)(b.CD,{eyebrow:"Browse",title:"All Campaigns",meta:(0,s.jsxs)(s.Fragment,{children:[null!=(t=null==G?void 0:G.total)?t:Z.length," campaigns"]})}),(0,s.jsxs)(j.Hk,{"data-testid":"af-campaigns-filters",children:[(0,s.jsx)(j.ZX,{eyebrow:"Filters",title:"Search & Filter",meta:(0,s.jsx)(j.tU,{value:L,onValueChange:a=>{("grid"===a||"list"===a)&&F(a)},children:(0,s.jsxs)(j.j7,{className:"border-b-0",children:[(0,s.jsxs)(j.Xi,{value:"grid","aria-controls":void 0,"data-testid":"af-campaigns-view-grid",children:[(0,s.jsx)(m.A,{className:"mr-2 h-3.5 w-3.5"}),"Grid"]}),(0,s.jsxs)(j.Xi,{value:"list","aria-controls":void 0,"data-testid":"af-campaigns-view-list",children:[(0,s.jsx)(u.A,{className:"mr-2 h-3.5 w-3.5"}),"List"]})]})})}),(0,s.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[(0,s.jsxs)("div",{className:"relative flex-1",children:[(0,s.jsx)(p.A,{className:"absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted"}),(0,s.jsx)(j.pd,{type:"text",placeholder:"Search campaigns...","aria-label":"Search campaigns",value:e.query,onChange:a=>{i({...e,query:a.target.value}),P(1)},className:"pl-9","data-testid":"af-campaigns-search"})]}),(0,s.jsxs)(j.l6,{value:e.platform,onValueChange:a=>{i({...e,platform:"all"===a||"meta"===a||"google"===a||"spotify"===a||"tiktok"===a?a:"all"}),P(1)},children:[(0,s.jsx)(j.bq,{className:"w-full sm:w-[180px]","data-testid":"af-campaigns-platform-filter",children:(0,s.jsx)(j.yv,{placeholder:"All Platforms"})}),(0,s.jsx)(j.gC,{children:T.map(a=>(0,s.jsx)(j.eb,{value:a.value,children:a.label},a.value))})]})]})]})]}),z?(0,s.jsx)("div",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3","data-testid":"af-campaigns-loading",children:Array.from({length:6}).map((a,t)=>(0,s.jsx)(j.EA,{className:"h-72 w-full rounded-2xl"},t))}):R?(0,s.jsx)(j.pp,{"data-testid":"af-campaigns-error",icon:(0,s.jsx)(g.A,{className:"h-10 w-10"}),title:"Couldn't load campaigns",description:"Something went wrong while fetching your campaigns. Please try again.",action:(0,s.jsxs)(j.$n,{variant:"primary",onClick:()=>void $(),children:[(0,s.jsx)(h.A,{className:"mr-2 h-4 w-4"}),"Try again"]})}):0===Z.length?(0,s.jsx)(j.pp,{"data-testid":"af-campaigns-empty",icon:(0,s.jsx)(d.A,{className:"h-10 w-10"}),title:"ALL"!==e.status||e.query||"all"!==e.platform?"No campaigns match your filters":"No campaigns yet",description:"ALL"!==e.status||e.query||"all"!==e.platform?"Try adjusting your filters to see more campaigns":"Create your first marketing campaign to promote your music across platforms",action:"ALL"!==e.status||e.query||"all"!==e.platform?void 0:(0,s.jsxs)(j.$n,{variant:"primary",onClick:()=>ai(),disabled:J.isLoading,children:[(0,s.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"Create Your First Campaign"]})}):"grid"===L?(0,s.jsx)("section",{className:"grid gap-6 sm:grid-cols-2 lg:grid-cols-3","data-testid":"af-campaigns-grid",children:Z.map((a,t)=>{var e;return(0,s.jsx)(C.p_,{id:a.id,name:a.name,status:a.status,objective:a.objective,budgetTotal:a.budgetTotal,budgetDaily:a.budgetDaily,currency:a.currency,createdAt:a.createdAt,startDate:a.startDate,endDate:a.endDate,campaignPlatforms:a.campaignPlatforms,platformDistribution:an(a),paymentStatus:null!=(e=W.get(a.id))?e:null,latestPayment:a.latestPayment,onDuplicate:as,isDuplicating:ae.isPending,channelId:E||void 0,animationDelay:50*t},a.id)})}):(0,s.jsx)("section",{className:"space-y-3","data-testid":"af-campaigns-list",children:Z.map((a,t)=>{var e;return(0,s.jsx)(C.g9,{id:a.id,name:a.name,status:a.status,objective:a.objective,budgetTotal:a.budgetTotal,budgetDaily:a.budgetDaily,currency:a.currency,createdAt:a.createdAt,startDate:a.startDate,endD
1ate:a.endDate,campaignPlatforms:a.campaignPlatforms,platformDistribution:an(a),paymentStatus:null!=(e=W.get(a.id))?e:null,latestPayment:a.latestPayment,onDuplicate:as,isDuplicating:ae.isPending,channelId:E||void 0,onViewAnalytics:a=>void M.push("/almost-famous/campaigns/".concat(a)),animationDelay:30*t},a.id)})}),G&&G.totalPages>1&&Z.length>0&&(0,s.jsxs)("section",{className:"mt-8 flex items-center justify-center gap-4","data-testid":"af-campaigns-pagination",children:[(0,s.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>P(a=>Math.max(1,a-1)),disabled:r<=1,children:[(0,s.jsx)(f.A,{className:"mr-2 h-4 w-4"}),"Previous"]}),(0,s.jsxs)("span",{className:"font-mono text-xs text-muted tabular-nums",children:["Page"," ",(0,s.jsx)("span",{className:"font-semibold text-ink",children:G.page})," ","of"," ",(0,s.jsx)("span",{className:"font-semibold text-ink",children:G.totalPages})]}),(0,s.jsxs)(j.$n,{variant:"ghost",size:"sm",onClick:()=>P(a=>Math.min(G.totalPages,a+1)),disabled:r>=G.totalPages,children:["Next",(0,s.jsx)(y.A,{className:"ml-2 h-4 w-4"})]})]})]}):(0,s.jsx)(N.b,{eyebrow:"Campaign Management",title:"Campaigns",sub:"Create a channel to start advertising with Almost Famous",testId:"af-campaigns-page",narrow:!0,children:(0,s.jsx)(j.pp,{"data-testid":"af-campaigns-no-channel",icon:(0,s.jsx)(d.A,{className:"h-10 w-10"}),title:"Create a channel to start advertising",description:"Campaigns run on a channel. Create your first channel to launch ads across platforms.",action:(0,s.jsx)(j.$n,{asChild:!0,variant:"primary",children:(0,s.jsxs)(o(),{href:"/new-channel",children:[(0,s.jsx)(c.A,{className:"mr-2 h-4 w-4"}),"Create a channel"]})})})})})},22259:(a,t,e)=>{"use strict";e.d(t,{A:()=>s});let s=(0,e(86346).A)("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]])},29674:(a,t,e)=>{"use strict";e.d(t,{F:()=>n});var s=e(55729),i=e(59688);let l=a=>{if(a instanceof Error)return a.message;if("string"==typeof a)return a;if("object"==typeof a&&null!==a&&"message"in a){let t=Reflect.get(a,"message");if("string"==typeof t)return t}return String(a)};function n(){return{runChain:(0,s.useCallback)(function(a,t){var e;if(0===a.length)throw Error("useChainedToast.runChain requires at least one step");let s=async()=>{let t;for(let e of a)t=await e();return t};return i.oR.promise(s(),{loading:null!=(e=t.loadingToast)?e:"Workingâ¦",success:a=>"function"==typeof t.successToast?t.successToast(a):t.successToast,error:a=>"function"==typeof t.errorToast?t.errorToast(a):t.errorToast?"".concat(t.errorToast,": ").concat(l(a)):l(a)||"Operation failed"}).unwrap()},[])}}}},a=>{a.O(0,[194,9897,106,714,9573,7881,8706,5048,1006,7516,3197,7363,636,6593,8792],()=>a(a.s=3460)),_N_E=a.O()}]);
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.