!function(){"use strict";function t(t,n,o,i,e){const a=wp.customize?.control(t);if(!a||!a.setting)return;n=n||a.setting.get();const r={...n};if("font-backup"in r&&delete r["font-backup"],void 0===r)return;if("string"!=typeof r["font-family"])return;"font-family"!==o&&"variant"!==o||(r[o]=i);let f=r.variant?r.variant:"regular";r.variant=f;const s=wp.customize.control(t+"[variant]"),p=s&&"wpbf-select"===s.params.type?s:void 0;if(p&&(void 0===o||"font-family"===o)){const n=function(t,n){const o=n["font-family"];if(!o)return[];const i=function(t){if(wpbfGoogleFonts)return wpbfGoogleFonts.items[t]?wpbfGoogleFonts.items[t]:void 0}(o),e=[];if(i){if(!wpbfFontVariantOptions)return e;let t=i.variants,n=0;for(;n<wpbfFontVariantOptions.complete.length;++n)t.includes(wpbfFontVariantOptions.complete[n].value)&&e.push({text:wpbfFontVariantOptions.complete[n].label,id:wpbfFontVariantOptions.complete[n].value})}else{let o=t.replace(/]/g,"");o=o.replace(/\[/g,"_");const i=wpbfFieldsFontVariants&&wpbfFieldsFontVariants[o]?wpbfFieldsFontVariants[o]:void 0;if(i&&"object"==typeof i)for(const t in i){if(!i.hasOwnProperty(t))continue;if(n["font-family"]!==t)continue;const o=i[t];if(!o.length)continue;let a=0;for(;a<o.length;++a)e.push({text:o[a].label,id:o[a].value})}else{if(e.length=0,!wpbfFontVariantOptions)return e;let t=0;for(;t<wpbfFontVariantOptions.standard.length;++t)e.push({text:wpbfFontVariantOptions.standard[t].label,id:wpbfFontVariantOptions.standard[t].value})}}return e}(t,r);n.length>1&&a.active()?p.activate():p.deactivate();f=function(t,n){return n.some((n=>n.id==t))}(f,n)?f:"regular";const o=p.container?.find(".wpbf-select2");o?.empty(),o?.append(n.map((t=>new Option(t.text,t.id,!1,!1)))),o?.val(f),r.variant=f}var l;-1!==f.indexOf("i")?r["font-style"]="italic":r["font-style"]="normal",r["font-weight"]="regular"===f||"italic"===f?400:"number"==typeof(l=f)||"string"==typeof l&&!isNaN(parseFloat(l))?parseInt(f,10):400,a.setting.set(r),wp.hooks.addAction("wpbf.dynamicControl.initWpbfControl","wpbf",(function(t){p&&t.id}))}wp.customize?.bind("ready",(function(){wp.customize&&function(n){if(!Array.isArray(wpbfTypographyControlIds))return;wpbfTypographyControlIds.forEach((o=>{n.control(o)&&n(o,(function(n){t(o,void 0,void 0,void 0),n.bind((function(n){t(o,n,void 0,void 0)})),function(n){if(!Array.isArray(wpbfFontProperties))return;wpbfFontProperties.forEach((o=>{const i=`${n}[${o}]`;wp.customize.control(i)&&wp.customize(i,(function(i){i.bind((function(i){t(n,void 0,o,i)}))}))}))}(o)}))}))}(wp.customize)}))}();
