"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),w=require("@aplus-frontend/antdv"),C=require("@aplus-frontend/utils"),N=require("lodash-unified"),P=require("../../utils/index.js"),s=require("../../config-provider/config-provider.js"),h=require("./util.js"),q=t=>{let r,a;const d=e=>e?`${s.globalConfigCached.value.namespace}-ap-modal-${e}`:`${s.globalConfigCached.value.namespace}-ap-modal`,{destroyOnClose:c=!0,wrapperOffset:n=!1,wrapperFullHeight:l=!1}=t;function p(){r&&r(!1),setTimeout(()=>{o.render(null,i),i.parentElement?.removeChild(i)},500)}function g(){r&&r(!0)}function u(){r&&r(!1)}function m(e){a&&a(e)}const v=o.defineComponent({data(){return{open:c,props:t}},created(){r=e=>{this.open=e},a=e=>{this.props={...this.props,...e}}},methods:{async handleCancel(){if(this.props?.onCancel){const e=this.props?.content?.component?.exposed??void 0;await this.props?.onCancel(e)}c?p():u()},async handleOk(){try{if(a({confirmLoading:!0}),this.props?.onOk){const e=this.props?.content?.component?.exposed??void 0;await this.props.onOk(e)}a({confirmLoading:!1}),c?p():u()}catch{a({confirmLoading:!1})}},handleFooter(e){return t?.footer!==void 0?typeof t.footer=="function"?t.footer({...e,contentExposed:this.props?.content?.component?.exposed??void 0}):t.footer:e?.originNode}},render(){const e=N.omit(this.props,["onCancel","onOk","open","onUpdate:open","getContainer","icon","footer"]);return o.createVNode(s.ConfigProvider,s.globalConfigCached.value,{default:()=>[o.createVNode(w.Modal,o.mergeProps({class:{[d()]:!0,[d("wrapper")]:n},centered:!0},e,{open:this.open,onCancel:this.handleCancel,onOk:this.handleOk,footer:this?.handleFooter}),{default:()=>[o.createVNode("div",{class:{[d("body-wrapper")]:n},style:{maxHeight:n!==!1?`calc(100vh - ${(n===!0?100:C.isNumeric(n)?Number(n):100)*2}px)`:void 0,height:l===!0?`calc(100vh - ${(n===!0?100:C.isNumeric(n)?Number(n):100)*2}px)`:void 0,overflowY:n!==!1||l===!0?"auto":void 0}},[o.createVNode("div",{class:d("body-wrapper-content"),style:{height:l===!0?"100%":void 0}},[this.props?.content])])]})]})}}),x=h.getContainerDom(s.globalConfigCached?.value?.getPopupContainer),b=h.getContainerDom(t.getContainer),y=x||b||P.getTopWindow().document.body,i=document.createElement("div");y.appendChild(i);const f=o.h(v),O=h.getModalGlobalAppContext();return f.appContext=t.appContext||O||f.appContext,o.render(f,i),{destroy:p,update:m,open:g,close:u}};exports.createModal=q;
