jQuery(document).ready(function(){new GFOwnerSetting});var legacyUI=gform_hubspot_owner_settings_strings.legacy_ui,prefix={input:legacyUI?"_gaddon_setting_":"_gform_setting_",field:legacyUI?"gaddon-setting-row-":"gform_setting_"};function GFOwnerSetting(){var r=jQuery;this.init=function(){this.initOwner(),new GFConditionsSetting},this.initOwner=function(){var t=this;r("#contact_owner0, #contact_owner1, #contact_owner2").on("change",function(){t.toggleOwner(!0)}),this.toggleOwner(!1)},this.toggleOwner=function(t){var e=["#"+prefix.field+"contact_owner_select","#"+prefix.field+"contact_owner_conditional"],o=r(".contact_owner_section"),i=r('input[name="'+prefix.input+'contact_owner"]:checked').val();r(e.join(", ")).hide(),"none"===i?t&&legacyUI?o.slideUp():o.hide():(o.is(":hidden")&&(t&&legacyUI?o.slideDown():o.show()),r("#"+prefix.field+"contact_owner_"+i).show())},this.init()}function GFConditionsSetting(){var n=jQuery;this.$element=jQuery("#gform_conditions_setting"),this.fieldId="conditions",this.fieldName=prefix.input+"conditions",this.options=null,this.init=function(){var r=this,t=(this.options={fieldName:this.fieldName,fieldId:this.fieldId,fields:gform_hubspot_owner_settings_strings.fields,owners:gform_hubspot_owner_settings_strings.owners,imagesURL:gf_vars.baseUrl+"/images",items:this.getItems(),operatorStrings:{is:"is",isnot:"isNot",">":"greaterThan","<":"lessThan",contains:"contains",starts_with:"startsWith",ends_with:"endsWith"}},t=(t=(t='{0}')+'{1}'+"").gformFormat(gform_hubspot_owner_settings_strings.assign_to,gform_hubspot_owner_settings_strings.condition),t='{0}{1}
'.gformFormat(t,this.getNewRow()),n(t));t.find(".repeater").repeater({limit:0,items:this.options.items,addButtonMarkup:'',removeButtonMarkup:'',callbacks:{save:function(t,e){n("#"+r.options.fieldId).val(n.toJSON(e))},beforeAdd:function(t,e,o){o.owner&&e.find(".gform-routing-owners").val(o.owner);var i=e.find(".gform-routing-field").first(),i=(i.value=o.fieldId,r.changeField(i),e.find(".gform-routing-operator").first());i.value=o.operator,r.changeOperator(i),e.find(".gform-routing-value").val(o.value)}}}).on("change",".gform-routing-field",function(t){r.changeField(this)}).on("change",".gform-routing-operator",function(){r.changeOperator(this)}),this.$element.append(t)},this.getNewRow=function(){var t=[];return t.push("{0}".gformFormat(this.getOwners())),t.push("{0}".gformFormat(this.getFields())),t.push("{0}".gformFormat(this.getOperators(this.options.fields[0]))),t.push("{0}".gformFormat(this.getValues())),t.push('{buttons}'),'{0}'.gformFormat(t.join(""))},this.getOwners=function(){for(var t=this.options.owners,e='"},this.getFields=function(){var t,e,o,i,r,n,s,a,g=[],l=this.options.fields;for(g.push('"),g.join("")},this.changeOperator=function(t){var e=n(t),o=e.closest("tr").find(".repeater-buttons").find(".add-item ").data("index"),i=e.closest("tr").find(".gform-routing-field"),i=this.getFilter(i.value);i&&e.closest("tr").find(".gform-routing-value").replaceWith(this.getValues(i,t.value,o))},this.changeField=function(t){var e,o=this.getFilter(t.value);o&&(e=(t=n(t)).closest("tr").find(".repeater-buttons").find(".add-item ").data("index"),t.closest("tr").find(".gform-routing-value").replaceWith(this.getValues(o,null,e)),t.closest("tr").find(".gform-filter-type").val(o.type).change(),o=n(this.getOperators(o,e)),t.closest("tr").find(".gform-routing-operator").replaceWith(o),t.closest("tr").find(".gform-routing-operator").change())},this.getOperators=function(t,e){var o,i,r=this.options.operatorStrings,n='"},this.getValues=function(t,e,o){var i,r,n,s,a="";if(null==o&&(o="{i}"),t&&t.values&&"contains"!=e){for(i=0;i{1}'.gformFormat(r,n);s=''.gformFormat(o,a)}else s=''.gformFormat(o);return s},this.getFilter=function(t){var e=this.options.fields;if(t)for(var o=0;o