var CustomifyAutoCSS=window.CustomifyAutoCSS||null;!function(r,o){(CustomifyAutoCSS=function(){this.values={},this.lastValues={},this.devices=["desktop","tablet","mobile"]})._change=!1,CustomifyAutoCSS.prototype.fonts={},CustomifyAutoCSS.prototype.styling_fields={color:null,image:null,position:null,cover:null,repeat:null,attachment:null,border_width:null,border_color:null,border_style:null},CustomifyAutoCSS.prototype.subsets={},CustomifyAutoCSS.prototype.variants={},CustomifyAutoCSS.prototype.media_queries={all:"%s",desktop:"%s",tablet:"@media screen and (max-width: 1024px) { %s }",mobile:"@media screen and (max-width: 568px) { %s }"},CustomifyAutoCSS.prototype.css={all:"",desktop:"",tablet:"",mobile:""},CustomifyAutoCSS.prototype.box_shadow_fields={color:null,x:0,y:0,blur:0,spread:0,inset:null},CustomifyAutoCSS.prototype.reset=function(){this.fonts={},this.subsets={},this.variants={},this.css={all:"",desktop:"",tablet:"",mobile:""}},CustomifyAutoCSS.prototype.encodeValue=function(e){return encodeURI(JSON.stringify(e))},CustomifyAutoCSS.prototype.decodeValue=function(e){return JSON.parse(decodeURI(e))},CustomifyAutoCSS.prototype.loop_fields=function(e,s,n,i){_.isUndefined(n)&&(n=!1),_.isObject(s)||(s={});var o=this,r={};return _.each(e,function(e){var t=_.isUndefined(s[e.name])?null:s[e.name];if((!_.isNull(t)||!n)&&e.selector&&e.css_format)switch(e.type){case"css_ruler":r[e.name]=o.css_ruler(e,t,i);break;case"slider":r[e.name]=o.slider(e,t,i);break;case"color":r[e.name]=o.color(e,t,i);break;case"shadow":r[e.name]=o.shadow(e,t,i);break;case"checkbox":"html_class"==e.css_format?o.html_class(e,t):r[e.name]=o.checkbox(e,t,i);break;case"image":r[e.name]=o.image(e,t,i);break;case"text_align":case"text_align_no_justify":r[e.name]=o.text_align(e,t,i);break;case"font":r[e.name]=o.font(e,t,i);break;case"styling":r[e.name]=o.styling(e,t,i);break;case"typography":r[e.name]=o.typography(e,t,i);break;case"modal":o.modal(e,t);break;default:switch(e.css_format){case"background":case"styling":r[e.name]=o.styling(e,t,i);break;case"typography":r[e.name]=o.typography(e,t,i);break;case"html_class":o.html_class(e,t);break;case"html_replace":o.html_replace(e,t);break;default:r[e.name]=o.maybe_devices_setup(e,"setup_default",t,i)}}}),r},CustomifyAutoCSS.prototype.run=function(e){_.isUndefined(e)&&(e=!1),this.lastValues=this.values,this.values=o.get(),window.Customify_JS&&window.Customify_JS.css_media_queries&&(this.media_queries=window.Customify_JS.css_media_queries),this.reset();var s=this,n=(s.loop_fields(Customify_Preview_Config.fields),""),i=0,t=(_.each(s.css,function(e,t){n+=(0"),t?r("#customify-google-font-css").attr("href",t):r("#customify-google-font-css").remove(),n=n.trim(),r("#customify-style-inline-css").length<=0&&r("head").append(""),r("#customify-style-inline-css").html(n),r(document).trigger("header_builder_panel_changed",["auto_render_css",e]),r(document).trigger("after_auto_render_css",["after_auto_render_css",e])},CustomifyAutoCSS.prototype.get_setting=function(e,t,s){_.isUndefined(t)&&(t="desktop"),_.isUndefined(s)&&(s=!1);var n,i=null,o=!1;if(_.isUndefined(Customify_Preview_Config.fields["setting|"+e])||(n=Customify_Preview_Config.fields["setting|"+e],o=!_.isUndefined(n.default)&&n.default),n=_.isUndefined(this.values[e])?o:this.values[e],_.isString(n))try{var r=this.decodeValue(n);_.isNull(r)||(n=r)}catch(e){}return s?(o=!!_.isUndefined(n[s])&&n[s],i="all"!==t&&_.isObject(o)&&_.isObject(o)&&!_.isUndefined(o[t])?o[t]:o):"all"!==t?_.isObject(n)&&!_.isUndefined(n[t])&&(i=n[t]):i=n,i},CustomifyAutoCSS.prototype.get_google_fonts_url=function(){var e="//fonts.googleapis.com/css?family=",s="",n=this;return!_.isEmpty(n.fonts)&&(_.each(n.fonts,function(e){s&&(s+="|"),s+=e.replace(/\s/g,"+");var t={};_.isUndefined(n.variants[e])||_.each(n.variants[e],function(e){"regular"!==e?"italic"===e?t[e]="400i":_.isString(e)?t[e]=e.replace("italic","i"):t[e]=e:t[e]="400"}),_.isEmpty(t)||(s+=":"+n.join(t,","))}),e+=s,_.isEmpty(n.subsets)||(e+="&subset="+n.join(n.subsets,",")),e)},CustomifyAutoCSS.prototype.join=function(e,t){return _.isUndefined(t)&&(t=""),_.isArray(e)?e.join(t):!_.isObject(e)||_.isEmpty(e)?"":_.values(e).join(t)},CustomifyAutoCSS.prototype.str_value=function(e,t,s){if(_.isEmpty(e))return"";if(!_.isString(t))return"";_.isUndefined(s)&&(s="");var n=new RegExp("{{value}}","g"),t=t.replace(n,e),n=new RegExp("{{value_no_unit}}","g");return t=t.replace(n,s)},CustomifyAutoCSS.prototype.setup_color=function(e,t){return!(!t||!e)&&this.str_value(e,t)},CustomifyAutoCSS.prototype.setup_checkbox=function(e,t){return!(!t||!e)&&t},CustomifyAutoCSS.prototype.setup_image=function(e,t){e=this.sanitize_media(e);return!(!e.url||!t)&&this.str_value(e.url,t)},CustomifyAutoCSS.prototype.setup_slider=function(e,t){_.isObject(e)||(e={}),(e=_.defaults(e,{unit:"px",value:null})).unit||(e.unit="px");var s,n="";return t&&e.value&&(s=e.value+e.unit,n=this.str_value(s,t,e.value)),n},CustomifyAutoCSS.prototype.setup_shadow=function(e,t){if(!_.isObject(e))return"";var e=_.defaults(e,this.box_shadow_fields),s=this.sanitize_color(e.color),n=e.inset?"inset":"";if(!s)return"";e.blur||(e.blur=0),e.spread||(e.spread=0),e.x||(e.x=0),e.y||(e.y=0);e=e.x+"px "+e.y+"px "+e.blur+"px "+e.spread+"px "+s+" "+n;return this.str_value(e,t)},CustomifyAutoCSS.prototype.setup_default=function(e,t){return!(!t||!e)&&this.str_value(e,t)},CustomifyAutoCSS.prototype.setup_css_ruler=function(n,e){_.isObject(n)||(n={}),n=_.defaults(n,{unit:"",top:"",right:"",bottom:"",left:""}),_.isUndefined(n.unit)||(n.unit="px"),e=_.defaults(e,{top:"",right:"",bottom:"",left:""});var i=this,o={};return _.each(e,function(e,t){var s=n[t];s&&e&&e&&(s+=n.unit,o[t]=i.str_value(s,e))}),i.join(o,"\n\t")},CustomifyAutoCSS.prototype.setup_text_align=function(e,t){return!(!t||!e)&&this.str_value(e,t)},CustomifyAutoCSS.prototype.sanitize_color=function(e){return e},CustomifyAutoCSS.prototype.sanitize_slider=function(e){return e=_.defaults(e,{unit:"px",value:null})},CustomifyAutoCSS.prototype.sanitize_media=function(e){return _.isObject(e)||(e={}),_.defaults(e,{id:null,url:null,mime:null})},CustomifyAutoCSS.prototype.maybe_devices_setup=function(n,i,o,e){var t="",r={},s=!1,l=!_.isEmpty(n.css_format)&&n.css_format,a=this,u=(_.isUndefined(e)&&(e=!1),!1);return(_.isUndefined(o)||_.isNull(o))&&(o={},u=!0),!_.isUndefined(n.device_settings)&&n.device_settings?(s=!0,_.each(a.devices,function(e){var t=null,s=(u?t=a.get_setting(n.name,e):_.isUndefined(o[e])||(t=o[e]),!1);(s=a[i]?a[i](t,l):s)&&(r[e]=s)})):(u&&(o=a.get_setting(n.name,"all")),a[i]&&(t=a[i](o,l)),r.no_devices=t),_.isEmpty(r),t="",e?r:(s?_.each(a.devices,function(e){var t;_.isUndefined(r[e])||(t=r[e])&&("format"===n.selector?a.css[e]+="\r\n"+t+"\r\n":a.css[e]+="\r\n"+n.selector+" {\r\n\t"+t+"\r\n}\r\n")}):r.no_devices&&("format"===n.selector?a.css.all+="\r\n"+r.no_devices+"\r\n":a.css.all+="\r\n"+n.selector+" {\r\n\t"+r.no_devices+"\r\n}\r\n"),t)},CustomifyAutoCSS.prototype.setup_font=function(e){return _.isObject(e)||(e={}),(e=_.defaults(e,{font:null,type:null,variant:null,subsets:null,font_data:null})).font?("google"==e.type&&(this.fonts[e.font]=e.font,e.variant&&_.isUndefined(this.variants[e.font])&&(this.variants[e.font]={},_.isString(e.variant)?((t={})[e.variant]=e.variant,this.variants[e.font]=_.extend(this.variants[e.font],t)):this.variants[e.font]=_.extend(this.variants[e.font],e.variant)),e.subsets&&(this.subsets=_.extend(this.subsets,e.subsets))),'font-family: "'+e.font+'";'):"";var t},CustomifyAutoCSS.prototype.font=function(s,n){var i="",o=this;return s.device_settings?_.each(this.devices,function(e){var t=null,t=(_.isEmpty(n)?t=o.get_setting(s.name,e):_.isUndefined(n[e])||(e=n[e]),o.setup_font(t));t&&(o.css[e]="\r\n"+s.selector+" {\r\n\t"+t+"\r\n}\r\n",i+="desktop"===e?"\r\n"+s.selector+" {\r\n\t"+t+"\r\n}":"\r\n."+e+" "+s.selector+" {\r\n\t"+t+"\r\n}\r\n")}):(_.isEmpty(n)&&(n=o.get_setting(s.name)),i=o.setup_font(n),o.css.all+=" "+s.selector+" {\r\n\t"+i+"\r\n}\r\n",i+=" "+s.selector+" {\r\n\t"+i+"\r\n}\r\n"),i},CustomifyAutoCSS.prototype.css_ruler=function(e,t,s){return this.maybe_devices_setup(e,"setup_css_ruler",t,s)},CustomifyAutoCSS.prototype.shadow=function(e,t,s){return this.maybe_devices_setup(e,"setup_shadow",t,s)},CustomifyAutoCSS.prototype.slider=function(e,t,s){return this.maybe_devices_setup(e,"setup_slider",t,s)},CustomifyAutoCSS.prototype.color=function(e,t,s){return this.maybe_devices_setup(e,"setup_color",t,s)},CustomifyAutoCSS.prototype.checkbox=function(e,t,s){return this.maybe_devices_setup(e,"setup_checkbox",t,s)},CustomifyAutoCSS.prototype.image=function(e,t,s){return this.maybe_devices_setup(e,"setup_image",t,s)},CustomifyAutoCSS.prototype.text_align=function(e,t,s){return this.maybe_devices_setup(e,"setup_text_align",t,s)},CustomifyAutoCSS.prototype.setup_styling_fields=function(t,e,s,n){var i,o=this;return _.isObject(s)||(s={}),_.isUndefined(n)&&(n="normal"),!1===t?null:(_.isObject(t)||(t={}),i={},_.each(e,function(e){_.isUndefined(o.box_shadow_fields[e.name])?(_.isUndefined(t[e.name])||t[e.name])&&(i[e.name]=e,_.isUndefined(s[n+"_"+e.name])?i[e.name].selector=s[n]:i[e.name].selector=s[n+"_"+e.name],0):(_.isUndefined(t[e.name])||t[e.name])&&(i[e.name]=e,i[e.name].selector=null)}),i)},CustomifyAutoCSS.prototype.styling=function(e){function t(e,t){_.each(e,function(s,e){_.isUndefined(a[s.selector])&&(a[s.selector]=""),_.isUndefined(t[e])||(_.isUndefined(t[e].no_devices)?_.each(t[e],function(e,t){_.isUndefined(u[t])&&(u[t]={}),_.isUndefined(u[t][s.selector])&&(u[t][s.selector]=""),e&&(u[t][s.selector]+=e)}):t[e].no_devices&&(a[s.selector]+=t[e].no_devices))})}var n=this,s=this.get_setting(e.name,"all"),i=(_.isObject(s)||_.isArray(s)||(s={}),s=_.defaults(s,{normal:{},hover:{}}),{}),o=(_.isString(e.selector)?(i.normal=e.selector,i.hover=e.selector):i=_.defaults(e.selector,{normal:null,hover:null}),null),r=-1,l=-1,e=(!_.isUndefined(e.fields)&&_.isObject(e.fields)&&(_.isUndefined(e.fields.tabs)||(o=e.tabs),_.isUndefined(e.fields.normal_fields)||(r=e.normal_fields),_.isUndefined(e.fields.hover_fields)||(l=e.hover_fields)),n.setup_styling_fields(r,Customify_Preview_Config.styling_config.normal_fields,i,"normal")),r=n.setup_styling_fields(l,Customify_Preview_Config.styling_config.hover_fields,i,"hover"),l=_.clone(Customify_Preview_Config.styling_config.tabs),a=(!1===o?l.hover=!1:_.isObject(o)&&(l=o),{}),u={},i=(_.isEmpty(s)||_.isUndefined(s.normal.bg_image)||n.sanitize_media(s.normal.bg_image).url||(delete s.normal.bg_repeat,delete s.normal.bg_cover,delete s.normal.bg_position,delete s.normal.bg_attachment),n.loop_fields(e,s.normal,!0,!0)),o=n.loop_fields(r,s.hover,!0,!0);t(e,i),t(r,o),_.each(a,function(e,t){n.css.all+="\r\n"+t+" {\r\n\t"+e+"\r\n}\r\n"}),_.each(n.devices,function(e){var t,s="";_.isUndefined(u[e])||(t=u[e],_.each(t,function(e,t){_.isString(e)?s+="\r\n"+t+" {\r\n\t"+e+"\r\n}\r\n":s+="\r\n"+t+" {\r\n\t"+n.join(e,"\n")+"\r\n}\r\n"})),n.css[e]+=s})},CustomifyAutoCSS.prototype.modal=function(s){var n=this,i=this.get_setting(s.name,"all");_.isObject(i)||(i={}),_.isObject(s.fields.tabs)&&_.each(s.fields.tabs,function(e,t){_.isObject(s.fields[t+"_fields"])&&n.loop_fields(s.fields[t+"_fields"],i[t])})},CustomifyAutoCSS.prototype.setup_font_style=function(e){_.isObject(e)||(e={});var t={},s=((e=_.defaults(e,{b:null,i:null,u:null,s:null,t:null})).b&&(t.b="font-weight: bold;"),e.i&&(t.i="font-style: italic;"),{});return e.u&&(s.underline="underline"),e.s&&(s["line-through"]="line-through"),_.isEmpty(s)||(t.d="text-decoration: "+this.join(s," ")+";"),e.t&&(t.t="text-transform: uppercase;"),this.join(t,"\r\n\t")},CustomifyAutoCSS.prototype.html_replace=function(e,t){var s=e.selector,t=_.clone(t);(_.isUndefined(t)||_.isEmpty(t))&&(t=e.default),r(s).html(t)},CustomifyAutoCSS.prototype.html_class=function(s,e){var e=_.isUndefined(e)?_.clone(e):this.get_setting(s.name,"all"),n=s.selector,t=null,i="checkbox"===s.type;if(_.isUndefined(this.lastValues[s.name])||(t=this.lastValues[s.name]),_.isString(t))try{var o=this.decodeValue(t);_.isNull(o)||(t=o)}catch(e){}if(i&&(_.isUndefined(s.device_settings)||!s.device_settings))return o=1<(o=s.name.split("__")).length?o[1]+"-active":s.name+"-active",void(e?r(n).addClass(o):r(n).removeClass(o));_.isString(t)&&!_.isEmpty(t)?r(n).removeClass(t):_.isObject(t)&&_.each(t,function(e,t){e&&(t=t+"--"+e,i&&(t=s.name+"-"+t),r(n).removeClass(t))}),_.isString(e)?r(n).addClass(e):_.isObject(e)&&_.each(e,function(e,t){e&&(t=t+"--"+e,i&&(t=s.name+"-"+t),r(n).addClass(t))})},CustomifyAutoCSS.prototype.typography=function(s,e){!_.isUndefined(e)&&_.isObject(e)||(e=this.get_setting(s.name,"all"));var t,n=this,i=(_.isObject(e)||(e={}),e=_.defaults(e,{font:null,font_type:null,languages:null,font_size:null,font_weight:null,line_height:null,letter_spacing:null,style:null,text_decoration:null,text_transform:null}),{}),o={},r={};_.each(Customify_Preview_Config.typo_fields,function(e){o[e.name]=e}),_.isUndefined(o.font)||(i.font=this.setup_font({font:e.font,type:e.font_type,subsets:e.languages,variant:e.variant})),_.isUndefined(o.style)||e.style&&"default"!==e.style&&(i.style="font-style: "+e.style+";"),_.isUndefined(o.font_weight)||e.font_weight&&"default"!==e.font_weight&&"default"!==e.font_weight&&("regular"===e.font_weight&&(e.font_weight="normal"),i.font_weight="font-weight: "+e.font_weight+";"),_.isUndefined(o.text_decoration)||e.text_decoration&&"default"!==e.text_decoration&&(i.text_decoration="text-decoration: "+e.text_decoration+";"),_.isUndefined(o.text_transform)||e.text_transform&&"default"!==e.text_transform&&(i.text_transform="text-transform: "+e.text_transform+";"),_.isUndefined(o.font_size)||(o.font_size.css_format="font-size: {{value}};",t=this.maybe_devices_setup(o.font_size,"setup_slider",e.font_size,!0),_.isEmpty(t)||(_.isUndefined(t.no_devices)?_.each(t,function(e,t){"desktop"==t?i.font_size=e:(_.isUndefined(r[t])&&(r[t]={}),r[t].font_size=e)}):i.font_size=t.no_devices)),_.isUndefined(o.line_height)||(o.line_height.css_format="line-height: {{value}};",t=this.maybe_devices_setup(o.line_height,"setup_slider",e.line_height,!0),_.isEmpty(t)||(_.isUndefined(t.no_devices)?_.each(t,function(e,t){"desktop"==t?i.line_height=e:(_.isUndefined(r[t])&&(r[t]={}),r[t].line_height=e)}):i.line_height=t.no_devices)),_.isUndefined(o.letter_spacing)||(o.letter_spacing.css_format="letter-spacing: {{value}};",(t=this.maybe_devices_setup(o.letter_spacing,"setup_slider",e.letter_spacing,!0))&&(_.isUndefined(t.no_devices)?_.each(t,function(e,t){"desktop"==t?i.letter_spacing=e:(_.isUndefined(r[t])&&(r[t]={}),r[t].letter_spacing=e)}):i.letter_spacing=t.no_devices)),_.each(r,function(e,t){n.css[t]+=" "+s.selector+" {\r\n\t"+n.join(e,"\r\n\t")+"\r\n}"}),n.css.all+=" "+s.selector+" {\r\n\t"+n.join(i,"\r\n\t")+"\r\n}"};var s=new CustomifyAutoCSS;o.bind("preview-ready",function(){s.lastValues=o.get(),s.values=o.get()}),o.bind("change",function(){}),_.each(Customify_Preview_Config.fields,function(t){(t.selector&&t.css_format||"modal"===t.type)&&wp.customize(t.name,function(e){e.bind(function(e){s.run(t.name)})})})}(jQuery,wp.customize);