UNPKG

@react-crates/modal

Version:

리액트 모달을 쉽게 등록하고 사용가능한 라이브러리입니다.

2 lines (1 loc) 46 kB
"use strict";var t=require("react/jsx-runtime"),n=require("react"),e=function(){return e=Object.assign||function(t){for(var n,e=1,o=arguments.length;e<o;e++)for(var i in n=arguments[e])Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i]);return t},e.apply(this,arguments)};function o(t,n){var e={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&n.indexOf(o)<0&&(e[o]=t[o]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(o=Object.getOwnPropertySymbols(t);i<o.length;i++)n.indexOf(o[i])<0&&Object.prototype.propertyIsEnumerable.call(t,o[i])&&(e[o[i]]=t[o[i]])}return e}function i(t,n,e,o){return new(e||(e=Promise))((function(i,r){function a(t){try{c(o.next(t))}catch(t){r(t)}}function s(t){try{c(o.throw(t))}catch(t){r(t)}}function c(t){var n;t.done?i(t.value):(n=t.value,n instanceof e?n:new e((function(t){t(n)}))).then(a,s)}c((o=o.apply(t,n||[])).next())}))}function r(t,n){var e,o,i,r,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return r={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(r[Symbol.iterator]=function(){return this}),r;function s(s){return function(c){return function(s){if(e)throw new TypeError("Generator is already executing.");for(;r&&(r=0,s[0]&&(a=0)),a;)try{if(e=1,o&&(i=2&s[0]?o.return:s[0]?o.throw||((i=o.return)&&i.call(o),0):o.next)&&!(i=i.call(o,s[1])).done)return i;switch(o=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,o=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){a.label=s[1];break}if(6===s[0]&&a.label<i[1]){a.label=i[1],i=s;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(s);break}i[2]&&a.ops.pop(),a.trys.pop();continue}s=n.call(t,a)}catch(t){s=[6,t],o=0}finally{e=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function a(t,n,e){if(e||2===arguments.length)for(var o,i=0,r=n.length;i<r;i++)!o&&i in n||(o||(o=Array.prototype.slice.call(n,0,i)),o[i]=n[i]);return t.concat(o||Array.prototype.slice.call(n))}var s=n.createContext(null);function c(){var t=n.useContext(s);if(!t)throw new Error("useModalComponentProps must be used within a ModalComponentProvider");return t}var l=new WeakMap,u=new WeakMap,d={},p=0,h=function(t){return t&&(t.host||h(t.parentNode))},m=function(t,n){return n.map((function(n){if(t.contains(n))return n;var e=h(n);return e&&t.contains(e)?e:(console.error("aria-hidden",n,"in not contained inside",t,". Doing nothing"),null)})).filter((function(t){return Boolean(t)}))};function f(t,n,e){void 0===e&&(e="data-aria-hidden");var o=Array.from(Array.isArray(t)?t:[t]),i=n||function(t){return"undefined"==typeof document?null:(Array.isArray(t)?t[0]:t).ownerDocument.body}(t);return i?(o.push.apply(o,Array.from(i.querySelectorAll("[aria-live]"))),function(t,n,e,o){var i=m(n,Array.isArray(t)?t:[t]);d[e]||(d[e]=new WeakMap);var r=d[e],a=[],s=new Set,c=new Set(i),h=function(t){t&&!s.has(t)&&(s.add(t),h(t.parentNode))};i.forEach(h);var f=function(t){t&&!c.has(t)&&Array.prototype.forEach.call(t.children,(function(t){if(s.has(t))f(t);else try{var n=t.getAttribute(o),i=null!==n&&"false"!==n,c=(l.get(t)||0)+1,d=(r.get(t)||0)+1;l.set(t,c),r.set(t,d),a.push(t),1===c&&i&&u.set(t,!0),1===d&&t.setAttribute(e,"true"),i||t.setAttribute(o,"true")}catch(n){console.error("aria-hidden: cannot operate on ",t,n)}}))};return f(n),s.clear(),p++,function(){a.forEach((function(t){var n=l.get(t)-1,i=r.get(t)-1;l.set(t,n),r.set(t,i),n||(u.has(t)||t.removeAttribute(o),u.delete(t)),i||t.removeAttribute(e)})),--p||(l=new WeakMap,l=new WeakMap,u=new WeakMap,d={})}}(o,i,e,"aria-hidden")):function(){return null}}var y=function(o){var i=o.breakPoint,r=o.modal,a=o.isCurrent,c=n.useState(r.state),l=c[0],u=c[1],d=n.useRef(null),p=n.useRef(null),h=n.useRef({first:null,last:null,elements:[],index:0,isComposing:!1}),m=l.component,y=l.componentProps,v=l.backCoverStyle,b=l.modalClassName,g=l.modalStyle,C=l.isActive,x=l.isOpened,M=l.isEscKeyActive,S=l.label,k=l.actionState,w=l.role,P=l.disableFocusHandling,j=n.useCallback((function(t){x&&p.current&&!p.current.contains(document.activeElement)&&(t.preventDefault(),p.current&&p.current.focus())}),[x]),O=n.useMemo((function(){return{actionBackCover:function(t){null!==r.options.backCoverConfirm&&0!==t.detail&&r.action(r.options.backCoverConfirm)},actionToEsc:function(t){"Escape"===t.key&&null!==r.options.backCoverConfirm&&M&&M&&r.action(r.options.backCoverConfirm)},disableOutsideFocus:function(t){if(!P&&("Escape"===t.key&&t.preventDefault(),"Tab"===t.key&&!h.current.isComposing&&(t.preventDefault(),p.current)))if(null!==h.current.first&&null!==h.current.last){if(t.target===h.current.first&&t.shiftKey)return h.current.last.focus(),void(h.current=e(e({},h.current),{index:h.current.elements.length-1}));if(t.target===h.current.last&&!t.shiftKey)return h.current.first.focus(),void(h.current=e(e({},h.current),{index:0}));h.current=e(e({},h.current),{index:h.current.index+1});var n=h.current.elements[h.current.index];if(!n)return h.current=e(e({},h.current),{index:0}),void p.current.focus();n.focus()}else p.current.focus()},focusBackCover:function(){p.current&&p.current.focus()},startComposition:function(){h.current.isComposing=!0},endComposition:function(){h.current.isComposing=!1}}}),[]),A=O.actionBackCover,T=O.actionToEsc,_=O.disableOutsideFocus,I=O.focusBackCover,E=O.startComposition,N=O.endComposition,D=n.useCallback((function(t){if(!x)return t.preventDefault(),void(d.current&&d.current.focus());if(!P){if(t.currentTarget.contains(t.target)&&t.currentTarget!==t.target){var n=h.current.elements.findIndex((function(n){return n===t.target}));if(-1!==n)return void(n!==h.current.index&&(h.current.index=n))}r.onOpenAutoFocus?r.onOpenAutoFocus(t):r.postOpen((function(){h.current.first&&h.current.first.focus()}))}}),[x]);return n.useEffect((function(){var t=function(t){u(t)};return r.init(),r.subscribe(t),r.componentRef=d.current,function(){r.componentRef=null,r.unsubscribe(t)}}),[]),n.useEffect((function(){if(r.updateIsCurrent(a),a&&d.current)return f(d.current)}),[a]),n.useEffect((function(){p.current&&(h.current=function(t){var n={first:null,last:null,elements:[],index:0,isComposing:!1},e=t.querySelectorAll('a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])');if(e.length>0){var o=e[0],i=e[e.length-1];o instanceof HTMLElement&&(n.first=o),i instanceof HTMLElement&&(n.last=i),n.elements=Array.from(e).filter((function(t){return t instanceof HTMLElement}))}return n}(p.current)),a&&x&&p.current&&!p.current.contains(document.activeElement)&&p.current&&p.current.focus()}),[x,k,m]),n.useEffect((function(){r.setBreakPoint(i)}),[i]),t.jsxs("div",e({tabIndex:-1,ref:d,"aria-label":S,"aria-labelledby":S,role:w,"aria-hidden":a?"false":"true","aria-modal":"true",className:"modalWrapper_rm",onFocus:j,onKeyDown:_},{children:[t.jsx("button",{className:"closeModalCover_rm ".concat(C?"":"close_rm"),style:v,type:"button",onClick:A,onFocus:I}),t.jsx("div",e({className:"modalContentContainer_rm"},{children:t.jsx("div",e({tabIndex:-1,ref:p,className:"modalContent_rm ".concat(b||""),style:g,onKeyUp:T,onFocus:D,onCompositionStart:E,onCompositionEnd:N},{children:t.jsx(s.Provider,e({value:y},{children:t.jsx(m,e({},y))}))}))}))]}))};function v(t,n){void 0===n&&(n={});var e=n.insertAt;if(t&&"undefined"!=typeof document){var o=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css","top"===e&&o.firstChild?o.insertBefore(i,o.firstChild):o.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t))}}v(".modalProvider_rm {\n display: block;\n overflow: hidden;\n position: fixed;\n top: 0;\n left: 0;\n z-index: 10001;\n width: 100vw;\n height: 100vh;\n /* 주소 표시줄이 보이거나 숨겨질 때 뷰포트 높이 조정 */\n height: calc(var(--vh, 1vh) * 100);\n background-color: transparent;\n pointer-events: none;\n transition: height 0.2s ease-in-out;\n outline: none;\n border: none;\n margin: none;\n padding: none;\n}\n\n.modalProvider_rm.open_rm {\n pointer-events: auto;\n}\n\n.modalProvider_rm .modalClearBtn_rm {\n all: unset;\n position: relative;\n width: 100%;\n height: 100%;\n pointer-events: none;\n background: transparent;\n outline: none;\n border: none;\n margin: none;\n padding: none;\n}\n\n.modalProvider_rm.open_rm .modalClearBtn_rm {\n pointer-events: auto;\n cursor: pointer;\n outline: none;\n border: none;\n margin: none;\n padding: none;\n}\n\n.modalProvider_rm .modalWrapper_rm {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n display: block;\n outline: none;\n border: none;\n margin: none;\n padding: none;\n}\n\n.modalProvider_rm .modalWrapper_rm .closeModalCover_rm {\n all: unset;\n position: absolute;\n width: 100%;\n height: 100%;\n pointer-events: auto;\n outline: none;\n border: none;\n margin: none;\n padding: none;\n}\n\n.modalProvider_rm .modalWrapper_rm .modalContentContainer_rm {\n position: absolute;\n top: 0;\n left: 0;\n display: block;\n width: 100%;\n height: 100%;\n background: transparent;\n outline: none;\n border: none;\n margin: none;\n padding: none;\n}\n\n.modalProvider_rm .modalWrapper_rm .modalContentContainer_rm .modalContent_rm {\n /* all: unset; */\n display: block;\n position: absolute;\n width: auto;\n height: auto;\n outline: none;\n border: none;\n margin: none;\n padding: none;\n}\n");var b="",g="",C="",x="",M=function(o){var i=o.modalManager,r=o.disableInteraction,a=void 0===r||r,s=o.children,c=n.useState(i.getState()),l=c[0],u=l.modalStack,d=l.isOpen,p=l.transactionState,h=l.breakPoint,m=l.currentModalId,f=l.zIndex,y=c[1],v=n.useRef(null);n.useEffect((function(){i.subscribe(y);var t=document.documentElement.style.getPropertyValue("--vh"),n=function(){i.setBreakPoint(window.innerWidth);var t=.01*window.innerHeight;document.documentElement.style.setProperty("--vh","".concat(t,"px"))};return n(),window.addEventListener("resize",n),function(){i.unsubscribe(y),i.remove("clear"),document.documentElement.style.setProperty("--vh",t),window.removeEventListener("resize",n)}}),[]),n.useEffect((function(){return d&&a?(b=document.body.style.overflow,g=document.body.style.height,C=document.body.style.width,x=document.body.style.pointerEvents,document.body.style.overflow="hidden",document.body.style.height="calc(var(--vh, 1vh) * 100)",document.body.style.width="100vw",document.body.style.pointerEvents="none",function(){document.body.style.overflow=b,document.body.style.height=g,document.body.style.width=C,document.body.style.pointerEvents=x,b="",g="",C="",x=""}):a?(document.body.style.overflow=b,document.body.style.height=g,document.body.style.width=C,document.body.style.pointerEvents=x,function(){b="",g="",C="",x=""}):void 0}),[d]);var M=n.useCallback((function(t){v.current&&v.current.contains(document.activeElement)||t.preventDefault()}),[p]);n.useEffect((function(){if(m>0){var t=u[u.length-1].componentRef;if(t)return void t.focus();v.current&&v.current.focus()}}),[m]);var k={isOpen:d,zIndex:f,modalStack:u,breakPoint:h,transactionState:p,currentModalId:m,onKeyDown:M,ref:v};return s?t.jsxs(t.Fragment,{children:[s,t.jsx(S,e({},k))]}):t.jsx(S,e({},k))},S=n.forwardRef((function(n,o){var i=n.isOpen,r=n.zIndex,a=n.modalStack,s=n.breakPoint,c=n.currentModalId,l=n.onKeyDown;return t.jsx("div",e({ref:o,tabIndex:-1,className:"modalProvider_rm ".concat(i?"open_rm":""),style:{zIndex:r},onKeyDown:l},{children:t.jsx("div",e({style:{width:"100%",height:"100%",overflow:"hidden",pointerEvents:"none"}},{children:a.map((function(n){return t.jsx(y,{breakPoint:s,modal:n,isCurrent:n.id===c},n.id)}))}))}))}));function k(n){return function(o){return t.jsx(M,e({modalManager:n},o))}}var w=function(n){var i=n.as,r=n.children,a=o(n,["as","children"]),s=c().title;if(!s&&!r)return null;var l=i||"h2";return t.jsx(l,e({},a,{children:s||r}))},P=function(n){var i=n.as,r=n.children,a=o(n,["as","children"]),s=c().subTitle;if(!s&&!r)return null;var l=i||"h3";return t.jsx(l,e({},a,{children:s||r}))};w.displayName="Modal.Title",P.displayNmae="Modal.Title.Sub",w.Sub=P;var j=function(n){var i=n.as,r=n.children,a=o(n,["as","children"]),s=c().content;if(!s&&!r)return null;var l=i||"div";return t.jsx(l,e({},a,{children:s||r}))},O=function(n){var i=n.as,r=n.children,a=o(n,["as","children"]),s=c().subContent;if(!s&&!r)return null;var l=i||"div";return t.jsx(l,e({},a,{children:s||r}))};j.displayName="Modal.Content",O.displayName="Modal.Content.Sub",j.Sub=O;var A=function(n){var i=n.onClick,r=n.children,a=n.confirmType,s=o(n,["onClick","children","confirmType"]),l=c(),u=function(t,n,e){var o=n.confirmContent,i=n.cancelContent,r=n.customActionContent;return t||(e?!0===e?o:r:i)}(r,l,a);return u?t.jsx("button",e({},s,{onClick:function(t){i&&i(t),l.action(a)},type:"button"},{children:u})):null},T=n.forwardRef((function(n,i){var r=n.onClick,a=n.children,s=n.type,l=void 0===s?"button":s,u=o(n,["onClick","children","type"]),d=c(),p=d.action,h=d.confirmContent;return t.jsx("button",e({ref:i,onClick:function(t){r&&r(t),p(!0)},type:l},u,{children:h||a||"확인"}))})),_=n.forwardRef((function(n,i){var r=n.onClick,a=n.children,s=n.type,l=void 0===s?"button":s,u=o(n,["onClick","children","type"]),d=c(),p=d.action,h=d.cancelContent;return t.jsx("button",e({ref:i,onClick:function(t){r&&r(t),p(!1)},type:l},u,{children:h||a||"취소"}))})),I=n.forwardRef((function(n,i){var r=n.onClick,a=n.children,s=n.confirmType,l=n.type,u=void 0===l?"button":l,d=o(n,["onClick","children","confirmType","type"]),p=c(),h=p.action,m=p.customActionContent;return t.jsx("button",e({ref:i,onClick:function(t){r&&r(t),h(s)},type:u},d,{children:m||a||"커스텀"}))}));A.displayName="Modal.Action",T.displayName="Modal.Action.Confirm",_.displayName="Modal.Action.Cancel",I.displayName="Modal.Action.Custom",A.Confirm=T,A.Cancel=_,A.Custom=I;var E={Title:w,Content:j,Action:A},N=function(){function t(t){this.modalManager=t,this.modalId=null,this.isOpen=!1,this.element=null,this.options={}}return t.prototype.editModal=function(){var t=this;this.isOpen&&this.modalId&&this.element&&this.modalManager.edit(this.modalId,e({component:function(){return t.element}},this.options))},t.prototype.setElement=function(t){return n.isValidElement(t)&&(this.element=t),this.editModal(),this},t.prototype.setOptions=function(t){var n=this;void 0===t&&(t={});return this.options=e(e({},t),{action:function(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];t.action&&t.action.apply(t,e),n.isOpen=!1,n.modalId=null}}),this},t.prototype.open=function(){!this.isOpen&&this.element&&(this.isOpen=!0,this.modalId=this.modalManager.open(this.element,this.options))},t}(),D=n.createContext(null);function z(){var t=n.useContext(D);if(!t)throw Error("useDynamicModal must be used within a DynamicModal");return t}var K=function(i){var r=i.onClick,a=o(i,["onClick"]),s=z(),c=n.useCallback((function(t){r&&r(t),s.open()}),[s,r]);return t.jsx("button",e({"aria-haspopup":"dialog",onClick:c},a))},R=function(t){var e=t.children,o=z();return n.useEffect((function(){o.setElement(e)}),[e]),null},F=function(o){var i=o.modalManager,r=o.options,a=o.children,s=n.useMemo((function(){return new N(i)}),[i]);return n.useEffect((function(){s.setOptions(r)}),[r]),t.jsx(D.Provider,e({value:s},{children:a}))},B=function(n){function i(i){var r=i.children,a=o(i,["children"]);return t.jsx(F,e({modalManager:n,options:a},{children:r}))}return i.displayName="DynamicModal",i.Trigger=K,i.Element=R,i.Action=E.Action,i};K.displayName="DynamicModal.Trigger",R.displayName="DynamicModal.Element";v(".modal-template-rm {\n all: unset;\n width: fit-content;\n max-width: 90vw;\n border-radius: 0.5rem;\n display: block;\n box-sizing: content-box;\n padding: 1.5rem;\n}\n\n.modal-template-rm.bottom {\n width: 100vw;\n max-width: 100vw;\n box-sizing: border-box;\n border-bottom-right-radius: 0rem; /* 8px */\n border-bottom-left-radius: 0rem;\n}\n\n.modal-template-bg-rm {\n background-color: #fff;\n border: 1px solid #e5e7eb;\n box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);\n}\n\n@media screen and (min-width: 900px) {\n .modal-template-rm {\n max-width: 31rem;\n }\n}\n\n.modal-template-header-rm {\n all: unset;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n width: fit-content;\n min-width: 15rem;\n height: fit-content;\n}\n\n.modal-template-main-rm {\n all: unset;\n margin-top: 0.5rem;\n width: fit-content;\n min-width: 15rem;\n display: flex;\n flex-direction: column;\n align-items: flex-start;\n height: fit-content;\n}\n\n.modal-template-footer-rm {\n all: unset;\n width: 100%;\n display: flex;\n box-sizing: border-box;\n height: fit-content;\n justify-content: end;\n margin-top: 1rem;\n padding: 0px;\n gap: 0.5rem;\n}\n\n.modal-collection-title-rm {\n all: unset;\n font-size: 1.125rem;\n font-weight: 600;\n text-align: left;\n padding: 0px;\n color: #09090b;\n}\n\n.modal-collection-sub-title-rm {\n all: unset;\n font-size: 1rem;\n font-weight: 500;\n text-align: left;\n padding: 0px;\n color: #71717a;\n}\n\n.modal-collection-content-rm {\n all: unset;\n width: fit-content;\n min-width: 15rem;\n font-size: 0.875rem;\n color: #6b7280;\n padding: 0px;\n text-align: left;\n}\n\n.modal-collection-sub-content-rm {\n all: unset;\n width: fit-content;\n min-width: 15rem;\n font-size: 0.75rem;\n color: #9ca3af;\n margin-top: 0.5rem;\n padding: 0px;\n text-align: left;\n}\n\n.modal-collection-action-rm {\n all: unset;\n display: block;\n width: fit-content;\n height: fit-content;\n margin: 0px;\n background-color: #fff;\n border: 1px solid #d1d5db;\n padding: 0.5rem 1rem;\n border-radius: 6px;\n font-size: 0.875rem;\n font-weight: 400;\n cursor: pointer;\n}\n\n.modal-collection-action-rm:hover {\n background-color: rgba(209, 213, 219, 0.8);\n}\n\n.modal-collection-action-rm:focus {\n box-shadow: 0 0 0 2px rgba(209, 213, 219, 0.8);\n}\n\n.modal-collection-confirm-rm {\n background-color: #030712;\n border: 1px solid #030712;\n color: #fff;\n}\n\n.modal-collection-confirm-rm:hover {\n background-color: rgba(3, 7, 18, 0.8);\n}\n\n.modal-collection-confirm-rm:focus {\n box-shadow: 0 0 0 2px rgba(209, 213, 219, 1);\n}\n\n.modal-collection-prompt-rm {\n width: 100%;\n margin-top: 1rem;\n}\n\n.modal-collection-prompt-input-rm {\n all: unset;\n display: block;\n width: 100%;\n max-width: 20rem;\n height: 2.25rem;\n border-radius: 0.375rem;\n box-sizing: border-box;\n font-size: 0.875rem;\n line-height: 1.25rem;\n padding: 0.25rem 0.75rem;\n border: 1px solid #d1d5db;\n}\n\n.modal-collection-prompt-input-rm:focus {\n box-shadow: 0 0 0 1px #fff, 0 0 0 2px rgba(3, 7, 18, 0.2);\n}\n");var Z=function(n){var o=n.children;return t.jsx("div",e({className:"modal-template-header-rm"},{children:o}))};Z.displayName="ModalTemplate.Header";var H=function(n){var o=n.children;return t.jsx("div",e({className:"modal-template-main-rm"},{children:o}))};H.displayName="ModalTemplate.Main";var W=function(n){var o=n.children;return t.jsx("div",e({className:"modal-template-footer-rm"},{children:o}))};W.displayName="ModalTemplate.Footer";var L=function(n){var o=n.className,i=n.children;return t.jsx("div",e({className:"modal-template-rm ".concat(o||"")},{children:i}))};L.Header=Z,L.Main=H,L.Footer=W;var q=function(n){var o=n.currentPosition;return t.jsxs(L,e({className:"modal-template-bg-rm ".concat("bottom"===o?"bottom":"")},{children:[t.jsxs(L.Header,{children:[t.jsx(E.Title,e({className:"modal-collection-title-rm"},{children:"Alert"})),t.jsx(E.Title.Sub,{className:"modal-collection-sub-title-rm"})]}),t.jsxs(L.Main,{children:[t.jsx(E.Content,{className:"modal-collection-content-rm"}),t.jsx(E.Content.Sub,{className:"modal-collection-sub-content-rm"})]}),t.jsx(L.Footer,{children:t.jsx(E.Action.Confirm,e({className:"modal-collection-action-rm modal-collection-confirm-rm"},{children:"Confirm"}))})]}))};q.displayName="ModalCollection.Alert";var V=function(n){var o=n.currentPosition;return t.jsxs(L,e({className:"modal-template-bg-rm ".concat("bottom"===o?"bottom":"")},{children:[t.jsxs(L.Header,{children:[t.jsx(E.Title,e({className:"modal-collection-title-rm"},{children:"Confirm"})),t.jsx(E.Title.Sub,{className:"modal-collection-sub-title-rm"})]}),t.jsxs(L.Main,{children:[t.jsx(E.Content,{className:"modal-collection-content-rm"}),t.jsx(E.Content.Sub,{className:"modal-collection-sub-content-rm"})]}),t.jsxs(L.Footer,{children:[t.jsx(E.Action.Cancel,e({className:"modal-collection-action-rm modal-collection-cancel-rm"},{children:"Cancel"})),t.jsx(E.Action.Confirm,e({className:"modal-collection-action-rm modal-collection-confirm-rm"},{children:"Confirm"}))]})]}))};V.displayName="ModalCollection.Confirm";var U=function(o){var i=o.action,r=o.currentPosition,a=n.useState(""),s=a[0],c=a[1];return t.jsxs(L,e({className:"modal-template-bg-rm ".concat("bottom"===r?"bottom":"")},{children:[t.jsxs(L.Header,{children:[t.jsx(E.Title,e({className:"modal-collection-title-rm"},{children:"Prompt"})),t.jsx(E.Title.Sub,{className:"modal-collection-sub-title-rm"})]}),t.jsxs(L.Main,{children:[t.jsx(E.Content,{className:"modal-collection-content-rm"}),t.jsx(E.Content.Sub,{className:"modal-collection-sub-content-rm"}),t.jsx("div",e({className:"modal-collection-prompt-rm"},{children:t.jsx("input",{onChange:function(t){c(t.target.value)},onKeyUp:function(t){"Enter"===t.key&&(t.preventDefault(),i(s))},className:"modal-collection-prompt-input-rm"})}))]}),t.jsxs(L.Footer,{children:[t.jsx(E.Action.Cancel,e({className:"modal-collection-action-rm modal-collection-cancel-rm"},{children:"Cancel"})),t.jsx(E.Action.Custom,e({className:"modal-collection-action-rm modal-collection-confirm-rm",confirmType:s},{children:"Confirm"}))]})]}))};U.displayName="ModalCollection.Prompt";var G,J,Q,X,Y,$,tt,nt,et,ot,it,rt,at={confirm:{component:V,defaultOptions:{backCoverConfirm:!1,escKeyActive:!0,role:"dialog",label:"confirm"}},alert:{component:q,defaultOptions:{backCoverConfirm:!0,escKeyActive:!0,role:"alertdialog",label:"alert"}},prompt:{component:U,defaultOptions:{backCoverConfirm:void 0,escKeyActive:!0,role:"dialog",label:"prompt"}}},st="idle",ct="active",lt={open:"open",active:"active",close:"close"};Object.values(lt);var ut="initial",dt="pending",pt="success",ht="error",mt={clear:"clear",unknown:"unknown",open:"open",close:"close",edit:"edit",remove:"remove",action:"action"},ft={transitionProperty:"opacity, transform, left, top, bottom, right, background, background-color",transitionDuration:"".concat(200,"ms"),transitionDelay:"0ms",transitionTimingFunction:"cubic-bezier(0.25, 0.1, 0.25, 1)"},yt={default:"default",backCover:"backCover",center:"center",top:"top",bottom:"bottom",left:"left",right:"right",leftTop:"leftTop",leftBottom:"leftBottom",rightTop:"rightTop",rightBottom:"rightBottom"},vt=((G={})[yt.default]=((J={})[lt.open]={opacity:0},J[lt.active]={opacity:1},J[lt.close]={opacity:0},J),G[yt.center]=((Q={})[lt.open]={left:"50%",top:"50%",transform:"translate(-50%, -50%) scale(0.95)"},Q[lt.active]={left:"50%",top:"50%",transform:"translate(-50%, -50%) scale(1)"},Q[lt.close]={left:"50%",top:"50%",transform:"translate(-50%, -50%) scale(0.95)"},Q),G[yt.bottom]=((X={})[lt.open]={left:"50%",top:"100%",transform:"translate(-50%, 0)"},X[lt.active]={left:"50%",top:"100%",transform:"translate(-50%, -100%)"},X[lt.close]={left:"50%",top:"100%",transform:"translate(-50%, 0)"},X),G[yt.top]=((Y={})[lt.open]={left:"50%",top:"0",transform:"translate(-50%, -100%)"},Y[lt.active]={left:"50%",top:"0",transform:"translate(-50%, 0)"},Y[lt.close]={left:"50%",top:"0",transform:"translate(-50%, -100%)"},Y),G[yt.left]=(($={})[lt.open]={left:"0",top:"50%",transform:"translate(-100%, -50%)"},$[lt.active]={left:"0",top:"50%",transform:"translate(0, -50%)"},$[lt.close]={left:"0",top:"50%",transform:"translate(-100%, -50%)"},$),G[yt.right]=((tt={})[lt.open]={left:"100%",top:"50%",transform:"translate(0, -50%)"},tt[lt.active]={left:"100%",top:"50%",transform:"translate(-100%, -50%)"},tt[lt.close]={left:"100%",top:"50%",transform:"translate(0, -50%)"},tt),G[yt.leftTop]=((nt={})[lt.open]={left:"0",top:"0",transform:"translate(-100%, -100%) scale(0)"},nt[lt.active]={left:"0",top:"0",transform:"translate(0, 0) scale(1)"},nt[lt.close]={left:"0",top:"0",transform:"translate(-100%, -100%) scale(0)"},nt),G[yt.leftBottom]=((et={})[lt.open]={left:"0",top:"100%",transform:"translate(-100%, 0) scale(0)"},et[lt.active]={left:"0",top:"100%",transform:"translate(0, -100%) scale(1)"},et[lt.close]={left:"0",top:"100%",transform:"translate(-100%, 0) scale(0)"},et),G[yt.rightTop]=((ot={})[lt.open]={left:"100%",top:"0",transform:"translate(0, -100%) scale(0)"},ot[lt.active]={left:"100%",top:"0",transform:"translate(-100%, 0) scale(1)"},ot[lt.close]={left:"100%",top:"0",transform:"translate(0, -100%) scale(0)"},ot),G[yt.rightBottom]=((it={})[lt.open]={left:"100%",top:"100%",transform:"translate(0, 0) scale(0)"},it[lt.active]={left:"100%",top:"100%",transform:"translate(-100%, -100%) scale(1)"},it[lt.close]={left:"100%",top:"100%",transform:"translate(0, 0) scale(0)"},it),G[yt.backCover]=((rt={})[lt.open]={top:"0",left:"0",background:"rgb(0, 0, 0)",opacity:0},rt[lt.active]={top:"0",left:"0",background:"rgb(0, 0, 0)",opacity:.5},rt[lt.close]={top:"0",left:"0",background:"rgb(0, 0, 0)",opacity:0},rt),G);function bt(t){return void 0===t&&(t=0),new Promise((function(n){setTimeout((function(){n(!0)}),Math.max(t,0))}))}var gt,Ct=function(){function t(t,n){var e=t.id,o=t.modalKey,i=t.name,r=t.component,a=t.options;this.manager=n,this.lifecycleState=lt.open,this.actionState=ut,this.actionCallback=function(){},this.afterCloseCallback=function(){},this.listeners=[],this.breakPoint=0,this.isInitial=!1,this.stateResponsive=!1,this.escKeyActive=!0,this.role="dialog",this.label="dialog",this.isOpened=!1,this.isPostOpened=!1,this._isCurrent=!1,this._isAwaitingConfirm=!1,this._isCloseDelay=!1,this._closeDelayDuration=-1,this._confirm=void 0,this._onOpenAutoFocus=void 0,this._currentPosition=yt.center,this._disableFocusHandling=!1,this.componentRef=null,this._id=e,this._name=i,this._modalKey=o,this.initialComponent=r,this.currentComponent=r,this._options=a,this.bind(),this.setOption(),this.setComponentProps(),this._state=this.getState()}return t.prototype.bind=function(){this.action=this.action.bind(this),this.getActionState=this.getActionState.bind(this),this.getLifecycleState=this.getLifecycleState.bind(this),this.initial=this.initial.bind(this),this.pending=this.pending.bind(this),this.success=this.success.bind(this),this.error=this.error.bind(this),this.end=this.end.bind(this),this.active=this.active.bind(this),this.close=this.close.bind(this),this.postOpen=this.postOpen.bind(this)},t.prototype.setOption=function(){var t=this.options,n=t.closeDelay,e=t.action,o=t.stateResponsiveComponent,i=t.escKeyActive,r=t.role,a=t.title,s=t.label,c=t.onOpenAutoFocus,l=t.disableFocusHandling;this.setCloseDelay(n),e&&(this.actionCallback=e),o&&(this.stateResponsive=o),!1===i&&(this.escKeyActive=!1),"string"==typeof r&&(this.role=r),this.label=s||("string"==typeof a?a:"unknown"===this._name?"dialog":this._name),c&&(this._onOpenAutoFocus=c),l&&(this._disableFocusHandling=l)},t.prototype.initComponent=function(){this.currentComponent=this.initialComponent,this.setComponentProps()},Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"modalKey",{get:function(){return this._modalKey},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"component",{get:function(){return this.currentComponent},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"confirm",{get:function(){return this._confirm},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCurrent",{get:function(){return this._isCurrent},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAwaitingConfirm",{get:function(){return this._isAwaitingConfirm},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCloseDelay",{get:function(){return this._isCloseDelay},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"closeDelayDuration",{get:function(){return this._closeDelayDuration},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"callback",{get:function(){return this.actionCallback},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onOpenAutoFocus",{get:function(){return this._onOpenAutoFocus},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"currentPosition",{get:function(){return this._currentPosition},enumerable:!1,configurable:!0}),t.prototype.setComponentProps=function(t){void 0===t&&(t={});var n=this.options,o=n.title,i=n.subTitle,r=n.content,a=n.subContent,s=n.confirmContent,c=n.cancelContent,l=n.customActionContent,u=n.payload,d={title:o,subTitle:i,content:r,subContent:a,confirmContent:s,cancelContent:c,customActionContent:l,isEscKeyActive:this.escKeyActive,payload:u,action:this.action,actionState:this.actionState,currentPosition:this._currentPosition,lifecycleState:this.lifecycleState};this.componentProps=e(e({},d),t)},t.prototype.changeComponent=function(t,n){if(void 0===n&&(n={}),"function"==typeof t)this.currentComponent=t;else{var e=this.manager.getModalComponentSeed(t);if(!e)return void this.initComponent();this.currentComponent=e.component}this.setComponentProps(n)},t.prototype.changeStateResponsiveComponent=function(t){var n=void 0===t?{}:t,e=n.component,o=n.options;return"initial"===this.actionState?(this.initComponent(),void this.notify()):e?(this.changeComponent(e,o),void this.notify()):void(this.stateResponsive&&(this.changeComponent(this.actionState,o),this.notify()))},t.prototype.changeState=function(t){if(t){if("function"==typeof t)return this.afterCloseCallback=t,void this.changeStateResponsiveComponent();if("string"!=typeof t){var n=t.isAwaitingConfirm,e=t.component,o=t.afterCloseCallback,i=t.options;n&&(this._isAwaitingConfirm=n),o&&(this.afterCloseCallback=o),this.changeStateResponsiveComponent({component:e,options:i})}else this.changeStateResponsiveComponent({options:{content:t}})}else this.changeStateResponsiveComponent()},t.prototype.edit=function(t){var n=t.component,i=o(t,["component"]);n&&(this.initialComponent=n,this._options.stateResponsiveComponent&&"initial"!==this.actionState||(this.currentComponent=n)),this._options=e(e({},this._options),i),this.setOption(),this.notify()},t.prototype.getActionState=function(){return this.actionState},t.prototype.getLifecycleState=function(){return this.lifecycleState},t.prototype.init=function(){var t;return i(this,void 0,void 0,(function(){var n=this;return r(this,(function(e){switch(e.label){case 0:return this.isInitial?[2]:(this.isInitial=!0,setTimeout((function(){n.active()}),0),[4,this.manager.executeAsync(bt,null!==(t=this.options.duration)&&void 0!==t?t:0)]);case 1:return e.sent(),this.isOpened=!0,this.notify(),[2]}}))}))},t.prototype.postOpen=function(t){this.isPostOpened||(this.isPostOpened=!0,"function"==typeof t&&t())},t.prototype.active=function(){this.lifecycleState="active",this.notify()},t.prototype.close=function(){return this.lifecycleState="close",this.notify(),this.options.closeModal(this.afterCloseCallback,this.confirm)},t.prototype.blockCloseDelay=function(){return this._isCloseDelay=!1,this},t.prototype.setCloseDelay=function(t){return void 0===t&&(t=-1),t<1?(this._isCloseDelay=!1,this):(this._isCloseDelay=!0,this._closeDelayDuration=t,this)},t.prototype.updateIsCurrent=function(t){return this._isCurrent===t||(this._isCurrent=t,this.notify()),this},t.prototype.getState=function(){var t=this.getModalStyle(),n=t.className,e=t.style,o=this.getBackCoverStyle();return{isActive:this.lifecycleState===lt.active,isOpened:this.isOpened,actionState:this.actionState,component:this.currentComponent,componentProps:this.componentProps,modalClassName:n,modalStyle:e,backCoverStyle:o,isEscKeyActive:this.escKeyActive,label:this.label,role:this.role,disableFocusHandling:this._disableFocusHandling}},t.prototype.subscribe=function(t){return this.listeners.push(t),this},t.prototype.unsubscribe=function(t){return this.listeners=this.listeners.filter((function(n){return n!==t})),this},t.prototype.notify=function(){var t=this.getState();return this._state=t,this.listeners.forEach((function(n){return n(t)})),this},t.prototype.getMiddlewareProps=function(){return{modalState:this}},t.prototype.action=function(t,n){return i(this,void 0,void 0,(function(){var e=this;return r(this,(function(o){return[2,this.manager.executeWithTransaction((function(){return void 0!==t&&(e._confirm=t),n&&(e.actionCallback=n),e.options.middleware(e.getMiddlewareProps())}),void 0)]}))}))},t.prototype.initial=function(){return this.actionState=ut,this.changeState(),this},t.prototype.pending=function(t){return this.actionState=dt,this.changeState(t),this},t.prototype.success=function(t){return this.actionState=pt,this.changeState(t),this},t.prototype.error=function(t){return this.actionState=ht,this.changeState(t),this},t.prototype.end=function(t){return this.actionState=ut,this.changeState(t),this},t.prototype.getModalStyle=function(){var t=this.options,n=t.position,i=t.duration,r=t.transitionOptions,a="function"==typeof n?n(this.breakPoint):n,s=this.lifecycleState===lt.active,c=this.manager.getCurrentModalPosition(this.lifecycleState,a),l=c[0],u=c[1],d=l.className,p=o(l,["className"]),h=this.manager.getModalTransition(i,r);return this._currentPosition!==u&&(this._currentPosition=u,this.setComponentProps()),{className:d,style:e(e({pointerEvents:s&&this.isOpened?"auto":"none"},h),p)}},t.prototype.getBackCoverStyle=function(){var t=this,n=this.options,i=n.backCoverColor,r=n.backCoverOpacity,a=n.backCoverConfirm,s=n.duration,c=n.transitionOptions,l=this.lifecycleState===lt.active,u=this.manager.getCurrentModalPosition(this.lifecycleState,yt.backCover)[0],d=u.background,p=u.opacity,h=o(u,["background","opacity"]),m=this.manager.getModalTransition(s,c),f=t.manager.getTransactionState()===st&&l&&null!==a?"pointer":"default";return e(e(e({cursor:f},m),h),{background:void 0!==i&&l?i:d,opacity:void 0!==r&&l?r:p,pointerEvents:l&&this.isOpened?"auto":"none"})},t.prototype.setBreakPoint=function(t){this.breakPoint!==t&&(this.breakPoint=t,this.notify())},t}();function xt(t){var n=t.modalState;return i(this,void 0,void 0,(function(){return r(this,(function(t){switch(t.label){case 0:return n.isAwaitingConfirm?[2,n.close()]:[4,n.callback(n.confirm,n)];case 1:return t.sent(),n.isCloseDelay?[4,bt(n.closeDelayDuration)]:[3,3];case 2:t.sent(),t.label=3;case 3:return n.isAwaitingConfirm?[2,!1]:[2,n.close()]}}))}))}var Mt=((gt={})[lt.open]=0,gt[lt.active]=1,gt[lt.close]=2,gt);function St(t,n){if("string"!=typeof t)return yt.center;var e=function(t){var n=t.split("-");if(n.length<1)return Array.from({length:3}).map((function(t){return yt.center}));var e=n.length-1;return Array.from({length:3}).map((function(t,o){return n[o]||n[e]}))}(t);return e[Mt[n]]}Object.getPrototypeOf((function(){return i(this,void 0,void 0,(function(){return r(this,(function(t){return[2]}))}))})).constructor;var kt=function(){function t(t,n){void 0===t&&(t=[]),void 0===n&&(n={}),this.currentId=0,this.transactionCount=0,this.transactionState=st,this.modalStack=[],this.listeners=[],this.modalComponentSeedMap=new Map,this.modalPositionMap=new Map,this.modalTransition=ft,this.modalDuration=200,this.stateResponsiveComponent=!1,this.breakPoint=0,this.originZindex=50,this.zIndex=50,this.modalComponentSeedMap||(this.modalComponentSeedMap=new Map),this.bind(),t.forEach(this.setModalComponentSeedMap),this.initModalOptions(n),this.setModalManagerState()}return t.prototype.bind=function(){this.setModalComponentSeedMap=this.setModalComponentSeedMap.bind(this),this.createModalCloser=this.createModalCloser.bind(this),this.setZIndex=this.setZIndex.bind(this),this.resetZIndex=this.resetZIndex.bind(this),this.executeAsync=this.executeAsync.bind(this),this.open=this.open.bind(this),this.remove=this.remove.bind(this),this.action=this.action.bind(this),this.getModalComponentSeed=this.getModalComponentSeed.bind(this),this.getCurrentModalPosition=this.getCurrentModalPosition.bind(this),this.getTransactionState=this.getTransactionState.bind(this),this.startTransaction=this.startTransaction.bind(this),this.endTransaction=this.endTransaction.bind(this)},t.prototype.initModalOptions=function(t){var n=t.position,o=t.transition,i=t.duration,r=t.stateResponsiveComponent,a=t.zIndex,s=e(e({},vt),n);this.stateResponsiveComponent=r||!1,this.setModalPosition(s),this.setModalTransition(o),this.setModalDuration(i),a&&(this.originZindex=a,this.zIndex=a)},t.prototype.setModalManagerState=function(){this.modalManagerState={modalStack:this.modalStack,transactionState:this.transactionState,isOpen:this.modalStack.length>0,breakPoint:this.breakPoint,currentModalId:this.getCurrentModalId(),zIndex:this.zIndex}},t.prototype.setModalComponentSeedMap=function(t){var n,o=t.name,i=t.component,r=t.defaultOptions;if(void 0!==i&&!Object.prototype.hasOwnProperty.call(mt,o)){var a=this.modalComponentSeedMap.get(o);if(!a||!(null===(n=a.defaultOptions)||void 0===n?void 0:n.required)){var s=e(e({},t),{defaultOptions:e(e({},r),{duration:(null==r?void 0:r.duration)||this.modalDuration})});this.modalComponentSeedMap.set(o,s)}}},t.prototype.setZIndex=function(t){void 0!==t&&(this.zIndex=t)},t.prototype.resetZIndex=function(){this.zIndex=this.originZindex},t.prototype.setModalComponent=function(t){return Array.isArray(t)?t.forEach(this.setModalComponentSeedMap):this.setModalComponentSeedMap(t),this},t.prototype.removeModalComponent=function(t){var n=this;return Array.isArray(t)?(t.forEach((function(t){n.modalComponentSeedMap.delete(t)})),this.modalStack=this.modalStack.filter((function(n){return!t.includes(n.name)}))):(this.modalComponentSeedMap.delete(t),this.modalStack=this.modalStack.filter((function(n){return n.name!==t}))),this},t.prototype.getModalComponentSeed=function(t){return this.modalComponentSeedMap.get(t)},t.prototype.createModalCloser=function(t,n){var e=this;return function(o,a){return i(e,void 0,void 0,(function(){return r(this,(function(e){switch(e.label){case 0:return n?[4,bt(n)]:[3,2];case 1:e.sent(),e.label=2;case 2:return o?[4,o(a)]:[3,4];case 3:e.sent(),e.label=4;case 4:return this.remove(t),[2,!0]}}))}))}},t.prototype.setModalTransition=function(t){if(void 0===t)return this;var n=e(e({},this.modalTransition),t);return this.modalTransition=n,this},t.prototype.setModalDuration=function(t){return void 0===t&&(t=-1),t<0||(this.modalDuration=t,this.setModalTransition({transitionDuration:"".concat(t,"ms")})),this},t.prototype.setModalPosition=function(t){var n=this;return Object.entries(t).forEach((function(t){var e=t[0],o=t[1];n.modalPositionMap.set(e,o)})),this},t.prototype.setModalOptions=function(t){var n=t.position,e=t.transition,o=t.duration,i=t.stateResponsiveComponent;this.setModalTransition(e),this.setModalDuration(o),i&&(this.stateResponsiveComponent=i),n&&this.setModalPosition(n)},t.prototype.getModalTransition=function(t,n){if(void 0===t&&(t=-1),void 0===n&&(n={}),t<0)return e(e({},this.modalTransition),n);var o="".concat(t,"ms");return e(e(e({},this.modalTransition),n),{transitionDuration:o})},t.prototype.getModalPosition=function(t){void 0===t&&(t=yt.center);var n=this.modalPositionMap.get(t);if(!n){var e=this.modalPositionMap.get(yt.center);return null!=e?e:vt.center}return n},t.prototype.getModalPositionMap=function(){return this.modalPositionMap},t.prototype.getCurrentModalPosition=function(t,n){void 0===n&&(n=yt.center);var o=St(n,t),i=this.getModalPosition(yt.default),r=i.open,a=i.active,s=i.close,c=this.getModalPosition(o),l=c.open,u=c.active,d=c.close;return t===lt.open?[e(e({},r),l),o]:t===lt.active?[e(e({},a),u),o]:[e(e({},s),d),o]},t.prototype.setTransactionState=function(t){return this.transactionState=t,this.notify(),this.transactionCount},t.prototype.startTransaction=function(){return this.transactionCount+=1,this.setTransactionState(ct)},t.prototype.endTransaction=function(){return this.transactionState===st?(this.transactionCount=0,this.transactionCount):(this.transactionCount-=1,this.transactionCount<1?(this.transactionCount=0,this.setTransactionState(st)):this.transactionCount)},t.prototype.getTransactionState=function(){return this.transactionState},t.prototype.executeAsync=function(t,n){return i(this,void 0,void 0,(function(){var e;return r(this,(function(o){switch(o.label){case 0:if("function"!=typeof t)throw new Error("modalManager.ts line 482: not function");this.startTransaction(),o.label=1;case 1:return o.trys.push([1,3,4,5]),[4,t(n)];case 2:return[2,o.sent()];case 3:if((e=o.sent())instanceof Error)throw e;if("string"==typeof e)throw new Error(e);throw new Error("modalManager.ts line 500: not error");case 4:return this.endTransaction(),[7];case 5:return[2]}}))}))},t.prototype.executeWithTransaction=function(t,n){return i(this,void 0,void 0,(function(){return r(this,(function(e){return this.transactionState!==st?[2,!1]:[2,this.executeAsync(t,n)]}))}))},t.prototype.subscribe=function(t){return this.listeners.push(t),this},t.prototype.unsubscribe=function(t){this.listeners=this.listeners.filter((function(n){return n!==t}))},t.prototype.notify=function(){var t=this;this.setModalManagerState(),this.listeners.forEach((function(n){return n(t.modalManagerState)}))},t.prototype.getState=function(){return this.modalManagerState},t.prototype.getModalStack=function(){return this.modalStack},t.prototype.createModal=function(t){var n=t.id,o=t.options,i=t.name,r=t.modalKey,a=t.component,s=this.createModalCloser(n,o.duration),c=o.middleware?o.middleware:xt,l=e(e({stateResponsiveComponent:this.stateResponsiveComponent},o),{action:o.action,closeModal:s,middleware:c}),u=new Ct({id:n,name:i,modalKey:r,component:a,options:l},this);return u.setBreakPoint(this.breakPoint),u},t.prototype.filterModalByName=function(t){return Array.isArray(t)?this.modalStack=this.modalStack.filter((function(n){return!t.includes(n.name)})):this.modalStack=this.modalStack.filter((function(n){return n.name!==t})),this},t.prototype.pushModal=function(t){var n,e=this;n=Array.isArray(t)?t.map((function(t){return e.createModal(t)})):[this.createModal(t)],this.modalStack=a(a([],this.modalStack,!0),n,!0),this.notify()},t.prototype.popModal=function(t){return 0===this.modalStack.length?(this.currentId=0,this):void 0===t?(this.modalStack=this.modalStack.slice(0,-1),this):t===mt.clear?(this.clearModalStack(),this):(this.filterModalByName(t),this)},t.prototype.clearModalStack=function(){return this.modalStack=[],this.currentId=0,this},t.prototype.getCurrentModalId=function(){return 0===this.modalStack.length?0:this.modalStack[this.modalStack.length-1].id},t.prototype.action=function(t,n){return i(this,void 0,void 0,(function(){var e,o;return r(this,(function(i){return e=t||this.getCurrentModalId(),(o=this.modalStack.filter((function(t){return e===t.id}))[0])?[2,o.action(n)]:[2,!1]}))}))},t.prototype.open=function(t,o){void 0===o&&(o={});var i="function"==typeof o?{action:o}:"string"==typeof o?{content:o}:o,r=i.modalKey||null;if(r&&this.modalStack.find((function(t){return t.modalKey===r})))return 0;if("string"==typeof t){var a=this.getModalComponentSeed(t);if(void 0===a)return 0;var s=a.component,c=a.defaultOptions;this.currentId+=1;var l={id:this.currentId,modalKey:r,name:t,component:s,options:e(e({},c),i)};return this.setZIndex(i.zIndex),this.pushModal(l),this.currentId}return"function"==typeof t?(this.currentId+=1,this.setZIndex(i.zIndex),this.pushModal({id:this.currentId,modalKey:r,name:"unknown",component:t,options:e({transitionOptions:this.modalTransition,duration:this.modalDuration},i)}),this.currentId):n.isValidElement(t)?(this.currentId+=1,this.setZIndex(i.zIndex),this.pushModal({id:this.currentId,modalKey:r,name:"unknown",component:function(){return t},options:e({transitionOptions:this.modalTransition,duration:this.modalDuration},i)}),this.currentId):0},t.prototype.remove=function(t){return"number"==typeof t?(this.modalStack=this.modalStack.filter((function(n){return n.id!==t})),this.resetZIndex(),this.notify(),this.getCurrentModalId()):Array.isArray(t)?(this.modalStack=this.modalStack.filter((function(n){return n.id!==t[0]})),this.popModal(t[1]),this.resetZIndex(),this.notify(),this.getCurrentModalId()):(this.popModal(t),this.resetZIndex(),this.notify(),this.getCurrentModalId())},t.prototype.edit=function(t,n){var e=n.zIndex,i=o(n,["zIndex"]),r=this.modalStack.filter((function(n){return n.id===t}))[0];return!!r&&(r.edit(i),e&&this.setZIndex(e),!0)},t.prototype.setBreakPoint=function(t){this.breakPoint=t,this.notify()},t}();function wt(t){return function(){var e=n.useState(!1),o=e[0],i=e[1];return n.useEffect((function(){var n=function(t){var n=t.modalStack;i(n.length>0)};return t.subscribe(n),function(){t.unsubscribe(n)}}),[t]),o}}function Pt(t,n){return e({open:t.open,remove:t.remove,action:t.action},n.reduce((function(n,e){var o=e[0];return n[o]=function(n){return t.open(o,n)},n}),{}))}exports.Modal=E,exports.ModalTemplate=L,exports.generateModal=function(t,n){void 0===t&&(t={}),void 0===n&&(n={});var o=Object.entries(t),i=o.map((function(t){var n=t[0],o=t[1];return e({name:n},o)})),r=new kt(i,n);return{modalManager:r,modalCtrl:Pt(r,o),ModalProvider:k(r),DynamicModal:B(r),useIsOpenModal:wt(r)}},exports.modalCollection=at;