"use strict";const e=require("../../../../common/vendor.js"),t=require("./types.js"),o=require("./index.js"),n=require("../common/util.js"),s=require("../composables/useTranslate.js");Math||(r+a+i)();const i=()=>"../wd-popup/wd-popup.js",a=()=>"../wd-button/wd-button.js",r=()=>"../wd-input/wd-input.js",u=e.defineComponent({name:"wd-message-box",options:{virtualHost:!0,addGlobalClass:!0,styleIsolation:"shared"},props:t.messageBoxProps,setup(t){const i=t,{translate:a}=s.useTranslate("message-box"),r=e.computed((()=>`wd-message-box__container ${i.customClass}`)),u=e.computed((()=>`wd-message-box__body ${p.title?"":"is-no-title"} ${"prompt"===p.type?"is-prompt":""}`)),l=o.getMessageDefaultOptionKey(i.selector),c=e.inject(l,e.ref(o.defaultOptions)),p=e.reactive({msg:"",show:!1,title:"",showCancelButton:!1,closeOnClickModal:!0,confirmButtonText:"",cancelButtonText:"",type:"alert",inputType:"text",inputValue:"",inputPlaceholder:"",inputError:"",showErr:!1,zIndex:99,lazyRender:!0}),d=e.computed((()=>{const e=n.deepAssign({block:!0},n.isDef(p.confirmButtonProps)?n.omitBy(p.confirmButtonProps,n.isUndefined):{});return e.customClass=`${e.customClass||""} wd-message-box__actions-btn`,e})),m=e.computed((()=>{const e=n.deepAssign({block:!0,type:"info"},n.isDef(p.cancelButtonProps)?n.omitBy(p.cancelButtonProps,n.isUndefined):{});return e.customClass=`${e.customClass||""} wd-message-box__actions-btn`,e}));function f(e){if(("modal"!==e||p.closeOnClickModal)&&("prompt"!==p.type||"confirm"!==e||function(){if(p.inputPattern&&!p.inputPattern.test(String(p.inputValue)))return p.showErr=!0,!1;if("function"==typeof p.inputValidate){if(!p.inputValidate(p.inputValue))return p.showErr=!0,!1}return p.showErr=!1,!0}()))switch(e){case"confirm":p.beforeConfirm?p.beforeConfirm({resolve:t=>{t&&w({action:e,value:p.inputValue})}}):w({action:e,value:p.inputValue});break;case"cancel":h({action:e});break;default:h({action:"modal"})}}function w(e){p.show=!1,n.isFunction(p.success)&&p.success(e)}function h(e){p.show=!1,n.isFunction(p.fail)&&p.fail(e)}function x({value:e}){""!==e?p.inputValue=e:p.showErr=!1}return e.watch((()=>c.value),(e=>{var t;(t=e)&&(p.title=n.isDef(t.title)?t.title:"",p.showCancelButton=!!n.isDef(t.showCancelButton)&&t.showCancelButton,p.show=t.show,p.closeOnClickModal=t.closeOnClickModal,p.confirmButtonText=t.confirmButtonText,p.cancelButtonText=t.cancelButtonText,p.msg=t.msg,p.type=t.type,p.inputType=t.inputType,p.inputSize=t.inputSize,p.inputValue=t.inputValue,p.inputPlaceholder=t.inputPlaceholder,p.inputPattern=t.inputPattern,p.inputValidate=t.inputValidate,p.success=t.success,p.fail=t.fail,p.beforeConfirm=t.beforeConfirm,p.inputError=t.inputError,p.showErr=t.showErr,p.zIndex=t.zIndex,p.lazyRender=t.lazyRender,p.confirmButtonProps=t.confirmButtonProps,p.cancelButtonProps=t.cancelButtonProps)}),{deep:!0,immediate:!0}),e.watch((()=>p.show),(e=>{!1===!!e&&(p.showErr=!1)}),{deep:!0,immediate:!0}),(t,o)=>e.e({a:p.title},p.title?{b:e.t(p.title)}:{},{c:"prompt"===p.type},"prompt"===p.type?e.e({d:e.o(x),e:e.o((e=>p.inputValue=e)),f:e.p({type:p.inputType,size:p.inputSize,placeholder:p.inputPlaceholder,modelValue:p.inputValue}),g:p.showErr},p.showErr?{h:e.t(p.inputError||e.unref(a)("inputNoValidate"))}:{}):{},{i:e.t(p.msg),j:e.n(u.value),k:p.showCancelButton},p.showCancelButton?{l:e.t(p.cancelButtonText||e.unref(a)("cancel")),m:e.o((e=>f("cancel"))),n:e.p({...m.value})}:{},{o:e.t(p.confirmButtonText||e.unref(a)("confirm")),p:e.o((e=>f("confirm"))),q:e.p({...d.value}),r:e.n("wd-message-box__actions "+(p.showCancelButton?"wd-message-box__flex":"wd-message-box__block")),s:e.n(r.value),t:e.o((e=>f("modal"))),v:e.o((e=>p.show=e)),w:e.p({transition:"zoom-in","close-on-click-modal":p.closeOnClickModal,"lazy-render":p.lazyRender,"custom-class":"wd-message-box","z-index":p.zIndex,duration:200,"root-portal":t.rootPortal,modelValue:p.show})})}}),l=e._export_sfc(u,[["__scopeId","data-v-5484ff85"]]);wx.createComponent(l);
