!function(e){function t(t){e.each(t,function(t,a){var n=e(a);0===n.data("index")&&(n.prop("disabled",0),n.hasClass("ff_el-chained-select-smart-search")&&(a.choices=new Choices(a)))})}function a(t){var a=e(this),r=n(a);if(r){if(a.val())return function(t,a){var r,c,s={params:i(t),name:t.attr("data-name"),type:null!==(r=t.attr("data-source-type"))&&void 0!==r?r:"url",url:null!==(c=t.attr("data-source-url"))&&void 0!==c?c:"",meta_key:t.attr("data-meta_key"),target_field:a.attr("data-key"),form_id:t.closest("form").attr("data-form_id"),action:"fluentform_get_chained_select_options"};a.html("<option>Loading...</option>"),e.getJSON(fluentFormVars.ajaxUrl,s).then(function(t){o(a,0),function(t,a){var n,r=a.hasClass("ff_el-chained-select-smart-search");r&&(n=new Choices(a[0]),a[0].choices=n);var i=[];e.each(t.data,function(t,n){r?i.push({value:n,label:n}):a.append(e("<option />",{value:n,text:n}))}),r&&n.setChoices(i)}(t,a),(a=n(a))&&o(a,1).trigger("change")})}(a,r);o(r,1).trigger("change")}}function n(e){var t=e.data("index")+1,a=e.closest(".ff-chained-select-field-wrapper").find("select[data-index='"+t+"']");return a.length?a:void 0}function r(e){var t=e.data("index")-1,a=e.closest(".ff-chained-select-field-wrapper").find("select[data-index='"+t+"']");return a.length?a:void 0}function i(e){var t=[{value:e.val(),key:e.attr("data-key")}];if(e.attr("data-index"))for(;$previousElement=r(e);)e=$previousElement,t.push({value:e.val(),key:e.attr("data-key")});return t}function o(t,a){if(t)return t.hasClass("ff_el-chained-select-smart-search")&&t[0].choices&&t[0].choices.destroy(),t.empty().prop("disabled",a).append(e("<option />",{value:"",text:t.attr("data-key")}))}var c=function(){e.each(e(".frm-fluent-form"),function(n,r){var i=e(r).find("select.el-chained-select");i.on("change",a),t(i),e(document).on("reInitExtras","#formId",function(){i.on("change",a),t(i)})})};setTimeout(function(){e(".frm-fluent-form")&&c()},100),e(document).on("elementor/popup/show",function(){c()})}(jQuery);