1import{k as ce,e as me,aE as pe,aP as ue,r as p,f as z,J as ge,l as he,j as e,a1 as q,B as C,C as G,a as K,d as xe,p as be,s as je,O as ve,Q as j,V as v,W as f,Y as y,X as fe,aQ as B,$ as N,I as U,a9 as ee,S as ye,a2 as Ne,D as W,E as A,ab as we,aB as Ce,al as Se,a4 as ke,a6 as S,aR as Ie,aS as Ue}from"./index-CAQ9C6-z.js";import{m as Fe}from"./formInvalid-D7amXiOx.js";import{S as Pe,a as De,b as Te,c as _e,d as k}from"./select-C1jcuWaT.js";import{A as J,a as H}from"./alert-CTONyx1G.js";import{d as qe}from"./directUpload-Dc5aW8FH.js";import{F as Be}from"./FocalPointSlider-D0YRD_6R.js";import{c as Ae,i as Ee}from"./calendarDate-Cy0AuFih.js";import{e as Le,i as Re,I as Oe,t as $e,a as Me}from"./intakeQuestions-iYeXwBPH.js";import{A as X}from"./arrow-left-BrnCBqZV.js";import{S as Ve}from"./shield-check-CxKDUjoc.js";import{U as Z}from"./upload-BTVigLWl.js";import{I as Ye}from"./image-vQO19pbr.js";import"./index-BdQq_4o_.js";import"./index-Q3UH4NY9.js";import"./chevron-down--E-1bxpl.js";import"./chevron-up-BOfZRiUg.js";import"./slider-B6J5yanw.js";const Qe=ke({title:S().min(1,"Title is required"),description:S().min(1,"Description is required"),category:S().min(1,"Category is required"),budget:Ue().optional(),deadline:S().optional(),imageUrl:S().min(1,"Campaign image is required"),applicationUrl:S().url("Please enter a valid URL").optional().or(Ie(""))});function ca(){const{toast:d}=ce(),[,m]=me(),{activeManagedBrandId:u}=pe(),[t,h]=ue("/brand/campaigns/:id/edit"),l=t?h==null?void 0:h.id:void 0,r=!!l,s=p.useRef(null),[g,x]=p.useState(null),[b,w]=p.useState(null),[R,F]=p.useState(!1),[ae,P]=p.useState(!1),[D,O]=p.useState(50),[$,M]=p.useState(Le()),{data:I}=z({queryKey:["/api/brand-profile"]});p.useEffect(()=>{I!=null&&I.profile&&M(Re(I.profile))},[I]);const{data:T,isLoading:V}=z({queryKey:["/api/brand/campaigns"],select:a=>a.campaigns??[],enabled:r}),i=r?T==null?void 0:T.find(a=>String(a.id)===String(l)):void 0,c=ge({resolver:Ne(Qe),defaultValues:{title:"",description:"",category:"brand_partnerships_campaign",budget:void 0,deadline:void 0,imageUrl:"",applicationUrl:""}});p.useEffect(()=>{i&&(c.reset({title:i.title||"",description:i.description||"",category:i.category||"brand_partnerships_campaign",budget:i.budget??void 0,deadline:i.deadline??void 0,imageUrl:i.imageUrl||"",applicationUrl:i.applicationUrl||""}),i.imageUrl&&w(i.imageUrl),O(i.imageFocalY??50))},[i]);const te=async a=>{const{imageUrl:n}=await qe("/api/upload/campaign-image",a);return n},_=he({mutationFn:async a=>{if(g){F(!0);try{const o=await te(g);a.imageUrl=o}catch(o){throw F(!1),o}F(!1)}r&&l?await A("PUT",`/api/brand/campaigns/${l}`,{...a,imageFocalY:D}):await A("POST","/api/brand/campaigns",{...a,imageFocalY:D,...u?{managedBrandId:u}:{}});const n=$e($);if(Object.keys(n).length>0)try{await A("PUT","/api/brand-profile",n)}catch(o){console.error("[brand] intake profile enrichment failed:",o)}},onSuccess:()=>{d({title:r?"Campaign updated":"Campaign submitted for review",description:r?"Your changes were saved and your campaign is back in the review queue.":"The Festival Babes team will review your campaign shortly."}),W.invalidateQueries({queryKey:["/api/brand/campaigns"]}),W.invalidateQueries({queryKey:["/api/brand-profile"]}),m("/brand/campaigns")},onError:a=>{d({title:"Error",description:a.message||"Failed to submit campaign",variant:"destructive"})}}),Y=a=>{if(!a){x(null),w(null),c.setValue("imageUrl","");return}if(!["image/jpeg","image/jpg","image/png","image/webp"].includes(a.type)){d({title:"Invalid file type",description:"Please upload a JPG, PNG, or WebP image",variant:"destructive"});return}if(a.size>50*1024*1024){d({title:"File too large",description:"Please upload an image smaller than 50MB",variant:"destructive"});return}x(a);const o=new FileReader;o.onload=de=>{var Q;w((Q=de.target)==null?void 0:Q.result),c.setValue("imageUrl","pending")},o.readAsDataURL(a)},re=a=>{var o;const n=((o=a.target.files)==null?void 0:o[0])||null;Y(n)},ie=p.useCallback(a=>{a.preventDefault(),P(!0)},[]),se=p.useCallback(a=>{a.preventDefault(),P(!1)},[]),ne=p.useCallback(a=>{var o;a.preventDefault(),P(!1);const n=((o=a.dataTransfer.files)==null?void 0:o[0])||null;n&&n.type.startsWith("image/")?Y(n):d({title:"Invalid file",description:"Please drop an image file",variant:"destructive"})},[]),le=()=>{x(null),w(null),c.setValue("imageUrl",""),s.current&&(s.current.value="")},oe=a=>{if(!g&&!(r&&(i!=null&&i.imageUrl)&&b)){d({title:"Image required",description:"Please upload a campaign image",variant:"destructive"});return}_.mutate(a)};return r&&V?e.jsxs("div",{className:"max-w-4xl space-y-6 py-8 text-center text-muted-foreground",children:[e.jsx(q,{className:"w-6 h-6 animate-spin mx-auto"}),"Loading your campaign..."]}):r&&!V&&!i?e.jsxs("div",{className:"max-w-4xl space-y-6",children:[e.jsxs(C,{variant:"ghost",onClick:()=>
1m("/brand/campaigns"),className:"gap-2","data-testid":"button-back",children:[e.jsx(X,{className:"w-4 h-4"}),"Back to My Campaigns"]}),e.jsx(G,{children:e.jsx(K,{className:"py-10 text-center text-muted-foreground",children:"We couldn't find that campaign. It may have been approved already or removed."})})]}):e.jsxs("div",{className:"max-w-4xl space-y-6",children:[e.jsxs(C,{variant:"ghost",onClick:()=>m("/brand/campaigns"),className:"gap-2","data-testid":"button-back",children:[e.jsx(X,{className:"w-4 h-4"}),"Back to My Campaigns"]}),e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"text-3xl md:text-4xl font-bold font-heading text-foreground",children:r?"Edit Campaign":"Submit a Campaign"}),e.jsx("p",{className:"text-muted-foreground mt-2",children:r?"Update your campaign details and resubmit":"Share an opportunity with our creator community"})]}),e.jsxs(J,{className:"border-purple-500/30 bg-purple-500/5",children:[e.jsx(Ve,{className:"h-4 w-4 text-purple-500"}),e.jsx(H,{children:"Your campaign will be reviewed by The Festival Babes team before it goes live."})]}),r&&(i==null?void 0:i.submissionStatus)==="rejected"&&i.reviewNote&&e.jsx(J,{variant:"destructive",children:e.jsxs(H,{children:[e.jsx("strong",{children:"Review note from the team:"})," ",i.reviewNote]})}),e.jsxs(G,{className:"border-rose-400/10 shadow-[0_0_30px_rgba(232,165,152,0.1)] bg-gradient-to-br from-card via-card to-rose-400/5",children:[e.jsxs(xe,{className:"border-b border-rose-400/10 pb-6",children:[e.jsx(be,{className:"text-2xl",children:"Campaign Details"}),e.jsx(je,{className:"text-muted-foreground",children:"Provide information about your opportunity"})]}),e.jsx(K,{className:"pt-6",children:e.jsx(ve,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(oe,Fe(d)),className:"space-y-6",children:[e.jsx(j,{control:c.control,name:"imageUrl",render:()=>e.jsxs(v,{children:[e.jsx(f,{children:"Campaign Image *"}),e.jsx(y,{children:e.jsxs("div",{children:[e.jsx("input",{ref:s,type:"file",accept:"image/jpeg,image/jpg,image/png,image/webp",onChange:re,className:"hidden","data-testid":"input-image-file"}),b?e.jsxs("div",{className:"relative rounded-md overflow-hidden border border-border",children:[e.jsx("img",{src:b,alt:"Campaign preview",loading:"lazy",decoding:"async",className:"w-full h-[300px] object-cover","data-testid":"image-preview"}),e.jsxs("div",{className:"absolute top-2 right-2 flex gap-2",children:[e.jsx(C,{type:"button",size:"icon",variant:"secondary",onClick:()=>{var a;return(a=s.current)==null?void 0:a.click()},className:"bg-background/90 backdrop-blur-sm","data-testid":"button-change-image",children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsx(C,{type:"button",size:"icon",variant:"destructive",onClick:le,className:"bg-destructive/90 backdrop-blur-sm","data-testid":"button-remove-image",children:e.jsx(fe,{className:"h-4 w-4"})})]}),g&&e.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/60 to-transparent p-3",children:e.jsxs("div",{className:"flex items-center gap-2 text-white",children:[e.jsx(Ye,{className:"h-4 w-4"}),e.jsx("p",{className:"text-sm font-medium truncate",children:g.name})]})})]}):e.jsx("div",{onClick:()=>{var a;return(a=s.current)==null?void 0:a.click()},onDragOver:ie,onDragLeave:se,onDrop:ne,className:` 2 relative cursor-pointer rounded-md border-2 border-dashed p-8 3 transition-all duration-200 hover:border-primary/50 hover:bg-accent/5 4 ${ae?"border-primary bg-accent/10":"border-muted-foreground/25"} 5 `,"data-testid":"dropzone-image",children:e.jsxs("div",{className:"flex flex-col items-center justify-center text-center",children:[e.jsx("div",{className:"rounded-full bg-primary/10 p-3 mb-4",children:e.jsx(Z,{className:"h-8 w-8 text-primary"})}),e.jsx("p",{className:"text-sm font-medium mb-1",children:"Drag & drop your image here, or click to browse"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"JPG, PNG, or WebP"})]})})]})}),b&&e.jsx(Be,{imageUrl:b,value:D,onChange:O}),e.jsx(B,{children:"Upload an eye-catching image for your campaign (required)"}),e.jsx(N,{})]})}),e.jsx(j,{control:c.control,name:"title",render:({field:a})=>e.jsxs(v,{children:[e.jsx(f,{children:"Title"}),e.jsx(y,{children:e.jsx(U,{placeholder:"Campaign title...",...a,"data-testid":"input-title"})}),e.jsx(N,{})]})}),e.jsx(j,{control:c.control,name:"category",render:({field:a})=>e.jsxs(v,{children:[e.jsx(f,{children:"Category"}),e.jsxs(Pe,{onValueChange:a.onChange,value:a.value,children:[e.jsx(y,{children:e.jsx(De,{"data-testid":"select-category",children:e.jsx(Te,{placeholder:"Select a category"})})}),e.jsxs(_e,{children:[e.jsx(k,{value:"festival_campaign",children:"Festival Campaign"}),e.jsx(k,{value:"artist_track_campaign",children:"Artist Track Campaign"}),e.jsx(k,{value:"artist_show_campaign",children:"Artist Show Campaign"}),e.jsx(k,{value:"brand_partnerships_campaign",children:"Brand Partnerships Campaign"}
5),e.jsx(k,{value:"media_coverage_campaign",children:"Media Coverage Campaign"}),e.jsx(k,{value:"discounts_offers_freebies",children:"Discounts, Offers & Freebies"})]})]}),e.jsx(N,{})]})}),e.jsx(j,{control:c.control,name:"description",render:({field:a})=>e.jsxs(v,{children:[e.jsx(f,{children:"Description"}),e.jsx(y,{children:e.jsx(ee,{placeholder:"Describe the opportunity...",rows:5,...a,"data-testid":"input-description"})}),e.jsx(N,{})]})}),e.jsxs("div",{className:"rounded-lg border border-primary/20 bg-primary/5 p-4 sm:p-5 space-y-6",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(ye,{className:"h-5 w-5 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-semibold text-foreground",children:"Tell us your goals"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Your package covers the deliverables â these answers help our team (and our AI) build the highest-impact campaign for you. Tap the quick-picks or add your own."})]})]}),Oe.map(a=>e.jsx(ze,{question:a,answers:$,setAnswers:M},a.id))]}),e.jsx(j,{control:c.control,name:"applicationUrl",render:({field:a})=>e.jsxs(v,{children:[e.jsx(f,{children:"Offer / referral URL (optional)"}),e.jsx(y,{children:e.jsx(U,{type:"url",placeholder:"https://example.com/offer",...a,value:a.value||"","data-testid":"input-application-url"})}),e.jsx(B,{children:"If this is a discount, freebie, or referral (not an in-app apply), paste the link here. Creators tap Get this offer and go straight to that page."}),e.jsx(N,{})]})}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[e.jsx(j,{control:c.control,name:"budget",render:({field:a})=>e.jsxs(v,{children:[e.jsx(f,{children:"Budget (Optional)"}),e.jsx(y,{children:e.jsx(U,{type:"number",placeholder:"5000",...a,value:a.value||"",onChange:n=>a.onChange(n.target.value?Number(n.target.value):void 0),"data-testid":"input-budget"})}),e.jsx(B,{children:"In USD"}),e.jsx(N,{})]})}),e.jsx(j,{control:c.control,name:"deadline",render:({field:a})=>e.jsxs(v,{children:[e.jsx(f,{children:"Deadline (Optional)"}),e.jsx(y,{children:e.jsx(U,{type:"date",value:Ee(a.value),onChange:n=>a.onChange(n.target.value?Ae(n.target.value):void 0),"data-testid":"input-deadline"})}),e.jsx(N,{})]})})]}),e.jsxs("div",{className:"flex justify-end gap-4",children:[e.jsx(C,{type:"button",variant:"outline",onClick:()=>m("/brand/campaigns"),"data-testid":"button-cancel",children:"Cancel"}),e.jsx(C,{type:"submit",disabled:_.isPending||R,"data-testid":"button-submit",children:R?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"mr-2 h-4 w-4 animate-spin"}),"Uploading Image..."]}):_.isPending?e.jsxs(e.Fragment,{children:[e.jsx(q,{className:"mr-2 h-4 w-4 animate-spin"}),r?"Saving...":"Submitting..."]}):r?"Save & Resubmit":"Submit for Review"})]})]})})})]})]})}function ze({question:d,answers:m,setAnswers:u}){const t=d;if(t.type==="chips-multi"){const l=m[t.id]??[],r=s=>u(g=>{const x=g[t.id]??[],b=x.includes(s)?x.filter(w=>w!==s):[...x,s];return{...g,[t.id]:b}});return e.jsx(E,{label:t.label,helper:t.helper,children:e.jsx("div",{className:"flex flex-wrap gap-2",children:t.options.map(s=>e.jsx(L,{active:l.includes(s.value),onClick:()=>r(s.value),"data-testid":`chip-${String(t.id)}-${s.value}`,children:s.label},s.value))})})}if(t.type==="chips-single"){const l=m[t.id]??"";return e.jsx(E,{label:t.label,helper:t.helper,children:e.jsx("div",{className:"flex flex-wrap gap-2",children:t.options.map(r=>{const s=l===r.value;return e.jsx(L,{active:s,onClick:()=>u(g=>({...g,[t.id]:s?"":r.value})),"data-testid":`chip-${String(t.id)}-${r.value}`,children:e.jsxs("span",{className:"flex flex-col items-start leading-tight",children:[e.jsx("span",{children:r.label}),r.hint&&e.jsx("span",{className:"text-[10px] opacity-80",children:r.hint})]})},r.value)})})})}const h=m[t.id]??"";return e.jsxs(E,{label:t.label,helper:t.helper,children:[e.jsx("div",{className:"flex flex-wrap gap-2 mb-2",children:t.options.map(l=>e.jsxs(L,{add:!0,onClick:()=>u(r=>({...r,[t.id]:Me(r[t.id]??"",l.value)})),"data-testid":`pill-${String(t.id)}-${l.value}`,children:[e.jsx(we,{className:"w-3 h-3 mr-1 -ml-0.5"}),l.label]},l.value))}),e.jsx(ee,{value:h,onChange:l=>u(r=>({...r,[t.id]:l.target.value})),rows:t.rows??3,placeholder:t.placeholder,"data-testid":`input-${String(t.id)}`})]})}function E({label:d,helper:m,children:u}){return e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(Ce,{className:"text-sm font-medium",children:d}),m&&e.jsx("p",{className:"text-xs text-muted-foreground",children:m}),e.jsx("div",{className:"pt-1",children:u})]})}function L({active:d,add:m,className:u,children:t,...h}
5){return e.jsx("button",{type:"button",className:Se("inline-flex items-center rounded-full border px-3 py-1.5 text-xs font-medium transition-colors","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1 focus-visible:ring-offset-background",d?"border-transparent bg-primary text-primary-foreground shadow-sm":"border-primary/40 text-primary hover:bg-primary/10 hover:border-primary/60",u),...h,children:t})}export{ca as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.