File: /home/dtptviut/domains/morsunivers.dk/public_html/wp-content/plugins/404-to-301/build/settings.js
(()=>{"use strict";var e={n:t=>{var s=t&&t.__esModule?()=>t.default:()=>t;return e.d(s,{a:s}),s},d:(t,s)=>{for(var n in s)e.o(s,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:s[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{activateLicense:()=>v,deactivateLicense:()=>b,refresh:()=>f,replaceItem:()=>m,setItems:()=>p,setLoading:()=>y,setRefreshing:()=>x});var s={};e.r(s),e.d(s,{getItemById:()=>S,getItems:()=>j,isLoading:()=>w,isRefreshing:()=>R});var n={};e.r(n),e.d(n,{getItems:()=>P});var o={};e.r(o),e.d(o,{abort:()=>H,setStarting:()=>F,setStatus:()=>L,start:()=>A,tick:()=>B});var i={};e.r(i),e.d(i,{getRemaining:()=>M,getStatus:()=>D,isRunning:()=>I,isStarting:()=>O});var r={};e.r(r),e.d(r,{getStatus:()=>$});const a=window.wp.apiFetch;var l=e.n(a);(()=>{if("undefined"!=typeof d404&&(d404.restNonce&&l().use(l().createNonceMiddleware(d404.restNonce)),d404.adminUrl)){const e=d404.adminUrl.replace(/wp-admin\/?$/,"");l().use(l().createRootURLMiddleware(`${e}wp-json/`))}})();const c=window.wp.data,d={items:[],isLoading:!1,isRefreshing:!1},h={API_FETCH:({request:e})=>l()(e)},_=window.wp.i18n,g=window.wp.notices,u="/404-to-301/v1/addons",p=e=>({type:"SET_ITEMS",items:e}),m=e=>({type:"REPLACE_ITEM",addon:e}),y=e=>({type:"SET_LOADING",isLoading:!!e}),x=e=>({type:"SET_REFRESHING",isRefreshing:!!e});function*f(){yield x(!0);try{const e=yield{type:"API_FETCH",request:{path:`${u}/refresh`,method:"POST"}};yield p(Array.isArray(e?.items)?e.items:[]),(0,c.dispatch)(g.store).createSuccessNotice((0,_.__)("Add-on list refreshed.","404-to-301"))}catch(e){(0,c.dispatch)(g.store).createErrorNotice(e?.message||(0,_.__)("Could not refresh the add-on list.","404-to-301"))}finally{yield x(!1)}}function*v(e,t){try{const s=yield{type:"API_FETCH",request:{path:`${u}/${encodeURIComponent(e)}/license`,method:"POST",data:{key:t}}};return s?.success?(yield m(s.addon),(0,c.dispatch)(g.store).createSuccessNotice((0,_.__)("License activated.","404-to-301")),{success:!0}):{success:!1,error:(0,_.__)("License activation failed. Please double-check the key and try again.","404-to-301")}}catch(e){return{success:!1,error:e?.message||(0,_.__)("License activation failed. Please try again.","404-to-301")}}}function*b(e){try{const t=yield{type:"API_FETCH",request:{path:`${u}/${encodeURIComponent(e)}/license`,method:"DELETE"}};return t?.success?(yield m(t.addon),(0,c.dispatch)(g.store).createSuccessNotice((0,_.__)("License deactivated.","404-to-301")),{success:!0}):{success:!1,error:(0,_.__)("License deactivation failed. Please try again.","404-to-301")}}catch(e){return{success:!1,error:e?.message||(0,_.__)("License deactivation failed. Please try again.","404-to-301")}}}const j=e=>e.items,S=(e,t)=>e.items.find(e=>Number(e.id)===Number(t)),w=e=>e.isLoading,R=e=>e.isRefreshing,N="/404-to-301/v1/addons";function*P(){yield y(!0);try{const e=yield{type:"API_FETCH",request:{path:N}};yield p(Array.isArray(e?.items)?e.items:[])}catch(e){(0,c.dispatch)(g.store).createErrorNotice(e?.message||(0,_.__)("Could not load the add-on list.","404-to-301")),yield p([])}finally{yield y(!1)}}const C=(0,c.createReduxStore)("d404/addons",{reducer:(e=d,t)=>{switch(t.type){case"SET_ITEMS":return{...e,items:t.items};case"REPLACE_ITEM":return t.addon&&t.addon.id?{...e,items:e.items.map(e=>Number(e.id)===Number(t.addon.id)?{...e,...t.addon}:e)}:e;case"SET_LOADING":return{...e,isLoading:t.isLoading};case"SET_REFRESHING":return{...e,isRefreshing:t.isRefreshing};default:return e}},controls:h,actions:t,selectors:s,resolvers:n});(0,c.register)(C);const E={status:null,isStarting:!1},k={API_FETCH:({request:e})=>l()(e)},T="/404-to-301/v1/migration",L=e=>({type:"SET_STATUS",status:e}),F=e=>({type:"SET_STARTING",isStarting:!!e});function*A(){yield F(!0);try{const e=yield{type:"API_FETCH",request:{path:T,method:"POST"}};return yield L(e),yield F(!1),e}catch(e){return(0,c.dispatch)(g.store).createErrorNotice(e?.message||(0,_.__)("Could not start the migration.","404-to-301")),yield F(!1),null}}function*B(){try{const e=yield{type:"API_FETCH",request:{path:`${T}/tick`,method:"POST"}};return yield L(e),e}catch(e){return(0,c.dispatch)(g.store).createErrorNotice(e?.message||(0,_.__)("Migration tick failed — will retry on next page load.","404-to-301")),null}}function*H(){try{const e=yield{type:"API_FETCH",request:{path:T,method:"DELETE"}};return yield L(e),(0,c.dispatch)(g.store).createSuccessNotice((0,_.__)("Migration aborted.","404-to-301")),e}catch(e){return(0,c.dispatch)(g.store).createErrorNotice(e?.message||(0,_.__)("Could not abort the migration.","404-to-301")),null}}const D=e=>e.status,I=e=>!!e.status?.running,M=e=>e.status?.remaining||0,O=e=>e.isStarting,U="/404-to-301/v1/migration";function*$(){try{const e=yield{type:"API_FETCH",request:{path:U}};yield L(e)}catch(e){}}const z=(0,c.createReduxStore)("d404/migration",{reducer:(e=E,t)=>{switch(t.type){case"SET_STATUS":return{...e,status:t.status};case"SET_STARTING":return{...e,isStarting:t.isStarting};default:return e}},controls:k,actions:o,selectors:i,resolvers:r});(0,c.register)(z);const V=window.wp.domReady;var q=e.n(V);const G=window.wp.element,W=window.wp.components,Z=window.wp.coreData,J=()=>{const[e,t]=(0,Z.useEntityProp)("root","site","404_to_301_settings"),{saveEditedEntityRecord:s}=(0,c.useDispatch)(Z.store),{createSuccessNotice:n,createErrorNotice:o,removeAllNotices:i}=(0,c.useDispatch)(g.store),{isSaving:r,hasLoaded:a,isDirty:l}=(0,c.useSelect)(e=>{const t=e(Z.store);return{isSaving:t.isSavingEntityRecord("root","site"),isDirty:t.hasEditsForEntityRecord("root","site"),hasLoaded:t.hasFinishedResolution("getEntityRecord",["root","site"])}},[]),d=e||{};return{settings:d,hasLoaded:a,isSaving:r,isDirty:l,getSetting:(e,t="")=>void 0===d[e]?t:d[e],setSetting:(e,s)=>{t({...d,[e]:s})},saveSettings:async()=>{i(),await s("root","site")?n((0,_.__)("Settings saved.","404-to-301"),{type:"snackbar"}):o((0,_.__)("Could not save settings.","404-to-301"),{type:"snackbar"})}}},X=window.wp.hooks,Y=window.ReactJSXRuntime,K=(0,G.forwardRef)(({icon:e,size:t=24,...s},n)=>(0,G.cloneElement)(e,{width:t,height:t,...s,ref:n})),Q=window.wp.primitives,ee=(0,Y.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,Y.jsx)(Q.Path,{d:"M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z"})});class te extends G.Component{constructor(e){super(e),this.state={error:null}}static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error("404 to 301 admin error:",e,t)}render(){const{error:e}=this.state;return e?(0,Y.jsxs)(W.Notice,{status:"error",isDismissible:!1,children:[(0,Y.jsx)("p",{children:(0,Y.jsx)("strong",{children:(0,_.__)("Something went wrong while rendering this page.","404-to-301")})}),(0,Y.jsx)("p",{children:e.message||String(e)})]}):this.props.children}}const se=te,ne=({children:e})=>(0,Y.jsxs)(W.SlotFillProvider,{children:[(0,Y.jsx)(se,{children:e}),(0,Y.jsx)(W.Popover.Slot,{})]});window.ReactDOM;const oe=()=>{const{isSaving:e,isDirty:t,saveSettings:s}=J();return(0,Y.jsx)("div",{className:"d404-footer",children:(0,Y.jsx)(W.Button,{variant:"primary",icon:e?null:"yes",isBusy:e,disabled:e||!t,onClick:s,children:e?(0,_.__)("Saving…","404-to-301"):(0,_.__)("Save Changes","404-to-301")})})},ie=()=>{const e=(0,c.useSelect)(e=>e(g.store).getNotices().filter(e=>"snackbar"===e.type),[]),{removeNotice:t}=(0,c.useDispatch)(g.store);return e.length?(0,Y.jsx)(W.SnackbarList,{className:"d404-notices",notices:e,onRemove:t}):null};function re(e){var t,s,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(s=re(e[t]))&&(n&&(n+=" "),n+=s)}else for(s in e)e[s]&&(n&&(n+=" "),n+=s);return n}const ae=function(){for(var e,t,s=0,n="",o=arguments.length;s<o;s++)(e=arguments[s])&&(t=re(e))&&(n&&(n+=" "),n+=t);return n},le=({wide:e=!1,children:t})=>(0,Y.jsx)("div",{className:ae("d404-page-body",{"d404-page-body--wide":e}),children:t}),ce=({title:e,children:t})=>{const s="undefined"!=typeof d404&&d404.version||"";return(0,Y.jsxs)("div",{className:"d404-page-header",children:[(0,Y.jsxs)("div",{className:"d404-page-title",children:[(0,Y.jsx)("h1",{children:e}),s&&(0,Y.jsx)("abbr",{className:"d404-version",title:`Version: ${s}`,children:s})]}),t]})},de=({current:e,navs:t,onChange:s})=>(0,Y.jsx)("nav",{className:"d404-tabs",style:{gridTemplateColumns:Object.keys(t).map(()=>"1fr").join(" ")},children:Object.keys(t).map(n=>(0,Y.jsx)("a",{href:`#${n}`,className:ae("d404-tab",{active:n===e}),onClick:e=>{e.preventDefault(),s(n)},children:t[n]},n))}),he=window.wp.compose,_e=window.wp.htmlEntities,ge="id,title",ue=e=>e?(0,_e.decodeEntities)(e.title?.rendered)||(0,_.sprintf)((0,_.__)("Page #%d","404-to-301"),e.id):"",pe=({value:e,onChange:t,label:s,help:n,hideLabelFromVision:o})=>{const i=parseInt(e,10)||0,[r,a]=(0,G.useState)(""),l=(0,he.useDebounce)(a,300),{pages:d,current:h,isSearching:g}=(0,c.useSelect)(e=>{const t=e(Z.store),s={per_page:20,_fields:ge,orderby:"title",order:"asc"};return r&&(s.search=r),{pages:t.getEntityRecords("postType","page",s),isSearching:!t.hasFinishedResolution("getEntityRecords",["postType","page",s]),current:i?t.getEntityRecord("postType","page",i,{_fields:ge}):null}},[r,i]),u=(0,G.useMemo)(()=>{const e=(d||[]).map(e=>({value:String(e.id),label:ue(e)}));return h&&!e.some(e=>e.value===String(h.id))&&e.unshift({value:String(h.id),label:ue(h)}),e},[d,h]);return(0,Y.jsx)("div",{className:"d404-page-select",children:(0,Y.jsx)(W.ComboboxControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:s,help:n,hideLabelFromVision:o,placeholder:(0,_.__)("Search for a page…","404-to-301"),isLoading:g,value:i?String(i):null,options:u,onFilterValueChange:e=>l(e),onChange:e=>t(parseInt(e,10)||0)})})},me=[{value:301,label:(0,_.__)("301 — Moved Permanently (SEO)","404-to-301"),terminal:!1},{value:302,label:(0,_.__)("302 — Found","404-to-301"),terminal:!1},{value:303,label:(0,_.__)("303 — See Other","404-to-301"),terminal:!1},{value:307,label:(0,_.__)("307 — Temporary Redirect","404-to-301"),terminal:!1},{value:308,label:(0,_.__)("308 — Permanent Redirect","404-to-301"),terminal:!1},{value:410,label:(0,_.__)("410 — Gone","404-to-301"),terminal:!0},{value:451,label:(0,_.__)("451 — Unavailable for Legal Reasons","404-to-301"),terminal:!0}],ye="undefined"!=typeof d404&&Array.isArray(d404.redirectStatuses)&&d404.redirectStatuses.length>0?d404.redirectStatuses:me,xe=(ye.map(({value:e,label:t})=>({value:e,label:t})),ye.filter(e=>e.terminal).map(e=>e.value),ye.filter(e=>!e.terminal).map(e=>({value:String(e.value),label:e.label}))),fe=()=>(0,Y.jsx)(W.PanelRow,{className:"d404-cross-sell",children:(0,Y.jsxs)(W.Notice,{status:"info",isDismissible:!1,children:[(0,Y.jsx)("p",{className:"d404-cross-sell__title",children:(0,Y.jsx)("strong",{children:(0,_.__)("Drowning in 404 logs?","404-to-301")})}),(0,Y.jsxs)("p",{children:[(0,_.__)("Install the Logs Cleaner addon to auto-prune the 404 log table — by age, by row count, or on a fixed schedule. Set it once and the table stays small on its own.","404-to-301")," ",(0,Y.jsx)("a",{href:"https://duckdev.com/addon/404-to-301-logs-cleaner/",target:"_blank",rel:"noreferrer",children:(0,_.__)("Get Logs Cleaner","404-to-301")})]})]})}),ve=/^[^\s@]+@[^\s@]+\.[^\s@]+$/,be=[{key:"email_reports",label:(0,_.__)("Email Reports","404-to-301"),url:"https://duckdev.com/addon/404-to-301-email-reports/",text:(0,_.__)("scheduled email digests of your 404s","404-to-301")},{key:"telegram_alerts",label:(0,_.__)("Telegram Alerts","404-to-301"),url:"https://duckdev.com/addon/404-to-301-telegram-alerts/",text:(0,_.__)("instant 404 alerts in Telegram","404-to-301")}],je=({addons:e})=>Array.isArray(e)&&0!==e.length?(0,Y.jsx)(W.PanelRow,{className:"d404-cross-sell",children:(0,Y.jsxs)(W.Notice,{status:"info",isDismissible:!1,children:[(0,Y.jsx)("p",{className:"d404-cross-sell__title",children:(0,Y.jsx)("strong",{children:(0,_.__)("Want more 404 notifications?","404-to-301")})}),(0,Y.jsx)("ul",{children:e.map(e=>(0,Y.jsxs)("li",{children:[(0,Y.jsx)("a",{href:e.url,target:"_blank",rel:"noreferrer",children:e.label}),` — ${e.text}.`]},e.key))})]})}):null,Se=e=>Array.isArray(e)?e.map(e=>String(e).trim()).filter(Boolean):"string"==typeof e?e.split(",").map(e=>e.trim()).filter(Boolean):[],we=(0,Y.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,Y.jsx)(Q.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})}),Re=(0,Y.jsx)(Q.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,Y.jsx)(Q.Path,{d:"M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"})}),Ne=(e,t)=>{const s=Array.isArray(e)?e:[];return(s.length?s:[""]).map(e=>({id:t(),value:e}))},Pe=({value:e,onChange:t,placeholder:s})=>{const n=(0,G.useRef)(0),o=()=>(n.current+=1,n.current),[i,r]=(0,G.useState)(()=>Ne(e,o));(0,G.useEffect)(()=>{const t=i.map(e=>e.value.trim()).filter(Boolean),s=Array.isArray(e)?e:[];var n,a;a=s,(n=t).length===a.length&&n.every((e,t)=>e===a[t])||r(Ne(s,o))},[e]);const a=e=>{r(e),t(e.map(e=>e.value.trim()).filter(Boolean))},l=i.filter(e=>e.value.trim()).length,c=i[i.length-1],d=!!c&&c.value.trim().length>0;return(0,Y.jsxs)("div",{className:"d404-repeater",children:[(0,Y.jsx)("div",{className:"d404-repeater__meta","aria-live":"polite",children:(0,_.sprintf)(/* translators: %d: number of paths in the list. */ /* translators: %d: number of paths in the list. */
(0,_._n)("%d path","%d paths",l,"404-to-301"),l)}),(0,Y.jsx)("div",{className:"d404-repeater__rows",role:"list",children:i.map((e,t)=>(0,Y.jsxs)("div",{className:"d404-repeater__row",role:"listitem",children:[(0,Y.jsx)("div",{className:"d404-repeater__field",children:(0,Y.jsx)(W.TextControl,{__nextHasNoMarginBottom:!0,hideLabelFromVision:!0,size:"compact",label:(0,_.sprintf)(/* translators: %d: row number. */ /* translators: %d: row number. */
(0,_.__)("Path %d","404-to-301"),t+1),value:e.value,onChange:t=>((e,t)=>a(i.map(s=>s.id===e?{...s,value:t}:s)))(e.id,t),placeholder:s})}),(0,Y.jsx)("div",{className:"d404-repeater__actions",children:(0,Y.jsx)(W.Button,{size:"small",isDestructive:!0,icon:we,label:(0,_.__)("Remove path","404-to-301"),onClick:()=>(e=>{const t=i.filter(t=>t.id!==e);a(t.length?t:[{id:o(),value:""}])})(e.id)})})]},e.id))}),(0,Y.jsx)("div",{className:"d404-repeater__footer",children:(0,Y.jsx)(W.Button,{variant:"secondary",size:"small",icon:Re,onClick:()=>a([...i,{id:o(),value:""}]),disabled:!d,"aria-disabled":!d,description:d?void 0:(0,_.__)("Fill in the current row before adding another.","404-to-301"),children:(0,_.__)("Add path","404-to-301")})})]})},Ce=()=>{const e=(0,G.useRef)(null),[t,s]=(0,G.useState)(!1),[n,o]=(0,G.useState)(null),{createSuccessNotice:i,createErrorNotice:r}=(0,c.useDispatch)(g.store);return(0,Y.jsxs)(W.PanelBody,{title:(0,_.__)("Import/Export Settings","404-to-301"),children:[(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)("p",{className:"components-base-control__help",children:(0,_.__)("Move plugin settings between sites — eg. from staging to production. The export contains every user-facing setting; install-specific state (database versions, migration flags) is excluded.","404-to-301")})}),(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsxs)("div",{className:"d404-import-export-actions",children:[(0,Y.jsx)(W.Button,{variant:"secondary",isBusy:t,disabled:t,onClick:async()=>{s(!0);try{((e,t)=>{const s=new Blob([JSON.stringify(e,null,2)],{type:"application/json"}),n=URL.createObjectURL(s),o=document.createElement("a");o.href=n,o.download=t,document.body.appendChild(o),o.click(),document.body.removeChild(o),URL.revokeObjectURL(n)})(await l()({path:"/404-to-301/v1/settings/export"}),`404-to-301-settings-${(window.location?.hostname||"site").replace(/[^a-z0-9.-]/gi,"")}-${(new Date).toISOString().slice(0,10)}.json`),i((0,_.__)("Settings exported.","404-to-301"))}catch(e){r(e?.message||(0,_.__)("Failed to export settings.","404-to-301"))}finally{s(!1)}},children:(0,_.__)("Download settings","404-to-301")}),(0,Y.jsx)(W.Button,{variant:"secondary",isBusy:t,disabled:t,onClick:()=>e.current?.click(),children:(0,_.__)("Import settings…","404-to-301")}),(0,Y.jsx)("input",{ref:e,type:"file",accept:"application/json,.json",onChange:async e=>{const t=e.target.files?.[0];if(e.target.value="",t){s(!0),o(null);try{const e=await t.text();let s;try{s=JSON.parse(e)}catch{throw new Error((0,_.__)("That file is not valid JSON.","404-to-301"))}const n={settings:s},r=await l()({path:"/404-to-301/v1/settings/import",method:"POST",data:n});o({count:Number(r?.imported||0),file:t.name}),i((0,_.__)("Settings imported.","404-to-301")),window.setTimeout(()=>window.location.reload(),600)}catch(e){r(e?.message||(0,_.__)("Failed to import settings.","404-to-301"))}finally{s(!1)}}},style:{display:"none"}})]})}),n&&(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.Notice,{status:"success",isDismissible:!1,children:(0,_.__)("Applied %1$d setting(s) from %2$s.","404-to-301").replace("%1$d",String(n.count)).replace("%2$s",n.file)})})]})},Ee=()=>{const[e,t]=(0,G.useState)(!1),[s,n]=(0,G.useState)(!1),[o,i]=(0,G.useState)(null),r=()=>t(!1);return(0,Y.jsxs)("div",{className:"d404-purge-wrap",children:[o&&(0,Y.jsx)("div",{className:`d404-purge-notice d404-purge-notice--${o.type}`,children:o.message}),(0,Y.jsx)("p",{className:"d404-purge-description",children:(0,_.__)("Permanently delete every entry in the 404 error log. This action cannot be undone. Custom redirects are not affected.","404-to-301")}),(0,Y.jsx)(W.Button,{variant:"primary",isDestructive:!0,onClick:()=>{i(null),t(!0)},children:(0,_.__)("Purge all logs","404-to-301")}),e&&(0,Y.jsxs)(W.Modal,{title:(0,_.__)("Purge all logs?","404-to-301"),onRequestClose:r,size:"small",children:[(0,Y.jsx)("p",{children:(0,_.__)("This will permanently delete every entry in the 404 error log. This action cannot be undone.","404-to-301")}),(0,Y.jsx)("p",{children:(0,_.__)("Custom redirects will not be affected.","404-to-301")}),(0,Y.jsxs)(W.Flex,{justify:"flex-end",gap:2,children:[(0,Y.jsx)(W.FlexItem,{children:(0,Y.jsx)(W.Button,{variant:"tertiary",onClick:r,children:(0,_.__)("Cancel","404-to-301")})}),(0,Y.jsx)(W.FlexItem,{children:(0,Y.jsx)(W.Button,{variant:"primary",isDestructive:!0,isBusy:s,disabled:s,onClick:async()=>{n(!0);try{await l()({path:"/404-to-301/v1/logs/purge",method:"DELETE"}),i({type:"success",message:(0,_.__)("All logs have been deleted.","404-to-301")})}catch{i({type:"error",message:(0,_.__)("Could not purge logs. Please try again.","404-to-301")})}finally{n(!1),t(!1)}},children:(0,_.__)("Yes, purge all logs","404-to-301")})})]})]})]})},ke={general:{label:(0,_.__)("General","404-to-301"),component:()=>{const{getSetting:e,setSetting:t}=J(),s=(0,X.applyFilters)("d404.settings.general.fields",null,{getSetting:e,setSetting:t}),n=(0,X.applyFilters)("d404.settings.general.cross_sell",null);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(W.PanelBody,{title:(0,_.__)("Behaviour","404-to-301"),children:[(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.SelectControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,_.__)("WordPress URL guessing","404-to-301"),help:(0,_.__)('How aggressively to block WordPress’ auto-correction of unknown URLs. "Light" stops the closest-post guess; "Strict" also bypasses trailing-slash, case, and attachment fallback redirects.',"404-to-301"),value:(()=>{const t=e("disable_guessing","light");return!0===t?"strict":!1===t?"off":["off","light","strict"].includes(t)?t:"light"})(),options:[{value:"off",label:(0,_.__)("Off — let WordPress guess (default WP behaviour)","404-to-301")},{value:"light",label:(0,_.__)("Light — block closest-post guessing only","404-to-301")},{value:"strict",label:(0,_.__)("Strict — bypass redirect_canonical() entirely","404-to-301")}],onChange:e=>t("disable_guessing",e)})}),(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,_.__)("Monitor post slug changes","404-to-301"),help:(0,_.__)("Automatically create a redirect from the old URL to the new one when a post or page slug is renamed.","404-to-301"),checked:!!e("monitor_post_slug",!1),onChange:e=>t("monitor_post_slug",e)})}),(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,_.__)("Mask IP addresses","404-to-301"),help:(0,_.__)("Drop visitor IPs before they hit the database. Useful for GDPR.","404-to-301"),checked:!!e("mask_ip",!1),onChange:e=>t("mask_ip",e)})}),(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,_.__)("Track admin 404s","404-to-301"),help:(0,_.__)("Also process 404 requests that occur on the WordPress admin side. Off by default — most sites only care about front-end 404s.","404-to-301"),checked:!!e("track_admin_404",!1),onChange:e=>t("track_admin_404",e)})})]}),s,n]})}},redirects:{label:(0,_.__)("Redirects","404-to-301"),component:()=>{const{getSetting:e,setSetting:t}=J(),s=!!e("redirect_enabled",!0),n=e("redirect_target","link"),o=(0,X.applyFilters)("d404.settings.redirects.fields",null,{getSetting:e,setSetting:t}),i=(0,X.applyFilters)("d404.settings.redirects.cross_sell",null);return(0,Y.jsxs)(W.PanelBody,{title:(0,_.__)("404 Redirects","404-to-301"),children:[(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,_.__)("Enable redirect","404-to-301"),help:(0,_.__)("When on, 404 URLs without a specific custom redirect fall back to the destination configured here.","404-to-301"),checked:s,onChange:e=>t("redirect_enabled",e)})}),!s&&(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.Notice,{status:"info",isDismissible:!1,children:(0,_.__)("The redirect is off. Per-URL redirects from the Redirects page still fire.","404-to-301")})}),(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.SelectControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,_.__)("Redirect type","404-to-301"),help:(0,_.__)("HTTP status code used when this fallback redirect fires.","404-to-301"),value:e("redirect_type","301"),options:xe,onChange:e=>t("redirect_type",e)})}),(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.SelectControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,_.__)("Redirect to","404-to-301"),help:(0,_.__)("Where 404 requests land when no custom redirect matches.","404-to-301"),value:n,options:[{label:(0,_.__)("A custom URL","404-to-301"),value:"link"},{label:(0,_.__)("An existing page","404-to-301"),value:"page"},{label:(0,_.__)("No redirect","404-to-301"),value:"none"}],onChange:e=>t("redirect_target",e)})}),"link"===n&&(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.__experimentalInputControl,{__next40pxDefaultSize:!0,type:"url",label:(0,_.__)("Destination URL","404-to-301"),help:(0,_.__)("Absolute URL (including https://).","404-to-301"),prefix:(0,Y.jsx)(W.__experimentalInputControlPrefixWrapper,{children:(0,Y.jsx)(K,{icon:ee,size:20})}),value:e("redirect_link",""),onChange:e=>t("redirect_link",e??"")})}),"page"===n&&(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(pe,{label:(0,_.__)("Destination page","404-to-301"),help:(0,_.__)("Search and pick the page that should serve as the 404 destination.","404-to-301"),value:e("redirect_page",0),onChange:e=>t("redirect_page",e)})}),o,i]})}},logs:{label:(0,_.__)("Logs","404-to-301"),component:()=>{const{getSetting:e,setSetting:t}=J(),s=(0,X.applyFilters)("d404.settings.logs.fields",null,{getSetting:e,setSetting:t}),n=(0,X.applyFilters)("d404.settings.logs.after",null,{getSetting:e,setSetting:t}),o=(0,X.applyFilters)("d404.settings.logs.cross_sell",(0,Y.jsx)(fe,{}));return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(W.PanelBody,{title:(0,_.__)("404 Logs","404-to-301"),children:[(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,_.__)("Log 404 errors","404-to-301"),help:(0,_.__)("Save every 404 hit to the database so you can review and fix them from the Logs page.","404-to-301"),checked:!!e("logs_enabled",!0),onChange:e=>t("logs_enabled",e)})}),(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,_.__)("Skip search engine bots","404-to-301"),help:(0,_.__)("Skip 404s from obvious crawlers (bot, spider, slurp, …) to keep the log table small.","404-to-301"),checked:!!e("logs_skip_bots",!0),onChange:e=>t("logs_skip_bots",e)})}),(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,_.__)("Skip duplicate URLs","404-to-301"),help:(0,_.__)("When on, repeat 404s on the same URL do not bump the hit counter. Useful when you only want the first occurrence.","404-to-301"),checked:!!e("logs_skip_duplicates",!1),onChange:e=>t("logs_skip_duplicates",e)})}),s,o]}),n]})}},notifications:{label:(0,_.__)("Notifications","404-to-301"),component:()=>{const{getSetting:e,setSetting:t}=J(),s=!!e("email_enabled",!1),n=(0,X.applyFilters)("d404.settings.notifications.fields",null,{getSetting:e,setSetting:t}),o=(0,X.applyFilters)("d404.settings.notifications.after",null,{getSetting:e,setSetting:t}),i=(0,X.applyFilters)("d404.settings.notifications.cross_sell",be),r=(0,Y.jsx)(je,{addons:i});return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(W.PanelBody,{title:(0,_.__)("Email Notifications","404-to-301"),children:[(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.ToggleControl,{__nextHasNoMarginBottom:!0,label:(0,_.__)("Notify by email on 404 errors","404-to-301"),help:(0,_.__)("Send an email when a 404 fires. Honours the threshold below so the inbox does not get flooded on busy sites.","404-to-301"),checked:s,onChange:e=>t("email_enabled",e)})}),!s&&(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.Notice,{status:"info",isDismissible:!1,children:(0,_.__)("Notifications are off — the threshold and recipient below are ignored until you enable them.","404-to-301")})}),(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.BaseControl,{__nextHasNoMarginBottom:!0,id:"d404-email-recipients",label:(0,_.__)("Recipient emails","404-to-301"),help:(0,_.__)("Press Enter or comma to add an address. Add as many recipients as you need.","404-to-301"),children:(0,Y.jsx)(W.FormTokenField,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,__experimentalExpandOnFocus:!0,__experimentalValidateInput:e=>ve.test(String(e).trim()),label:null,value:Se(e("email_recipient",[])),onChange:e=>t("email_recipient",Se(e)),tokenizeOnSpace:!0,tokenizeOnBlur:!0,placeholder:(0,_.__)("name@example.com","404-to-301")})})}),(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(W.TextControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"number",min:1,label:(0,_.__)("Hits threshold","404-to-301"),help:(0,_.__)("Only send an email once a URL has racked up at least this many 404 hits.","404-to-301"),value:e("email_threshold",1),onChange:e=>t("email_threshold",Math.max(1,parseInt(e,10)||1))})}),n,r]}),o]})}},tools:{label:(0,_.__)("Tools","404-to-301"),component:()=>{const{getSetting:e,setSetting:t}=J(),s=(0,X.applyFilters)("d404.settings.tools.fields",null,{getSetting:e,setSetting:t}),n=(0,X.applyFilters)("d404.settings.tools.cross_sell",null);return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(W.PanelBody,{title:(0,_.__)("Exclude Paths","404-to-301"),children:(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsxs)("div",{className:"d404-repeater-field",children:[(0,Y.jsx)("div",{className:"d404-repeater-field__label",children:(0,_.__)("Paths to ignore","404-to-301")}),(0,Y.jsx)(Pe,{value:e("exclude_paths",[]),onChange:e=>t("exclude_paths",e),placeholder:(0,_.__)("e.g. /wp-json/ or /feed/","404-to-301")}),(0,Y.jsx)("p",{className:"components-base-control__help",children:(0,_.__)("Any 404 whose URL contains one of these substrings is skipped — no log, no redirect, no email.","404-to-301")})]})})}),(0,Y.jsx)(Ce,{}),s,n,(0,Y.jsx)(W.PanelBody,{title:(0,_.__)("Danger Zone","404-to-301"),className:"d404-panel-danger",children:(0,Y.jsx)(W.PanelRow,{children:(0,Y.jsx)(Ee,{})})})]})}}},Te=()=>{const{hasLoaded:e}=J(),t=Object.keys(ke)[0],[s,n]=(0,G.useState)(t),o=Object.fromEntries(Object.entries(ke).map(([e,t])=>[e,t.label])),i=(ke[s]||ke[t]).component;return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(ce,{title:(0,_.__)("404 to 301 - Settings","404-to-301"),children:(0,Y.jsx)(de,{current:s,navs:o,onChange:n})}),(0,Y.jsx)(le,{children:e?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(i,{}),(0,Y.jsx)(oe,{})]}):(0,Y.jsx)("div",{className:"d404-page-loader",children:(0,Y.jsx)(W.Spinner,{})})}),(0,Y.jsx)(ie,{})]})};q()(()=>{const e=document.getElementById("404-to-301-settings");e&&(0,G.createRoot)(e).render((0,Y.jsx)(ne,{children:(0,Y.jsx)(Te,{})}))})})();