window.OptionsResolver=function(){var o=[],i=[],r={},s={},c={},e={},a={};this.setDefined=function(t){return t&&t.constructor===Array?o=o.concat(t):o.push(t),this},this.getDefinedOptions=function(){return o},this.isDefined=function(t){return-1!==o.indexOf(t)},this.setRequired=function(t){return t&&t.constructor===Array?(i=i.concat(t),o=o.concat(t)):(i.push(t),o.push(t)),this},this.getRequiredOptions=function(){return i},this.isRequired=function(t){return-1!==i.indexOf(t)},this.isMissing=function(t){return!r[t]},this.getMissingOptions=function(){var n=[];return i.forEach(function(t){r[t]||n.push(t)}),n},this.setDefault=function(t,n){return r[t]&&(a[t]=r[t]),r[t]=n,this.setDefined(t),this},this.setDefaults=function(t){if(t&&t.constructor===Object){for(var n in t)this.setDefault(n,t[n]),this.setDefined(n);return this}throw"InvalidParameter: Default values is invalid object"},this.getDefaultValues=function(t){return t?r[t]:r},this.setAllowedTypes=function(t,n){return s[t]=n,this},this.getAllowedTypes=function(t){return t?s[t]:s},this.setAllowedValues=function(t,n){return c[t]=n,this},this.getAllowedValues=function(t){return t?c[t]:c},this.setNormalizer=function(t,n){return e[t]=n,this},this.resolve=function(t){return t=t||{},o=_arrayUnique(o),_checkUndefinedOptions(Object.keys(t)),t=_setOptionsDefault(t),_checkMissingRequiredOptions(t),_checkInvalidOptionsType(t),_checkInvalidOptionsValue(t),t=_normalizerOptionsValue(t)},_checkUndefinedOptions=function(t){var n='"'+o.join('", "')+'"';for(var e in t){var i=t[e];if(-1===o.indexOf(i))throw'UndefinedOptionsException: The option "'+i+'" does not exist. Know options are: '+n}},_checkMissingRequiredOptions=function(t){for(var n in i){var e=i[n];if(!t[e])throw'MissingOptionsException: The required options "'+e+'" is missing'}},_setOptionsDefault=function(o){return Object.keys(r).forEach(function(t,n){if(!o[t]){var e=r[t],i=a[t];o[t]=e&&e.constructor===Function?e(o,i):e}}),o},_checkInvalidOptionsType=function(t){for(var n in s){var e=t[n];switch(s[n].toLowerCase()){case"int":case"integer":"number"==typeof e&&/^\-?\d+$/.test(e)||_throwInvalidOptionsTypeException(n,e,"int");break;case"string":case"str":"string"!=typeof e&&_throwInvalidOptionsTypeException(n,e,"string");break;case"array":case"arr":e&&e.constructor===Array||_throwInvalidOptionsTypeException(n,e,"array");break;case"bool":case"boolean":"boolean"!=typeof e&&_throwInvalidOptionsTypeException(n,e,"boolean");break;case"float":"number"==typeof e&&/^\-?\d+\.\d+$/.test(e)||_throwInvalidOptionsTypeException(n,e,"float");break;case"object":case"obj":"object"==typeof e&&e.constructor===Object||_throwInvalidOptionsTypeException(n,e,"object");break;case"regexp":"object"==typeof e&&e.constructor===RegExp||_throwInvalidOptionsTypeException(n,e,"regexp");break;case"fn":case"func":case"function":"function"==typeof e&&e.constructor===Function||_throwInvalidOptionsTypeException(n,e,"function")}}},_checkInvalidOptionsValue=function(t){for(var n in c){var e=t[n],i=c[n],o=!0,r="";if(i&&i.constructor===Array?(o=0<=i.indexOf(e),r=' Accepted values are: "'+i.join('", "')+'"'):i&&i.constructor===Function?o=i(e):(o=e===i,r=' Accepted value are "'+i+'"'),!o)throw'The option "'+n+'" with value "'+e+'" is invalid.'+r}},_normalizerOptionsValue=function(t){for(var n in e)t[n]=e[n](t,t[n]);return t},_throwInvalidOptionsTypeException=function(t,n,e){throw'InvalidOptionsException: The option "'+t+'" with "'+n+'" is expected to be of type "'+e+'"'},_arrayUnique=function(t){return t.filter(function(t,n,e){return e.indexOf(t)==n})}};