!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("openstack-uicore-foundation",[],t):"object"==typeof exports?exports["openstack-uicore-foundation"]=t():e["openstack-uicore-foundation"]=t()}(this,(()=>(()=>{"use strict";var e={9299:(e,t,o)=>{o.d(t,{default:()=>C});var n=o(2015),r=o.n(n),i=o(9825),l=o.n(i),c=o(8619),a=o(8177),u=o.n(a),p=o(1519),s=o.n(p);const f=require("@mui/icons-material/Info");var m=o.n(f);const d=require("@mui/icons-material/Warning");var y=o.n(d);const x={warning:r().createElement(y(),{color:"warning"}),success:r().createElement(u(),{color:"success"}),error:r().createElement(s(),{color:"error"}),info:r().createElement(m(),{color:"info"})},g=({open:e,title:t,text:o,iconType:n="",onConfirm:i,onCancel:l,confirmButtonText:a="Confirm",confirmButtonColor:u="primary",cancelButtonText:p="Cancel",cancelButtonColor:s="primary"})=>r().createElement(c.Dialog,{open:e,onClose:l},r().createElement(c.DialogTitle,{sx:{p:2},component:"div"},r().createElement(c.Typography,{variant:"h5"},t)),r().createElement(c.Divider,null),r().createElement(c.DialogContent,{sx:{p:2}},r().createElement("div",{style:{display:"flex",alignItems:"center"}},x[n]&&r().createElement("div",{style:{marginRight:10}},x[n]),r().createElement(c.Typography,{variant:"body1"},o))),r().createElement(c.Divider,{sx:{margin:"10px 0px 10px 0px"}}),r().createElement(c.DialogActions,null,r().createElement(c.Button,{fullWidth:!0,onClick:l,color:s,variant:"outlined",sx:{whiteSpace:"nowrap",minWidth:100}},p),r().createElement(c.Button,{fullWidth:!0,onClick:i,color:u,variant:"contained",sx:{whiteSpace:"nowrap",minWidth:100}},a)));g.propTypes={open:l().bool,title:l().string.isRequired,text:l().string.isRequired,iconType:l().string,onConfirm:l().func.isRequired,onCancel:l().func.isRequired,confirmButtonText:l().string,confirmButtonColor:l().string,cancelButtonText:l().string,cancelButtonColor:l().string},g.defaultProps={open:!1,iconType:"warning",confirmButtonText:"Confirm",confirmButtonColor:"primary",cancelButtonText:"Cancel",cancelButtonColor:"default"};const C=g},1116:e=>{e.exports=require("@babel/runtime/helpers/defineProperty")},8177:e=>{e.exports=require("@mui/icons-material/CheckCircle")},1519:e=>{e.exports=require("@mui/icons-material/Error")},8619:e=>{e.exports=require("@mui/material")},9825:e=>{e.exports=require("prop-types")},2015:e=>{e.exports=require("react")}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,o),i.exports}(()=>{o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t}})(),(()=>{o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}})(),(()=>{o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}})();var n={};o.r(n),o.d(n,{GlobalConfirmDialog:()=>m,default:()=>d});var r=o(1116),i=o.n(r),l=o(2015),c=o.n(l),a=o(9299);function u(e,t){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),o.push.apply(o,n)}return o}function p(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?u(Object(o),!0).forEach((function(t){i()(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):u(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}const s="__oif_confirm_dialog_bridge__",f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:{},m=()=>{const[e,t]=(0,l.useState)(null);(0,l.useEffect)((()=>(f[s]=e=>new Promise((o=>{t(p(p({},e),{},{open:!0,onResolve:o}))})),()=>{f[s]=null})),[]);return e?c().createElement(a.default,{open:e.open,title:e.title,text:e.text,iconType:e.iconType,confirmButtonText:e.confirmButtonText,cancelButtonText:e.cancelButtonText,confirmButtonColor:e.confirmButtonColor,cancelButtonColor:e.cancelButtonColor,onConfirm:()=>{null!=e&&e.onResolve&&e.onResolve(!0),t(null)},onCancel:()=>{null!=e&&e.onResolve&&e.onResolve(!1),t(null)}}):null},d=({title:e,text:t,iconType:o="",confirmButtonText:n="Confirm",cancelButtonText:r="Cancel",confirmButtonColor:i="primary",cancelButtonColor:l="primary"})=>{if(!f[s])throw new Error("[openstack-uicore-foundation] showConfirmDialog: <GlobalConfirmDialog /> is not mounted. Add <GlobalConfirmDialog /> to the root of your app.");return f[s]({title:e,text:t,iconType:o,confirmButtonText:n,cancelButtonText:r,confirmButtonColor:i,cancelButtonColor:l})};return n})()));
//# sourceMappingURL=show-confirm-dialog.js.map