$(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]",sortby:"[data-js-sort-by]",subtopics:"[data-js-subtopic-option]",dateFrom:"[data-js-filter-release-from]",dateTo:"[data-js-filter-release-to]",includeRelated:"[data-js-report-related]"},element:{main:undefined,filter:undefined,results:undefined,sortby:undefined,topic:undefined,pagination:undefined,subtopics:undefined,dateFrom:undefined,dateTo:undefined,includeRelated:undefined},property:{itemsPerPage:20,filterByCurrentTopic:!1,filterByContentType:!1,filterByItemNodeGUIDs:"",orderByColumn:"",resultsTemplate:"",itemsToHighlight:0,excludeSnapshots:!1,excludeHiddenReports:!1,searchReleases:!1,includeRelatedTopics:!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.sortby=$(t.selector.sortby,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();t.element.includeRelated=$(t.selector.includeRelated,t.element.main).first();n.property.includeRelatedTopics=t.element.includeRelated.is(":checked")},properties:function(){var t=n.property,i=n.element.main;t.enableTopicFilter=i.data("enable-topic-filter");t.enableSubtopicFilter=!0;t.enableSortBy=i.data("enable-sort-by");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.excludeHiddenReports=i.data("exclude-hidden-reports");t.searchReleases=i.data("search-releases");t.truncateSummary=i.data("truncate-summary")},components:function(){var t=n,i=t.property;i.enableTopicFilter&&t.Topic.Init();i.enableSubtopicFilter&&t.Subtopic.Init();i.enableSortBy&&t.SortBy.Init();i.enableDateRange&&t.DateRange.Init();t.element.includeRelated&&t.RelatedTopics.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,r=window.location.search,u,i;if(this.element.clear=$(this.selector.clear).first(),r&&r.indexOf("viewmode")===-1)try{u=new RegExp(/\??(\{.*\})/g);i=u.exec(decodeURIComponent(r));i!=null&&i.length>1&&(t.property.parametersForAjax=JSON.parse(i[1]))}catch(f){t.property.parametersForAjax={};console.error("JSON parse has failed.",f)}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();i.Subtopic.UpdateAllCheckbox();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();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,"?search=",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]",subtopicsAll:"[data-js-subtopic-all]"},element:{wrapper:undefined},Init:function(){var t=this;t.element.wrapper=$(t.selector.wrapper,n.element.main).first();t.Bindings();t.UpdateAllCheckbox()},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(){if(u.is(t.selector.subtopicsAll)){if(!n.property.subtopics||!n.property.subtopics.length){t.UpdateAllCheckbox();return}t.Clear(!1)}n.property.subtopics=t.Get();n.Filter.Update();t.UpdateAllCheckbox()})})},Update:function(){var t=this,i=n.property.topic,r;i==""?t.Clear(!0):i!=undefined&&n.element.subtopics!=undefined&&(r=!1,$.each(n.element.subtopics,function(n,t){var u=$(t),f=u.data("js-subtopic-topic")?u.data("js-subtopic-topic").indexOf(i)!==-1:!0;u.toggle(f);f&&(r=!0)}),t.element.wrapper.toggle(r),t.UpdateAllCheckbox())},UpdateAllCheckbox:function(){var i=this.element.wrapper.find(this.selector.subtopicsAll).find("input[type=checkbox]"),t;i&&(t=!n.property.subtopics||!n.property.subtopics.length,i.prop("checked",t).siblings("[data-checkbox-label]").toggleClass("is-checked",t))},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]:not([value=''])"),r.is(":checked")&&t.push(r.val()))}),t},Clear:function(t){var i=this,r=n.element.subtopics;$.each(r,function(n,i){t&&$(i).hide();var r=$(i).find("[data-checkbox]");r.is(":checked")&&r.prop("checked",!1).siblings("[data-checkbox-label]").removeClass("is-checked")});t&&i.element.wrapper.hide()}},SortBy:{Init:function(){this.Bindings()},Bindings:function(){var t=n.element.sortby;t.off("change.DataResource").on("change.DataResource",function(){var i=t.val();n.property.orderByColumn=i;n.Results.Loading(!0);n.Results.Update(!0)})}},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()})}}},RelatedTopics:{Init:function(){this.Bindings()},Bindings:function(){if(n.element.includeRelated!==undefined)n.element.includeRelated.off("change.ReportsFilter").on("change.ReportsFilter",function(){n.property.includeRelatedTopics=n.element.includeRelated.is(":checked");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,orderByColumn:i.property.orderByColumn,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,excludeHiddenReports:i.property.excludeHiddenReports,searchReleases:i.property.searchReleases,includeRelatedTopics:i.property.includeRelatedTopics,truncateSummary:i.property.truncateSummary};$.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;i.Loading(!0);var u=i.Pagination,f=new URLSearchParams(window.location.search),r=f.get("page");u.property.number.page=r==null?1:parseInt(r);i.Get(function(r){!t||n.Results.Pagination.methods.goToPage(1);i.property.data=r.d.Groups.map(function(n){return n.Items=n.Items.filter(function(n){return n.ReportUrl!==null}),n});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}}","{{#IsGrouped}}",'<li class="e-report-listing__list-item {{GroupBackgroundClass}}">','<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("{{GroupIconClass}}"),"<\/div>","<\/div>",'<div class="e-report-listing__list-item__cell e-report-listing__list-item__cell--content">','<h3 class="e-report-listing__group-heading">{{GroupName}}<\/h3>','<ul class="e-report-listing__group-list">',"{{#Items}}",'<li class="e-report-listing__group-item">','<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>",'<p class="e-report-listing__subtitle">','<strong class="e-report-listing__type">{{ReportTypeName}}<\/strong> | ','<time class="e-report-listing__date" datetime="{{ReleaseDateAttributeFormatted}}">{{ReleaseDateDisplayFormatted}}<\/time>','{{#ReportSourceName}} | <span class="e-report-listing__source">{{ReportSourceName}}<\/span>{{/ReportSourceName}}','{{#ReportSecondarySourceName}} | <span class="e-report-listing__source">Part of {{ReportSecondarySourceName}}<\/span>{{/ReportSecondarySourceName}}',"<\/p>",'<div class="e-report-listing__summary cke_editable">',"{{{Summary}}}","<\/div>","<\/li>","{{/Items}}","<\/ul>","<\/div>","<\/div>","<\/li>","{{/IsGrouped}}","{{^IsGrouped}}","{{#Items}}",'<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>",'<p class="e-report-listing__subtitle">','<strong class="e-report-listing__type">{{ReportTypeName}}<\/strong> | ','<time class="e-report-listing__date" datetime="{{ReleaseDateAttributeFormatted}}">{{ReleaseDateDisplayFormatted}}<\/time>','{{#ReportSourceName}} | <span class="e-report-listing__source">{{ReportSourceName}}<\/span>{{/ReportSourceName}}','{{#ReportSecondarySourceName}} | <span class="e-report-listing__source">Part of {{ReportSecondarySourceName}}<\/span>{{/ReportSecondarySourceName}}',"<\/p>",'<div class="e-report-listing__summary cke_editable">',"{{{Summary}}}","<\/div>","<\/div>","<\/div>","<\/li>","{{/Items}}","{{/IsGrouped}}","{{/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}}","{{#Items}}",'<article class="s-reports-listing__item {{ReportBackgroundClass}}" {{#IsExternalReport}} data-js-external-release="{{NodeGUID}}"{{/IsExternalReport}}>','<aside class="s-reports-listing__item__cell s-reports-listing__item__cell--icon">','<span class="s-reports-listing__icon">',Site.SVGMarkup("{{ReportIconClass}}"),"<\/span>","<\/aside>",'<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>",'<p class="s-reports-listing__subtitle">','<strong class="s-reports-listing__type">{{ReportTypeName}}<\/strong> | ','<time class="s-reports-listing__date" datetime="{{ReleaseDateAttributeFormatted}}">{{ReleaseDateDisplayFormatted}}<\/time>','{{#ReportSourceName}} | <span class="e-report-listing__source">{{ReportSourceName}}<\/span>{{/ReportSourceName}}','{{#ReportSecondarySourceName}} | <span class="e-report-listing__source">Part of {{ReportSecondarySourceName}}<\/span>{{/ReportSecondarySourceName}}',"<\/p>",'<div class="s-reports-listing__summary">{{{Summary}}}<\/div>',"<\/div>","<\/article>","{{/Items}}","{{/filtered}}","<\/div>","<\/div>","{{/filtered.length}}",""].join("")}},Pagination:undefined}}}