$(document).ready(function(){ReportsFilter.Init()});var ReportsFilter=function(){return{Init:function(){$("[data-js-report-filter-main-wrapper]").each(function(){var n=new ReportsFilterMain;n.Init($(this))})}}}(),ReportsFilterMain=function(){var n;return{selector:{main:undefined,filter:"[data-js-filter-wrapper]",topic:"[data-js-topic-selection]",results:"[data-js-results-wrapper]",subtopics:"[data-js-subtopic-option]",dateFrom:"[data-js-filter-release-from]",dateTo:"[data-js-filter-release-to]"},element:{main:undefined,filter:undefined,results:undefined,topic:undefined,pagination:undefined,subtopics:undefined,dateFrom:undefined,dateTo:undefined},property:{itemsPerPage:20,filterByCurrentTopic:!1,filterByContentType:!1,filterByItemNodeGUIDs:"",resultsTemplate:"",itemsToHighlight:0,excludeSnapshots:!1,searchReleases:!1},Init:function(t){this.element.main=t;n=this;this.Setup.init()},Setup:{init:function(){n.element.main.length&&(this.elements(),this.components())},elements:function(){var t=n;this.properties();t.element.filter=$(t.selector.filter,t.element.main).first();t.element.results=$(t.selector.results,t.element.main).first();t.element.pagination=$(t.selector.pagination,t.element.main).first();t.element.topic=$(t.selector.topic,t.element.main).first();t.element.subtopics=$(t.selector.subtopics,t.element.main);t.element.dateFrom=$(t.selector.dateFrom,t.element.main).first();t.element.dateTo=$(t.selector.dateTo,t.element.main).first()},properties:function(){var t=n.property,i=n.element.main;t.enableTopicFilter=i.data("enable-topic-filter");t.enableSubtopicFilter=!0;t.enableDateRange=i.data("enable-date-range");t.itemsPerPage=i.data("items-per-page")?parseInt(i.data("items-per-page")):t.itemsPerPage;t.filterByCurrentTopic=i.data("filter-by-current-topic");t.contentType=i.data("content-type");t.filterByChildrenOfCurrentNode=i.data("filter-by-children-of-current-node");t.filterByItemNodeGUIDs=i.data("filter-by-item-node-guids");t.releaseDateFrom=i.data("release-date-from");t.currentNodeId=i.data("current-node-id");t.resultsTemplate=i.data("results-template");t.initalTotalResults=i.data("total-results");t.ignoredReportGuids=i.data("ignored-report-guids");t.itemsToHighlight=i.data("items-to-highlight");t.excludeSnapshots=i.data("exclude-snapshots");t.searchReleases=i.data("search-releases")},components:function(){var t=n,i=t.property;i.enableTopicFilter&&t.Topic.Init();i.enableSubtopicFilter&&t.Subtopic.Init();i.enableDateRange&&t.DateRange.Init();t.Results.Init();t.Filter.Init()}},Filter:{selector:{clear:"[data-js-clear-filters]",topic:"[data-js-topic-selection]",subtopic:"[data-js-subtopic-option]",dateFrom:"[data-js-filter-release-from]",dateTo:"[data-js-filter-release-to]"},element:{clear:undefined},property:{filtersInitialised:!1,parametersForAjax:{}},Init:function(){var t=n.Filter,i=window.location.search;if(this.element.clear=$(this.selector.clear).first(),i&&i.indexOf("viewmode")===-1)try{t.property.parametersForAjax=JSON.parse(/\??(\{.*\})/g.exec(decodeURIComponent(i))[1])}catch(r){t.property.parametersForAjax={};console.error("JSON parse has failed.",r)}t.Bindings();t.PopulateFilters();t.property.filtersInitialised=!0},Bindings:function(){var n=this;$(this.selector.clear).off("click.ReportListing").on("click.ReportListing",function(){n.ClearFilters()})},PopulateFilters:function(){var t=n.Filter,i=n,r,f,s,o,e,h,u;for(r in t.property.parametersForAjax)if(t.property.parametersForAjax.hasOwnProperty(r))switch(r){case"Topic":f=$(t.selector.topic).find("option[data-topic-id='"+t.property.parametersForAjax[r]+"']");f.length&&($(t.selector.topic).val(f.val()),i.property.topic=f.val(),i.Subtopic.Update());break;case"Subtopics":for(s=$(t.selector.subtopic),o=t.property.parametersForAjax[r].toString().split(","),e=0;e<o.length;e++)h=s.find("[data-checkbox][data-subtopic-id='"+o[e]+"']"),h.prop("checked",!0).siblings("[data-checkbox-label]").addClass("is-checked");i.property.subtopics=i.Subtopic.Get();break;case"ReleaseDateFrom":$(t.selector.dateFrom).length>0&&(u=$(t.selector.dateFrom).eq(0).pickadate("picker"),u.set("select",t.property.parametersForAjax[r],{format:"yyyy/mm/dd"}),i.property.dateFrom=u.get("select","yyyy-mm-dd")+" 00:00:00");break;case"ReleaseDateTo":$(t.selector.dateTo).length>0&&(u=$(t.selector.dateTo).eq(0).pickadate("picker"),u.set("select",t.property.parametersForAjax[r],{format:"yyyy/mm/dd"}),i.property.dateTo=u.get("select","yyyy-mm-dd")+" 23:59:59")}i.Results.Loading(!0);i.Results.Update()},Tags:undefined,Update:function(){this.PushState();console.log("in update function");n.Results.Loading(!0);n.Results.Update(!0)},PushState:function(){var i=n,u,t={},r=n.Filter,s,h,f,e,o,c;i.property.topic!==undefined&&i.property.topic!==""&&(s=$(r.selector.topic).find("option:selected").data("topic-id"),t.Topic=s+"");i.property.subtopics!==undefined&&i.property.subtopics.length>0&&(h=$(r.selector.subtopic),f=[],$.each(h,function(n,t){var r=$(t),i;r.is(":visible")&&(i=r.find("input[type=checkbox]"),i.is(":checked")&&f.push(i.data("subtopic-id")+""))}),t.Subtopics=f);i.property.dateFrom!==undefined&&(e=$(r.selector.dateFrom).eq(0).pickadate("picker"),e.get("select")!=null&&(t.ReleaseDateFrom=e.get("select","yyyy-mm-dd")));i.property.dateTo!==undefined&&(o=$(r.selector.dateTo).eq(0).pickadate("picker"),o.get("select")!=null&&(t.ReleaseDateTo=o.get("select","yyyy-mm-dd")));c=encodeURI(JSON.stringify(t));u=[window.location.pathname,"?",c].join("");history&&history.pushState?$.isEmptyObject(t)?history.pushState(t,"Reports",window.location.pathname):history.pushState(t,"Reports",u):window.location=$.isEmptyObject(t)?window.location.pathname:u},ClearFilters:function(){var r=n.Filter,i,t;for(i in n.element)if(n.element.hasOwnProperty(i)){if(t=n.element[i],typeof t=="undefined")continue;t.is("select")?t.get(0).selectedIndex=0:t.is("input[type=text]")&&t.val("")}$.each(n.element.subtopics,function(n,t){$(t).hide();var i=$(t).find("[data-checkbox]");i.is(":checked")&&i.prop("checked",!1).siblings("[data-checkbox-label]").removeClass("is-checked")});$(n.Subtopic.element.label).hide();n.Setup.properties();n.Results.Update()}},Topic:{Init:function(){this.Bindings()},Bindings:function(){var t=n.element.topic;t.off("change.DataResource").on("change.DataResource",function(){n.property.topic=$(this).val();n.Subtopic.Update();n.property.subtopics=n.Subtopic.Get();n.Filter.Update()})}},Subtopic:{selector:{wrapper:"[data-js-subtopic-wrapper]"},element:{wrapper:undefined},Init:function(){var t=this;t.element.wrapper=$(t.selector.wrapper,n.element.main).first();t.Bindings()},Bindings:function(){var t=this,i=n.element.subtopics;$.each(i,function(i,r){var u=$(r);u.off("change.DataResource").on("change.DataResource",function(){n.property.subtopics=t.Get();n.Filter.Update()})})},Update:function(){var r=this,t=n.property.topic,i;t==""?r.Clear():t!=undefined&&n.element.subtopics!=undefined&&(i=!1,$.each(n.element.subtopics,function(n,r){var u=$(r),f=u.data("js-subtopic-topic").indexOf(t)!==-1;u.toggle(f);f&&(i=!0)}),r.element.wrapper.toggle(i))},Get:function(){var t=[],i=n.element.subtopics;return $.each(i,function(n,i){var u=$(i),r;u.is(":visible")&&(r=u.find("input[type=checkbox]"),r.is(":checked")&&t.push(r.val()))}),t},Clear:function(){var t=this,i=n.element.subtopics;$.each(i,function(n,t){$(t).hide();var i=$(t).find("[data-checkbox]");i.is(":checked")&&i.prop("checked",!1).siblings("[data-checkbox-label]").removeClass("is-checked")});t.element.wrapper.hide()}},DateRange:{Init:function(){this.Bindings()},Bindings:function(){if(n.element.dateFrom!==undefined&&n.element.dateTo!==undefined){n.element.dateFrom.on("change",function(){n.property.dateFrom=undefined;$(this).val()!=""&&(n.property.dateFrom=$(this).pickadate("picker").get("select","yyyy-mm-dd")+" 00:00:00");n.Filter.Update()});n.element.dateTo.on("change",function(){n.property.dateTo=undefined;$(this).val()!=""&&(n.property.dateTo=$(this).pickadate("picker").get("select","yyyy-mm-dd")+" 00:00:00");n.Filter.Update()})}}},Results:{selector:{resultsTop:"[data-js-results-wrapper]"},property:{filtered:{},data:null,loadingTimeout:undefined,parent:undefined,totalResults:0,isFiltered:!1},elements:{resultsTop:undefined},Init:function(){var i=n,t=this,r;t.Pagination=new Pagination(this);t.property.parent=n;t.elements.resultsTop=$(t.selector.resultsTop,i.element.main);r=window.location.hash;r||(t.property.totalResults=i.property.initalTotalResults,t.Pagination.property.number.page=1,t.Output.setPaginationProperties(),t.Pagination.init());t.Pagination.events.init()},Get:function(t){var i=n,r=i.Filter.property.parametersForAjax;r.Filters={itemsPerPage:i.property.itemsPerPage,filterByCurrentTopic:i.property.filterByCurrentTopic,releaseDateFrom:i.property.dateFrom,releaseDateTo:i.property.dateTo,topic:i.property.topic,subtopics:i.property.subtopics,currentNodeId:i.property.currentNodeId,page:i.Results.Pagination.property.number.page||1,ignoredReportGuids:i.property.ignoredReportGuids,excludeSnapshots:i.property.excludeSnapshots,searchReleases:i.property.searchReleases};$.ajax({type:"POST",contentType:"application/json; charset=utf-8",url:"/AIHWWebServices/SearchService.asmx/AllReports",data:JSON.stringify({search:r.Filters}),success:t})},Update:function(t){var i=this,u,r;i.Loading(!0);u=i.Pagination;r=window.location.hash;u.property.number.page=parseInt(r?r.substring(5):1)||1;i.Get(function(r){!t||n.Results.Pagination.methods.goToPage(1);i.property.data=r.d.Results.filter(function(n){return n.ReportUrl!==null});i.property.totalResults=r.d.TotalResults;i.property.isFiltered=n.property.initalTotalResults>r.d.TotalResults;i.Clear();i.Output.init()})},Loading:function(t){var i=this;typeof t=="boolean"&&t===!0?n.element.main.addClass("is-loading"):(n.element.main.removeClass("is-loading"),clearTimeout(i.property.loadingTimeout))},Clear:function(){n.element.results.html("");typeof this.Pagination.element.wrapper!="undefined"&&typeof this.Pagination.element.list!="undefined"&&(typeof this.Pagination.element.list!="undefined"&&this.Pagination.element.list.html(""),this.Pagination.element.wrapper.hide(),this.Pagination.property.markup.pages=[])},Output:{init:function(){var r=n,t=r.Results,i=t.Pagination;t.Clear();this.setPaginationProperties();this.filterAndSetResults();i.init();document.addEventListener("SmoothStateLoaded",function(){i.init()});t.Loading(!1)},filterAndSetResults:function(){var t=n,i=t.Results,r,u,f;i.property.filtered=i.property.data;r="";t.property.itemsToHighlight>0&&!i.property.isFiltered&&i.property.filtered!=null&&t.Results.Pagination.property.number.page==1?(u=i.property.filtered.slice(0,t.property.itemsToHighlight),r=Mustache.to_html(n.Results.Template.loadTemplate(t.property.resultsTemplate),$.extend({},i.property,{filtered:u,isHighlight:!0})),f=i.property.filtered.slice(t.property.itemsToHighlight),r+=Mustache.to_html(n.Results.Template.loadTemplate(t.property.resultsTemplate),$.extend({},i.property,{filtered:f,isHighlight:!1}))):r=Mustache.to_html(n.Results.Template.loadTemplate(t.property.resultsTemplate),i.property);t.element.results.html(r)},setPaginationProperties:function(){var u=n,i=u.Results,r=i.Pagination,t=r.property.number,f=r.property.callbacks;t.resultsPerPage=u.property.itemsPerPage;t.results=i.property.totalResults;t.pages=Math.ceil(t.results/t.resultsPerPage);r.element.wrappingEl=n.element.main;f.onpage=function(){i.Update()}}},Template:{loadTemplate:function(n){return n=="latestReports"?this.latestReports():n=="topicReports"?this.topicReports():""},latestReports:function(){return["","{{#filtered.length}}",'<ul class="e-report-listing__list">',"{{#filtered}}",'<li class="e-report-listing__list-item {{ReportBackgroundClass}}">','<div class="e-report-listing__list-item__inner">','<div class="e-report-listing__list-item__cell e-report-listing__list-item__cell--icon">','<div class="e-report-listing__icon-wrapper">',Site.SVGMarkup("{{ReportIconClass}}"),"<\/div>","<\/div>",'<div class="e-report-listing__list-item__cell e-report-listing__list-item__cell--content">','<a href="{{ReportUrl}}" class="e-report-listing__link" {{#IsExternalReport}} data-js-external-release="{{NodeGUID}}"{{/IsExternalReport}}>','<span class="e-report-listing__link__text">',"{{{TitleDisplay}}}&nbsp;",Site.SVGMarkup("chevron-right"),"<\/span>","<\/a>",'<time class="e-report-listing__date" datetime="{{ReleaseDateAttributeFormatted}}">{{ReleaseDateDisplayFormatted}}<\/time>',"<\/div>","<\/div>","<\/li>","{{/filtered}}","<\/ul>","{{/filtered.length}}",""].join("")},topicReports:function(){return["","{{#filtered.length}}",'<div class="s-reports-listing{{#isHighlight}} s-featured-content{{/isHighlight}}">','<div class="s-reports-listing__inner">',"{{#filtered}}",'<article class="s-reports-listing__item {{ReportBackgroundClass}}" {{#IsExternalReport}} data-js-external-release="{{NodeGUID}}"{{/IsExternalReport}}>',"{{^ImageUrl}}",'<aside class="s-reports-listing__item__cell s-reports-listing__item__cell--noimage">','<div class="s-reports-listing__image-wrapper">','<span class="s-reports-listing__icon">',Site.SVGMarkup("{{ReportIconClass}}"),"<\/span>","<\/div>","<\/aside>","{{/ImageUrl}}","{{#ImageUrl}}",'<aside class="s-reports-listing__item__cell s-reports-listing__item__cell--image">','<div class="s-reports-listing__image-wrapper">','<span class="s-reports-listing__icon">',Site.SVGMarkup("{{ReportIconClass}}"),"<\/span>",'<a href="{{ReportUrl}}" class="s-reports-listing__link" aria-hidden="true" {{#IsExternalReport}} data-js-external-release="{{NodeGUID}}"{{/IsExternalReport}}>','<span class="sr-only">{{{TitleDisplay}}}<\/span>',"<picture>",'<source srcset="{{ImageUrl}}&amp;width=180&amp;height=250&amp;mode=crop&amp;format=webp&amp;quality=80&amp;upscale=false" type="image/webp">','<source srcset="{{ImageUrl}}&amp;width=180&amp;height=250&amp;mode=crop&amp;quality=80&amp;upscale=false" type="image/jpeg">','<img class="s-reports-listing__image" src="{{ImageUrl}}&amp;width=180&amp;height=250&amp;mode=crop&amp;quality=80&amp;upscale=false" alt="{{ImageAltText}}" onerror="this.onerror = null; erroredImages.value = this;">',"<\/picture>","<\/a>","<\/div>","<\/aside>","{{/ImageUrl}}",'<div class="s-reports-listing__item__cell s-reports-listing__item__cell--text">','<h4 class="s-reports-listing__heading">','<a href="{{ReportUrl}}" class="s-reports-listing__heading__link" {{#IsExternalReport}} data-js-external-release="{{NodeGUID}}"{{/IsExternalReport}}>',"{{{TitleDisplay}}}&nbsp;",Site.SVGMarkup("chevron-right"),"<\/a>","<\/h4>",'<div class="s-reports-listing__summary">{{{Summary}}}<\/div>','<time class="s-reports-listing__date" datetime="{{ReleaseDateAttributeFormatted}}">{{ReleaseDateDisplayFormatted}}<\/time>',"<\/div>","<\/article>","{{/filtered}}","<\/div>","<\/div>","{{/filtered.length}}",""].join("")}},Pagination:undefined}}}