text: var mbox=function(){function u(t,e){var n={},o=Object.keys(t),s=Object.keys(e);return o.forEach(function(o){n[o]=t[o]}),s.forEach(function(o){n[o]=e[o]}),n}var p={en:{CANCEL:"Cancel",OK:"OK"},el:{CANCEL:"Ακύρωση",OK:"Εντάξει"},it:{CANCEL:"Annulla",OK:"OK"},de:{CANCEL:"Abbrechen",OK:"OK"},pt:{OK:"Está bem",CANCEL:"cancelar"}},b={global:{options:{inDuration:250,outDuration:250,locale:"en",dismissible:!1,bottom_sheet:!1,fixed_footer:!1,opacity:.5,startingTop:"4%",startingEnd:"10%"}},options:{},set_out_duration:function(o){if(isNaN(o))throw new Error("Speed value must be a number but a "+typeof o+" was given");b.global.options.outDuration=o},set_in_duration:function(o){if(isNaN(o))throw new Error("Speed value must be a number but a "+typeof o+" was given");b.global.options.inDuration=o},set_dismissible:function(o){b.global.options.dismissible=!!o},set_bottom_sheet:function(o){b.global.options.bottom_sheet=o},set_fixed_footer:function(o){b.global.options.fixed_footer=o},set_opacity:function(o){if(null==o)throw new Error("You need to provide opacity");b.global.options.opacity=o},set_starting_top:function(o){b.global.options.startingTop=o},set_starting_end:function(o){b.global.options.startingEnd=o},template:'<div class="modal mbox-wrapper"><div class="modal-content"><h5>$$$_message_$$$</h5>$$$_input_$$$</div><div class="modal-footer">$$$_buttons_$$$</div></div>',set_locale:function(o){b.global.options.locale=o},setLocale:this.set_locale,add_locale:function(o,t){p[o.toLowerCase()]=t},addLocale:this.add_locale,reset_options:function(){b.process_options(b.global.options)},alert:function(){b.reset_options();var o=b.parse_args(arguments),t=o.message,e=o.cb;b.open("alert",t),document.querySelector(".mbox-wrapper .mbox-ok-button").addEventListener("click",function(){b.close(),e&&e()})},confirm:function(){b.reset_options();var o=b.parse_args(arguments),t=o.message,e=o.cb;if(!e)throw new Error("Confirm requires a callback");b.open("confirm",t);var n=document.querySelector(".mbox-wrapper .mbox-ok-button"),s=document.querySelector(".mbox-wrapper .mbox-cancel-button");n.addEventListener("click",function(){b.close(),e(!0)}),s.addEventListener("click",function(){b.close(),e(!1)})},prompt:function(){b.reset_options();var o=b.parse_args(arguments),t=o.message,e=o.cb;if(!e)throw new Error("Prompt requires a callback");b.open("prompt",t);var n=document.querySelector(".mbox-wrapper .mbox-ok-button"),s=document.querySelector(".mbox-wrapper .mbox-cancel-button");n.addEventListener("click",function(){var o=document.querySelector(".mbox-wrapper input").value;b.close(),e(o)}),s.addEventListener("click",function(){b.close(),e(!1)})},custom:function(o){if(b.reset_options(),"object"!=typeof o)throw"Custom box requires argument 1 to be an object";"object"==typeof o.options&&b.process_options(o.options);var t=b.template;if(t=t.replace(/\$\$\$_input_\$\$\$/gi,"<hr />"),!o.buttons||0===o.buttons.length)throw"You must provide at least 1 button";var n="";o.buttons.forEach(function(o,t){var e="mbox-custom-button-"+t;n+=b.gen_button(o.color||"grey lighten-4",o.label||"",e)}),t=(t=t.replace(/\$\$\$_message_\$\$\$/gi,o.message||"")).replace(/\$\$\$_buttons_\$\$\$/gi,n);b.options.open_speed;o.buttons.forEach(function(e,o){var n="mbox-custom-button-"+o;document.body.addEventListener("click",function(o){if(o.target.classList.contains(n)){var t=e.callback;t&&"function"==typeof t?t():b.close()}})});var e=document.createElement("div");e.id="mbox-template-wrapper",e.innerHTML=t,(i=b.options||b.global.options).bottom_sheet&&e.firstChild.classList.add("bottom-sheet"),i.fixed_footer&&e.firstChild.classList.add("modal-fixed-footer"),document.body.append(e);var s=document.querySelector(".modal"),i=b.options,a=u(b.global.options,i);M.Modal.init(s,a).open()},open:function(o,t){console.log("global options"),console.log(b.global.options);var e,n=b.template,s=null;s=b.options.locale?b.options.locale:b.global.options.locale;var i=p[s];switch(o){case"alert":e=b.gen_button("light-blue darken-2",i.OK,"mbox-ok-button"),n=n.replace(/\$\$\$_input_\$\$\$/gi,"<hr />");break;case"confirm":e=b.gen_button("light-blue darken-2",i.OK,"mbox-ok-button"),e+=b.gen_button("grey darken-2",i.CANCEL,"mbox-cancel-button"),n=n.replace(/\$\$\$_input_\$\$\$/gi,"<hr />");break;case"prompt":e=b.gen_button("light-blue darken-2",i.OK,"mbox-ok-button"),e+=b.gen_button("grey darken-2",i.CANCEL,"mbox-cancel-button"),n=n.replace(/\$\$\$_input_\$\$\$/gi,'<input type="text" />')}t&&(n=n.replace(/\$\$\$_message_\$\$\$/gi,t)),e&&(n=n.replace(/\$\$\$_buttons_\$\$\$/gi,e));var a=document.createElement("div");a.innerHTML=n,a.id="mbox-template-wrapper",(l=b.options||b.global.options).bottom_sheet&&a.firstChild.classList.add("bottom-sheet"),l.fixed_footer&&a.firstChild.classList.add("modal-fixed-footer"),document.body.append(a);var r=document.querySelector(".modal"),l=b.options,c=u(b.global.options,l);console.log(c),M.Modal.init(r,c).open(),document.querySelector(".mbox-wrapper .mbox-ok-button").focus()},close:function(){var o=document.querySelector(".modal"),t=M.Modal.getInstance(o);t&&t.close(),console.log(o),o.parentElement.remove();document.querySelectorAll(".mbox-button")},parse_args:function(o){o=[].slice.call(o);var t={message:null,cb:null};return o.forEach(function(o){"string"==typeof o&&(t.message=o),"function"==typeof o&&(t.cb=o),"object"==typeof o&&b.process_options(o)},this),t},process_options:function(t){Object.keys(t).forEach(function(o){b.options[o]=t[o]},this)},gen_button:function(o,t,e){return'&nbsp;<button type="button" class="mbox-button '+e+" waves-effect waves-light btn "+o+'">'+t+"</button>"}};return{alert:b.alert,confirm:b.confirm,prompt:b.prompt,custom:b.custom,add_locale:b.add_locale,set_locale:b.set_locale,close:b.close,set_in_duration:b.set_in_duration,set_out_duration:b.set_out_duration,set_bottom_sheet:b.set_bottom_sheet,set_dismissible:b.set_dismissible,set_fixed_footer:b.set_fixed_footer,set_opacity:b.set_opacity,set_starting_end:b.set_starting_end,set_starting_top:b.set_starting_top}}();