PageSourceSearch

https://cdn.azmen.com/react/v101/chunks/EditUploadPage.js

js azmen.com collected 2026-09-28 06:31:02 UTC 35,990 bytes, 1 lines download raw bytes

1import{r as o,j as t,b as ge,d as ye,g as Oe,a3 as Be,c as Qe,e as At,h as Tt,u as Mt,f as Ot,p as Bt,o as _t,a as Xe}from"../app.js";import{s as Pt}from"./authActions.js";import{S as F}from"./sentry.js";import{f as Te,g as $t,i as qt}from"./helpers.js";import{E as Me}from"./EntityAutocomplete.js";import{F as zt,C as Wt,a as Yt,T as Dt,A as fe}from"./AddEntityModal.js";import{L as Ht,s as Vt,p as Gt,l as Jt}from"./Lightbox.js";import"./profileHelpers.js";const Kt=/permission[_ ]denied/i;function Zt(p){const r=p?.files;if(!r)return[];const u=Array.isArray(r)?r:Object.values(r),h=[],B=new Set;for(const k of u){const y=typeof k=="string"?k:k?.fileId;typeof y=="string"&&y&&!B.has(y)&&(B.add(y),h.push(y))}return h}function Qt(p){return p?.code==="PERMISSION_DENIED"||Kt.test(String(p?.message||""))}async function Xt(p,r){return Promise.all(p.map(async u=>{try{const h=await r(u);return h?.exists()?{id:u,status:"ok",record:h.val()}:{id:u,status:"missing"}}catch(h){return{id:u,status:Qt(h)?"denied":"error",error:h}}}))}function es(p){return p.map((r,u)=>{const h=r.status==="ok"&&r.record?r.record:{},B=typeof h.downloadURL=="string"&&h.downloadURL?h.downloadURL:null;let k="unreadable";return B?k="ok":(r.status==="ok"||r.status==="missing")&&(k="archived"),{id:r.id,number:u+1,state:k,available:k==="ok",downloadURL:B,fileType:h.fileType||null,fileSize:h.fileSize||null}})}function ts(p){const r=p.filter(u=>u.status==="denied"||u.status==="error");return r.length===0?null:{error:r[0].error,status:r.every(u=>u.status===r[0].status)?r[0].status:"mixed",fileIds:r.map(u=>u.id),total:p.length}}function ss(p,r){return p.state==="unreadable"?"Couldn’t load · try reloading":p.state==="archived"||r?"Archived · no preview":"No preview"}function ns({siteCount:p,fileCount:r,unpreviewableCount:u}){return p===0?null:r===0?"This upload doesn’t list any original files. This is what the site shows for it:":u>0?"Some original files can’t be previewed here. This is what the site shows for this upload:":null}function rs(p,r){return p.length===0?null:p.filter(h=>!h.markedForRemoval).length===0&&r.length===0?"You cannot remove all files without adding new ones.":null}function as({user:p,uploadData:r,uploadFiles:u,siteMedia:h=[],siteTitle:B="",varValues:k,isAzFans:y=!1,keepExistingEdits:we=!1}){const K=e=>e&&(e.includes("/")||e.startsWith("http")),ne=e=>e&&(e.startsWith("video/")||e.includes("video")),oe=e=>e&&(e.startsWith("image/")||e.includes("image")),I=r.gender==="male"?"m":"f",x=r.type||"movie",Z=(r.celebName||"").split("|").filter(Boolean),A=(r.celebIds||"").split("|").filter(Boolean),j=(r.appearance||"").split("|"),le=()=>Z.map((e,s)=>{const n=A[s]||"";return{id:`existing-${s}-${Date.now()}`,name:e==="az-undetermined"?"Unknown Celebrity":e,firebaseId:n,thumb:K(n)?n:"",appearance:j[s]&&j[s]!=="-1"?j[s]:"",isOriginal:!0,isUnknown:e==="az-undetermined"}}),ve=()=>{if(x==="movie"){const e=r.movieId||"";return{name:r.movieName||"",id:e,thumb:K(e)?e:"",isUnknown:r.movieName==="az-undetermined"}}if(x==="series"){const e=r.seriesId||"";return{name:r.seriesName||"",id:e,thumb:K(e)?e:"",isUnknown:r.seriesName==="az-undetermined"}}if(x==="story"){const e=r.storyId||"";return{name:r.storyName||"",id:e,thumb:K(e)?e:"",isUnknown:!1}}return{name:"",id:"",thumb:"",isUnknown:!1}},P=r.categories?r.categories.split("|").map(e=>e.trim()).filter(Boolean):[],Y=r.tags?r.tags.split(",").map(e=>e.trim()).filter(Boolean):[],d=we&&r.editRequest?.changes||null,[b,D]=o.useState(()=>{const e=d?.filesRemoved?.map(s=>s.fileId)||[];return u.map(s=>({...s,markedForRemoval:e.includes(s.id),replacementFile:null,replacementPreview:null,replacementProgress:0}))}),[w,_]=o.useState([]),[$,de]=o.useState(()=>new Set),U=e=>de(s=>s.has(e)?s:new Set(s).add(e)),T=e=>e.available&&!$.has(e.id)&&(oe(e.fileType)||ne(e.fileType)),[M,ce]=o.useState(()=>new Set),[N,je]=o.useState(null),Ne=o.useMemo(()=>b.filter(T),[b,$]),et=o.useMemo(()=>Ne.map(e=>ne(e.fileType)?{mp4:e.downloadURL,thumbnail:e.downloadURL}:{src:e.downloadURL,thumbnail:e.downloadURL}),[Ne]),tt=e=>{const s=Ne.findIndex(n=>n.id===e);s!==-1&&je({items:et,start:s})},st=e=>je({...Vt(h,M,e),title:B,status:"published"}),_e=ns({siteCount:h.length-M.size,fileCount:b.length,unpreviewableCount:b.filter(e=>!T(e)).length}),[R,me]=o.useState(()=>{const e=le();return d?.celebsModified&&d.celebsModified.forEach(s=>{const n=e.findIndex(a=>a.firebaseId===s.originalId);n!==-1&&s.appearanceChanged&&(e[n]={...e[n],appearance:s.newAppearance})}),e}),[H,ke]=o.useState(()=>{if(!d?.celebsRemoved?.length)return new Set;const e=d.celebsRemoved.map(n=>n.id),s=new Set;return A.forEach((n,a)=>{e.includes(n)&&s.add(a)}),s}),[Q,q]=o.useState(null),[z,X]=o.useState(()=>d?.celebsAdded?.length?d.celebsAdded.map(e=>({id:`restored-${Date.now()}-${Math.random()}`,name:e.name,firebaseId:e.id,appearance:e.appearance||"",thumb:"",disabled:!0})):[]),[nt,re]=o.useState(!1),[C,rt]=o.useState(d?.typeChanged?d.typeChanged.to:x),[v]=o.useState(ve),[ae,ee]=o.useState(!!d?.entityRemoved),[g,W]=o.useState(()=>d?.entityAdded?{name:d.entityAdded.name,id:d.entityAdded.id,yor:d.entityAdded.yor||"",thumb:""}:{name:"",id:"",yor:"",thumb:""}),at=e=>{rt(e),e!==x?(ee(!0),W({name:"",id:"",yor:"",thumb:""})):(ee(!1),W({name:"",id:"",yor:"",thumb:""}))},[pe,it]=o.useState(()=>{if(!d?.categoriesAdded&&!d?.categoriesRemoved)return P;let e=[...P];return d.categoriesRemoved&&(e=e.filter(s=>!d.categoriesRemoved.includes(s))),d.categoriesAdded&&(e=[...e,...d.categoriesAdded.filter(s=>!e.includes(s))]),e}),[ue,ot]=o.useState(()=>{if(!d?.tagsAdded&&!d?.tagsRemoved)return Y;let e=[...Y];return d.tagsRemoved&&(e=e.filter(s=>!d.tagsRemoved.includes(s))),d.tagsAdded&&(e=[...e,...d.tagsAdded.filter(s=>!e.includes(s))]),e}),[f,lt]=o.useState(d?.genderChanged?d.genderChanged.to==="male"?"m":"f":I),dt=e=>{e!==f&&(lt(e),e===I?(ke(new Set),me(le()),X([]),q(null),re(!1),ee(!1),W({name:"",id:"",yor:"",thumb:""})):(ke(new Set(R.map((s,n)=>n))),X([]),q(null),re(!1),ee(!0),W({name:"",id:"",yor:"",thumb:""})))},[ct,V]=o.useState(!1),[is,te]=o.useState(null),[Pe,Ce]=o.useState(null),[$e,qe]=o.useState(null),[mt,Se]=o.useState(!1),[pt,Re]=o.useState(!1),[ut,Ie]=o.useState(!1),[Ee,ze]=o.useState(!1),[We,se]=o.useState(""),[Ye,os]=o.use
1State(""),Le=o.useRef(null),De=!y&&C!=="story",ht=e=>{D(s=>s.map(n=>n.id===e?{...n,markedForRemoval:!n.markedForRemoval}:n))},xt=e=>{const s=document.createElement("input");s.type="file",s.accept="video/*",s.onchange=n=>{const a=n.target.files[0];if(!a)return;const l=URL.createObjectURL(a);D(c=>c.map(m=>m.id===e?{...m,replacementFile:a,replacementPreview:l,markedForRemoval:!1}:m))},s.click()},bt=e=>{D(s=>s.map(n=>(n.id===e&&n.replacementPreview&&URL.revokeObjectURL(n.replacementPreview),n.id===e?{...n,replacementFile:null,replacementPreview:null,replacementProgress:0}:n)))},ft=e=>{ke(s=>{const n=new Set(s);return n.has(e)?n.delete(e):n.add(e),n}),Q===e&&q(null)},gt=(e,s)=>{me(n=>{const a=[...n];return a[e]={...a[e],appearance:s},a})},yt=e=>e&&e.startsWith("-")&&!e.includes("/"),wt=async e=>{try{const s=f==="m"?"m":"f",n=new URLSearchParams({q:e.trim(),type:"celebs",gender:s});let a={};try{if(typeof getSearchTokenFor=="function"&&typeof PRIMARY_BASE<"u"){const E=await getSearchTokenFor(PRIMARY_BASE);a={"x-st":E.token,...E.sid?{"x-sid":E.sid}:{}}}}catch{}const l=await fetch(`${PRIMARY_BASE}/exp/fetch-for-upload?${n}`,{method:"GET",headers:{...a},credentials:typeof IS_LOCAL<"u"&&IS_LOCAL?"omit":"include"});if(!l.ok)return null;const c=await l.json();return!Array.isArray(c)||c.length===0?null:c.find(E=>E.text?.toLowerCase()===e.toLowerCase())||c[0]}catch(s){return F.captureException(s,{tags:{area:"edit-upload",op:"fetchCelebFromSearch"}}),null}},vt=async e=>{const s=R[e];if(!(!s||!s.firebaseId)){qe(e);try{let n=null;if(yt(s.firebaseId)){const a=ge(ye),l=await Oe(Be(a,`celebs/${s.firebaseId}`));l.exists()&&(n=l.val())}else{const a=await wt(s.name);if(a){const l=a.dob?new Date(a.dob):null,c=l?`${String(l.getMonth()+1).padStart(2,"0")}/${String(l.getDate()).padStart(2,"0")}/${l.getFullYear()}`:"";n={name:a.text||s.name,dateOfBirth:c,photoURL:s.thumb||"",country:a.country||"",imdbUrl:"",socials:[],shoeSize:"",_fromSearch:!0}}}n?(n._firebaseId=s.firebaseId,n._appearance=s.appearance,n._celebIndex=e,Ce(n),q(e),V(!0)):se("Could not load celebrity details. The record may not exist.")}catch(n){F.captureException(n,{tags:{area:"edit-upload",op:"fetchCelebRecord"},extra:{firebaseId:s.firebaseId}}),se("Failed to load celebrity details. Please try again.")}finally{qe(null)}}},jt=e=>{const s=Q;s!==null&&(me(n=>{const a=[...n];return a[s]={...a[s],name:e.name,firebaseId:e.firebaseId,thumb:e.thumb||a[s].thumb,appearance:e.appearance||a[s].appearance,isUnknown:!1,detailsEdited:!0,_editedRecord:e._editedRecord,_originalRecord:e._originalRecord},a}),V(!1),Ce(null),q(null),te(null))},He=(e,s)=>{me(n=>{const a=[...n];return a[e]={...a[e],name:s.name,firebaseId:s.firebaseId||s.id,thumb:s.thumb||"",appearance:a[e].appearance,isUnknown:!1,swapped:!0},a}),q(null)},Nt=e=>{Q!==null&&He(Q,e),V(!1),te(null)},kt=e=>{X(s=>s.some(n=>n.firebaseId===e.firebaseId)?s:[...s,{...e,appearance:""}]),re(!1)},Ct=e=>{X(s=>[...s,{...e,appearance:""}]),V(!1),te(null)},St=e=>{X(s=>s.filter((n,a)=>a!==e))},Rt=(e,s)=>{X(n=>{const a=[...n];return a[e]={...a[e],appearance:s},a})},It=e=>{W({name:e.name,id:e.id,yor:e.yor||"",thumb:e.thumb||""})},Ue=e=>{W({name:e.name,id:e.id,yor:e.yor||"",thumb:e.thumb||""}),Se(!1),Re(!1),Ie(!1)},Fe=()=>{W({name:"",id:"",yor:"",thumb:""})},Et=()=>{const e=b.some(L=>L.markedForRemoval),s=b.some(L=>L.replacementFile),n=w.length>0,a=H.size>0,l=z.length>0,c=R.some(L=>L.swapped),m=R.some(L=>L.detailsEdited),E=R.some((L,ie)=>{const Ae=j[ie]&&j[ie]!=="-1"?j[ie]:"";return L.appearance!==Ae}),O=ae||!!g.id,G=C!==x,J=f!==I,he=JSON.stringify([...pe].sort())!==JSON.stringify([...P].sort()),xe=JSON.stringify([...ue].sort())!==JSON.stringify([...Y].sort());return e||s||n||a||l||c||E||m||O||G||J||he||xe},Lt=async e=>{e.preventDefault(),ze(!0),se("");try{if(F.addBreadcrumb({category:"edit-upload",message:"Edit request submit started",level:"info",data:{uploadId:r.id}}),!Et())throw new Error("No changes detected. Modify something before submitting.");const s=rs(b,w);if(s)throw new Error(s);const n=R.filter((i,S)=>!H.has(S)),a=R.some(i=>i.isUnknown);if(n.length===0&&z.length===0&&!a)throw new Error("At least one celebrity must remain on the upload.");let l=[];w.length>0&&(l=await Ut(w));let c=[];for(const i of b.filter(S=>S.replacementFile)){const S=await Ve(i.replacementFile,r.id);c.push({originalFileId:i.id,originalDownloadURL:i.downloadURL,originalFileType:i.fileType,newFileId:S.fileId,newDownloadURL:S.downloadURL,newFileType:i.replacementFile.type,newFileSize:Te(i.replacementFile.size)})}const m={},E=b.filter(i=>i.markedForRemoval&&!i.replacementFile).map(i=>({fileId:i.id,downloadURL:i.downloadURL,fileType:i.fileType}));E.length>0&&(m.filesRemoved=E),l.length>0&&(m.filesAdded=l),c.length>0&&(m.filesReplaced=c);const O=[];H.forEach(i=>
1{R[i]&&O.push({name:Z[i],id:A[i]})}),O.length>0&&(m.celebsRemoved=O),z.length>0&&(m.celebsAdded=z.map(i=>({name:i.name,id:i.firebaseId,appearance:i.appearance||""})));const G=[];R.forEach((i,S)=>{if(H.has(S))return;const Ge=j[S]&&j[S]!=="-1"?j[S]:"",Je=i.swapped,Ke=i.appearance!==Ge,Ze=i.detailsEdited;if(Je||Ke||Ze){const be={originalName:Z[S],originalId:A[S],newName:i.name,newId:i.firebaseId,newAppearance:i.appearance||"",...Je?{swapped:!0}:{},...Ke?{appearanceChanged:!0,originalAppearance:Ge}:{}};Ze&&i._editedRecord&&i._originalRecord&&(be.detailsEdited=!0,be.editedRecord=i._editedRecord,be.originalRecord={name:i._originalRecord.name,dateOfBirth:i._originalRecord.dateOfBirth,country:i._originalRecord.country,photoURL:i._originalRecord.photoURL,imdbUrl:i._originalRecord.imdbUrl,socials:i._originalRecord.socials,shoeSize:i._originalRecord.shoeSize}),G.push(be)}}),G.length>0&&(m.celebsModified=G),f!==I&&(m.genderChanged={from:I==="m"?"male":"female",to:f==="m"?"male":"female"}),C!==x&&(m.typeChanged={from:x,to:C}),ae&&(m.entityRemoved={type:x,name:v.name,id:v.id}),g.id&&(m.entityAdded={type:C,name:g.name,id:g.id,yor:g.yor});const J=pe.filter(i=>!P.includes(i)),he=P.filter(i=>!pe.includes(i));J.length>0&&(m.categoriesAdded=J),he.length>0&&(m.categoriesRemoved=he);const xe=ue.filter(i=>!Y.includes(i)),L=Y.filter(i=>!ue.includes(i));xe.length>0&&(m.tagsAdded=xe),L.length>0&&(m.tagsRemoved=L);const ie=await $t(),Ae={createdOn:Date.now(),status:"pending",ip:ie,original:{celebNames:r.celebName||"",celebIds:r.celebIds||"",appearances:r.appearance||"",type:x,entityName:v.name,entityId:v.id,categories:r.categories||"",tags:r.tags||"",website:r.website||"",gender:r.gender||"",genderShort:I},changes:m},Ft=ge(ye,`uploads/${r.id}/editRequest`);await Qe(Ft,Ae),F.addBreadcrumb({category:"edit-upload",message:"Edit request saved",level:"info",data:{uploadId:r.id}}),window.location.href="/profile.html#edit-requests"}catch(s){F.captureException(s,{tags:{area:"edit-upload",op:"submit"},extra:{uploadId:r.id}}),se(s.message),ze(!1),setTimeout(()=>{Le.current?.scrollIntoView({behavior:"smooth",block:"center"})},100)}},Ve=async(e,s)=>{const a=`Uploads/${`${Date.now()}-${e.name}`}`,l=At(Tt,a);return new Promise((c,m)=>{Mt(l,e,{contentType:e.type}).on("state_changed",null,m,async()=>{try{const O=await Ot(l),G=ge(ye,"files"),J=Bt(G);await Qe(J,{uploadedBy:p.uid,downloadURL:O,createdOn:Date.now(),uploadId:s,fileType:e.type,fileSize:Te(e.size),fileURL:a}),c({fileId:J.key,downloadURL:O,fileType:e.type,fileSize:Te(e.size)})}catch(O){m(O)}})})},Ut=async e=>{const s=[];for(const n of e){const a=await Ve(n.file,r.id);s.push(a),_(l=>l.map(c=>c.id===n.id?{...c,isDone:!0,progress:100}:c))}return s};return Ye?t.jsxs("div",{className:"max-w-[900px] mx-auto px-4 py-8",children:[t.jsx("div",{className:"alert-bar !bg-green-500/10 !border-green-500/30 !text-green-400 mb-6",children:t.jsxs("div",{className:"flex-1",children:[t.jsxs("svg",{className:"inline-block mr-2 align-middle",width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),t.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),Ye]})}),t.jsx("a",{href:"/profile.html#content-uploaded",className:"btn-primary-tw inline-block py-2.5 px-6 text-sm",children:"Back to My Uploads"})]}):t.jsxs("div",{className:"max-w-[900px] mx-auto px-4 pb-10",children:[t.jsxs("div",{className:"flex items-center justify-between mb-1",children:[t.jsx("h1",{className:"text-[22px] font-semibold",children:"Edit Upload"}),t.jsx("a",{href:"/profile.html#content-uploaded",className:"btn-ghost text-sm",children:"← Back"})]}),t.jsx("p",{className:"text-[#888] text-sm mb-5",children:"Make your changes below. All edits are submitted as a request and will be reviewed within 72 hours."}),We&&t.jsxs("div",{ref:Le,className:"alert-bar mb-5 !bg-red-500/10 !border-red-500/30 !text-red-400",tabIndex:"0",children:[t.jsx("div",{className:"flex-1",children:We}),t.jsx("button",{type:"button",onClick:()=>se(""),className:"alert-bar-close !text-red-400","aria-label":"Dismiss",children:"×"})]}),t.jsx("form",{onSubmit:Lt,onKeyDown:e=>e.key==="Enter"&&e.preventDefault(),children:t.jsxs("fieldset",{disabled:Ee,className:"border-none p-0 m-0 space-y-6",children:[!y&&t.jsxs("section",{children:[t.jsxs("h2",{className:"text-[17px] font-semibold mb-3 flex items-center gap-2",children:[t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("circle",{cx:"12",cy:"12",r:"10"}),t.jsx("path",{d:"M12 8v8"}),t.jsx("path",{d:"M8 12h8"})]}),"Gender"]}),t.jsx("div",{className:"flex flex-wrap gap-2",children:[{value:"f",label:"Female"},{value:"m",label:"Male"}].map(e=>t.jsxs("label",{className:`inline-flex items-center gap-2 px-3 py-1.5 rounded border cursor-pointer transition-colors text-[15px] font-semibold ${f===e.value?"border-primary bg-primary/10 text-primary":"border-[#333] text-[#888] hover:border-[#555] hover:text-white"}`,children:[t.jsx("input",{className:"hidden",type:"radio",value:e.value,checked:f===e.value,onChange:()=>dt(e.value)}),e.label]},e.value))}),f!==I&&t.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[t.jsxs("p",{className:"text-primary text-[12px] font-semibold",children:["Changing from ",I==="m"?"male":"female"," to ",f==="m"?"male":"female"]}),t.jsx("span",{className:"text-[11px] text-[#888]",children:"All celebs, entities, and categories will be reset"})]})]}),t.jsxs("section",{children:[t.jsxs("h2",{className:"text-[17px] font-semibold mb-3 flex items-center gap-2",children:[t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),t.jsx("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),t.jsx("polyline",{points:"21 15 16 10 5 21"})]}),"Current Files"]}),b.length===0?t.jsx("p",{className:"text-[#888] text-sm",children:"No files found for this upload."}):t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(140px,1fr))] gap-3",children:b.map(e=>{const s=ne(e.fileType),n=oe(e.fileType),a=e.markedForRemoval,l=!!e.replacementFile;return t.jsxs("div",{className:`relative rounded border overflow-hidden transition-all ${a?"border-red-500/50 opacity-50 grayscale":l?"border-green-500/50":"border-[#333]"}`,children:[t.jsx("button",{type:"button",className:`w-full aspect-[4/3] bg-[#111] flex items-center justify-center overflow-hidden border-none p-0 ${T(e)?"cursor-pointer":"cursor-default"}`,onClick:()=>tt(e.id),disabled:!T(e),children:l?t.jsx("div",{className:"w-full h-full flex items-center justify-center bg-green-500/5",children:t.jsx("span",{className:"text-green-400 text-xs font-semibold px-2 text-center",children:"Replacement queued"})}):T(e)?n?t.jsx("img",{src:e.downloadURL,alt:"Upload file",className:"w-full h-full object-cover",loading:"lazy",onError:()=>U(e.id)}):t.jsxs("div",{className:"relative w-full h-full",children:[t.jsx("video",{src:e.downloadURL,preload:"metadata",muted:!0,playsInl
1ine:!0,className:"w-full h-full object-cover",onLoadedData:c=>{c.target.currentTime=.1},onError:()=>U(e.id)}),t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/30 pointer-events-none",children:t.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"#fff",children:t.jsx("path",{d:"M8 5v14l11-7z"})})})]}):t.jsxs("div",{className:"w-full h-full flex flex-col items-center justify-center gap-1 px-2 text-center",children:[t.jsxs("span",{className:"text-[11px] font-semibold text-[#999]",children:["Original file ",e.number]}),t.jsx("span",{className:"text-[10px] text-[#666]",children:ss(e,$.has(e.id))})]})}),a&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/40 pointer-events-none",children:t.jsx("span",{className:"text-red-400 text-xs font-bold uppercase tracking-wider",children:"Removed"})}),t.jsx("div",{className:"px-2 py-1.5 bg-[#1a1a1a] text-[10px] text-[#888] truncate",children:e.state==="ok"?t.jsxs(t.Fragment,{children:[e.fileType?.split("/")[1]||"file"," · ",e.fileSize||"?"]}):e.state==="unreadable"?"Unavailable":"Archived"}),t.jsxs("div",{className:"flex border-t border-[#333]",children:[t.jsx("button",{type:"button",className:`flex-1 py-1.5 text-[11px] font-semibold transition-colors cursor-pointer border-none ${a?"bg-[#222] text-green-400 hover:bg-green-500/10":"bg-[#222] text-red-400 hover:bg-red-500/10"}`,onClick:()=>ht(e.id),children:a?"Undo":"Remove"}),s&&!a&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px bg-[#333]"}),l?t.jsx("button",{type:"button",className:"flex-1 py-1.5 text-[11px] font-semibold bg-[#222] text-[#888] hover:bg-[#2a2a2a] transition-colors cursor-pointer border-none",onClick:()=>bt(e.id),children:"Cancel"}):t.jsx("button",{type:"button",className:"flex-1 py-1.5 text-[11px] font-semibold bg-[#222] text-primary hover:bg-primary/10 transition-colors cursor-pointer border-none",onClick:()=>xt(e.id),children:"Replace"})]})]})]},e.id)})}),_e&&t.jsxs("div",{className:"mt-4",children:[t.jsx("p",{className:"text-[12px] text-[#888] mb-2",children:_e}),t.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(100px,1fr))] gap-2",children:h.map((e,s)=>M.has(s)?null:t.jsx("button",{type:"button",className:"aspect-[4/3] bg-[#111] rounded border border-[#333] overflow-hidden p-0 cursor-pointer flex items-center justify-center",onClick:()=>st(s),children:e.thumbnail?t.jsx("img",{src:e.thumbnail,alt:"On the site",className:"w-full h-full object-cover",loading:"lazy",onError:()=>ce(n=>new Set(n).add(s))}):t.jsx("span",{className:"text-[10px] text-[#666]",children:"Video"})},`${e.src||e.mp4}-${s}`))})]})]}),t.jsxs("section",{children:[t.jsxs("h2",{className:"text-[17px] font-semibold mb-3 flex items-center gap-2",children:[t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),t.jsx("polyline",{points:"17 8 12 3 7 8"}),t.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]}),"Add New Files"]}),t.jsx(zt,{files:w,onChange:_,onError:e=>{se(e),setTimeout(()=>{Le.current?.scrollIntoView({behavior:"smooth",block:"center"})},100)}})]}),t.jsxs("section",{children:[t.jsxs("h2",{className:"text-[17px] font-semibold mb-3 flex items-center gap-2",children:[t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),t.jsx("circle",{cx:"12",cy:"7",r:"4"})]}),"Celebrities"]}),R.length>0&&t.jsxs("div",{className:"space-y-2 mb-4",children:[t.jsx("label",{className:"text-[13px] text-[#888] uppercase tracking-wider font-semibold",children:"Current"}),R.map((e,s)=>{const n=H.has(s),a=Q===s;return t.jsxs("div",{children:[t.jsxs("div",{className:`flex items-center gap-3 px-3 py-2.5 rounded border transition-all ${n?"border-red-500/30 bg-red-500/5 opacity-60":e.swapped||e.detailsEdited?"border-primary/30 bg-primary/5":"border-[#333] bg-[#1a1a1a]"}`,children:[e.thumb&&t.jsx("img",{src:e.thumb,alt:e.name,className:"w-10 h-[56px] shrink-0 rounded object-cover border border-[#333] bg-[#111]"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsx("span",{className:`text-[15px] font-semibold ${n?"line-through text-[#888]":"text-white"}`,children:e.name}),e.swapped&&t.jsx("span",{className:"text-primary text-[11px] font-semibold uppercase",children:"Swapped"}),e.detailsEdited&&!e.swapped&&t.jsx("span",{className:"text-primary text-[11px] font-semibold uppercase",children:"Details Edited"})]}),De&&!n&&!e.isUnknown&&t.jsx("input",{type:"text",placeholder:"Role name (optional)",className:"form-input-dark text-[13px] !py-1 mt-1.5 w-full max-w-[250px]",value:e.appearance,onChange:l=>gt(s,l.target.value)})]}),!e.isUnknown&&f===I&&t.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[!n&&t.jsx("button",{type:"button",className:"px-3 py-1 rounded text-[12px] font-semibold border border-primary/30 text-primary bg-transparent hover:bg-primary/10 transition-colors cursor-pointer disabled:opacity-50",onClick:()=>
1vt(s),disabled:$e===s,children:$e===s?"Loading...":"Edit"}),!n&&t.jsx("button",{type:"button",className:"px-3 py-1 rounded text-[12px] font-semibold border border-[#444] text-[#aaa] bg-transparent hover:bg-[#2a2a2a] transition-colors cursor-pointer",onClick:()=>q(a?null:s),children:a?"Cancel":"Swap"}),t.jsx("button",{type:"button",className:`px-3 py-1 rounded text-[12px] font-semibold transition-colors cursor-pointer border ${n?"border-green-500/30 text-green-400 bg-transparent hover:bg-green-500/10":"border-red-500/30 text-red-400 bg-transparent hover:bg-red-500/10"}`,onClick:()=>ft(s),children:n?"Undo":"Remove"})]})]}),a&&t.jsxs("div",{className:"mt-2 ml-[52px]",children:[t.jsx("p",{className:"text-[12px] text-[#888] mb-1.5",children:"Search for a different celebrity to swap in:"}),t.jsx(Me,{entityType:"celebrity",value:"",entityId:"",onChange:()=>{},onSelect:l=>He(s,l),onAddClick:()=>{te(s),V(!0)},gender:f,existingSelections:[...R.filter((l,c)=>c!==s&&!H.has(c)).map(l=>l.firebaseId),...z.map(l=>l.firebaseId)],isAzFans:y,autoFocus:!0})]})]},e.id)})]}),z.length>0&&t.jsxs("div",{className:"space-y-2 mb-4",children:[t.jsx("label",{className:"text-[13px] text-green-400 uppercase tracking-wider font-semibold",children:"Adding"}),z.map((e,s)=>t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded border border-green-500/30 bg-green-500/5",children:[e.thumb&&t.jsx("img",{src:e.thumb,alt:e.name,className:"w-10 h-[56px] shrink-0 rounded object-cover border border-[#333] bg-[#111]"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-[15px] font-semibold text-white",children:e.name}),t.jsx("span",{className:"text-green-400 text-[11px] font-semibold uppercase",children:"New"})]}),De&&t.jsx("input",{type:"text",placeholder:"Role name (optional)",className:"form-input-dark text-[13px] !py-1 mt-1.5 w-full max-w-[250px]",value:e.appearance,onChange:n=>Rt(s,n.target.value)})]}),t.jsx("button",{type:"button",className:"shrink-0 w-8 h-8 flex items-center justify-center rounded border border-[#333] text-[#888] hover:text-red-400 hover:border-red-500/50 transition-colors bg-transparent cursor-pointer",onClick:()=>St(s),children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},e.firebaseId||`new-${s}`))]}),nt?t.jsxs("div",{className:"mb-2",children:[t.jsx(Me,{entityType:"celebrity",value:"",entityId:"",onChange:()=>{},onSelect:kt,onAddClick:()=>{te(null),V(!0)},gender:f,existingSelections:[...R.filter((e,s)=>!H.has(s)).map(e=>e.firebaseId),...z.map(e=>e.firebaseId)],isAzFans:y,autoFocus:!0}),t.jsx("button",{type:"button",className:"btn-ghost text-[12px] mt-2",onClick:()=>re(!1),children:"Cancel"})]}):t.jsx("button",{type:"button",className:"btn-ghost text-sm",onClick:()=>re(!0),children:"+ Add Celebrity"})]}),!y&&t.jsxs("section",{children:[t.jsxs("h2",{className:"text-[17px] font-semibold mb-3 flex items-center gap-2",children:[t.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"2",y:"2",width:"20",height:"20",rx:"2.18",ry:"2.18"}),t.jsx("line",{x1:"7",y1:"2",x2:"7",y2:"22"}),t.jsx("line",{x1:"17",y1:"2",x2:"17",y2:"22"}),t.jsx("line",{x1:"2",y1:"12",x2:"22",y2:"12"})]}),"Content Type"]}),t.jsxs("div",{className:"mb-4",children:[t.jsx(Wt,{value:C,onChange:at,hideLabel:!0}),C!==x&&t.jsxs("p",{className:"text-primary text-[12px] mt-2 font-semibold",children:["Changing from ",x," to ",C]})]}),!ae&&v.name&&t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded border border-[#333] bg-[#1a1a1a] mb-3",children:[v.thumb&&t.jsx("img",{src:v.thumb,alt:v.name,className:"w-10 h-[56px] shrink-0 rounded object-cover border border-[#333] bg-[#111]"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("span",{className:"text-[13px] text-[#888] uppercase tracking-wider font-semibold block mb-0.5",children:["Current ",x]}),t.jsx("span",{className:"text-[15px] font-semibold text-white",children:v.isUnknown?`Unknown ${x}`:v.name})]}),t.jsx("button",{type:"button",className:"shrink-0 px-3 py-1 rounded text-[12px] font-semibold border border-red-500/30 text-red-400 bg-transparent hover:bg-red-500/10 transition-colors cursor-pointer",onClick:()=>ee(!0),children:"Remove"})]}),ae&&v.name&&t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded border border-red-500/30 bg-red-500/5 mb-3",children:[v.thumb&&t.jsx("img",{src:v.thumb,alt:v.name,className:"w-10 h-[56px] shrink-0 rounded object-cover border border-[#333] bg-[#111] opacity-40 grayscale"}),t.jsxs("div",{className:"flex-1",children:[t.jsx("span",{className:"text-red-400 text-[15px] font-semibold line-through",children:v.name}),t.jsx("span",{className:"text-red-400 text-[11px] ml-2 font-semibold uppercase",children:"Removed"})]}),C===x&&f===I&&t.jsx("button",{type:"button",className:"shrink-0 px-3 py-1 rounded text-[12px] font-semibold border border-green-500/30 text-green-400 bg-transparent hover:bg-green-500/10 transition-colors cursor-pointer",onClick:()=>{ee(!1),Fe()},children:"Undo"})]}),g.id?t.jsxs("div",{className:"flex items-center gap-3 px-3 py-2.5 rounded border border-green-500/30 bg-green-500/5 mb-3",children:[g.thumb&&t.jsx("img",{src:g.thumb,alt:g.name,className:"w-10 h-[56px] shrink-0 rounded object-cover border border-[#333] bg-[#111]"}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("span",{className:"text-green-400 text-[11px] font-semibold uppercase block mb-0.5",children:["New ",C]}),t.jsx("span",{className:"text-[15px] font-semibold text-white",children:g.name}),g.yor&&t.jsxs("span",{className:"text-[#888] text-[13px] ml-1",children:["(",g.
1yor,")"]})]}),t.jsx("button",{type:"button",className:"shrink-0 w-8 h-8 flex items-center justify-center rounded border border-[#333] text-[#888] hover:text-red-400 hover:border-red-500/50 transition-colors bg-transparent cursor-pointer",onClick:Fe,children:t.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),t.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}):(ae||v.isUnknown)&&t.jsx("div",{className:"mt-2",children:t.jsx(Me,{entityType:C,value:g.name,entityId:g.id,entityYear:g.yor,entityThumb:g.thumb,onChange:e=>W({...g,name:e}),onSelect:It,onAddClick:()=>{C==="movie"?Se(!0):C==="series"?Re(!0):C==="story"&&Ie(!0)},onClear:Fe,gender:f,visible:!0})})]}),t.jsxs("section",{children:[t.jsx("h2",{className:"text-[17px] font-semibold mb-3",children:"Categories"}),t.jsx(Yt,{gender:f,categories:pe,onChange:it,isAzFans:y,hideLabel:!0})]}),t.jsxs("section",{children:[t.jsx("h2",{className:"text-[17px] font-semibold mb-3",children:"Tags"}),t.jsx(Dt,{tags:ue,onChange:ot,hideLabel:!0})]}),t.jsx("button",{type:"submit",className:"btn-primary-tw w-full py-3.5 text-base",disabled:Ee,children:Ee?"Submitting Edit Request...":"Submit Edit Request"})]})}),N&&N.items.length>0&&t.jsx(Ht,{items:N.items,startIndex:N.start,onClose:()=>je(null),title:N.title,status:N.status}),t.jsx(fe,{entityType:"celebrity",isOpen:ct,onClose:()=>{V(!1),te(null),q(null),Ce(null)},onAdd:Pe?jt:Q!==null?Nt:Ct,gender:f,varValues:k,isAzFans:y,initialData:Pe}),!y&&t.jsxs(t.Fragment,{children:[t.jsx(fe,{entityType:"movie",isOpen:mt,onClose:()=>Se(!1),onAdd:Ue,gender:f,varValues:k}),t.jsx(fe,{entityType:"series",isOpen:pt,onClose:()=>Re(!1),onAdd:Ue,gender:f,varValues:k}),t.jsx(fe,{entityType:"story",isOpen:ut,onClose:()=>Ie(!1),onAdd:Ue,gender:f})]})]})}const bs=()=>{const p=document.querySelector('meta[name="website"]')?.content==="azfans",[r,u]=o.useState(null),[h,B]=o.useState(null),[k,y]=o.useState([]),[we,K]=o.useState([]),[ne,oe]=o.useState(""),[I,x]=o.useState(!0),[Z,A]=o.useState(""),[j,le]=o.useState(null),[ve,P]=o.useState(!1),[Y,d]=o.useState(!1),b=new URLSearchParams(window.location.search).get("id");if(o.useEffect(()=>{if(!b){A("No upload ID provided. Please navigate here from your uploads page."),x(!1);return}const D=_t(Xe,async w=>{if(!w){window.location.href="/signin.html?next="+encodeURI(window.location.href);return}try{const _=await w.getIdTokenResult(!0);if(F.setUser({id:w.uid,email:w.email}),F.setContext("firebaseClaims",_?.claims||{}),_.claims.isBanned)return localStorage.removeItem("azn_id"),Pt(Xe);if(qt(w.uid)){A("Your account has been restricted from uploading content."),x(!1);return}u(w);const $=ge(ye),de=await Oe(Be($,`uploads/${b}`));if(!de.exists()){A("Upload not found. It may have been removed."),x(!1);return}const U=de.val();if(U.createdBy!==w.uid){A("You do not have permission to edit this upload."),x(!1);return}U.editRequest&&U.editRequest.status==="pending"&&le(U.editRequest),B({id:b,...U});const T=await Xt(Zt(U),N=>Oe(Be($,`files/${N}`))),M=ts(T);M&&F.captureException(M.error,{tags:{area:"edit-upload",op:"fetchFile",status:M.status},extra:{uploadId:b,fileIds:M.fileIds,failed:M.fileIds.length,total:M.total}});const ce=T.filter(N=>N.status==="missing").length;if(ce>0&&F.addBreadcrumb({category:"edit-upload",level:"info",message:"File records gone",data:{uploadId:b,archived:ce,total:T.length}}),y(es(T)),U.status==="published")try{const N=Gt(b,U);K(Jt(N)),oe(N.title||"")}catch(N){F.captureException(N,{tags:{area:"edit-upload",op:"siteMedia"},extra:{uploadId:b}})}x(!1)}catch(_){F.captureException(_,{tags:{area:"edit-upload",op:"loadUpload"},extra:{uploadId:b}}),A("Failed to load upload data. Please try again."),x(!1)}});return()=>D()},[b]),I)return t.jsx("div",{className:"max-w-[900px] mx-auto px-4",children:t.jsx("div",{className:"flex justify-center py-15",children:t.jsx("div",{className:"spinner"})})});if(Z)return t.jsxs("div",{className:"max-w-[900px] mx-auto px-4 py-8",children:[t.jsx("div",{className:"alert-bar !bg-red-500/10 !border-red-500/30 !text-red-400",children:t.jsx("div",{className:"flex-1",children:Z})}),t.jsx("a",{href:"/profile.html#content-uploaded",className:"btn-ghost text-sm mt-4 inline-block",children:"← Back to My Uploads"})]});if(j&&!ve){const D=j.createdOn?new Date(j.createdOn).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}):"Unknown date",w=j.changes?Object.keys(j.changes):[];return t.jsx("div",{className:"max-w-[900px] mx-auto px-4 py-8",children:t.jsxs("div",{className:"card-dark",children:[t.jsxs("div",{className:"flex items-start gap-3 mb-4",children:[t.jsx("span",{className:"w-10 h-10 rounded-sm bg-amber-500/10 border border-amber-500/20 flex items-center justify-center text-amber-400 shrink-0",children:t.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),t.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),t.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}),t.jsxs("div",{children:[t.jsx("h2",{className:"text-[17px] font-semibold mb-1",children:"Pending Edit Request"}),t.jsxs("p",{className:"text-[#999] text-sm",children:["This upload already has a pending edit request submitted on ",t.jsx("span",{className:"text-[#ccc]",children:D}),"."]}),w.length>0&&t.jsxs("p",{className:"text-[#777] text-[13px] mt-1",children:["Changes: ",w.map(_=>_.replace(/([A-Z])/g," $1").replace(/^./,$=>
1$.toUpperCase()).trim()).join(", ")]})]})]}),t.jsx("p",{className:"text-[#aaa] text-sm mb-5",children:"You can continue where you left off or discard your previous changes and start over."}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsx("a",{href:"/profile.html#content-uploaded",className:"btn-ghost text-sm",children:"← Back to Uploads"}),t.jsx("button",{type:"button",className:"btn-primary-tw text-sm",onClick:()=>{d(!0),P(!0)},children:"Continue Editing"}),t.jsx("button",{type:"button",className:"btn-ghost text-sm",onClick:()=>{d(!1),P(!0)},children:"Start Fresh"})]})]})})}return t.jsx(as,{user:r,uploadData:h,uploadFiles:k,siteMedia:we,siteTitle:ne,varValues,isAzFans:p,keepExistingEdits:Y})};export{bs 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.