text: var tribe_dropdowns=tribe_dropdowns||{};!function(e,t){"use strict";function a(t,r){if(!e.isArray(r))return!1;for(var o in r){var i=r[o];if(i.hasOwnProperty("id")&&i.id==t.id)return i;if(i.hasOwnProperty("text")&&i.text==t.text)return i;if(i.hasOwnProperty("children")&&e.isArray(i.children)){var n=a(t,i.children);if(n)return n}}return!1}t.selector={dropdown:".tribe-dropdown"},e.fn.tribe_dropdowns=function(){return t.dropdown(this),this},t.freefrom_create_search_choice=function(e,t){var a=this.opts,r=a.$select;if(e.match(a.regexToken)&&(!r.is("[data-int]")||r.is("[data-int]")&&e.match(/\d+/))){var o={id:e,text:e,"new":!0};return r.is("[data-create-choice-template]")&&(o.text=_.template(r.data("createChoiceTemplate"))({term:e})),o}},t.allow_html_markup=function(e){return e},t.search_id=function(e){var t=void 0;return"undefined"!=typeof e.id?t=e.id:"undefined"!=typeof e.ID?t=e.ID:"undefined"!=typeof e.value&&(t=e.value),void 0===e?void 0:t},t.matcher=function(e,a){var r=this.element,o=r.data("dropdown"),i=a.toUpperCase().indexOf(e.toUpperCase())!==-1;if(!i&&"undefined"!=typeof o.tags){var n=_.where(o.tags,{text:a});if(o.tags.length>0&&_.isObject(n)){var s=t.search_id(n[0]);i=s.toUpperCase().indexOf(e.toUpperCase())!==-1}}return i},t.init_selection=function(t,r){var o=t.is("[multiple]"),i=t.data("dropdown"),n=t.val().split(i.regexSplit),s=[];e(n).each(function(){var e={id:this,text:this},r=i.ajax?t.data("options"):i.data,o=a(e,r);o&&s.push(o)}),s.length&&o?r(s):s.length&&r(s[0])},t.element=function(a){var r,o=e(this),i={},n=["depends","condition","conditionNot","condition-not","conditionNotEmpty","condition-not-empty","conditionEmpty","condition-empty","conditionIsNumeric","condition-is-numeric","conditionIsNotNumeric","condition-is-not-numeric","conditionChecked","condition-is-checked"];if(i.$select=o,i.dropdownAutoWidth=!0,i.containerCss={},o.is(":visible")&&(i.containerCss.display="inline-block"),i.dropdownCss={},i.dropdownCss.width="auto",o.is("[data-dropdown-css-width]")&&(i.dropdownCss.width=o.data("dropdown-css-width"),i.dropdownCss.width||delete i.dropdownCss.width),i.matcher=t.matcher,o.is("select")||(i.id=t.search_id),i.allowClear=!0,o.is("[data-prevent-clear]")&&(i.allowClear=!1),o.is("[data-searching-placeholder]")&&(i.formatSearching=o.data("searching-placeholder")),o.is("[data-options]")&&(i.data=o.data("options"),o.is("select")||(i.initSelection=t.init_selection)),o.is("[data-allow-html]")&&(i.escapeMarkup=t.allow_html_markup),o.is("[data-hide-search]")&&(i.minimumResultsForSearch=1/0),o.is("[data-freeform]")&&(i.createSearchChoice=t.freefrom_create_search_choice),"tribe-ea-field-origin"===o.attr("id")&&(i.formatResult=i.upsellFormatter,i.formatSelection=i.upsellFormatter,i.escapeMarkup=t.allow_html_markup),o.is("[multiple]")&&(i.multiple=!0,o.is("data-separator")||o.data("separator",","),_.isArray(o.data("separator"))?i.tokenSeparators=o.data("separator"):i.tokenSeparators=[o.data("separator")],i.separator=o.data("separator"),i.regexSeparatorElements=["^("],i.regexSplitElements=["(?:"],e.each(i.tokenSeparators,function(e,t){i.regexSeparatorElements.push("[^"+t+"]+"),i.regexSplitElements.push("["+t+"]")}),i.regexSeparatorElements.push(")$"),i.regexSplitElements.push(")"),i.regexSeparatorString=i.regexSeparatorElements.join(""),i.regexSplitString=i.regexSplitElements.join(""),i.regexToken=new RegExp(i.regexSeparatorString,"ig"),i.regexSplit=new RegExp(i.regexSplitString,"ig")),o.is("[data-tags]")&&(i.tags=o.data("tags"),i.initSelection=t.init_selection,i.createSearchChoice=function(e,t){if(e.match(i.regexToken))return{id:e,text:e}},0===i.tags.length&&(i.formatNoMatches=function(){return o.attr("placeholder")})),o.is("[data-source]")){var s=o.data("source");i.data={results:[]},i.escapeMarkup=t.allow_html_markup,i.formatResult=function(t,a,r){return"undefined"!=typeof t.breadcrumbs?e.merge(t.breadcrumbs,[t.text]).join(" &#187; "):t.text},i.ajax={dataType:"json",type:"POST",url:t.ajaxurl(),results:function(t,a,r){return e.isPlainObject(t)&&"undefined"!=typeof t.success?e.isPlainObject(t.data)&&"undefined"!=typeof t.data.results?t.success?t.data:("string"===e.type(t.data.message)?console.error(t.data.message):console.error("The Select2 search failed in some way... Verify the source."),{results:[]}):(console.error("We received a malformed results array, could not complete the Select2 Search."),{results:[]}):(console.error("We received a malformed Object, could not complete the Select2 Search."),{results:[]})}},i.ajax.data=function(e,t){return{action:"tribe_dropdown",source:s,search:e,page:t,args:o.data("source-args")}}}o.data("dropdown",i),r=o.select2(i).select2("container"),n.length>0&&n.map(function(e){var t="data-"+e,a=o.attr(t);a&&this.attr(t,a)},r)},t.action_change=function(t){var a=e(this),r=e(this).data("value");a.is("[multiple]")&&a.is("[data-source]")&&(t.added?_.isArray(r)?r.push(t.added):r=[t.added]:r=_.isArray(r)?_.without(r,t.removed):[],a.data("value",r).attr("data-value",JSON.stringify(r)))},t.ajaxurl=function(){return"undefined"!=typeof window.ajaxurl?window.ajaxurl:"undefined"!=typeof TEC&&"undefined"!=typeof TEC.ajaxurl?TEC.ajaxurl:void console.error("Dropdowns framework cannot properly do an AJAX request without the WordPress `ajaxurl` variable setup.")},t.action_select2_removed=function(t){var a=e(this);a.is("[data-sticky-search]")&&a.is("[data-last-search]")&&a.removeAttr("data-last-search").removeData("lastSearch")},t.action_bugfix_group_select=function(a){var r=e(this),o=r.select2("data"),i=e(".select2-drop:visible");i.find(".select2-selected").each(function(){var a=e(this),r=a.data("select2-data"),i=!0;"undefined"!=typeof r.children&&(e.each(o,function(e,a){t.search_id(r)==t.search_id(a)&&(i=!1)}),i&&a.removeClass("select2-selected"))})},t.action_select2_close=function(t){var a=e(this),r=e(".select2-drop .select2-input.select2-focused");a.is("[data-sticky-search]")&&r.off("keyup-change.tribe")},t.action_select2_open=function(t){var a=e(this),r=e(".select2-drop .select2-input:visible");a.is("[data-search-placeholder]")&&r.attr("placeholder",a.data("searchPlaceholder")),a.is("[data-sticky-search]")&&(r.on("keyup-change.tribe",function(){a.data("lastSearch",e(this).val()).attr("data-last-search",e(this).val())}),a.is("[data-last-search]")&&r.val(a.data("lastSearch")).trigger("keyup-change"))},t.dropdown=function(e){var a=e.not(".select2-offscreen, .select2-container");return a.each(t.element).on("select2-open",t.action_select2_open).on("select2-close",t.action_select2_close).on("select2-removed",t.action_select2_removed).on("select2-loaded",t.action_bugfix_group_select).on("change",t.action_change),a},e(function(){e(t.selector.dropdown).tribe_dropdowns()}),e(window).on("unload",function(){e(t.selector.dropdown).tribe_dropdowns()})}(jQuery,tribe_dropdowns);