(()=>{function e(e,t){for(var a=0;a<t.length;a++){var i=t[a];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}var t=function(){function t(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),this.template=$("#currency_template").html(),this.totalItem=0,this.deletedItems=[],this.initData(),this.handleForm()}var a,i;return a=t,(i=[{key:"initData",value:function(){var e=this,t=$.parseJSON($("#currencies").html());$.each(t,(function(t,a){var i=e.template.replace(/__id__/gi,a.id).replace(/__position__/gi,a.order).replace(/__isPrefixSymbolChecked__/gi,1==a.is_prefix_symbol?"selected":"").replace(/__notIsPrefixSymbolChecked__/gi,0==a.is_prefix_symbol?"selected":"").replace(/__isDefaultChecked__/gi,1==a.is_default?"checked":"").replace(/__title__/gi,a.title).replace(/__decimals__/gi,a.decimals).replace(/__exchangeRate__/gi,a.exchange_rate).replace(/__symbol__/gi,a.symbol);$(".swatches-container .swatches-list").append(i),e.totalItem++}))}},{key:"addNewAttribute",value:function(){var e=this,t=e.template.replace(/__id__/gi,0).replace(/__position__/gi,e.totalItem).replace(/__isPrefixSymbolChecked__/gi,"").replace(/__notIsPrefixSymbolChecked__/gi,"").replace(/__isDefaultChecked__/gi,0==e.totalItem?"checked":"").replace(/__title__/gi,"").replace(/__decimals__/gi,0).replace(/__exchangeRate__/gi,1).replace(/__symbol__/gi,"");$(".swatches-container .swatches-list").append(t),e.totalItem++}},{key:"exportData",value:function(){var e=[];return $(".swatches-container .swatches-list li").each((function(t,a){var i=$(a);e.push({id:i.data("id"),is_default:i.find("[data-type=is_default] input[type=radio]").is(":checked")?1:0,order:i.index(),title:i.find("[data-type=title] input").val(),symbol:i.find("[data-type=symbol] input").val(),decimals:i.find("[data-type=decimals] input").val(),exchange_rate:i.find("[data-type=exchange_rate] input").val(),is_prefix_symbol:i.find("[data-type=is_prefix_symbol] select").val()})})),e}},{key:"handleForm",value:function(){var e=this;$(".swatches-container .swatches-list").sortable(),$("body").on("submit",".main-setting-form",(function(){var t=e.exportData();$("#currencies").val(JSON.stringify(t)),$("#deleted_currencies").val(JSON.stringify(e.deletedItems))})).on("click",".js-add-new-attribute",(function(t){t.preventDefault(),e.addNewAttribute()})).on("click",".swatches-container .swatches-list li .remove-item a",(function(t){t.preventDefault();var a=$(t.currentTarget).closest("li");e.deletedItems.push(a.data("id")),a.remove()}))}}])&&e(a.prototype,i),Object.defineProperty(a,"prototype",{writable:!1}),t}();$(window).on("load",(function(){new t}))})();
