"use strict";(globalThis.webpackChunkwp_seopress_pro=globalThis.webpackChunkwp_seopress_pro||[]).push([[511],{511:(e,s,t)=>{t.r(s),t.d(s,{default:()=>c});var a=t(609),r=t(87),o=t(723),n=t(427);const{FieldRow:l}=window.seopressComponents,i=[{label:"Block directory browsing",tag:"Options -Indexes"},{label:"Protect wp-config.php file",tag:"<files wp-config.php>\norder allow,deny\ndeny from all\n</files>"},{label:"301 redirection",tag:"redirect 301 /your-old-url/ https://www.example.com/your-new-url"}],c=()=>{const e=window.SEOPRESS_PRO_DATA||{},s=e.HTACCESS_STATUS||"ok",[t,c]=(0,r.useState)(e.HTACCESS_FILE_CONTENT||""),[p,u]=(0,r.useState)(!1),[m,d]=(0,r.useState)(null),_=(0,r.useRef)(null);return(0,a.createElement)("div",{className:"seopress-tab-content"},(0,a.createElement)("p",null,(0,o.__)("View and edit your .htaccess file directly from WordPress to add custom redirects, security rules, or performance optimizations.","wp-seopress-pro")),(0,a.createElement)(n.Notice,{isDismissible:!1,status:"warning"},(0,a.createElement)("span",{dangerouslySetInnerHTML:{__html:(0,o.__)("<strong>Important:</strong> We recommend backing up your .htaccess file before making any changes.","wp-seopress-pro")}})),m&&(0,a.createElement)(n.Notice,{isDismissible:!1,status:"success"===m.status?"info":"error"},m.message),"ok"!==s?(0,a.createElement)(l,{label:(0,o.__)("Edit your htaccess file","wp-seopress-pro")},"blocked"===s?(0,a.createElement)(n.Notice,{isDismissible:!1,status:"error"},(0,o.__)("Access not allowed by the PHP define.","wp-seopress-pro")):"multisite"===s?(0,a.createElement)(n.Notice,{isDismissible:!1},(0,o.__)("Multisite is enabled, go to network SEO settings to manage your .htaccess file.","wp-seopress-pro")):"nginx"===s?(0,a.createElement)(n.Notice,{isDismissible:!1},(0,o.__)("Your server is running Nginx, which does not use .htaccess files. This feature is only available for Apache servers.","wp-seopress-pro")):"not_writable"===s?(0,a.createElement)(n.Notice,{isDismissible:!1,status:"error"},(0,o.__)("You don't have an htaccess file on your server or it's not writable.","wp-seopress-pro")):null):(0,a.createElement)(a.Fragment,null,(0,a.createElement)(l,{label:(0,o.__)("Edit your htaccess file","wp-seopress-pro")},(0,a.createElement)("textarea",{ref:_,className:"large-text code",rows:25,value:t,onChange:e=>c(e.target.value),placeholder:(0,o.__)("This is your htaccess file!","wp-seopress-pro")})),(0,a.createElement)("div",{className:"wrap-tags",style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"16px"}},i.map((e=>(0,a.createElement)(n.Button,{key:e.label,variant:"secondary",className:"seopress-btn-outline-neutral",onClick:()=>(e=>{const s=_.current;if(!s)return void c((s=>s+"\n"+e));const a=s.selectionStart,r=s.selectionEnd,o=t.substring(0,a)+"\n"+e+t.substring(r);c(o),setTimeout((()=>{s.focus(),s.selectionStart=s.selectionEnd=a+e.length+1}),0)})(e.tag)},(0,a.createElement)("span",{className:"dashicons dashicons-plus-alt2"}),(0,o.__)(e.label,"wp-seopress-pro"))))),(0,a.createElement)(n.Button,{variant:"secondary",onClick:async()=>{u(!0),d(null);try{const s=new FormData;s.append("action","seopress_save_htaccess"),s.append("_ajax_nonce",e.NONCES?.htaccess||""),s.append("htaccess_content",t);const a=await fetch(e.AJAX_URL,{method:"POST",body:s}),r=await a.json();if(r.success&&r.data){const e="is-error"===r.data.class;d({status:e?"error":"success",message:r.data.msg})}else d({status:"error",message:(0,o.__)("Failed to save file.","wp-seopress-pro")})}catch(e){d({status:"error",message:e.message})}finally{u(!1)}},disabled:p},p?(0,o.__)("Saving...","wp-seopress-pro"):(0,o.__)("Saves htaccess changes","wp-seopress-pro"))))}}}]);