1import{r as a,o as X,p as Y,b as k,d as M,c as Z,j as t,a as O,H as ee,g as te,i as ae}from"../app.js";import{s as se}from"./authActions.js";import{S as d}from"./sentry.js";import{g as re,c as g}from"./profileHelpers.js";import{p as V}from"./Lightbox.js";import{U as oe,h as ne}from"./UploadCard.js";import{S as de}from"./AuthLayout.js";import"./storyKeys.js";function be(){const[w,y]=a.useState("loading"),[I,j]=a.useState(""),[h,E]=a.useState(null),[ie,$]=a.useState(null),[z,K]=a.useState(!1),[L,q]=a.useState(!1),[l,F]=a.useState(null),[H,Q]=a.useState([]),[v,W]=a.useState(0),[u,N]=a.useState(!1),[x,U]=a.useState(""),[f,A]=a.useState(!1),C=a.useRef(null),c=a.useRef(null),b=a.useRef(null),T=a.useRef(null),_=a.useCallback(()=>{setTimeout(()=>T.current?.scrollIntoView({behavior:"smooth"}),100)},[]);a.useEffect(()=>{const e=re("id");if(!e){window.location.href="/profile.html";return}c.current=e;const r=X(O,async i=>{try{if(!i){window.location.href="/signin.html?next="+encodeURI(window.location.href);return}const n=i.uid;b.current=n;try{const o=await i.getIdTokenResult(!0);try{d.setUser({id:n||void 0,email:i.email||void 0}),d.setContext("firebaseClaims",o?.claims||{})}catch{}if(o.claims?.isBanned)return localStorage.removeItem("azn_id"),se(O)}catch(o){try{d.captureException(o,{tags:{area:"auth",op:"getIdTokenResult"}})}catch{}}C.current=await ee(i);let s;try{const o=await te(k(M,`uploads/${e}`));if(!o.exists()){window.location.href="/profile.html";return}s=o.val()}catch(o){try{d.captureException(o,{tags:{area:"db",op:"getUpload"},extra:{uploadId:e}})}catch{}j("An error occurred loading this upload."),y("error");return}const m=s.assignedModeratorId===n,B=s.createdBy===n;if(!m&&!B){window.location.href="/profile.html";return}if(K(m),$(s),E(V(e,s)),y("loaded"),ne([[e,s]]).then(o=>{o.size&&E(V(e,s,o))}).catch(()=>{}),s.status==="returned"&&s.moderationContent?.status_message){const o=s.assignedModeratorId===n;F({text:s.moderationContent.status_message,createdOn:s.createdOn,fromMe:o}),q(!0),ae(k(M,`uploads/${e}/moderationContent/moderator_chat`),p=>{const D=p.val()?Object.values(p.val()):[],P=D.length+1;W(P),N(P>=20),Q(D),_()})}}catch(n){try{d.captureException(n,{tags:{area:"init"}})}catch{}j("An error occurred."),y("error")}});return()=>r()},[_]);const S=a.useCallback(async()=>{const e=x.trim();if(!(!e||f||u))try{d.addBreadcrumb({category:"chat",message:"Moderator chat submit",level:"info",data:{uploadId:c.current,senderId:b.current}}),A(!0),N(!0);const r=Y(k(M,`uploads/${c.current}/moderationContent/moderator_chat`));await Z(r,{chat:e,senderId:b.current,date:Date.now()}),U("")}catch(r){try{d.captureException(r,{tags:{area:"chat",op:"submit"}})}catch{}j("An error occurred sending your message.")}finally{A(!1),N(v>=20)}},[x,f,u,v]),G=a.useCallback(e=>{e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),S())},[S]),R=a.useCallback(async(e,r)=>{const i=e==="approved"?urls.approveUpload:urls.declineUpload,n=new URLSearchParams({idToken:C.current,uploadId:c.current});r&&n.append("decline_reason",r);try{if(d.addBreadcrumb({category:"moderation",message:"Moderation action",level:"info",data:{action:e,uploadId:c.current}}),(await(await fetch(i,{method:"POST",body:n})).json()).status==="ok")alert(`Upload has been successfully ${e}!`),setTimeout(()=>{window.location.href=e==="approved"?`https://admin.aznude.net/index.php?mode=returned&returned_id=${c.current}`:"/profile.html#content-moderation"},2e3);else{try{d.captureException(new Error("Moderation non-ok"),{tags:{area:"moderation",op:e}})}catch{}alert("Error happened!")}}catch(s){try{d.captureException(s,{tags:{area:"moderation",op:e}})}catch{}alert("Error happened!")}},[]),J=a.useCallback(async()=>{const e=prompt("Are you sure you want to decline this upload and ban the user? Type the decline reason below.");if(e===null)return;const r=document.querySelector('meta[name="website"]')?.getAttribute("content"),i=new URLSearchParams({idToken:C.current,uploadId:c.current,decline_reason:e});r&&i.append("website",r);try{d.addBreadcrumb({category:"moderation",message:"Decline and ban",level:"warning",data:{uploadId:c.current}});const s=await(await fetch(urls.declineUploadAndBanUser,{method:"POST",body:i})).json();if(s.status==="ok")alert(s.message),setTimeout(()=>{window.location.href="/profile.html#content-moderation"},2e3);else{try{d.captureException(new Error("Decline+ban non-ok"),{tags:{area:"moderation",op:"declineAndBan"}})}catch{}alert("Error happened!")}}catch(n){try{d.captureException(n,{tags:{area:"moderation",op:"declineAndBan"}})}catch{}alert("Error happened!")}},[]);return a.useEffect(()=>{if(w==="loading"||!h)return;const e=setTimeout(()=>{typeof window.setupVideoPreviews=="function"&&window.setupVideoPreviews(!0)},50);return()=>clearTimeout(e)},[w,h]),w==="loading"?t.jsx("div",{className:"max-w-[900px] mx-auto px-[15px] py-10",children:t.jsx(de,{})}):t.jsxs("div",{className:"max-w-[1200px] mx-auto px-[15px] py-8",children:[t.jsx("h2",{className:"text-xl font-semibold text-white mb-6",children:"Manage Content"}),I&&t.jsx("div",{className:"bg-yellow-900/40 border border-yellow-600/50 text-yellow-200 text-sm px-4 py-3 rounded mb-5",children:I}),h&&t.jsx(oe,{item:h,preventAddMoreInfoButton:!0}),L&&t.jsxs("div",{className:"mt-8",children:[t.jsx("hr",{className:"border-[#333] mb-6"}),t.jsx("h3",{className:"text-base font-semibold text-white mb-4",children:"Moderator Chat"}),t.jsxs("div",{className:"flex flex-col gap-3 max-h-[400px] overflow-y-auto bg-[#111] border border-[#2a2a2a] rounded p-4 mb-4",children:[l&&(l.fromMe?t.jsxs("div",{className:"flex justify-end items-center gap-2",children:[t.jsx("p",{className:"text-[11px] text-[#888] m-0 shrink-0",children:g(l.createdOn)}),t.jsx("div",{className:"max-w-[75%] bg-primary/20 border border-primary/30 rounded-lg px-4 py-2.5",children:t.jsx("p",{className:"text-sm text-white m-0",children:l.text})})]}):t.jsxs("div",{className:"flex justify-start items-center gap-2",children:[t.jsx("div",{className:"max-w-[75%] bg-[#1e1e1e] border border-[#2e2e2e] rounded-lg px-4 py-2.5",children:t.jsx("p",{className:"text-sm text-white m-0",children:l.text})}),t.jsx("p",{className:"text-[11px] text-[#888] m-0 shrink-0",children:g(l.createdOn)})]})),H.map((e,r)=>e.senderId===b.current?t.jsxs("div",{className:"flex justify-end items-center gap-2",children:[t.jsx("p",{className:"text-[11px] text-[#888] m-0 shrink-0",children:g(e.date)}),t.jsx("div",{className:"max-w-[75%] bg-primary/20 border border-primary/30 rounded-lg px-4 py-2.5",children:t.jsx("p",{className:"text-sm text-white m-0",children:e.chat})})]},r):t.jsxs("div",{className:"flex justify-start items-center gap-2",children:[t.jsx("div",{className:"max-w-[75%] bg-[#1e1e1e] border border-[#2e2e2e] rounded-lg px-4 py-2.5",children:t.jsx("p",{className:"text-sm text-white m-0",children:e.chat})}),t.jsx("p",{className:"text-[11px] text-[#888] m-0 shrink-0",children:g(e.date)})]},r)),t.jsx("div",{ref:T})]}),u&&v>=20?t.jsx("p",{className:"text-sm text-[#888]",children:"Message limit reached (20 messages)."}):t.jsxs("div",{className:"flex gap-3 items-end",children:[t.jsx("textarea",{rows:3,placeholder:"Type your message here...",className:"flex-1 bg-[#1a1a1a] border border-[#2e2e2e] text-white text-sm rounded px-3 py-2 resize-none focus:outline-none focus:border-primary/60 disabled:opacity-40",value:x,onChange:e=>U(e.target.value),onKeyPress:G,disabled:u||f}),t.jsx("button",{onClick:S,disabled:u||f||!x.trim(),className:"px-4 py-2 bg-primary text-black text-sm font-semibold rounded hover:opacity-90 disabled:opacity-40 disabled:cursor-not-allowed transition-opacity",children:"Send"})]})]}),z&&t.jsxs("div",{className:"mt-8",children:[t.jsx("hr",{className:"border-[#333] mb-6"}),t.jsx("h3",{className:"text-base font-semibold text-white mb-4",children:"Moderation Actions"}),t.jsxs("div",{className:"flex flex-wrap gap-3",children:[t.jsx("button",{onClick:()=>{confirm("Are you sure you want to approve this upload?")&&R("approved")},className:"px-5 py-2 bg-green-700 hover:bg-green-600 text-white text-sm font-semibold rounded transition-colors",children:"Approve Upload"}),t.jsx("button",{onClick:()=>{const e=prompt("Are you sure you want to decline this upload? Type the decline reason below.");e!==null&&R("declined",e)},className:"px-5 py-2 bg-red-800 hover:bg-red-700 text-white text-sm font-semibold rounded transition-colors",children:"Decline Upload"}),t.jsx("button",{onClick:J,className:"px-5 py-2 bg-[#5a0000] hover:bg-[#7a0000] text-white text-sm font-semibold rounded transition-colors",children:"Decline & Ban User"})]})]})]})}export{be 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.