!function(o){"use strict";function t(t,r,n,s={}){const e=window.dropPrint?.elements;if(!(e?.overlay?.length&&e.overlayIconContainer?.length&&e.overlayTitle?.length&&e.overlayMessage?.length&&e.overlayActions?.length))return void("is-error"===t&&"string"==typeof n&&n&&alert(`DropPrint Error: ${r}\n${n}`));const{showActions:i=!0,buttonsToShow:a=[],iconClass:l="",customButtons:d=[]}=s;e.overlay.removeClass("is-loading is-error is-prompt is-blocked is-visible"),t?e.overlay.addClass(t).addClass("is-visible").css("display","flex"):e.overlay.css("display","none");const c=e.overlaySpinner,y=e.overlayDashicon;"is-loading"===t?(c?.addClass("is-active").show(),y?.hide()):(c?.removeClass("is-active").hide(),l&&y?.length?y.attr("class",`dashicons ${l}`).show():y?.hide()),e.overlayTitle.text(r||""),e.overlayMessage.html(n||"");const h={reset:e.dropPrintOverlayResetBtn,"confirm-reset":e.dropPrintOverlayConfirmResetBtn,download:e.dropPrintOverlayDownloadBtn,docs:e.dropPrintOverlayDocsBtn,save:e.dropPrintOverlaySaveBtn,save_now:e.dropPrintOverlaySaveNowBtn,refresh:e.dropPrintOverlayRefreshBtn,ok:e.dropPrintOverlayOkBtn};for(const o in h)h[o]&&h[o].length&&h[o].hide();e.overlayActions.find(".dp-custom-button").remove();let v=!1;Array.isArray(a)&&a.length>0&&a.forEach(o=>{h[o]&&h[o].length&&(h[o].show(),v=!0)}),Array.isArray(d)&&d.length>0&&d.forEach(t=>{if(t&&t.text&&"function"==typeof t.action){const r=o("<button></button>").attr("id",t.id||"").addClass("button dp-custom-button").addClass(t.class||"button-secondary").text(t.text).on("click.dpCustomAction",function(o){o.preventDefault(),t.action.call(this,o)});e.overlayActions.append(r),v=!0}}),e.overlayActions.toggle(i&&v)}window.dropPrint=window.dropPrint||{},window.dropPrint.elements=window.dropPrint.elements||{},window.dropPrint.dropPrintUpdateOverlay=t,window.dropPrint.dropPrintShowErrorOverlay=function(o,r,n={}){let s=["ok","reset","docs"];o&&o.toLowerCase().includes("file too large")&&(s=["reset","docs"]);const e=Array.isArray(n.buttonsToShow)?n.buttonsToShow:s;t("is-error",o,r,{showActions:!0,iconClass:n.iconClass||"dashicons-warning",...n,buttonsToShow:e})},window.dropPrint.dropPrintShowPromptOverlay=function(o,r,n={}){const s=Array.isArray(n.buttonsToShow)?n.buttonsToShow:["ok","reset","docs"];t("is-prompt",o,r,{showActions:!0,iconClass:n.iconClass||"dashicons-info-outline",...n,buttonsToShow:s})}}(jQuery);