"use strict";function filterRegions(n){vacancyOverviewViewModel.filterRegion(n)}var Scripts,vacancyOverviewViewModel;(function(n){var t;(function(n){var t;(function(n){var t=function(){function n(n,t){this.name=n;this.sortorder=t}return n}();n.RegionResult=t})(t=n.Vacancies||(n.Vacancies={}))})(t=n.Components||(n.Components={}))})(Scripts||(Scripts={})),function(n){var t;(function(n){var t;(function(n){var t=function(){function n(n,t,i,r,u){this.id=n;this.title=t;this.description=i;this.url=r;this.region=u}return n}();n.Vacancy=t})(t=n.Vacancies||(n.Vacancies={}))})(t=n.Components||(n.Components={}))}(Scripts||(Scripts={})),function(n){var t;(function(n){var t;(function(n){var t=function(){function n(n,t,i){this.name=n;this.vacancies=t;this.value=i;this.value===undefined&&(this.value=n)}return n}();n.Region=t})(t=n.Vacancies||(n.Vacancies={}))})(t=n.Components||(n.Components={}))}(Scripts||(Scripts={})),function(n){var t;(function(n){var t;(function(n){var t=function(){function n(n,t){this.vacancies=[];this.regions=[];this.regions=n;this.vacancies=t}return n}();n.SearchResult=t})(t=n.Vacancies||(n.Vacancies={}))})(t=n.Components||(n.Components={}))}(Scripts||(Scripts={})),function(n){var t;(function(n){var t;(function(n){var t=function(){function t(){this.apiLocation="/api/sitecore/Vacancies/"}return t.prototype.search=function(t,i,r){$.ajax({url:this.apiLocation+"Vacancies?vacanciesPageID="+t+"&callToActionId="+i,dataType:"json",cache:!1,ifModified:!1,success:function(t){for(var o=[],u=null,f,e,i=0;i<t.Vacancies.length;i++)u=t.Vacancies[i],o.push(new n.Vacancy(u.ID,u.Title,u.Description,u.Url,u.Region));for(f=[],i=0;i<t.Regions.length;i++)e=t.Regions[i],f.push(new n.RegionResult(e.Name,e.SortOrder));r(new n.SearchResult(f,o))}})},t}();n.VacancySearchService=t})(t=n.Vacancies||(n.Vacancies={}))})(t=n.Components||(n.Components={}))}(Scripts||(Scripts={})),function(n){var t;(function(n){var t;(function(n){var t=function(){function t(n,t,i,r){this.searchService=n;this.vacancyOverviewPageId=t;this.callToActionId=i;this.onSearchLoaded=r;this.vacancies=[];this.filteredRegions=ko.observableArray();this.selectedRegion=ko.observable();this.isLoading=ko.observable(!1)}return t.prototype.search=function(){this.isLoading(!0);this.searchService.search(this.vacancyOverviewPageId,this.callToActionId,this.showResults.bind(this))},t.prototype.loadMore=function(){this.search()},t.prototype.showResults=function(t){var f,r,i,u,e;for(this.vacancies=t.vacancies,this.regions=[],this.regionResults=t.regions,f=function(t){r.regions.push(new n.Region(t.name,r.vacancies.filter(function(n){return n.region===t.name})))},r=this,i=0,u=t.regions;i<u.length;i++)e=u[i],f(e);this.filterRegion("");this.onSearchLoaded();this.isLoading(!1)},t.prototype.filterRegion=function(n){var i=this,t=this.regions;n!==""&&(t=t.filter(function(t){return t.name===n}));t=t.sort(function(n,t){var r=i.regionResults.filter(function(t){return t.name==n.name})[0],u=i.regionResults.filter(function(n){return n.name==t.name})[0];return r.sortorder>u.sortorder?1:r.sortorder<u.sortorder?-1:n.vacancies.length==0&&t.vacancies.length>0?1:n.vacancies.length>0&&t.vacancies.length==0?-1:r.name.localeCompare(u.name)});this.filteredRegions(t)},t}();n.VacancyOverviewViewModel=t})(t=n.Vacancies||(n.Vacancies={}))})(t=n.Components||(n.Components={}))}(Scripts||(Scripts={}));vacancyOverviewViewModel=null;$(document).ready(function(){var n=$("#vacancyOverview"),t=n.attr("data-vacancyOverviewViewModel"),i=n.attr("data-callToActionId"),r=[];vacancyOverviewViewModel=new Scripts.Components.Vacancies.VacancyOverviewViewModel(new Scripts.Components.Vacancies.VacancySearchService,t,i,function(){chopstickBlocklink();var t=$(".js-selectize-region").data("placeholder"),n=[new Scripts.Components.Vacancies.Region(t,[],"")];n=n.concat(r);$(".js-selectize-region").selectize({options:n,dataAttr:"name",valueField:"value",labelField:"name",onChange:function(n){vacancyOverviewViewModel.filterRegion(n)},allowEmptyOption:!0});$(".selectize-input input").attr("readonly","true");setTimeout(function(){$(".js-modal-vacancies").magnificPopup({type:"inline",midClick:!0,mainClass:"mfp-fade"})})});ko.applyBindings(vacancyOverviewViewModel);vacancyOverviewViewModel.search()})