1import{d as D,u as E,b as u,r as q,aU as A,c as B,L as I,e as O,C as H,f as d,i as s,m as r,j as o,z as C,n as h,_ as x,F as M,N as Q,l as z,g as G,t as f,k as J,aT as K,a as k,v as n,x as V,aE as W}from"./index.16ba4ea0.js";import{_ as X}from"./Notfound.vue_vue_type_script_setup_true_lang.b9e0406b.js";import{_ as Y}from"./Pagination.vue_vue_type_script_setup_true_lang.8b7ec3c5.js";import"./vendor-highcharts.9b480a8e.js";import"https://cdn.jsdelivr.net/npm/[email protected]/dist/buttplug-wasm.mjs";const Z={class:"mx-auto max-w-4xl px-4 py-6"},ee={class:"mb-6"},te={class:"flex flex-col sm:flex-row items-stretch sm:items-center gap-3 px-1"},se={key:0,class:"py-12 flex justify-center items-center"},ae={key:1,class:"bg-zinc-800 rounded-lg divide-y divide-zinc-700 shadow-lg"},oe={class:"sm:col-span-9 space-y-1"},le={class:"text-zinc-100 font-medium line-clamp-1"},ne=["href"],ie={class:"text-zinc-100 font-medium line-clamp-1"},de=["href"],re={class:"text-xs text-zinc-500"},ce={key:0,class:"text-xs text-zinc-500"},ue={class:"font-semibold text-zinc-100"},me={class:"sm:col-span-3 flex items-center justify-end space-x-2 mt-2 md:mt-0"},fe={key:2,class:"mt-12"},ve={key:0,class:"fixed inset-0 flex items-center justify-center z-50"},_e={class:"relative bg-zinc-900 p-6 md:p-8 rounded-lg shadow-lg overflow-y-auto max-h-[90vh] w-full max-w-md text-white"},pe={class:"flex items-center justify-between mb-4"},he={class:"text-xl md:text-2xl font-semibold text-center flex-1"},xe={class:"flex justify-end"},ge={class:"flex flex-col md:flex-row md:items-center gap-2 md:gap-4"},ye={class:"md:w-3/4"},be={class:"flex flex-col md:flex-row md:items-center gap-2 md:gap-4"},we={class:"md:w-3/4"},ke={class:"flex justify-end mt-6"},R=10,Re=D({__name:"ManageRedirection",setup(Ce){const{user:g}=E(),l=u([]),v=u(!1),c=u(1),_=u(0),y=u(""),p=u(!1),b=u(!1),i=q({from_path:"",to_path:""});
1A(y,()=>{c.value=1,m(1)},{debounce:300});const m=async(t=1)=>{var e;v.value=!0;try{const a=await k.redirections.getRedirections({page:t,query:((e=y.value)==null?void 0:e.trim())||void 0,limit:R});l.value=a.items||[],_.value=a.total||0,c.value=t}catch(a){console.error(a),l.value=[],_.value=0}finally{v.value=!1}},U=async t=>{if(!!(g!=null&&g.id))try{await k.redirections.createRedirection(t.from_path,t.to_path,g.id),w(),m(1)}catch(e){console.error(e)}},j=async t=>{if(!!t.id)try{await k.redirections.updateRedirection(t.id,t.from_path,t.to_path);const e=l.value.findIndex(a=>a.id===t.id);e!==-1&&(l.value[e]={...l.value[e],...t}),w()}catch(e){console.error(e)}},N=async t=>{if(!!t&&!!confirm("Are you sure you want to delete this redirection?"))try{await k.redirections.deleteRedirection(t),l.value=l.value.filter(e=>e.id!==t),l.value.length===0&&c.value>1?m(c.value-1):m(c.value)}catch(e){console.error(e)}},T=()=>{Object.assign(i,{from_path:"",to_path:""}),p.value=!0,b.value=!0},$=t=>{Object.assign(i,t),p.value=!1,b.value=!0},w=()=>b.value=!1,F=B(()=>Math.ceil(_.value/R)>1&&!v.value),L=async t=>{const e=Math.ceil(_.value/R);t<1||t>e||(await m(t),window.scrollTo({top:0,behavior:"smooth"}))},P=t=>t?new Date(t).toLocaleDateString():"N/A";return I(()=>m(c.value)),O(H("manage-redirections",{title:"Redirection Manager \u2013 FapTap",description:"Admin panel for managing URL redirections"})),(t,e)=>(n(),d(M,null,[s("div",Z,[e[10]||(e[10]=s("h1",{class:"text-3xl font-semibold text-center text-white mb-6"},[r(" Manage Redirections "),s("small",{class:"block text-sm text-zinc-400 font-normal mt-1"},"Admin access only")],-1)),s("div",ee,[s("div",te,[o(C,{autofocus:"",placeholder:"Search by From URL",type:"text",class:"flex-1 bg-zinc-800 border-zinc-700",modelValue:y.value,"onUpdate:modelValue":e[0]||(e[0]=a=>y.value=a)},null,8,["modelValue"]),o(x,{theme:"blue",class:"shrink-0 px-4 w-full sm:w-auto justify-center",onClick:T},{default:h(()=>[...e[4]||(e[4]=[r("Create Redirection",-1)])]),_:1})])]),v.value?(n(),d("div",se,[o(V,{name:"loading",class:"h-10 w-10 text-blue-500 animate-spin"})])):l.value.length?(n(),d("div",ae,[(n(!0),d(M,null,Q(l.value,a=>(n(),d("div",{key:a.id,class:"p-4 grid grid-cols-1 sm:grid-cols-12 items-center gap-3 hover:bg-zinc-700 transition-colors rounded-md"},[s("div",oe,[s("div",le,[e[5]||(e[5]=r(" From: ",-1)),s("a",{target:"_blank",href:a.from_path,class:"underline text-blue-400"},f(a.from_path),9,ne)]),s("div",ie,[e[6]||(e[6]=r(" To: ",-1)),s("a",{target:"_blank",href:a.to_path,class:"underline text-blue-400"},f(a.to_path),9,de)]),s("div",re,"Created at: "+f(P(a.created_at)),1),a.username?(n(),d("div",ce,[e[7]||(e[7]=r(" Created by: ",-1)),s("span",ue,f(a.username),1)])):z("",!0)]),s("div",me,[o(x,{theme:"blue",size:"sm",onClick:S=>$(a)},{default:h(()=>[...e[8]||(e[8]=[r("Edit",-1)])]),_:1},8,["onClick"]),o(x,{theme:"red",size:"sm",onClick:S=>N(a.id)},{default:h(()=>[...e[9]||(e[9]=[r("Delete",-1)])]),_:1},8,["onClick"])])]))),128))])):v.value?z("",!0):(n(),d("div",fe,[o(X,{title:"No Redirections Found",message:"No redirections match your current search query."})])),o(Y,{currentPage:c.value,total:_.value,limit:R,show:F.value,"onUpdate:currentPage":L},null,8,["currentPage","total","show"])]),(n(),G(K,{to:"body"},[b.value?(n(),d("div",ve,[s("div",{class:"fixed inset-0 bg-black/80",onClick:w}),s("div",_e,[s("div",pe,[s("div",he,f(p.value?"Create Redirection":"Edit Redirection"),1),s("div",xe,[o(x,{theme:"transparent",onClick:w},{default:h(()=>[o(V,{name:"close",class:"h-6 w-6 text-zinc-400"})]),_:1})])]),s("form",{onSubmit:e[3]||(e[3]=J(a=>p.value?U(i):j(i),["prevent"])),class:"flex flex-col gap-5"},[s("div",ge,[e[11]||(e[11]=s("label",{class:"md:w-1/4 text-white font-medium text-right hidden md:block"},"From URL",-1)),s("div",ye,[o(C,{required:"",modelValue:i.from_path,"onUpdate:modelValue":e[1]||(e[1]=a=>i.from_path=a),placeholder:"e.g., /vides"},null,8,["modelValue"])])]),s("div",be,[e[12]||(e[12]=s("label",{class:"md:w-1/4 text-white font-medium text-right hidden md:block"},"To URL",-1)),s("div",we,[o(C,{required:"",modelValue:i.to_path,"onUpdate:modelValue":e[2]||(e[2]=a=>i.to_path=a),placeholder:"e.g., videos"},null,8,["modelValue"])])]),s("div",ke,[o(x,{type:"submit",theme:"blue"},{default:h(()=>[r(f(p.value?"Create":"Save"),1)]),_:1})])],32)])])):z("",!0)]))],64))}});const Ne=W(Re,[["__scopeId","data-v-8ed77a94"]]);export{Ne 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.