!function(r){"use strict";var o=null===(r=window.srfmPreviewStyling)||void 0===r?void 0:r.containerId;if(o&&/^[a-zA-Z0-9_-]+$/.test(o)){var t=document.querySelector("."+o);if(t){var e=t.className,i=document.createElement("style");i.id="srfm-preview-override-style",t.appendChild(i),window.addEventListener("message",(function(r){if(r.origin===window.location.origin&&r.data)if("srfm-reset-styling"!==r.data.type){if("srfm-update-styling"===r.data.type){var s=r.data.styling;if(s){var a={};if(s.primaryColor){var m="hsl(from "+s.primaryColor+" h s l / ";a["--srfm-color-scheme-primary"]=s.primaryColor,a["--srfm-quill-editor-color"]=s.primaryColor,a["--srfm-color-input-border-hover"]=m+"0.65)",a["--srfm-color-input-border-focus-glow"]=m+"0.15)",a["--srfm-color-input-selected"]=m+"0.1)",a["--srfm-btn-color-hover"]=m+"0.9)",a["--srfm-btn-color-disabled"]=m+"0.25)"}if(s.textColor){var n="hsl(from "+s.textColor+" h s l / ";a["--srfm-color-scheme-text"]=s.textColor,a["--srfm-color-input-label"]=s.textColor,a["--srfm-color-input-text"]=s.textColor,a["--srfm-color-input-description"]=n+"0.65)",a["--srfm-color-input-placeholder"]=n+"0.5)",a["--srfm-color-input-prefix"]=n+"0.65)",a["--srfm-color-input-background"]=n+"0.02)",a["--srfm-color-input-background-hover"]=n+"0.05)",a["--srfm-color-input-background-disabled"]=n+"0.07)",a["--srfm-color-input-border"]=n+"0.25)",a["--srfm-color-input-border-disabled"]=n+"0.15)",a["--srfm-color-multi-choice-svg"]=n+"0.7)"}s.textOnPrimaryColor&&(a["--srfm-color-scheme-text-on-primary"]=s.textOnPrimaryColor);var d=s.formPaddingUnit||"px",f=s.formBorderRadiusUnit||"px";if(void 0!==s.formPaddingTop&&(a["--srfm-form-padding-top"]=s.formPaddingTop+d),void 0!==s.formPaddingRight&&(a["--srfm-form-padding-right"]=s.formPaddingRight+d),void 0!==s.formPaddingBottom&&(a["--srfm-form-padding-bottom"]=s.formPaddingBottom+d),void 0!==s.formPaddingLeft&&(a["--srfm-form-padding-left"]=s.formPaddingLeft+d),void 0!==s.formBorderRadiusTop&&(a["--srfm-form-border-radius-top"]=s.formBorderRadiusTop+f),void 0!==s.formBorderRadiusRight&&(a["--srfm-form-border-radius-right"]=s.formBorderRadiusRight+f),void 0!==s.formBorderRadiusBottom&&(a["--srfm-form-border-radius-bottom"]=s.formBorderRadiusBottom+f),void 0!==s.formBorderRadiusLeft&&(a["--srfm-form-border-radius-left"]=s.formBorderRadiusLeft+f),t.classList.remove("srfm-bg-color","srfm-bg-gradient","srfm-bg-image"),"color"===s.bgType)t.classList.add("srfm-bg-color"),s.bgColor&&(a["--srfm-bg-color"]=s.bgColor);else if("gradient"===s.bgType)t.classList.add("srfm-bg-gradient"),s.bgGradient&&(a["--srfm-bg-gradient"]=s.bgGradient);else if("image"===s.bgType){if(t.classList.add("srfm-bg-image"),s.bgImage){var l=s.bgImage.replace(/"/g,"");(l.startsWith("https://")||l.startsWith("http://"))&&(a["--srfm-bg-image"]='url("'+l+'")')}if(s.bgImagePosition){var g,c,u=100*(null!==(g=s.bgImagePosition.x)&&void 0!==g?g:.5),b=100*(null!==(c=s.bgImagePosition.y)&&void 0!==c?c:.5);a["--srfm-bg-position"]=u+"% "+b+"%"}s.bgImageSize&&(a["--srfm-bg-size"]=s.bgImageSize),s.bgImageRepeat&&(a["--srfm-bg-repeat"]=s.bgImageRepeat),s.bgImageAttachment&&(a["--srfm-bg-attachment"]=s.bgImageAttachment)}if(s.fieldSpacing){var p,v=null===(p=window.srfmPreviewStyling)||void 0===p?void 0:p.fieldSpacingVars;if(v){var y=v.small||{},h=v[s.fieldSpacing]||{},w=Object.assign({},y,h);for(var x in w)x.startsWith("--")&&(a[x]=w[x])}}if(function(r){var t="."+o+" {\n";for(var e in r)void 0!==r[e]&&null!==r[e]&&(t+="\t"+e+": "+r[e]+";\n");t+="}\n",i.textContent=t}(a),s.buttonAlignment){var C=t.querySelector(".srfm-submit-container .wp-block-button");if(C){C.style.textAlign="justify"===s.buttonAlignment?"center":s.buttonAlignment;var P=C.querySelector("button");P&&(P.style.width="justify"===s.buttonAlignment?"100%":"")}}var R=new CustomEvent("srfm-preview-styling-update",{detail:{styling:s,container:t}});document.dispatchEvent(R)}}}else{i.textContent="",t.className=e;var B=t.querySelector(".srfm-submit-container .wp-block-button");if(B){B.removeAttribute("style");var I=B.querySelector("button");I&&I.removeAttribute("style")}}}))}}}();