this.BX=this.BX||{};(function(e,r){"use strict";function t(e,r,t){n(e,r);r.set(e,t)}function n(e,r){if(r.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}var i=new WeakMap;var a=new WeakMap;var c=function(){function e(r,n){babelHelpers.classCallCheck(this,e);t(this,i,{writable:true,value:""});t(this,a,{writable:true,value:{}});babelHelpers.classPrivateFieldSet(this,i,r);babelHelpers.classPrivateFieldSet(this,a,n)}babelHelpers.createClass(e,[{key:"getCurrency",value:function e(){return babelHelpers.classPrivateFieldGet(this,i)}},{key:"getFormat",value:function e(){return babelHelpers.classPrivateFieldGet(this,a)}},{key:"setFormat",value:function e(r){babelHelpers.classPrivateFieldSet(this,a,r)}}]);return e}();function s(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function u(e){for(var r=1;r-1&&!i){return}var s=u(u({},this.defaultFormat),n);if(a===-1){this.currencies.push(new c(t,s))}else{this.currencies[a].setFormat(s)}}},{key:"setCurrencies",value:function e(t,n){if(r.Type.isArray(t)){for(var i=0;i-1?this.getCurrencyList()[t].getFormat():false}},{key:"getCurrencyIndex",value:function e(r){var t=this.getCurrencyList();for(var n=0;n-1){this.currencies=BX.util.deleteFromArray(this.currencies,t)}}},{key:"clean",value:function e(){this.currencies=[]}},{key:"initRegion",value:function e(){if(this.region===""){var t=r.Extension.getSettings("currency.currency-core");this.region=t.get("region")||"-"}}},{key:"checkInrFormat",value:function e(r){this.initRegion();return r==="INR"&&(this.region==="hi"||this.region==="in")}},{key:"currencyFormat",value:function e(t,n,i){var a="";var c=this.getCurrencyFormat(n);if(r.Type.isObject(c)){t=Number(t);var s=c.DECIMALS;var u=c.SEPARATOR||c.THOUSANDS_SEP;if(c.HIDE_ZERO==="Y"&&r.Type.isInteger(t)){s=0}if(this.checkInrFormat(n)){a=this.numberFormatInr(t,s,c.DEC_POINT,u)}else{a=BX.util.number_format(t,s,c.DEC_POINT,u)}if(i){a=c.FORMAT_STRING.replace(/(^|[^&])#/,"$1"+a)}}return a}},{key:"getPriceControl",value:function e(t,n){var i="";var a=this.getCurrencyFormat(n);if(r.Type.isObject(a)){i=a.FORMAT_STRING.replace(/(^|[^&])#/,"$1"+t.outerHTML)}return i}},{key:"loadCurrencyFormat",value:function e(r){var t=this;return new Promise((function(e,n){var i=t.getCurrencyIndex(r);if(i>-1){e(t.getCurrencyList()[i].getFormat())}else{BX.ajax.runAction("currency.format.get",{data:{currencyId:r}}).then((function(n){var i=n.data;t.setCurrencyFormat(r,i);e(i)}))["catch"]((function(e){n(e.errors)}))}}))}},{key:"numberFormatInr",value:function e(r,t,n,i){if(Number.isNaN(t)||t<0){t=2}n=n||",";i=i||".";var a="";r=(+r||0).toFixed(t);if(r<0){a="-";r=-r}var c=parseInt(r,10).toString();var s="";var u;if(c.length<=3){u=c}else{var l=i+c.slice(-3);var o=c.slice(0,-3);var y=o.length>2?o.length%2:0;s=y?o.slice(0,y)+i:"";u=o.slice(y).replace(/(\d{2})(?=\d)/g,"$1"+i)+l}var f=t?n+Math.abs(r-c).toFixed(t).replace(/-/,"0").slice(2):"";return a+s+u+f}}]);return e}();babelHelpers.defineProperty(l,"currencies",[]);babelHelpers.defineProperty(l,"defaultFormat",{FORMAT_STRING:"#",DEC_POINT:".",THOUSANDS_SEP:" ",DECIMALS:2,HIDE_ZERO:"N"});babelHelpers.defineProperty(l,"region","");r.Reflection.namespace("BX.Currency").Core=l;e.CurrencyCore=l})(this.BX.Currency=this.BX.Currency||{},BX); //# sourceMappingURL=currency-core.bundle.map.js