1import{_ as Z}from"./D9MvgeHQ.js";import{K as tt,al as et,e as P,r as c,g as at,c as r,d as a,b as U,h as f,i as m,v as T,t as L,aL as d,aM as v,b2 as w,b1 as O,F as st,m as nt,b5 as y,Y as q,b4 as ot,B as lt,z as it,o as l,a3 as C}from"./hpNDvw06.js";const dt={class:"container-fluid blog-cms-admin"},rt={class:"row mb-3"},ct={class:"col-12 d-flex justify-content-between align-items-center flex-wrap gap-2"},ut={class:"d-flex gap-2"},mt={key:0,class:"alert alert-secondary"},pt={key:1,class:"alert alert-danger"},vt={key:2,class:"alert alert-warning"},ht={key:3},gt={class:"card mb-3"},bt={class:"card-body d-flex flex-wrap align-items-end gap-2"},ft={class:"flex-grow-1",style:{"min-width":"220px"}},yt={class:"form-check m-0 mb-1"},_t=["disabled"],kt={class:"card mb-3"},xt={class:"card-body"},St={class:"row g-2 align-items-end"},Pt={class:"col-lg-4 col-md-6"},Ut={class:"col-lg-4 col-md-6"},Tt={class:"col-lg-2 col-md-6"},Ct={class:"col-lg-2 col-md-6"},Rt={class:"form-check m-0"},Vt={class:"col-12"},Mt={class:"col-12 d-flex justify-content-end"},At=["disabled"],Dt={class:"card"},$t={class:"card-body p-0"},Nt={class:"table-responsive"},Lt={class:"table table-sm mb-0 align-middle"},wt={key:0},zt={key:1},Bt={style:{"min-width":"260px"}},Et=["onUpdate:modelValue","disabled"],Ft=["href"],It={style:{"min-width":"320px"}},Ot=["onUpdate:modelValue","disabled"],qt=["href"],Wt={style:{"min-width":"170px"}},jt=["onUpdate:modelValue","disabled"],Ht={class:"form-check m-0"},Kt=["onUpdate:modelValue"],Yt={class:"form-check-label"},Gt={style:{"min-width":"220px"}},Jt=["onUpdate:modelValue","disabled"],Qt={class:"text-nowrap"},Xt={class:"text-end text-nowrap"},Zt=["disabled","onClick"],te={key:0,class:"text-muted small me-2"},ee=["disabled","onClick"],oe=tt({__name:"redirects",setup(ae){const{authData:_}=et(),z=it(),B=P(()=>{var t;const e=(t=z.public)==null?void 0:t.apiUrl;return String(e||"").replace(/\/+$/,"")}),W=P(()=>`${B.value}/auth/status`),k=P(()=>`${B.value}/content-redirects`),{showSuccess:R,showError:g,showWarning:j}=ot(),u=c("loading"),x=c("Unable to validate access."),S=c(!1),V=c(!1),M=c(""),A=c(""),h=c([]),D=c(""),$=c(!1),i=c({sourcePath:"",targetPath:"",sourceType:"manual",active:!0,note:""}),H=()=>{var t;const e=new URL(String(((t=z.public)==null?void 0:t.dashboardSigninUrl)||""));e.searchParams.set("redirect","admin_blog"),u.value="unauthorized",x.value="Session expired â redirecting to sign in...",window.location.href=e.toString()},b=async(e,t={})=>{var n;try{return await $fetch(e,{credentials:"include",headers:lt(),...t})}catch(s){const o=Number((s==null?void 0:s.statusCode)??((n=s==null?void 0:s.response)==null?void 0:n.status)??0);if(o===403){u.value="unauthorized",await q("/admin/access-required");return}if(o===401){H();return}throw s}},K=async()=>{var e;try{const t=await b(W.value);if(!t)return;u.value=y("/admin/cms/redirects",t)?"authorized":"unauthorized",u.value==="unauthorized"&&await q("/admin/access-required")}catch(t){u.value="error",x.value=String(((e=t==null?void 0:t.data)==null?void 0:e.message)||(t==null?void 0:t.message)||x.value)}},E=e=>({id:String((e==null?void 0:e.id)||""),sourcePath:String((e==null?void 0:e.sourcePath)||""),targetPath:String((e==null?void 0:e.targetPath)||""),sourceType:["migration_support","migration_documentation"].includes(String((e==null?void 0:e.sourceType)||""))?String(e==null?void 0:e.sourceType):"manual",active:(e==null?void 0:e.active)===!0,note:String((e==null?void 0:e.note)||""),updatedAt:String((e==null?void 0:e.updatedAt)||"")}),N=async()=>{var e;S.value=!0;try{const t=await b(k.value);h.value=Array.isArray(t)?t.map(E):[]}catch(t){g(String(((e=t==null?void 0:t.data)==null?void 0:e.message)||(t==null?void 0:t.message)||"Failed to load redirects."))}finally{S.value=!1}},F=P(()=>{let e=h.value.slice();$.value&&(e=e.filter(n=>n.active===!0));const t=String(D.value||"").trim().toLowerCase();return t?e.filter(n=>`${n.sourcePath} ${n.targetPath} ${n.note}`.toLowerCase().includes(t)):e}),p=e=>{const t=String((e==null?void 0:e.sourceType)||"").trim();return t==="migration_support"||t==="migration_documentation"},Y=async()=>{var e;if(!i.value.sourcePath.trim()||!i.value.targetPath.trim()){g("Source path and target path are required.");return}V.value=!0;try{await b(k.value,{method:"POST",body:i.value}),i.value={sourcePath:"",targetPath:"",sourceType:"manual",active:!0,note:""},await N(),R("Redirect created.")}catch(t){g(String(((e=t==null?void 0:t.data)==null?void 0:e.message)||(t==null?void 0:t.message)||"Failed to create redirect."))}finally{V.value=!1}},G=async e=>{var t;if(e!=null&&e.id){M.value=e.id;try{const n=p(e),s=await b(`${k.value}/${encodeURIComponent(e.id)}`,{method:"PUT",body:n?{active:e.active}:{sourcePath:e.sourcePath,targetPath:e.targetPath,sourceType:e.sourceType,active:e.active,note:e.note}});if(s){const o=h.value.findIndex(X=>X.id===e.id);o!==-1&&h.value.splice(o,1,E(s))}R("Redirect saved.")}catch(n){g(String(((t=n==null?void 0:n.data)==null?void 0:t.message)||(n==null?void 0:n.message)||"Failed to save redirect."))}finally{M.value=""}}},J=async e=>{var n;if(!(e!=null&&e.id))return;if(p(e)){j("Migration redirects are managed automatically and cannot be deleted here.");return}if(window.confirm(`Delete redirect from ${e.sourcePath}?`)){A.value=e.id;try{await b(`${k.value}/${encodeURIComponent(e.id)}`,{method:"DELETE"}),h.value=h.value.filter(s=>s.id!==e.id),R("Redirect deleted.")}catch(s){g(String(((n=s==null?void 0:s.data)==null?void 0:n.message)||(s==null?void 0:s.message)||"Failed to delete redirect."))}finally{A.value=""}}},I=e=>{const t=String(e||"").trim();return t?/^https?:\/\//i.test(t)||t.startsWith("/")?t:`/${t}`:"#"},Q=e=>{if(!e)return"â";const t=new Date(e);return Number.isNaN(t.getTime())?"â":new Intl.DateTimeFormat("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}).format(t)};return at(async()=>{await K(),u.value==="authorized"&&await N()}),(e,t)=>{const n=Z;return l(),r("div",dt,[a("div",rt,[a("div",ct,[t[11]||(t[11]=a("h1",{class:"mb-0"},"Content Redirects",-1)),a("div",ut,[m(y)("/admin/cms/locales",m(_))?(l(),U(n,{key:0,class:"btn btn-sm btn-primary",to:"/admin/cms/locales"},{default:T(()=>[...t[7]||(t[7]=[C("Locales",-1)])]),_:1})):f("",!0),m(y)("/admin/cms/vocabulary",m(_))?(l(),U(n,{key:1,class:"btn btn-sm btn-primary",to:"/admin/cms/vocabulary"},{default:T(()=>[...t[8]||(t[8]=[C("KB Tags",-1)])]),_:1})):f("",!0),m(y)("/admin/cms/migrations",m(_))?(l(),U(n,{key:2,class:"btn btn-sm btn-primary",to:"/admin/cms/migrations"},{default:T(()=>[...t[9]||(t[9]=[C("Migrations",-1)])]),_:1})):f("",!0),m(y)("/admin/cms",m(_))?(l(),U(n,{key:3,class:"btn btn-sm btn-primary",to:"/admin/cms"},{default:T(()=>[...t[10]||(t[10]=[C("Back to Editor",-1)])]),_:1})):f("",!0)])])]),u.value==="loading"?(l(),r("div",mt,"Checking access...")):u.value==="error"?(l(),r("div",pt,L(x.value),1)):u.value!=="authorized"?(l(),r("div",vt," You are not authorized to manage redirects. ")):(l(),r("div",ht,[a("div",gt,[a("div",bt,[a("div",ft,[t[12]||(t[12]=a("label",{class:"form-label mb-1"},"Search",-1)),d(a("input",{"onUpdate:modelValue":t[0]||(t[0]=s=>D.value=s),class:"form-control",type:"search",placeholder:"Find by source or target"},null,512),[[v,D.value]])]),a("label",yt,[d(a("input",{"onUpdate:modelValue":t[1]||(t[1]=s=>$.value=s),class:"form-check-input",type:"checkbox"},null,512),[[w,$.value]]),t[13]||(t[13]=a("span",{class:"form-check-label"},"Show active only",-1))]),a("button",{class:"btn btn-sm btn-outline-secondary",disabled:S.value,onClick:N}," Refresh ",8,_t)])]),a("div",kt,[a("div",xt,[t[21]||(t[21]=a("h5",{class:"mb-3"}
1,"New Redirect",-1)),a("div",St,[a("div",Pt,[t[14]||(t[14]=a("label",{class:"form-label mb-1"},"Source Path",-1)),d(a("input",{"onUpdate:modelValue":t[2]||(t[2]=s=>i.value.sourcePath=s),class:"form-control",type:"text",placeholder:"/support/old-article"},null,512),[[v,i.value.sourcePath]])]),a("div",Ut,[t[15]||(t[15]=a("label",{class:"form-label mb-1"},"Target Path/URL",-1)),d(a("input",{"onUpdate:modelValue":t[3]||(t[3]=s=>i.value.targetPath=s),class:"form-control",type:"text",placeholder:"/documentation/kb/kb-something"},null,512),[[v,i.value.targetPath]])]),a("div",Tt,[t[17]||(t[17]=a("label",{class:"form-label mb-1"},"Type",-1)),d(a("select",{"onUpdate:modelValue":t[4]||(t[4]=s=>i.value.sourceType=s),class:"form-select"},[...t[16]||(t[16]=[a("option",{value:"manual"},"Manual",-1),a("option",{value:"migration_support"},"Migration (Support)",-1),a("option",{value:"migration_documentation"},"Migration (Documentation)",-1)])],512),[[O,i.value.sourceType]])]),a("div",Ct,[t[19]||(t[19]=a("label",{class:"form-label mb-1"},"Status",-1)),a("label",Rt,[d(a("input",{"onUpdate:modelValue":t[5]||(t[5]=s=>i.value.active=s),class:"form-check-input",type:"checkbox"},null,512),[[w,i.value.active]]),t[18]||(t[18]=a("span",{class:"form-check-label"},"Active",-1))])]),a("div",Vt,[t[20]||(t[20]=a("label",{class:"form-label mb-1"},"Note",-1)),d(a("input",{"onUpdate:modelValue":t[6]||(t[6]=s=>i.value.note=s),class:"form-control",type:"text",placeholder:"Optional note"},null,512),[[v,i.value.note]])]),a("div",Mt,[a("button",{class:"btn btn-sm btn-warning",disabled:V.value,onClick:Y}," Add Redirect ",8,At)])])])]),a("div",Dt,[a("div",$t,[a("div",Nt,[a("table",Lt,[t[25]||(t[25]=a("thead",null,[a("tr",null,[a("th",null,"Source"),a("th",null,"Target"),a("th",null,"Type"),a("th",null,"Status"),a("th",null,"Note"),a("th",null,"Updated"),a("th",{class:"text-end"},"Actions")])],-1)),a("tbody",null,[S.value?(l(),r("tr",wt,[...t[22]||(t[22]=[a("td",{colspan:"7",class:"text-muted p-3"},"Loading redirects...",-1)])])):F.value.length?f("",!0):(l(),r("tr",zt,[...t[23]||(t[23]=[a("td",{colspan:"7",class:"text-muted p-3"},"No redirects found.",-1)])])),(l(!0),r(st,null,nt(F.value,s=>(l(),r("tr",{key:s.id},[a("td",Bt,[d(a("input",{"onUpdate:modelValue":o=>s.sourcePath=o,class:"form-control form-control-sm",type:"text",disabled:p(s)},null,8,Et),[[v,s.sourcePath]]),a("a",{class:"small d-inline-block mt-1",href:I(s.sourcePath),target:"_blank",rel:"noopener noreferrer"}," Open source ",8,Ft)]),a("td",It,[d(a("input",{"onUpdate:modelValue":o=>s.targetPath=o,class:"form-control form-control-sm",type:"text",disabled:p(s)},null,8,Ot),[[v,s.targetPath]]),a("a",{class:"small d-inline-block mt-1",href:I(s.targetPath),target:"_blank",rel:"noopener noreferrer"}," Open target ",8,qt)]),a("td",Wt,[d(a("select",{"onUpdate:modelValue":o=>s.sourceType=o,class:"form-select form-select-sm",disabled:p(s)},[...t[24]||(t[24]=[a("option",{value:"manual"},"Manual",-1),a("option",{value:"migration_support"},"Migration (Support)",-1),a("option",{value:"migration_documentation"},"Migration (Documentation)",-1)])],8,jt),[[O,s.sourceType]])]),a("td",null,[a("label",Ht,[d(a("input",{"onUpdate:modelValue":o=>s.active=o,class:"form-check-input",type:"checkbox"},null,8,Kt),[[w,s.active]]),a("span",Yt,L(s.active?"Active":"Disabled"),1)])]),a("td",Gt,[d(a("input",{"onUpdate:modelValue":o=>s.note=o,class:"form-control form-control-sm",type:"text",disabled:p(s)},null,8,Jt),[[v,s.note]])]),a("td",Qt,L(Q(s.updatedAt)),1),a("td",Xt,[a("button",{class:"btn btn-sm btn-primary me-2",disabled:M.value===s.id,onClick:o=>G(s)}," Save ",8,Zt),p(s)?(l(),r("span",te,"Managed by migration (active toggle only)")):(l(),r("button",{key:1,class:"btn btn-sm btn-outline-danger",disabled:A.value===s.id,onClick:o=>J(s)}," Delete ",8,ee))])]))),128))])])])])])]))])}}});export{oe 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.