(()=>{"use strict";function t(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function e(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}!function(n,i,o){var a=wp.customize,c="data-customize-setting-link",r={cache:{},init:function(){r.buildFonts(),r.showFonts()},buildFonts:function(){r.cache.fonts="",r.cache.chosen={},n.each(o,(function(t,e){var n="";void 0!==e.disabled&&(n=' disabled="disabled" '),r.cache.fonts+='<option value="'+t+'"'+n+">"+t+"</option>"}))},populateVariants:function(t,e){t.length>0&&void 0!==o[e]&&((t=t.find("select")).html(r.showVariants(o[e].variants)).children("option:first").attr("selected","selected"),t.trigger("change"))},showFonts:function(){n(".chosen-select").each((function(){var t=n(this),e=t.attr(c);r.cache.chosen[e]=n(this),a(e,(function(e){t.on("chosen:ready",(function(){var i=e.get();n(this).html(r.cache.fonts).val(i),setTimeout((function(){t.trigger("chosen:updated")}),200)})),t.on("change",(function(){var t=n(this),e=t.val(),i="#"+t.closest("li").attr("id").replace("family","");r.populateVariants(n(i+"variant"),e)})),t.chosen({search_contains:!0,width:"100%"})}))})),r.showDefaultVariants()},showDefaultVariants:function(){n("[id$=_variant] select").each((function(){var t=n(this),e=t.attr(c),i=e.replace("_variant","_family");a(e,(function(e){if(void 0!==r.cache.chosen[i]&&r.cache.chosen[i].length>0){var n=r.cache.chosen[i].val();n&&t.html(r.showVariants(o[n].variants)).val(e.get())}}))}))},showVariants:function(t){var e="";return e+='<option value="default">Default</option>',n.each(t,(function(t,n){var i=n.replace("italic"," Italic").replace(/\w\S*/g,(function(t){return t.charAt(0).toUpperCase()+t.substr(1).toLowerCase()}));e+='<option value="'+n+'">'+i+"</option>"})),e}};n(i).ready((function(){n('.customize-control-checkbox-multiple input[type="checkbox"]').on("change",(function(){var t=n(this).parents(".customize-control").find('input[type="checkbox"]:checked').map((function(){return this.value})).get().join(",");n(this).parents(".customize-control").find('input[type="hidden"]').val(t).trigger("change")})),r.init(),n('.customize-control input[type="range"]').on("change input",(function(){var t=n(this).attr("name");n('input[type="text"][data-name="'+t+'"]').val(n(this).val())})).trigger("change"),n(".social_profiles").each((function(){var o,a=n(this),c=a.data("control-id"),r="."+c+"profile-add",l="."+c+"profile-remove",s="."+c+"profile-move",u=".social-profile",f=a.find(".social_profiles_wrap"),h=wp.template(c+"-social-profile"),p=a.find("#"+c),d=function(t){t=t||!1;var e=[];o&&(clearTimeout(o),o=null),a.find(u).each((function(){var t=n(this);e.push({label:t.find("input.label").val(),url:t.find("input.url").val(),icon:t.find("input.icon").val()})})),p.val(JSON.stringify(e)),t?p.trigger("change"):o=setTimeout((function(){return p.trigger("change")}),1500)},v=function(n,i){return f.append(h(function(n){for(var i=1;i<arguments.length;i++){var o=null!=arguments[i]?arguments[i]:{};i%2?t(Object(o),!0).forEach((function(t){e(n,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(o,t))}))}return n}({index:n,label:"",url:"",icon:""},i)))},g=function(){try{f.empty(),n.each(JSON.parse(p.val()),v)}catch(t){console.log(t)}},b={handle:s,cancel:"input",connectWith:"."+c+"_social_profiles",items:"> .social-profile",update:function(){f.find(u).each((function(t){var e=n(this).find(".field-title h3");e.text(e.text().replace(/([\d]+)/g,t+1))})),d(!0)}};g(),f.sortable(b),n(i).on("click",r,(function(t){t.preventDefault(),v(f.find(u).length,{}),f.sortable("refresh")})),n(i).on("click",l,(function(t){t.preventDefault();var e=n(this).closest(u);e.slideUp(100,"linear",(function(){e.remove(),f.sortable("refresh"),d(!0),g()}))})),n(i).on("change","."+c+"-trigger",d)}))}))}(jQuery,document,ayyashCustomizerFontsL10n)})();