"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/backup/restore"],{2402:(e,t,o)=>{o.r(t),o.d(t,{default:()=>c});var s=o(89),n=o(2398);const c=e=>(({type:e,disableRestore:t,...o})=>{const c=o=>{let n=!1;if("local"===e){const e=document.getElementById("restoreModifiedDump-restoreModifiedDumpCheckbox");n=n||e&&!e.checked}const a=document.getElementById("contentSelectSection-restoreType-full"),r=!a||a.checked,l=document.getElementById("contentSelectSection-restoreType-granular"),d=l&&l.checked,i=document.getElementById("restoreComponents");if(i&&(i.style.display=r?"":"none",r)){let e=!1;i.querySelectorAll("input").forEach((t=>{t.checked&&(e=!0)})),n=n||!e}const u=document.getElementById("contentSelectSection-restoreObjectType");u&&(u.closest(".form-row").style.display=d?"":"none",u.querySelectorAll("option").forEach((e=>{const t=document.getElementById(`contentSelectSection-restoreObjects_${e.value}`);let a=d&&e.selected;if(t){const r=document.getElementById(`contentSelectSection-subscriptionLookup_${e.value}`),l=(0,s.getComponent)(t.id);if(r){r.closest(".form-row").style.display=a?"":"none";const e=(0,s.getComponent)(r.id);!0===o&&e.addEventObserver("dataavailable",(()=>{if(e.isEmpty())return void c();const t=document.getElementById("contentSelectSection-restoreObjectType").value,o=document.getElementById(`contentSelectSection-restoreObjects_${t}`),n=(0,s.getComponent)(o.id),a=JSON.parse(e.getValue()),r={"subscription-name":a.name,"subscription-guid":a.guid};n instanceof s.DoubleListSelector&&n.reload(r),n instanceof s.DynamicSubForm&&n.setDataUrlParams(r),c()})),a&&(n=n||e.isEmpty(),a=a&&!e.isEmpty())}l instanceof s.DoubleListSelector&&(t.closest(".form-row").style.display=a?"":"none",l.onChange=c,a?n=n||l.isEmpty():l.reset()),l instanceof s.DynamicSubForm&&(t.style.display=a?"":"none",l.onChange=c,a?n=n||l.isEmpty():l.reset())}})));const m=document.getElementById("restorationOptions-contentRestoreType-form-row");if(m){m.style.display=d?"":"none";const e=document.getElementById("restorationOptions");1===e.querySelectorAll(".form-row").length&&(e.style.display=d?"":"none")}const p=(0,s.getComponent)("btn-send");p&&(t||n?p.disable():p.enable())};[document.getElementById("restoreModifiedDump-restoreModifiedDumpCheckbox"),document.getElementById("contentSelectSection-restoreType-full"),document.getElementById("contentSelectSection-restoreType-granular"),document.getElementById("contentSelectSection-restoreObjectType")].concat(Array.prototype.slice.call(document.querySelectorAll("#restoreComponents input"))).forEach((e=>{e&&("SELECT"===e.tagName?e.addEventListener("change",c):e.addEventListener("click",c))}));const a=document.getElementById("contentSelectSection-restoreType-granularNotSupported");a&&(a.disabled=!0);const r=document.getElementById("contentSelectSection-restoreType-fullNotSupportedInResellerPowerUser");r&&(r.disabled=!0),Jsw.onReady((function(){c(!0)})),(0,n.default)(o)})(e)},2398:(e,t,o)=>{o.r(t),o.d(t,{default:()=>r});var s=o(89),n=o(530),c=o(393),a=o(1179);const r=({urls:e,taskStatuses:t})=>{const o=s.Locale.getSection("controllers.backup.restore-status"),r=({id:t,status:c,message:a,downloadLog:r,viewLog:l,close:d,stop:i,additionalContent:u})=>{const m=[a];r&&m.push("&nbsp;",r),l&&m.push("&nbsp;",l),d&&m.push("&nbsp;",(0,s.createElement)("a",{onclick:()=>(async t=>{try{const{status:o}=await s.api.post((0,s.addUrlParams)(e.closeStatus,{taskId:t}));if("success"===o){const e=document.getElementById(`task-status-${t}`);e?.parentNode.removeChild(e)}}catch({message:e}){(0,n.addToast)({intent:"danger",message:e})}})(t)},o.lmsg("closeMessage"))),i&&m.push("&nbsp;",(0,s.createElement)("a",{onclick:()=>{return o=t,void s.api.post((0,s.addUrlParams)(e.stopTask,{taskId:o}));var o}},o.lmsg("stop"))),u&&m.push(u),(0,s.addStatusMessage)(c,m,{id:`task-status-${t}`})},l=[];t.forEach((e=>{"backup"===e.type&&"progress"===e.status||("progress"===e.status?l.push(e):r(e))})),document.querySelectorAll(".msg-progress").forEach((e=>{l.some((t=>e.id===`task-status-${t.id}`))||e.parentNode.removeChild(e)})),l.forEach((t=>{const{id:o}=t,n=`task-status-${o}`;if(document.getElementById(n))return;r(t);const l=()=>{s.api.get((0,s.addUrlParams)(e.restoreStatus,{taskId:o})).then((e=>{const t=document.getElementById(n);t&&("progress"===e.status?(setTimeout(l,1e4),e.stop||(t.parentNode.removeChild(t),r(e))):(t.parentNode.removeChild(t),r(e),(0,s.getComponent)("backup-list").reload(),c.default?.cache&&(0,a.evictUserStatisticsCache)(c.default.cache)))})).catch((()=>setTimeout(l,1e4)))};setTimeout(l,1e4)}))}},1179:(e,t,o)=>{o.r(t),o.d(t,{evictUserStatisticsCache:()=>s});const s=e=>{Object.values(e.extract()).filter((({__typename:e})=>"User"===e)).map((t=>e.evict({id:e.identify(t),fieldName:"statistics"})))}}}]);
//# sourceMappingURL=restore.js.map?b9ac5e8db595ae86c044