UNPKG

@react-crates/modal

Version:

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

2 lines (1 loc) 45.6 kB
import{jsxs as t,jsx as n,Fragment as e}from"react/jsx-runtime";import{createContext as o,useContext as i,useState as r,useRef as a,useCallback as s,useMemo as c,useEffect as l,forwardRef as u,isValidElement as d}from"react";var p=function(){return p=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},p.apply(this,arguments)};function h(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 m(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 f(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 y(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 v=o(null);function b(){var t=i(v);if(!t)throw new Error("useModalComponentProps must be used within a ModalComponentProvider");return t}var g=new WeakMap,C=new WeakMap,M={},S=0,k=function(t){return t&&(t.host||k(t.parentNode))},w=function(t,n){return n.map((function(n){if(t.contains(n))return n;var e=k(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 x(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=w(n,Array.isArray(t)?t:[t]);M[e]||(M[e]=new WeakMap);var r=M[e],a=[],s=new Set,c=new Set(i),l=function(t){t&&!s.has(t)&&(s.add(t),l(t.parentNode))};i.forEach(l);var u=function(t){t&&!c.has(t)&&Array.prototype.forEach.call(t.children,(function(t){if(s.has(t))u(t);else try{var n=t.getAttribute(o),i=null!==n&&"false"!==n,c=(g.get(t)||0)+1,l=(r.get(t)||0)+1;g.set(t,c),r.set(t,l),a.push(t),1===c&&i&&C.set(t,!0),1===l&&t.setAttribute(e,"true"),i||t.setAttribute(o,"true")}catch(n){console.error("aria-hidden: cannot operate on ",t,n)}}))};return u(n),s.clear(),S++,function(){a.forEach((function(t){var n=g.get(t)-1,i=r.get(t)-1;g.set(t,n),r.set(t,i),n||(C.has(t)||t.removeAttribute(o),C.delete(t)),i||t.removeAttribute(e)})),--S||(g=new WeakMap,g=new WeakMap,C=new WeakMap,M={})}}(o,i,e,"aria-hidden")):function(){return null}}var P=function(e){var o=e.breakPoint,i=e.modal,u=e.isCurrent,d=r(i.state),h=d[0],m=d[1],f=a(null),y=a(null),b=a({first:null,last:null,elements:[],index:0,isComposing:!1}),g=h.component,C=h.componentProps,M=h.backCoverStyle,S=h.modalClassName,k=h.modalStyle,w=h.isActive,P=h.isOpened,O=h.isEscKeyActive,A=h.label,T=h.actionState,_=h.role,I=h.disableFocusHandling,N=s((function(t){P&&y.current&&!y.current.contains(document.activeElement)&&(t.preventDefault(),y.current&&y.current.focus())}),[P]),D=c((function(){return{actionBackCover:function(t){null!==i.options.backCoverConfirm&&0!==t.detail&&i.action(i.options.backCoverConfirm)},actionToEsc:function(t){"Escape"===t.key&&null!==i.options.backCoverConfirm&&O&&O&&i.action(i.options.backCoverConfirm)},disableOutsideFocus:function(t){if(!I&&("Escape"===t.key&&t.preventDefault(),"Tab"===t.key&&!b.current.isComposing&&(t.preventDefault(),y.current)))if(null!==b.current.first&&null!==b.current.last){if(t.target===b.current.first&&t.shiftKey)return b.current.last.focus(),void(b.current=p(p({},b.current),{index:b.current.elements.length-1}));if(t.target===b.current.last&&!t.shiftKey)return b.current.first.focus(),void(b.current=p(p({},b.current),{index:0}));b.current=p(p({},b.current),{index:b.current.index+1});var n=b.current.elements[b.current.index];if(!n)return b.current=p(p({},b.current),{index:0}),void y.current.focus();n.focus()}else y.current.focus()},focusBackCover:function(){y.current&&y.current.focus()},startComposition:function(){b.current.isComposing=!0},endComposition:function(){b.current.isComposing=!1}}}),[]),E=D.actionBackCover,z=D.actionToEsc,K=D.disableOutsideFocus,j=D.focusBackCover,B=D.startComposition,F=D.endComposition,R=s((function(t){if(!P)return t.preventDefault(),void(f.current&&f.current.focus());if(!I){if(t.currentTarget.contains(t.target)&&t.currentTarget!==t.target){var n=b.current.elements.findIndex((function(n){return n===t.target}));if(-1!==n)return void(n!==b.current.index&&(b.current.index=n))}i.onOpenAutoFocus?i.onOpenAutoFocus(t):i.postOpen((function(){b.current.first&&b.current.first.focus()}))}}),[P]);return l((function(){var t=function(t){m(t)};return i.init(),i.subscribe(t),i.componentRef=f.current,function(){i.componentRef=null,i.unsubscribe(t)}}),[]),l((function(){if(i.updateIsCurrent(u),u&&f.current)return x(f.current)}),[u]),l((function(){y.current&&(b.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}(y.current)),u&&P&&y.current&&!y.current.contains(document.activeElement)&&y.current&&y.current.focus()}),[P,T,g]),l((function(){i.setBreakPoint(o)}),[o]),t("div",p({tabIndex:-1,ref:f,"aria-label":A,"aria-labelledby":A,role:_,"aria-hidden":u?"false":"true","aria-modal":"true",className:"modalWrapper_rm",onFocus:N,onKeyDown:K},{children:[n("button",{className:"closeModalCover_rm ".concat(w?"":"close_rm"),style:M,type:"button",onClick:E,onFocus:j}),n("div",p({className:"modalContentContainer_rm"},{children:n("div",p({tabIndex:-1,ref:y,className:"modalContent_rm ".concat(S||""),style:k,onKeyUp:z,onFocus:R,onCompositionStart:B,onCompositionEnd:F},{children:n(v.Provider,p({value:C},{children:n(g,p({},C))}))}))}))]}))};function O(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))}}O(".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 A="",T="",_="",I="",N=function(o){var i=o.modalManager,c=o.disableInteraction,u=void 0===c||c,d=o.children,h=r(i.getState()),m=h[0],f=m.modalStack,y=m.isOpen,v=m.transactionState,b=m.breakPoint,g=m.currentModalId,C=m.zIndex,M=h[1],S=a(null);l((function(){i.subscribe(M);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(M),i.remove("clear"),document.documentElement.style.setProperty("--vh",t),window.removeEventListener("resize",n)}}),[]),l((function(){return y&&u?(A=document.body.style.overflow,T=document.body.style.height,_=document.body.style.width,I=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=A,document.body.style.height=T,document.body.style.width=_,document.body.style.pointerEvents=I,A="",T="",_="",I=""}):u?(document.body.style.overflow=A,document.body.style.height=T,document.body.style.width=_,document.body.style.pointerEvents=I,function(){A="",T="",_="",I=""}):void 0}),[y]);var k=s((function(t){S.current&&S.current.contains(document.activeElement)||t.preventDefault()}),[v]);l((function(){if(g>0){var t=f[f.length-1].componentRef;if(t)return void t.focus();S.current&&S.current.focus()}}),[g]);var w={isOpen:y,zIndex:C,modalStack:f,breakPoint:b,transactionState:v,currentModalId:g,onKeyDown:k,ref:S};return d?t(e,{children:[d,n(D,p({},w))]}):n(D,p({},w))},D=u((function(t,e){var o=t.isOpen,i=t.zIndex,r=t.modalStack,a=t.breakPoint,s=t.currentModalId,c=t.onKeyDown;return n("div",p({ref:e,tabIndex:-1,className:"modalProvider_rm ".concat(o?"open_rm":""),style:{zIndex:i},onKeyDown:c},{children:n("div",p({style:{width:"100%",height:"100%",overflow:"hidden",pointerEvents:"none"}},{children:r.map((function(t){return n(P,{breakPoint:a,modal:t,isCurrent:t.id===s},t.id)}))}))}))}));function E(t){return function(e){return n(N,p({modalManager:t},e))}}var z=function(t){var e=t.as,o=t.children,i=h(t,["as","children"]),r=b().title;return r||o?n(e||"h2",p({},i,{children:r||o})):null},K=function(t){var e=t.as,o=t.children,i=h(t,["as","children"]),r=b().subTitle;return r||o?n(e||"h3",p({},i,{children:r||o})):null};z.displayName="Modal.Title",K.displayNmae="Modal.Title.Sub",z.Sub=K;var j=function(t){var e=t.as,o=t.children,i=h(t,["as","children"]),r=b().content;return r||o?n(e||"div",p({},i,{children:r||o})):null},B=function(t){var e=t.as,o=t.children,i=h(t,["as","children"]),r=b().subContent;return r||o?n(e||"div",p({},i,{children:r||o})):null};j.displayName="Modal.Content",B.displayName="Modal.Content.Sub",j.Sub=B;var F=function(t){var e=t.onClick,o=t.children,i=t.confirmType,r=h(t,["onClick","children","confirmType"]),a=b(),s=function(t,n,e){var o=n.confirmContent,i=n.cancelContent,r=n.customActionContent;return t||(e?!0===e?o:r:i)}(o,a,i);return s?n("button",p({},r,{onClick:function(t){e&&e(t),a.action(i)},type:"button"},{children:s})):null},R=u((function(t,e){var o=t.onClick,i=t.children,r=t.type,a=void 0===r?"button":r,s=h(t,["onClick","children","type"]),c=b(),l=c.action,u=c.confirmContent;return n("button",p({ref:e,onClick:function(t){o&&o(t),l(!0)},type:a},s,{children:u||i||"확인"}))})),Z=u((function(t,e){var o=t.onClick,i=t.children,r=t.type,a=void 0===r?"button":r,s=h(t,["onClick","children","type"]),c=b(),l=c.action,u=c.cancelContent;return n("button",p({ref:e,onClick:function(t){o&&o(t),l(!1)},type:a},s,{children:u||i||"취소"}))})),H=u((function(t,e){var o=t.onClick,i=t.children,r=t.confirmType,a=t.type,s=void 0===a?"button":a,c=h(t,["onClick","children","confirmType","type"]),l=b(),u=l.action,d=l.customActionContent;return n("button",p({ref:e,onClick:function(t){o&&o(t),u(r)},type:s},c,{children:d||i||"커스텀"}))}));F.displayName="Modal.Action",R.displayName="Modal.Action.Confirm",Z.displayName="Modal.Action.Cancel",H.displayName="Modal.Action.Custom",F.Confirm=R,F.Cancel=Z,F.Custom=H;var W={Title:z,Content:j,Action:F},L=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,p({component:function(){return t.element}},this.options))},t.prototype.setElement=function(t){return d(t)&&(this.element=t),this.editModal(),this},t.prototype.setOptions=function(t){var n=this;void 0===t&&(t={});return this.options=p(p({},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}(),q=o(null);function U(){var t=i(q);if(!t)throw Error("useDynamicModal must be used within a DynamicModal");return t}var G=function(t){var e=t.onClick,o=h(t,["onClick"]),i=U(),r=s((function(t){e&&e(t),i.open()}),[i,e]);return n("button",p({"aria-haspopup":"dialog",onClick:r},o))},V=function(t){var n=t.children,e=U();return l((function(){e.setElement(n)}),[n]),null},J=function(t){var e=t.modalManager,o=t.options,i=t.children,r=c((function(){return new L(e)}),[e]);return l((function(){r.setOptions(o)}),[o]),n(q.Provider,p({value:r},{children:i}))},Q=function(t){function e(e){var o=e.children,i=h(e,["children"]);return n(J,p({modalManager:t,options:i},{children:o}))}return e.displayName="DynamicModal",e.Trigger=G,e.Element=V,e.Action=W.Action,e};G.displayName="DynamicModal.Trigger",V.displayName="DynamicModal.Element";O(".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 X=function(t){var e=t.children;return n("div",p({className:"modal-template-header-rm"},{children:e}))};X.displayName="ModalTemplate.Header";var Y=function(t){var e=t.children;return n("div",p({className:"modal-template-main-rm"},{children:e}))};Y.displayName="ModalTemplate.Main";var $=function(t){var e=t.children;return n("div",p({className:"modal-template-footer-rm"},{children:e}))};$.displayName="ModalTemplate.Footer";var tt=function(t){var e=t.className,o=t.children;return n("div",p({className:"modal-template-rm ".concat(e||"")},{children:o}))};tt.Header=X,tt.Main=Y,tt.Footer=$;var nt=function(e){var o=e.currentPosition;return t(tt,p({className:"modal-template-bg-rm ".concat("bottom"===o?"bottom":"")},{children:[t(tt.Header,{children:[n(W.Title,p({className:"modal-collection-title-rm"},{children:"Alert"})),n(W.Title.Sub,{className:"modal-collection-sub-title-rm"})]}),t(tt.Main,{children:[n(W.Content,{className:"modal-collection-content-rm"}),n(W.Content.Sub,{className:"modal-collection-sub-content-rm"})]}),n(tt.Footer,{children:n(W.Action.Confirm,p({className:"modal-collection-action-rm modal-collection-confirm-rm"},{children:"Confirm"}))})]}))};nt.displayName="ModalCollection.Alert";var et=function(e){var o=e.currentPosition;return t(tt,p({className:"modal-template-bg-rm ".concat("bottom"===o?"bottom":"")},{children:[t(tt.Header,{children:[n(W.Title,p({className:"modal-collection-title-rm"},{children:"Confirm"})),n(W.Title.Sub,{className:"modal-collection-sub-title-rm"})]}),t(tt.Main,{children:[n(W.Content,{className:"modal-collection-content-rm"}),n(W.Content.Sub,{className:"modal-collection-sub-content-rm"})]}),t(tt.Footer,{children:[n(W.Action.Cancel,p({className:"modal-collection-action-rm modal-collection-cancel-rm"},{children:"Cancel"})),n(W.Action.Confirm,p({className:"modal-collection-action-rm modal-collection-confirm-rm"},{children:"Confirm"}))]})]}))};et.displayName="ModalCollection.Confirm";var ot=function(e){var o=e.action,i=e.currentPosition,a=r(""),s=a[0],c=a[1];return t(tt,p({className:"modal-template-bg-rm ".concat("bottom"===i?"bottom":"")},{children:[t(tt.Header,{children:[n(W.Title,p({className:"modal-collection-title-rm"},{children:"Prompt"})),n(W.Title.Sub,{className:"modal-collection-sub-title-rm"})]}),t(tt.Main,{children:[n(W.Content,{className:"modal-collection-content-rm"}),n(W.Content.Sub,{className:"modal-collection-sub-content-rm"}),n("div",p({className:"modal-collection-prompt-rm"},{children:n("input",{onChange:function(t){c(t.target.value)},onKeyUp:function(t){"Enter"===t.key&&(t.preventDefault(),o(s))},className:"modal-collection-prompt-input-rm"})}))]}),t(tt.Footer,{children:[n(W.Action.Cancel,p({className:"modal-collection-action-rm modal-collection-cancel-rm"},{children:"Cancel"})),n(W.Action.Custom,p({className:"modal-collection-action-rm modal-collection-confirm-rm",confirmType:s},{children:"Confirm"}))]})]}))};ot.displayName="ModalCollection.Prompt";var it,rt,at,st,ct,lt,ut,dt,pt,ht,mt,ft,yt={confirm:{component:et,defaultOptions:{backCoverConfirm:!1,escKeyActive:!0,role:"dialog",label:"confirm"}},alert:{component:nt,defaultOptions:{backCoverConfirm:!0,escKeyActive:!0,role:"alertdialog",label:"alert"}},prompt:{component:ot,defaultOptions:{backCoverConfirm:void 0,escKeyActive:!0,role:"dialog",label:"prompt"}}},vt="idle",bt="active",gt={open:"open",active:"active",close:"close"};Object.values(gt);var Ct="initial",Mt="pending",St="success",kt="error",wt={clear:"clear",unknown:"unknown",open:"open",close:"close",edit:"edit",remove:"remove",action:"action"},xt={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)"},Pt={default:"default",backCover:"backCover",center:"center",top:"top",bottom:"bottom",left:"left",right:"right",leftTop:"leftTop",leftBottom:"leftBottom",rightTop:"rightTop",rightBottom:"rightBottom"},Ot=((it={})[Pt.default]=((rt={})[gt.open]={opacity:0},rt[gt.active]={opacity:1},rt[gt.close]={opacity:0},rt),it[Pt.center]=((at={})[gt.open]={left:"50%",top:"50%",transform:"translate(-50%, -50%) scale(0.95)"},at[gt.active]={left:"50%",top:"50%",transform:"translate(-50%, -50%) scale(1)"},at[gt.close]={left:"50%",top:"50%",transform:"translate(-50%, -50%) scale(0.95)"},at),it[Pt.bottom]=((st={})[gt.open]={left:"50%",top:"100%",transform:"translate(-50%, 0)"},st[gt.active]={left:"50%",top:"100%",transform:"translate(-50%, -100%)"},st[gt.close]={left:"50%",top:"100%",transform:"translate(-50%, 0)"},st),it[Pt.top]=((ct={})[gt.open]={left:"50%",top:"0",transform:"translate(-50%, -100%)"},ct[gt.active]={left:"50%",top:"0",transform:"translate(-50%, 0)"},ct[gt.close]={left:"50%",top:"0",transform:"translate(-50%, -100%)"},ct),it[Pt.left]=((lt={})[gt.open]={left:"0",top:"50%",transform:"translate(-100%, -50%)"},lt[gt.active]={left:"0",top:"50%",transform:"translate(0, -50%)"},lt[gt.close]={left:"0",top:"50%",transform:"translate(-100%, -50%)"},lt),it[Pt.right]=((ut={})[gt.open]={left:"100%",top:"50%",transform:"translate(0, -50%)"},ut[gt.active]={left:"100%",top:"50%",transform:"translate(-100%, -50%)"},ut[gt.close]={left:"100%",top:"50%",transform:"translate(0, -50%)"},ut),it[Pt.leftTop]=((dt={})[gt.open]={left:"0",top:"0",transform:"translate(-100%, -100%) scale(0)"},dt[gt.active]={left:"0",top:"0",transform:"translate(0, 0) scale(1)"},dt[gt.close]={left:"0",top:"0",transform:"translate(-100%, -100%) scale(0)"},dt),it[Pt.leftBottom]=((pt={})[gt.open]={left:"0",top:"100%",transform:"translate(-100%, 0) scale(0)"},pt[gt.active]={left:"0",top:"100%",transform:"translate(0, -100%) scale(1)"},pt[gt.close]={left:"0",top:"100%",transform:"translate(-100%, 0) scale(0)"},pt),it[Pt.rightTop]=((ht={})[gt.open]={left:"100%",top:"0",transform:"translate(0, -100%) scale(0)"},ht[gt.active]={left:"100%",top:"0",transform:"translate(-100%, 0) scale(1)"},ht[gt.close]={left:"100%",top:"0",transform:"translate(0, -100%) scale(0)"},ht),it[Pt.rightBottom]=((mt={})[gt.open]={left:"100%",top:"100%",transform:"translate(0, 0) scale(0)"},mt[gt.active]={left:"100%",top:"100%",transform:"translate(-100%, -100%) scale(1)"},mt[gt.close]={left:"100%",top:"100%",transform:"translate(0, 0) scale(0)"},mt),it[Pt.backCover]=((ft={})[gt.open]={top:"0",left:"0",background:"rgb(0, 0, 0)",opacity:0},ft[gt.active]={top:"0",left:"0",background:"rgb(0, 0, 0)",opacity:.5},ft[gt.close]={top:"0",left:"0",background:"rgb(0, 0, 0)",opacity:0},ft),it);function At(t){return void 0===t&&(t=0),new Promise((function(n){setTimeout((function(){n(!0)}),Math.max(t,0))}))}var Tt,_t=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=gt.open,this.actionState=Ct,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=Pt.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,e=n.title,o=n.subTitle,i=n.content,r=n.subContent,a=n.confirmContent,s=n.cancelContent,c=n.customActionContent,l=n.payload,u={title:e,subTitle:o,content:i,subContent:r,confirmContent:a,cancelContent:s,customActionContent:c,isEscKeyActive:this.escKeyActive,payload:l,action:this.action,actionState:this.actionState,currentPosition:this._currentPosition,lifecycleState:this.lifecycleState};this.componentProps=p(p({},u),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,e=h(t,["component"]);n&&(this.initialComponent=n,this._options.stateResponsiveComponent&&"initial"!==this.actionState||(this.currentComponent=n)),this._options=p(p({},this._options),e),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 m(this,void 0,void 0,(function(){var n=this;return f(this,(function(e){switch(e.label){case 0:return this.isInitial?[2]:(this.isInitial=!0,setTimeout((function(){n.active()}),0),[4,this.manager.executeAsync(At,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===gt.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 m(this,void 0,void 0,(function(){var e=this;return f(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=Ct,this.changeState(),this},t.prototype.pending=function(t){return this.actionState=Mt,this.changeState(t),this},t.prototype.success=function(t){return this.actionState=St,this.changeState(t),this},t.prototype.error=function(t){return this.actionState=kt,this.changeState(t),this},t.prototype.end=function(t){return this.actionState=Ct,this.changeState(t),this},t.prototype.getModalStyle=function(){var t=this.options,n=t.position,e=t.duration,o=t.transitionOptions,i="function"==typeof n?n(this.breakPoint):n,r=this.lifecycleState===gt.active,a=this.manager.getCurrentModalPosition(this.lifecycleState,i),s=a[0],c=a[1],l=s.className,u=h(s,["className"]),d=this.manager.getModalTransition(e,o);return this._currentPosition!==c&&(this._currentPosition=c,this.setComponentProps()),{className:l,style:p(p({pointerEvents:r&&this.isOpened?"auto":"none"},d),u)}},t.prototype.getBackCoverStyle=function(){var t=this,n=this.options,e=n.backCoverColor,o=n.backCoverOpacity,i=n.backCoverConfirm,r=n.duration,a=n.transitionOptions,s=this.lifecycleState===gt.active,c=this.manager.getCurrentModalPosition(this.lifecycleState,Pt.backCover)[0],l=c.background,u=c.opacity,d=h(c,["background","opacity"]),m=this.manager.getModalTransition(r,a),f=t.manager.getTransactionState()===vt&&s&&null!==i?"pointer":"default";return p(p(p({cursor:f},m),d),{background:void 0!==e&&s?e:l,opacity:void 0!==o&&s?o:u,pointerEvents:s&&this.isOpened?"auto":"none"})},t.prototype.setBreakPoint=function(t){this.breakPoint!==t&&(this.breakPoint=t,this.notify())},t}();function It(t){var n=t.modalState;return m(this,void 0,void 0,(function(){return f(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,At(n.closeDelayDuration)]:[3,3];case 2:t.sent(),t.label=3;case 3:return n.isAwaitingConfirm?[2,!1]:[2,n.close()]}}))}))}var Nt=((Tt={})[gt.open]=0,Tt[gt.active]=1,Tt[gt.close]=2,Tt);function Dt(t,n){if("string"!=typeof t)return Pt.center;var e=function(t){var n=t.split("-");if(n.length<1)return Array.from({length:3}).map((function(t){return Pt.center}));var e=n.length-1;return Array.from({length:3}).map((function(t,o){return n[o]||n[e]}))}(t);return e[Nt[n]]}Object.getPrototypeOf((function(){return m(this,void 0,void 0,(function(){return f(this,(function(t){return[2]}))}))})).constructor;var Et=function(){function t(t,n){void 0===t&&(t=[]),void 0===n&&(n={}),this.currentId=0,this.transactionCount=0,this.transactionState=vt,this.modalStack=[],this.listeners=[],this.modalComponentSeedMap=new Map,this.modalPositionMap=new Map,this.modalTransition=xt,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,e=t.transition,o=t.duration,i=t.stateResponsiveComponent,r=t.zIndex,a=p(p({},Ot),n);this.stateResponsiveComponent=i||!1,this.setModalPosition(a),this.setModalTransition(e),this.setModalDuration(o),r&&(this.originZindex=r,this.zIndex=r)},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,e=t.name,o=t.component,i=t.defaultOptions;if(void 0!==o&&!Object.prototype.hasOwnProperty.call(wt,e)){var r=this.modalComponentSeedMap.get(e);if(!r||!(null===(n=r.defaultOptions)||void 0===n?void 0:n.required)){var a=p(p({},t),{defaultOptions:p(p({},i),{duration:(null==i?void 0:i.duration)||this.modalDuration})});this.modalComponentSeedMap.set(e,a)}}},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,i){return m(e,void 0,void 0,(function(){return f(this,(function(e){switch(e.label){case 0:return n?[4,At(n)]:[3,2];case 1:e.sent(),e.label=2;case 2:return o?[4,o(i)]:[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=p(p({},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 p(p({},this.modalTransition),n);var e="".concat(t,"ms");return p(p(p({},this.modalTransition),n),{transitionDuration:e})},t.prototype.getModalPosition=function(t){void 0===t&&(t=Pt.center);var n=this.modalPositionMap.get(t);if(!n){var e=this.modalPositionMap.get(Pt.center);return null!=e?e:Ot.center}return n},t.prototype.getModalPositionMap=function(){return this.modalPositionMap},t.prototype.getCurrentModalPosition=function(t,n){void 0===n&&(n=Pt.center);var e=Dt(n,t),o=this.getModalPosition(Pt.default),i=o.open,r=o.active,a=o.close,s=this.getModalPosition(e),c=s.open,l=s.active,u=s.close;return t===gt.open?[p(p({},i),c),e]:t===gt.active?[p(p({},r),l),e]:[p(p({},a),u),e]},t.prototype.setTransactionState=function(t){return this.transactionState=t,this.notify(),this.transactionCount},t.prototype.startTransaction=function(){return this.transactionCount+=1,this.setTransactionState(bt)},t.prototype.endTransaction=function(){return this.transactionState===vt?(this.transactionCount=0,this.transactionCount):(this.transactionCount-=1,this.transactionCount<1?(this.transactionCount=0,this.setTransactionState(vt)):this.transactionCount)},t.prototype.getTransactionState=function(){return this.transactionState},t.prototype.executeAsync=function(t,n){return m(this,void 0,void 0,(function(){var e;return f(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 m(this,void 0,void 0,(function(){return f(this,(function(e){return this.transactionState!==vt?[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,e=t.options,o=t.name,i=t.modalKey,r=t.component,a=this.createModalCloser(n,e.duration),s=e.middleware?e.middleware:It,c=p(p({stateResponsiveComponent:this.stateResponsiveComponent},e),{action:e.action,closeModal:a,middleware:s}),l=new _t({id:n,name:o,modalKey:i,component:r,options:c},this);return l.setBreakPoint(this.breakPoint),l},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=y(y([],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===wt.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 m(this,void 0,void 0,(function(){var e,o;return f(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,n){void 0===n&&(n={});var e="function"==typeof n?{action:n}:"string"==typeof n?{content:n}:n,o=e.modalKey||null;if(o&&this.modalStack.find((function(t){return t.modalKey===o})))return 0;if("string"==typeof t){var i=this.getModalComponentSeed(t);if(void 0===i)return 0;var r=i.component,a=i.defaultOptions;this.currentId+=1;var s={id:this.currentId,modalKey:o,name:t,component:r,options:p(p({},a),e)};return this.setZIndex(e.zIndex),this.pushModal(s),this.currentId}return"function"==typeof t?(this.currentId+=1,this.setZIndex(e.zIndex),this.pushModal({id:this.currentId,modalKey:o,name:"unknown",component:t,options:p({transitionOptions:this.modalTransition,duration:this.modalDuration},e)}),this.currentId):d(t)?(this.currentId+=1,this.setZIndex(e.zIndex),this.pushModal({id:this.currentId,modalKey:o,name:"unknown",component:function(){return t},options:p({transitionOptions:this.modalTransition,duration:this.modalDuration},e)}),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,o=h(n,["zIndex"]),i=this.modalStack.filter((function(n){return n.id===t}))[0];return!!i&&(i.edit(o),e&&this.setZIndex(e),!0)},t.prototype.setBreakPoint=function(t){this.breakPoint=t,this.notify()},t}();function zt(t){return function(){var n=r(!1),e=n[0],o=n[1];return l((function(){var n=function(t){var n=t.modalStack;o(n.length>0)};return t.subscribe(n),function(){t.unsubscribe(n)}}),[t]),e}}function Kt(t,n){return p({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}),{}))}function jt(t,n){void 0===t&&(t={}),void 0===n&&(n={});var e=Object.entries(t),o=e.map((function(t){var n=t[0],e=t[1];return p({name:n},e)})),i=new Et(o,n);return{modalManager:i,modalCtrl:Kt(i,e),ModalProvider:E(i),DynamicModal:Q(i),useIsOpenModal:zt(i)}}export{W as Modal,tt as ModalTemplate,jt as generateModal,yt as modalCollection};