jQuery(function(a){if("undefined"==typeof wc_country_select_params)return!1;if(a().select2){var b=function(){a("select.country_select:visible, select.state_select:visible").each(function(){a(this).select2({minimumResultsForSearch:10,placeholder:a(this).attr("placeholder"),placeholderOption:"first",width:"element"})})};b(),a("body").bind("country_to_state_changed",function(){b()})}var c=wc_country_select_params.countries.replace(/"/g,'"'),d=a.parseJSON(c);a("select.country_to_state, input.country_to_state").change(function(){var b=a(this).val(),c=a(this).closest("div").find("#billing_state, #shipping_state, #calc_shipping_state"),e=c.parent(),f=c.attr("name"),g=c.attr("id"),h=c.val(),i=c.attr("placeholder");if(d[b])if(a.isEmptyObject(d[b]))c.parent().hide().find(".select2-container").remove(),c.replaceWith(''),a("body").trigger("country_to_state_changed",[b,a(this).closest("div")]);else{var j="",k=d[b];for(var l in k)k.hasOwnProperty(l)&&(j=j+'");c.parent().show(),c.is("input")&&(c.replaceWith(''),c=a(this).closest("div").find("#billing_state, #shipping_state, #calc_shipping_state")),c.html('"+j),c.val(h),a("body").trigger("country_to_state_changed",[b,a(this).closest("div")])}else c.is("select")?(e.show().find(".select2-container").remove(),c.replaceWith(''),a("body").trigger("country_to_state_changed",[b,a(this).closest("div")])):c.is(".hidden")&&(e.show().find(".select2-container").remove(),c.replaceWith(''),a("body").trigger("country_to_state_changed",[b,a(this).closest("div")]));a("body").trigger("country_to_state_changing",[b,a(this).closest("div")])}),a(function(){a(":input.country_to_state").change()})});