"use strict";(self.webpackChunkPlesk=self.webpackChunkPlesk||[]).push([["app/backup/restore"],{2610:(e,t,o)=>{o.r(t),o.d(t,{default:()=>c});var s=o(89),n=o(2606);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 r=document.getElementById("contentSelectSection-restoreType-full"),a=!r||r.checked,l=document.getElementById("contentSelectSection-restoreType-granular"),d=l&&l.checked,i=document.getElementById("restoreComponents");if(i&&(i.style.display=a?"":"none",a)){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 r=d&&e.selected;if(t){const a=document.getElementById(`contentSelectSection-subscriptionLookup_${e.value}`),l=(0,s.getComponent)(t.id);if(a){a.closest(".form-row").style.display=r?"":"none";const e=(0,s.getComponent)(a.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),r=JSON.parse(e.getValue()),a={"subscription-name":r.name,"subscription-guid":r.guid};n instanceof s.DoubleListSelector&&n.reload(a),n instanceof s.DynamicSubForm&&n.setDataUrlParams(a),c()})),r&&(n=n||e.isEmpty(),r=r&&!e.isEmpty())}l instanceof s.DoubleListSelector&&(t.closest(".form-row").style.display=r?"":"none",l.onChange=c,r?n=n||l.isEmpty():l.reset()),l instanceof s.DynamicSubForm&&(t.style.display=r?"":"none",l.onChange=c,r?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 r=document.getElementById("contentSelectSection-restoreType-granularNotSupported");r&&(r.disabled=!0);const a=document.getElementById("contentSelectSection-restoreType-fullNotSupportedInResellerPowerUser");a&&(a.disabled=!0),Jsw.onReady((function(){c(!0)})),(0,n.default)(o)})(e)},2606:(e,t,o)=>{o.r(t),o.d(t,{default:()=>a});var s=o(89),n=o(531),c=o(393),r=o(1301);const a=({urls:e,taskStatuses:t})=>{const o=s.Locale.getSection("controllers.backup.restore-status"),a=({id:t,status:c,message:r,downloadLog:a,viewLog:l,close:d,stop:i,additionalContent:u})=>{const m=[r];a&&m.push("&nbsp;",a),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);const o=document.querySelector(`[data-row-id="task:${t}"]`);o?.parentNode.removeChild(o)}}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):a(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;a(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),a(e))):(t.parentNode.removeChild(t),a(e),(0,s.getComponent)("backup-list").reload(),c.default?.cache&&(0,r.evictUserStatisticsCache)(c.default.cache)))})).catch((()=>setTimeout(l,1e4)))};setTimeout(l,1e4)}))}},1301:(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?3a26d9dc22f1a94beac2