import{_ as q}from"./index.vue_vue_type_script_setup_true_lang-D8O2mMsP.js?v=1773287522785";import{Y as D,Z as L,_ as V}from"./index-oaByoBTF.js?v=1773287522785";import{n as w,c as A}from"./index-BTglIPU2.js?v=1773287522785";import{u as O}from"./useLoading-CZ2gSAW7.js?v=1773287522785";import{_ as R}from"./task-view.vue_vue_type_script_setup_true_lang-DbXy1NR8.js?v=1773287522785";import{k as Z,r as p,e as E,c as I,w as k,$ as c,a8 as b,a9 as o,a0 as l,S as a,_ as f,Z as J,F as W,P as Y,ak as j}from"./vue-core-DJjvd5ZC.js?v=1773287522785";import{a9 as z,a1 as G,a6 as H,aW as K,k as M,al as Q,ad as X}from"./naive-ui--dJnpVcV.js?v=1773287522785";import"./prismjs-BZPoR7_J.js?v=1773287522785";import"./index-COOnaZWq.js?v=1773287522785";const ee={class:"data-box"},te=Z({__name:"index",props:{done:{type:Function}},setup(x,{expose:C}){const S=x,d=p(null),r=p([]),_=p([]),e=E({site_id:null,target_id:null,all:!1,source_site:["file"],db_table:[],create_recovery_point:!1}),N=I(()=>e.db_table.length>0&&e.db_table.length<_.value.length),B={site_id:{required:!0,type:"number",trigger:"change",message:"Source site cannot be empty"},target_id:{required:!0,type:"number",trigger:"change",message:"Target site cannot be empty"},source_site:{required:!0,type:"array",trigger:"change",message:"Please select type"},db_table:{required:!0,type:"array",trigger:"change",message:"Please select database table"}};k(()=>e.db_table,s=>{s.length===_.value.length?e.all=!0:s.length||(e.all=!1)}),k(()=>e.all,s=>{var t;s?(e.db_table=_.value,(t=d.value)==null||t.validate()):e.db_table=[]});const P=async()=>{var s;await((s=d.value)==null?void 0:s.validate()),await D({cp_files:!!e.source_site.includes("file"),cp_data_tables:!!e.source_site.includes("db"),is_backup:e.create_recovery_point,data_tables:JSON.stringify(e.source_site.includes("db")?e.db_table:[]),source_id:Number(e.site_id),target_id:Number(e.target_id)}),S.done()},m=async()=>{const{message:s}=await L({set_id:Number(e.site_id)});w(s)&&(_.value=s,e.db_table=[])},{loading:U,setLoading:g}=O();return(async()=>{try{g(!0);const{message:s}=await V();w(s)&&(r.value=s.map(t=>({label:t.name,value:t.id})),r.value.length&&(e.site_id=r.value[0].value,m()))}finally{g(!1)}})(),C({onConfirm:P}),(s,t)=>{const v=H,i=G,u=Q,y=M,h=K,F=X,T=q,$=z;return c(),b(R,{title:"Copy Progress",params:"wp_copy"},{default:o(()=>[l($,{show:a(U),class:"p-16px"},{default:o(()=>[l(T,{ref_key:"formRef",ref:d,model:a(e),rules:B},{default:o(()=>[l(i,{label:"Source Site",path:"site_id"},{default:o(()=>[l(v,{class:"w-300px",value:a(e).site_id,"onUpdate:value":[t[0]||(t[0]=n=>a(e).site_id=n),m],options:a(r),filterable:""},null,8,["value","options"])]),_:1}),l(i,{label:"Target site",path:"target_id"},{default:o(()=>[l(v,{class:"w-300px",value:a(e).target_id,"onUpdate:value":t[1]||(t[1]=n=>a(e).target_id=n),options:a(r),filterable:"",placeholder:"Please select target site"},null,8,["value","options"])]),_:1}),l(i,{label:"Copy Type",path:"source_site","show-feedback":!a(e).source_site.length},{default:o(()=>[l(h,{value:a(e).source_site,"onUpdate:value":t[2]||(t[2]=n=>a(e).source_site=n)},{default:o(()=>[l(y,null,{default:o(()=>[l(u,{value:"file",label:"File"}),l(u,{value:"db",label:"Database"})]),_:1})]),_:1},8,["value"])]),_:1},8,["show-feedback"]),l(i,{label:" "},{default:o(()=>[l(F,{"show-icon":!1},{default:o(()=>t[6]||(t[6]=[f("div",null,"Files: Copy the newly added theme and plug-in files from the source wp website to the target wp website. ",-1),f("div",null,"Database: Select the data table in the source wp website and copy it to the target wp website. Note: the existing table will be overwritten!",-1)])),_:1,__:[6]})]),_:1}),a(e).source_site.includes("db")?(c(),b(i,{key:0,label:" ",path:"db_table"},{default:o(()=>[f("div",ee,[l(u,{checked:a(e).all,"onUpdate:checked":t[3]||(t[3]=n=>a(e).all=n),label:s.$t("Public.SelectAll"),indeterminate:a(N)},null,8,["checked","label","indeterminate"]),l(h,{value:a(e).db_table,"onUpdate:value":t[4]||(t[4]=n=>a(e).db_table=n)},{default:o(()=>[l(y,{class:"flex-col!"},{default:o(()=>[(c(!0),J(W,null,Y(a(_),n=>(c(),b(u,{value:n,label:n,key:n},null,8,["value","label"]))),128))]),_:1})]),_:1},8,["value"])])]),_:1})):j("",!0),l(i,{label:"Backup"},{default:o(()=>[l(u,{checked:a(e).create_recovery_point,"onUpdate:checked":t[5]||(t[5]=n=>a(e).create_recovery_point=n),label:"Create a backup of your target website"},null,8,["checked"])]),_:1})]),_:1},8,["model"])]),_:1},8,["show"])]),_:1})}}}),de=A(te,[["__scopeId","data-v-8eccfa2c"]]);export{de as default};
