import{u as F,a3 as T,c as v,q as N,E as D,d as Y,h as O,b as M}from"./app-core.3e3b5f4b.js";import{_ as V}from"./Index.4596235c.js";import{C as q}from"./Index.ce0c115a.js";import{C as z}from"./SettingsRow.d1734943.js";import{S as j}from"./Short.c0fe98ee.js";import{_ as U}from"./_plugin-vue_export-helper.eefbdd86.js";import{_ as s}from"./vendor-other.ac1169a2.js";import{aq as c,f as l,i as _,Q as f,R as h,j as d,U as u,a0 as m,ae as b,M as p,T as x}from"./vendor-vue-ui.65fbb3e9.js";import{_ as K}from"./Redirects.afe75f73.js";import{u as G}from"./Index.97a50a75.js";import{_ as Q}from"./Button.60477c93.js";import{B as W}from"./Input.32b40815.js";import{B as J}from"./Toggle.44cb6570.js";import{C as X}from"./Index.792b437f.js";import{C as Z}from"./Table.ce99ee5f.js";import"./vendor-lodash.a7229f96.js";import"./JsonValues.a0694556.js";import"./Url.1735e9b5.js";import"./Select.b03c8501.js";import"./Caret.bc946270.js";import"./Close.3dad5b8a.js";import"./DatePicker.7b96e120.js";import"./Calendar.c85faba7.js";import"./Pencil.b9e32152.js";import"./vendor-date-picker.8d2ad5fb.js";import"./Tooltip.83c2998c.js";import"./Trash.c607f240.js";import"./Plus.24850bdc.js";import"./Slide.1fe27f7c.js";import"./Row.35464476.js";import"./Blur.4f53e55b.js";import"./Card.3492d277.js";import"./Index.b067c390.js";import"./Exclamation.6db6b970.js";import"./Checkbox.6b6a136d.js";import"./Checkmark.429c2d8c.js";import"./ProBadge.b0e426b0.js";import"./External.98703be1.js";import"./Gear.3b4200d4.js";import"./Download.4bd6f161.js";const B="all-in-one-seo-pack",$={setup(){return{postEditorStore:F()}},components:{CoreSettingsRow:z,SvgRightArrowShort:j},data(){return{strings:{title:s("Redirects",B),description:s("Here you can add a redirect or view your existing redirects from this page. Click on the button below to view the Redirects panel.",B),button:s("Open Redirects",B)}}}},ee={class:"aioseo-redirects-sidebar"},te={class:"aioseo-sidebar-content-title"};function re(e,t,g,a,n,r){const S=c("svg-right-arrow-short"),C=c("base-button"),y=c("core-settings-row");return l(),_("div",ee,[e.$root.$data.screenContext==="sidebar"?(l(),f(y,{key:0,class:"snippet-description-row open-redirects-copy"},{content:h(()=>[d("div",te,u(n.strings.title),1),d("p",null,u(n.strings.description),1),m(C,{class:"open-redirects-modal gray small",onClick:t[0]||(t[0]=R=>a.postEditorStore.currentPost.redirects.modalOpen=!0)},{default:h(()=>[m(S),b(" "+u(n.strings.button),1)]),_:1})]),_:1})):p("",!0)])}const se=U($,[["render",re],["__scopeId","data-v-1754537e"]]),o="all-in-one-seo-pack",oe={setup(){const{redirectHasUnPublishedPost:e}=G();return{notificationsStore:Y(),redirectsStore:D(),settingsStore:N(),redirectHasUnPublishedPost:e}},components:{BaseButton:Q,BaseInput:W,BaseToggle:J,CoreAddRedirection:V,CoreAlert:X,CoreModal:q,CoreWpTable:Z},props:{excludeColumns:Array,disableSource:Boolean,showBulkActions:{type:Boolean,default:!0},showHeader:{type:Boolean,default:!0},showTableFooter:{type:Boolean,default:!0}},data(){return{wpTableKey:0,wpTableLoading:!1,modalOpened:!1,testLoading:!1,testResults:null,testUrl:"",strings:{searchUrls:s("Search URLs",o),edit:s("Edit",o),checkRedirect:s("Check Redirect",o),delete:s("Delete",o),redirectTest:s("Redirect Test",o),redirectTestDescription:s("Enter a URL below to see if it redirects correctly. This will test the actual redirect and show you what happens.",o),enterUrlPlaceholder:s("Enter a URL to test...",o),test:s("Test",o),sourceUrl:s("Source URL",o),targetUrl:s("Target URL",o),type:s("Type",o),enabled:s("Enabled",o),areYouSureDelete:s("Are you sure you want to delete this redirect?",o),areYouSureDeleteSelected:s("Are you sure you want to delete the selected redirect(s)?",o),bulkActionCannotBeUndone:s("This action cannot be undone.",o),redirectTypes:{301:s("301 Moved Permanently",o),302:s("302 Found",o),307:s("307 Temporary Redirect",o),308:s("308 Permanent Redirect",o),400:s("400 Bad Request",o),401:s("401 Unauthorized",o),403:s("403 Forbidden",o),404:s("404 Not Found",o),410:s("410 Gone",o),500:s("500 Internal Server Error",o)}}}},computed:{tableId(){return this.disableSource?"aioseo-post-redirects-table":"aioseo-redirects-table"},pageNumber(){return this.$route.query.page?parseInt(this.$route.query.page):1},searchTerm(){return this.$route.query.search||null},getRows(){return this.redirectsStore.rows.map(e=>({...e,source_url:this.disableSource?"":e.source_url}))},columns(){const e=[{slug:"source_url",label:this.strings.sourceUrl,width:"300px",sortable:!0},{slug:"target_url",label:this.strings.targetUrl,width:"300px",sortable:!0},{slug:"type",label:this.strings.type,width:"120px",sortable:!0},{slug:"enabled",label:this.strings.enabled,width:"80px",sortable:!0}];return this.excludeColumns&&this.excludeColumns.length?e.filter(t=>!this.excludeColumns.includes(t.slug)):e},bulkOptions(){return[{label:s("Delete",o),value:"delete"}]},additionalFilters(){return[]}},methods:{processFilterTable({slug:e,values:t}){this.redirectsStore.selectedFilters[e]=t,this.wpTableLoading=!0,this.redirectsStore.getRedirects().then(()=>{this.wpTableLoading=!1})},processPagination(e){this.redirectsStore.totals.main.page=e,this.wpTableLoading=!0,this.redirectsStore.getRedirects().then(()=>{this.wpTableLoading=!1})},processAdditionalFilters(e){Object.keys(e).forEach(t=>{this.redirectsStore.selectedFilters[t]=e[t]}),this.wpTableLoading=!0,this.redirectsStore.getRedirects().then(()=>{this.wpTableLoading=!1})},processBulkAction({action:e,selectedRows:t}){e==="delete"&&this.notificationsStore.show({type:"warning",title:this.strings.areYouSureDeleteSelected,message:this.strings.bulkActionCannotBeUndone,actions:[{label:s("Yes, delete the redirects",o),action:"processDeleteSelected",data:t}]})},processDeleteSelected(e){T.post(v.restUrl("redirects/delete")).send({redirectIds:e}).then(()=>{this.redirectsStore.getRedirects()})},processChangeItemsPerPage(e){this.settingsStore.changeItemsPerPage({slug:"redirects",itemsPerPage:e})},processSearch(e){this.wpTableLoading=!0,this.redirectsStore.getRedirects({searchTerm:e}).then(()=>{this.wpTableLoading=!1})},processSort({column:e,direction:t}){this.redirectsStore.sort.main=e,this.redirectsStore.sortDir.main=t,this.wpTableLoading=!0,this.redirectsStore.getRedirects().then(()=>{this.wpTableLoading=!1})},maybeDeleteRow(e){this.notificationsStore.show({type:"warning",title:this.strings.areYouSureDelete,message:this.strings.bulkActionCannotBeUndone,actions:[{label:s("Yes, delete the redirect",o),action:"processDeleteRow",data:e}]})},processDeleteRow(e){const t=this.redirectsStore.rows[e];T.post(v.restUrl("redirects/delete")).send({redirectIds:[t.id]}).then(()=>{this.redirectsStore.getRedirects()})},toggleInput(e,t){T.post(v.restUrl("redirects/update")).send({id:e.id,enabled:t}).then(()=>{this.redirectsStore.getRedirects()})},showRedirectTest(e){this.testUrl=`${this.redirectsStore.options.server.home}${e.source_url}`,this.testResults=null,this.modalOpened=!0},processRedirectTest(){this.testUrl&&(this.testLoading=!0,this.testResults=null,T.post(v.restUrl("redirects/test")).send({url:this.testUrl}).then(e=>{this.testResults=e.body,this.testLoading=!1}).catch(()=>{this.testLoading=!1}))},getColumnLabel(e){return this.strings.redirectTypes[e]||e}},mounted(){this.redirectsStore.rows.length||(this.wpTableLoading=!0,this.redirectsStore.getRedirects().then(()=>{this.wpTableLoading=!1}))}},ne={class:"aioseo-redirects-table"},ie=["onClick"],ae={class:"row-actions"},le={class:"edit"},ce=["onClick"],de={key:0,class:"test"},ue=["onClick"],pe={class:"trash"},he=["onClick"],me={class:"test-redirect-modal"},ge={class:"aioseo-description"},_e={class:"test-redirect-input"},be={key:0,class:"test-redirect-results"};function fe(e,t,g,a,n,r){const S=c("base-toggle"),C=c("core-add-redirection"),y=c("core-wp-table"),R=c("base-input"),k=c("base-button"),L=c("core-alert"),H=c("core-modal");return l(),_("div",ne,[(l(),f(y,{ref:"table",id:r.tableId,"additional-filters":r.additionalFilters,"bulk-options":r.bulkOptions,columns:r.columns,filters:a.redirectsStore.filters,"initial-items-per-page":a.settingsStore.settings.tablePagination.redirects,"initial-page-number":r.pageNumber,"initial-search-term":r.searchTerm,key:n.wpTableKey,loading:n.wpTableLoading,rows:r.getRows,"search-label":n.strings.searchUrls,"selected-filters":a.redirectsStore.selectedFilters,"show-bulk-actions":g.showBulkActions,"show-header":g.showHeader,"show-table-footer":g.showTableFooter,totals:a.redirectsStore.totals.main,"show-items-per-page":"",onFilterTable:r.processFilterTable,onPaginate:r.processPagination,onProcessAdditionalFilters:r.processAdditionalFilters,onProcessBulkAction:r.processBulkAction,onProcessChangeItemsPerPage:r.processChangeItemsPerPage,onSearch:r.processSearch,onSortColumn:r.processSort},{source_url:h(({row:i,index:w,column:P,editRow:E})=>[d("strong",null,[d("a",{class:"edit-link",href:"#",onClick:x(A=>E(w),["prevent"])},u(P),9,ie)]),d("div",ae,[d("span",le,[d("a",{href:"#",onClick:x(A=>E(w),["prevent"])},u(n.strings.edit),9,ce),t[2]||(t[2]=b(" | ",-1))]),i.enabled&&!a.redirectHasUnPublishedPost(i)?(l(),_("span",de,[d("a",{href:"#",onClick:x(A=>r.showRedirectTest(i),["prevent"])},u(n.strings.checkRedirect),9,ue),t[3]||(t[3]=b(" | ",-1))])):p("",!0),d("span",pe,[d("a",{class:"submitdelete",href:"#",onClick:x(A=>r.maybeDeleteRow(w),["prevent"])},u(n.strings.delete),9,he)])])]),target_url:h(({row:i})=>[b(u(400<=i.type?"-":i.target_url),1)]),type:h(({column:i})=>[b(u(r.getColumnLabel(i)),1)]),enabled:h(({column:i,row:w})=>[m(S,{modelValue:i,"onUpdate:modelValue":P=>r.toggleInput(w,i)},null,8,["modelValue","onUpdate:modelValue"])]),"edit-row":h(({row:i,editRow:w})=>[m(C,{edit:"",onCancel:P=>w(null),onAddedRedirect:P=>w(null),url:{id:i.id,url:i.source_url,regex:i.regex,ignoreSlash:i.ignore_slash,ignoreCase:i.ignore_case,showOptions:!0,errors:[],warnings:[]},target:i.target_url,type:i.type,"query-params":i.query_parameters,"custom-rules":i.rules,"is-table":!0},null,8,["onCancel","onAddedRedirect","url","target","type","query-params","custom-rules"])]),_:1},8,["id","additional-filters","bulk-options","columns","filters","initial-items-per-page","initial-page-number","initial-search-term","loading","rows","search-label","selected-filters","show-bulk-actions","show-header","show-table-footer","totals","onFilterTable","onPaginate","onProcessAdditionalFilters","onProcessBulkAction","onProcessChangeItemsPerPage","onSearch","onSortColumn"])),m(H,{show:n.modalOpened,onClose:t[1]||(t[1]=i=>n.modalOpened=!1)},{headerTitle:h(()=>[b(u(n.strings.redirectTest),1)]),body:h(()=>[d("div",me,[d("div",ge,u(n.strings.redirectTestDescription),1),d("div",_e,[m(R,{class:"test-redirect-url",size:"medium",prependIcon:"link",placeholder:n.strings.enterUrlPlaceholder,modelValue:n.testUrl,"onUpdate:modelValue":t[0]||(t[0]=i=>n.testUrl=i)},null,8,["placeholder","modelValue"]),m(k,{size:"medium",type:"blue",loading:n.testLoading,onClick:r.processRedirectTest},{default:h(()=>[b(u(n.strings.test),1)]),_:1},8,["loading","onClick"])]),n.testResults?(l(),_("div",be,[m(L,{type:n.testResults.type==="success"?"green":"red"},{default:h(()=>[b(u(n.testResults.message),1)]),_:1},8,["type"])])):p("",!0)])]),_:1},8,["show"])])}const Se=U(oe,[["render",fe]]),Ce="all-in-one-seo-pack",we={setup(){return{licenseStore:O(),postEditorStore:F(),redirectsStore:D()}},components:{CoreAddRedirection:V,CoreModal:q,RedirectsSideBar:se,RedirectsLite:K,RedirectsTable:Se},props:{parentComponentContext:String},data(){return{strings:{modalHeader:s("Redirects",Ce)}}},computed:{getUrl(){return{url:this.postEditorStore.currentPost.permalinkPath,showOptions:!0}},hasRedirects(){return this.redirectsStore.rows.length},postId(){return this.postEditorStore.currentPost.context==="post"?parseInt(this.postEditorStore.currentPost.id):0}},methods:{reload(){this.redirectsStore.getPostRedirects()}}},ye={key:0},Re={class:"bd"},ke={key:1},Pe={key:0,class:"aioseo-tab-content aioseo-redirects metabox"},Te={key:1},ve={class:"bd"},xe={key:1};function Ue(e,t,g,a,n,r){const S=c("redirects-lite"),C=c("core-modal"),y=c("redirects-side-bar"),R=c("core-add-redirection"),k=c("redirects-table");return l(),_("div",null,[a.licenseStore.isUnlicensed?(l(),_("div",ye,[e.$root.$data.screenContext==="metabox"?(l(),f(S,{key:0,noCoreCard:!0,parentComponentContext:g.parentComponentContext},null,8,["parentComponentContext"])):p("",!0),m(C,{"modal-name":"post-settings-sidebar-redirects",show:a.postEditorStore.currentPost.redirects.modalOpen&&e.$root.$data.screenContext==="sidebar",classes:["aioseo-redirects"],onClose:t[0]||(t[0]=L=>a.postEditorStore.currentPost.redirects.modalOpen=!1)},{headerTitle:h(()=>[b(u(n.strings.modalHeader),1)]),body:h(()=>[d("div",Re,[m(S,{noCoreCard:!0,parentComponentContext:g.parentComponentContext},null,8,["parentComponentContext"])])]),_:1},8,["show"]),g.parentComponentContext!=="modal"?(l(),f(y,{key:1})):p("",!0)])):p("",!0),a.licenseStore.isUnlicensed?p("",!0):(l(),_("div",ke,[e.$root.$data.screenContext==="metabox"?(l(),_("div",Pe,[r.hasRedirects?p("",!0):(l(),f(R,{key:a.postEditorStore.currentPost.permalinkPath,"disable-source":!0,"post-id":r.postId,"post-status":a.postEditorStore.currentPost.postStatus,url:r.getUrl,onAddedRedirect:r.reload},null,8,["post-id","post-status","url","onAddedRedirect"])),r.hasRedirects?(l(),_("div",Te,[m(k,{"disable-source":!0,"exclude-columns":["group"],"show-bulk-actions":!1,"show-header":!1,"show-table-footer":!1})])):p("",!0)])):p("",!0),m(C,{"modal-name":"post-settings-sidebar-redirects",show:a.postEditorStore.currentPost.redirects.modalOpen&&e.$root.$data.screenContext==="sidebar",classes:["aioseo-redirects"],onClose:t[1]||(t[1]=L=>a.postEditorStore.currentPost.redirects.modalOpen=!1),"allow-overflow":""},{headerTitle:h(()=>[b(u(n.strings.modalHeader),1)]),body:h(()=>[d("div",ve,[r.hasRedirects?p("",!0):(l(),f(R,{key:a.postEditorStore.currentPost.permalinkPath,"disable-source":!0,"post-id":r.postId,"post-status":a.postEditorStore.currentPost.postStatus,url:r.getUrl,onAddedRedirect:r.reload},null,8,["post-id","post-status","url","onAddedRedirect"])),r.hasRedirects?(l(),_("div",xe,[m(k,{"disable-source":!0,"exclude-columns":["group"],"show-bulk-actions":!1,"show-header":!1,"show-table-footer":!1})])):p("",!0)])]),_:1},8,["show"]),g.parentComponentContext!=="modal"?(l(),f(y,{key:1})):p("",!0)]))])}const I=U(we,[["render",Ue]]),Le={setup(){return{rootStore:M(),licenseStore:O()}},components:{Redirects:I,RedirectsLite:I},props:{parentComponentContext:String}},Ae={class:"aioseo-tab-content"};function Be(e,t,g,a,n,r){const S=c("Redirects",!0),C=c("RedirectsLite");return l(),_("div",Ae,[!a.licenseStore.isUnlicensed&&a.rootStore.isPro?(l(),f(S,{key:0,parentComponentContext:g.parentComponentContext},null,8,["parentComponentContext"])):p("",!0),a.licenseStore.isUnlicensed||!a.rootStore.isPro?(l(),f(C,{key:1,parentComponentContext:g.parentComponentContext},null,8,["parentComponentContext"])):p("",!0)])}const St=U(Le,[["render",Be]]);export{St as default};