"use strict";{const e=self,t=e,o=e.document;(self.webpackChunkStylus=self.webpackChunkStylus||[]).push([["js_dlg_message-box_js"],{7239:(e,s,n)=>{n.r(s);var l=n(7986),c=n(3831),r=n(7501),i=n(6940);const messageBox={element:null,listeners:null,_blockScroll:null,_originalFocus:null,_resolve:null},a=messageBox;messageBox.close=async isAnimated=>{t.off("keydown",messageBox.listeners.key,!0),t.off("scroll",messageBox.listeners.scroll),t.off("mouseup",messageBox.listeners.mouseUp),t.off("mousemove",messageBox.listeners.mouseMove),isAnimated&&await c.animateElement(messageBox.element,"fadeout"),messageBox.element.remove(),messageBox.element=null,messageBox._resolve=null},messageBox.show=({title,contents,className="",buttons=[],onshow,blockScroll})=>{return messageBox.listeners||function(){let clickX,clickY,listening=!1,offsetX=0,offsetY=0;messageBox.listeners={closeIcon(){resolveWith({button:-1})},button(){resolveWith({button:this.buttonIndex})},key(event){const{key,shiftKey,ctrlKey,altKey,metaKey,target}=event;if(!(shiftKey&&"Tab"!==key||ctrlKey||altKey||metaKey)){switch(key){case"Enter":if(c.closestFocusable(target))return;break;case"Escape":event.preventDefault(),event.stopPropagation();break;case"Tab":return c.moveFocus(messageBox.element,shiftKey?-1:1),void event.preventDefault();default:return}resolveWith("Enter"===key?{enter:!0}:{esc:!0})}},scroll(){scrollTo(messageBox._blockScroll.x,messageBox._blockScroll.y)},mouseDown(event){0===event.button&&(listening||(t.on("mouseup",messageBox.listeners.mouseUp,{passive:!0}),t.on("mousemove",messageBox.listeners.mouseMove,{passive:!0}),listening=!0),clickX=event.clientX-offsetX,clickY=event.clientY-offsetY)},mouseUp(event){0===event.button&&(t.off("mouseup",messageBox.listeners.mouseUp),t.off("mousemove",messageBox.listeners.mouseMove),listening=!1)},mouseMove(event){offsetX=i.clamp(event.clientX,30,innerWidth-30)-clickX,offsetY=i.clamp(event.clientY,30,innerHeight-30)-clickY,messageBox.element.firstChild.style.transform=`translate(${offsetX}px,${offsetY}px)`}}}(),function(){messageBox.element&&messageBox.close();const e="message-box";messageBox.element=l.$create("div",{id:e,className},[l.$create("div",[l.$create(`#${e}-title`,{onmousedown:messageBox.listeners.mouseDown},title),l.$create(`#${e}-close-icon`,{onclick:messageBox.listeners.closeIcon},l.$create("i.i-close")),l.$create(`#${e}-contents`,r.tHTML(contents)),l.$create(`#${e}-buttons`,buttons.filter(Boolean).map((btn,buttonIndex)=>("button"!==btn.localName&&(btn=l.$create("button",btn)),btn.buttonIndex=buttonIndex,btn.onclick??=messageBox.listeners.button,btn)))])])}(),function(){messageBox._blockScroll=blockScroll&&{x:scrollX,y:scrollY},blockScroll&&t.on("scroll",messageBox.listeners.scroll,{passive:!1});t.on("keydown",messageBox.listeners.key,!0)}(),o.body.appendChild(messageBox.element),messageBox._originalFocus=o.activeElement,"_blank"===(c.moveFocus(messageBox.element,0)||{}).target&&/config-dialog/.test(className)&&c.moveFocus(messageBox.element,1),o.activeElement===messageBox._originalFocus&&o.body.focus(),"function"==typeof onshow&&onshow(messageBox.element),o.getElementById("message-box-title").textContent||(o.getElementById("message-box-title").hidden=!0,o.getElementById("message-box-close-icon").hidden=!0),new Promise(resolve=>{messageBox._resolve=resolve});function resolveWith(value){setTimeout(messageBox._resolve,0,value),messageBox.element.contains(o.activeElement)&&messageBox._originalFocus.focus(),messageBox.close(!0)}},messageBox.alert=(contents,className,title)=>messageBox.show({title,contents,className:`center ${className||""}`,buttons:[i.t("confirmClose")]}),messageBox.confirm=async(contents,className,title)=>{const res=await messageBox.show({title,contents,className:`center ${className||""}`,buttons:[i.t("confirmYes"),i.t("confirmNo")]});return 0===res.button||res.enter},s.default=a}}])}