function SearchResultsManagement(n,t,i){function l(){o=!1}function a(n){o=!0;n&&r.ReloadData()}function b(){r.SearchExpired(!1);r.NotFoundRecords(!1);r.GlobalError(!1);p();var n=v();$.ajax({type:"POST",url:r.LinkGetRecords(),data:{querySearch:n},cache:!1,async:!0,beforeSend:function(){h=n;parent&&window.GlobalEvents.BeforeLoadSearchResultPage.fire(n)},success:function(n){var t=JSON.parse(n);if(!t.Success){t.Data&&t.Data.SearchExpired?(r.SearchExpired(!0),window.location.href=_utilities.getAbsoluteURL("/Navigation/SearchResultExpired")):r.GlobalError(!0);return}switch(r.Navigation.View()){case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.GridView:r.GridView.ReloadRecords(t.Data);break;case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Citation:r.CitationView.ReloadRecords(t.Data);break;case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Thumbnail:r.ThumbnailView.ReloadRecords(t.Data)}parent&&window.GlobalEvents.AfterLoadedSearchResultPage.fire(t.Data)},complete:function(){s()}})}function v(){var n=new QuerySearchRecordsUIviewModel;return r.ActiveContentType()&&(n.ContentTypeId=r.ActiveContentType().Id),n.Page=r.Navigation.Page(),n.PageSize=r.Navigation.PageSize(),n.SortSequence=r.Navigation.SortSequence(),n.SortOrder=r.Navigation.SortOrder(),n.View=r.Navigation.View(),n}function k(n,t){return n==null&&t==null?!0:n!=null&&t==null||n==null&&t!=null?!1:n==null||t==null?!1:n.ContentTypeId!==t.ContentTypeId?!1:n.Page!==t.Page?!1:n.PageSize!==t.PageSize?!1:n.SortSequence!==t.SortSequence?!1:n.SortOrder!==t.SortOrder?!1:n.View!==t.View?!1:!0}function y(n){return ko.utils.arrayFirst(r.ContentTypes(),function(t){return t.Id==n})}function p(){r.IsLoading(!0)}function s(){r.IsLoading(!1)}function w(n){var i,t,u;if(!n||n.length==0)return r.ContentTypes([]),!1;for(i=[],t=0;t<n.length;t++)u=new ContentTypeKnockoutModel(r,n[t]),i.push(u);return r.ContentTypes(i),!0}function d(){var t=y(n.ActiveContentTypeId||null);!t&&r.ContentTypes().length>0&&(t=r.ContentTypes()[0]);t==undefined&&(t=null);r.ActiveContentType(t)}function c(n){var t,i;if(!n)throw new Error("Update SearchResultsManagement screen: contentTypes is null");w(n);t=y(null);!t&&r.ContentTypes().length>0&&(t=r.ContentTypes()[0]);r.ActiveContentType(t);r.ActiveContentType()&&t.Id==r.ActiveContentType().Id&&(i=v(),h==null||k(h,i)||r.ReloadData())}function g(){p();r.EnablePublishInfo(n.EnablePublishInfo);w(n.ContentTypeList)||r.SearchExpired(!0);d();l();ko.applyBindings(r,t);a(!1);s();r.Selection.Update(null,null,_enums.PAGE.SEARCH_RESULT);window.GlobalEvents.RecordSearchCompleted.fire({resultSearchModel:n,resultSearchRoot:r});window.location.href.toLowerCase().indexOf("searchresults")>0&&_macros.FacetedMacroUpdate(r,!1,_enums.PAGE.SEARCH_RESULT)}var r=this,h=null,o;this.InitData=n;var u=n.PrimarySearchId,e=n.PreviousSearchId,f=n.CurrentSearchId;this.ResultsType=ko.observable(i);this.IsSearchResults=ko.computed(function(){return r.ResultsType()==window._SearchRecords.RESULTS_TYPE.Search});this.IsBasketResults=ko.computed(function(){return r.ResultsType()==window._SearchRecords.RESULTS_TYPE.Basket});this.LinkGetRecords=ko.computed(function(){if(r.ResultsType()==window._SearchRecords.RESULTS_TYPE.Search)return _utilities.getAbsoluteURL("SearchResults/GetRecordsPage");if(r.ResultsType()==window._SearchRecords.RESULTS_TYPE.Basket)return _utilities.getAbsoluteURL("Basket/GetRecordsPage");if(r.ResultsType()==window._SearchRecords.RESULTS_TYPE.Collections)return _utilities.getAbsoluteURL("Collections/GetRecordsPage");throw new Error("SearchResultsManagement->LinkGetRecords(computed): Type not defined");});this.EnablePublishInfo=ko.observable(!1);this.SearchExpired=ko.observable(!1);this.NotFoundRecords=ko.observable(!1);this.GlobalError=ko.observable(!1);this.IsLoading=ko.observable(!0);this.ContentTypes=ko.observableArray([]);this.ActiveContentType=ko.observable(null);this.ActiveContentType.subscribeChanged(function(n,t){var i=n||t&&t.Id!=n.Id;r.CreateLayoutForContentType(n,i)});this.Navigation=new NavigationKnockoutModel(r,t);this.Selection=new SelectionRecordsKnockoutModel(r);this.GridView=null;this.ThumbnailView=new CardViewKnockoutModel(r);this.CitationView=new CardViewKnockoutModel(r);o=!1;this.IsAutoDataReload=function(){return o};this.ReloadData=function(){if(r.IsAutoDataReload()){switch(r.Navigation.View()){case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.GridView:r.GridView||(r.GridView=new GridViewKnockoutModel(r))}setTimeout(function(){b()},0)}};this.ResetSelection=function(){switch(r.Navigation.View()){case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.GridView:r.GridView&&r.GridView.ResetSelection();break;case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Citation:r.CitationView&&r.CitationView.ResetSelection();break;case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Thumbnail:r.ThumbnailView&&r.ThumbnailView.ResetSelection()}};this.GetRecordCount=function(){return r.Navigation.RecordsCount()};this.ContentTypeTabClick=function(n){r.ActiveContentType(n)};this.CreateLayoutForContentType=function(n,t){l();r.Navigation.Update(n,null,_enums.PAGE.SEARCH_RESULT);var i=r.GetViewFromTemplates(n.Views,r.Navigation.View());if(!i)throw new Error("Create or update layout : view is null");switch(r.Navigation.View()){case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.GridView:r.GridView||(r.GridView=new GridViewKnockoutModel(r));r.GridView.Update(i,null,_enums.PAGE.SEARCH_RESULT);break;case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Citation:r.CitationView.Update(i,null,_enums.PAGE.SEARCH_RESULT);break;case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Thumbnail:r.ThumbnailView.Update(i,null,_enums.PAGE.SEARCH_RESULT)}a(t)};this.GetViewById=function(n){for(var t=0;t<r.InitData.ViewList.length;t++)if(r.InitData.ViewList[t].Value==n)return r.InitData.ViewList[t];return null};this.GetViewFromTemplates=function(n,t){if(!n)return null;for(var i=0;i<n.length;i++)if(n[i].ViewType==t)return n[i];return null};this.GetCurrentSearchId=function(){return f?f:u};this.GetPrimarySearchId=function(){return u};this.GetPreviousSearchId=function(){return e};this.RunSearchById=function(t,i){$.ajax({type:"GET",url:_utilities.getAbsoluteURL("CurrentSearch/RunSearchByIdAndGetState?searchResultId="+t),cache:!1,async:!0,contentType:"application/json, UTF-8",dataType:"json",beforeSend:function(){},success:function(t){var o=JSON.parse(t),h;if(!o.Success){window._toast.warning(o.Message);return}if(!o.Data.ContentTypes||o.Data.ContentTypes.length==0){r.NotFoundRecords(!0);u=o.Data.PrimarySearchId;e=o.Data.PreviousSearchId;f=o.Data.CurrentSearchId;_macros.FacetedMacroUpdate(r,!0,i);s();return}(h=o.Data.ContentTypes,h)&&(u=o.Data.PrimarySearchId,e=o.Data.PreviousSearchId,f=o.Data.CurrentSearchId,u||(u=o.Data.CurrentSearchId),c(o.Data.ContentTypes),_macros.CurrentSearchMacroUpdate(o.Data.Conditions),_macros.FacetedMacroUpdate(r,!1,i),window.GlobalEvents.RecordSearchCompleted.fire({resultSearchModel:n,resultSearchRoot:r}))},complete:function(){},error:function(n,t,i){_message.errorAjax(n,t,i)}})};this.Update=function(t,i,o){if(!t){$.ajax({type:"GET",url:_utilities.getAbsoluteURL("CurrentSearch/GetStateCurrentSearch"),cache:!1,async:!0,contentType:"application/json, UTF-8",dataType:"json",beforeSend:function(){},success:function(t){var i=JSON.parse(t),h;if(!i.Success){window._toast.warning(i.Message);return}if(!i.Data.ContentTypes||i.Data.ContentTypes.length==0){r.NotFoundRecords(!0);u=i.Data.PrimarySearchId;e=i.Data.PreviousSearchId;f=i.Data.CurrentSearchId;_macros.FacetedMacroUpdate(r,!0,o);s();return}(h=i.Data.ContentTypes,h)&&(u=i.Data.PrimarySearchId,e=i.Data.PreviousSearchId,f=i.Data.CurrentSearchId,u||(u=i.Data.CurrentSearchId),c(i.Data.ContentTypes),_macros.CurrentSearchMacroUpdate(i.Data.Conditions),_macros.FacetedMacroUpdate(r,!1,o),window.GlobalEvents.RecordSearchCompleted.fire({resultSearchModel:n,resultSearchRoot:r}))},complete:function(){},error:function(n,t,i){_message.errorAjax(n,t,i)}});return}c(t);i&&(u=i,e=i,f=i);_macros.FacetedMacroUpdate(r,!1,o)};g()}function ContentTypeKnockoutModel(n,t){function u(){t&&(i.Id=t.ContentTypeId,i.Name=t.ContentTypeName,i.Description=t.ContentTypeDescription,i.RecordsCount=t.FoundedRecordsCount,i.CurrentView=t.CurrentView,i.CurrentPage=t.CurrentPage,i.CurrentPageSize=t.CurrentPageSize?t.CurrentPageSize:r.InitData.DefaultPageSize?r.InitData.DefaultPageSize:r.InitData.PageSizeList&&r.InitData.PageSizeList.length>0?r.InitData.PageSizeList[0]:10,i.CurrentSortSequence=t.CurrentSortSequence,i.CurrentSortDirection=t.CurrentSortDirection,i.CurrentSortMode=t.CurrentSortMode,i.Views=t.Views,i.SortLevels=t.SortLevels)}if(!n)throw new Error("Create ContentTypeKnockoutModel: searchResultModel is null");if(!n.InitData)throw new Error("Create ContentTypeKnockoutModel: searchResultModel.InitData is null");var i=this,r=n;return this.Views=[],this.SortLevels=[],this.Id=null,this.Name="",this.Description="",this.RecordsCount=0,this.CurrentView=t.CurrentView,this.CurrentPage=1,this.CurrentPageSize=10,this.CurrentSortSequence=null,this.CurrentSortDirection=_SearchRecords.SORT_ORDER.Ascending,this.CurrentSortMode=_SearchRecords.SORT_MODE.WithoutNoiseWords,u(),i}function NavigationKnockoutModel(n,t){function f(n){for(let t=0;t<i.SortFieldList().length;t++)if(i.SortFieldList()[t].Sequence==n)return i.SortFieldList()[t];return null}function e(n){var f=[],t,u;if(n&&n.Views&&n.Views.length>=0)for(t=0;t<n.Views.length;t++){if(u=r.GetViewById(n.Views[t].ViewType),!u)throw new Error("initViewList: view is not found in the Views parent.InitData.ViewList");f.push(u)}i.ViewList(f)}function o(){i.SortOrderList(r.InitData.SortOrderList)}function s(){var n=[],t;for(r.InitData.PageSizeList&&r.InitData.PageSizeList.length!=0||(r.InitData.DefaultPageSize?n.push({Value:r.InitData.DefaultPageSize,Text:r.InitData.DefaultPageSize}):n.push({Value:10,Text:10}),i.PageSizesList(n)),t=0;t<r.InitData.PageSizeList.length;t++)n.push({Value:r.InitData.PageSizeList[t],Text:r.InitData.PageSizeList[t]});i.PageSizesList(n)}function h(n){var r=[],t;if(n){if(n.SortLevels){for(t=0;t<n.SortLevels.length;t++)r.push(n.SortLevels[t]);i.SortFieldList(r)}}else i.SortFieldList(r)}function u(){var n=i.PagesCount(),r,u,f,o,e;if(i.RecordsCount()>i.PageSize()){for(u=Math.floor(n/7)>0?7:n,i.Page()<=4?r=1:(f=n-i.Page(),f>=4?(r=i.Page()-3,u=i.Page()+3):n>7?(u=i.Page()+f,r=i.Page()-6+f):(r=1,u=n)),o=[],e=r;e<=u;e++)o.push(e);i.PageButtons(o)}else i.PageButtons([]);$(t).find(".page-link").each(function(){$(this).keydown(function(n){return n.keyCode==_enums.KEYBOARD_KEYS.Enter?($(this).click(),n.stopPropagation(),!1):!0})})}function c(){o();s()}if(!n)throw new Error("Create NavigationKnockoutModel: searchResultModel is null");if(!n.InitData)throw new Error("Create NavigationKnockoutModel: searchResultModel.InitData is null");var i=this,r=n;this.ViewList=ko.observableArray([]);this.SortFieldList=ko.observableArray([]);this.SortOrderList=ko.observableArray([]);this.PageSizesList=ko.observableArray([]);this.RecordsCount=ko.computed(function(){return r.ActiveContentType()?r.ActiveContentType().RecordsCount:0});this.View=ko.observable(null);this.View.subscribe(function(n){r.ActiveContentType()&&r.IsAutoDataReload()&&(r.ActiveContentType().CurrentView=n,r.CreateLayoutForContentType(r.ActiveContentType(),!0))});this.IsGridView=ko.computed(function(){return i.View()==window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.GridView});this.IsCitation=ko.computed(function(){return i.View()==window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Citation});this.IsThumbnail=ko.computed(function(){return i.View()==window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Thumbnail});this.ExistGridView=ko.observable(!1);this.ExistCitation=ko.observable(!1);this.ExistThumbnail=ko.observable(!1);this.ExistOnlyOneView=ko.computed(function(){var n=0;return i.ExistGridView()&&n++,i.ExistCitation()&&n++,i.ExistThumbnail()&&n++,n==1});this.SortSequence=ko.observable(null);this.SortSequence.subscribe(function(n){var t=window._SearchRecords.SORT_ORDER.Ascending,u=f(n);if(u&&u.Fields&&u.Fields.length>0&&(t=u.Fields[0].FieldSortDirection),!r.ActiveContentType()||!r.IsAutoDataReload()){i.SortOrder()!=t&&i.SortOrder(t);return}if(r.ActiveContentType().CurrentSortSequence=n,i.SortOrder()!=t){i.SortOrder(t);return}r.ReloadData()});this.SortOrder=ko.observable(null);this.SortOrder.subscribe(function(n){r.ActiveContentType()&&r.IsAutoDataReload()&&(r.ActiveContentType().CurrentSortDirection=n,r.ReloadData())});this.SortOrderClass=ko.computed(function(){var n="";return i.SortOrder()==window._SearchRecords.SORT_ORDER.Ascending?n="far fa-sort-alpha-up":i.SortOrder()==window._SearchRecords.SORT_ORDER.Descending&&(n="far fa-sort-alpha-down-alt"),n});this.PageButtons=ko.observableArray([]);this.Page=ko.observable(null);this.Page.subscribe(function(n){r.ActiveContentType()&&r.IsAutoDataReload()&&(r.ActiveContentType().CurrentPage=n,r.ReloadData())});this.PageSize=ko.observable(null);this.PageSize.subscribe(function(n){if(r.ActiveContentType()&&r.IsAutoDataReload()){r.ActiveContentType().CurrentPageSize=n;var u=i.RecordsCount()%n,t=Math.floor(i.RecordsCount()/n),f=u>0?t+1:t;i.Page()>f||r.ReloadData()}});this.CustomPage=ko.observable("");this.PagesCount=ko.computed(function(){var r=i.RecordsCount()%i.PageSize(),t=Math.floor(i.RecordsCount()/i.PageSize()),n=r>0?t+1:t;return n!==0&&i.Page()>n&&i.Page(1),setTimeout(function(){u()},0),n});this.PagingVisible=ko.computed(function(){return i.PagesCount()>1});this.PagesizingVisible=ko.computed(function(){for(var n=0;n<i.PageSizesList().length;n++)if(i.RecordsCount()>i.PageSizesList()[n].Value)return!0;return!1});this.JumpingControlsVisible=ko.computed(function(){return i.PagesCount()>7});this.JumpingToBackVisible=ko.computed(function(){return i.JumpingControlsVisible()?i.Page()!=1:!1});this.JumpingToNextVisible=ko.computed(function(){return i.JumpingControlsVisible()?i.Page()<i.PagesCount():!1});this.JumpToBackPage=function(){i.Page()!=1&&(i.CustomPage(""),i.Page()-1>0&&i.Page(i.Page()-1),u())};this.JumpToNextPage=function(){i.CustomPage("");i.Page()+1<=i.PagesCount()&&i.Page(i.Page()+1);u()};this.JumpToLastPage=function(){i.Page()>=i.PagesCount()||(i.CustomPage(""),i.Page(i.PagesCount()),u())};this.JumpToCustomPage=function(){parseInt(i.CustomPage())<1&&i.CustomPage(1);parseInt(i.CustomPage())>i.PagesCount()&&i.CustomPage(i.PagesCount());i.Page(parseInt(i.CustomPage()));i.CustomPage("");u()};this.JumpToPage=function(n){i.CustomPage("");i.Page(n);u()};this.CustomPageKeyPress=function(n,t){return(t.which==13)?(i.JumpToCustomPage(),!1):!0};this.ActiveGridViewLayout=function(){i.View(window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.GridView)};this.ActiveCitationLayout=function(){i.View(window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Citation)};this.ActiveThumbnailLayout=function(){i.View(window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Thumbnail)};this.InvertSortOrder=function(){i.SortOrder()==window._SearchRecords.SORT_ORDER.Ascending?i.SortOrder(window._SearchRecords.SORT_ORDER.Descending):i.SortOrder(window._SearchRecords.SORT_ORDER.Ascending)};this.Update=function(n){if(!n)throw new Error("Update NavigationKnockoutModel: ct is null");h(n);e(n);i.ExistGridView(!1);i.ExistCitation(!1);i.ExistThumbnail(!1);for(var t=0;t<n.Views.length;t++)switch(n.Views[t].ViewType){case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.GridView:i.ExistGridView(!0);break;case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Citation:i.ExistCitation(!0);break;case window._SearchRecords.SEARCH_RESULT_VIEW_TYPE.Thumbnail:i.ExistThumbnail(!0)}i.CustomPage("");i.View(n.CurrentView);i.SortSequence(n.CurrentSortSequence);i.SortOrder(n.CurrentSortDirection);i.PageSize(n.CurrentPageSize);i.Page(n.CurrentPage);setTimeout(function(){u()},0)};this.GetCurentSortFieldInfo=function(){if(!i.SortSequence()||!i.SortFieldList()||i.SortFieldList().length==0)return null;for(var n=0;n<i.SortFieldList().length;n++)if(i.SortSequence()==i.SortFieldList()[n].Sequence)return i.SortFieldList()[n];return null};c()}function SelectionRecordsKnockoutModel(n){function u(){if(r&&r.length!=0)for(var n=0;n<r.length;n++)r[n](t.GetSelection(),t)}function f(){}var t,i,r;if(!n)throw new Error("Create SelectionRecordsKnockoutModel: searchResultModel is null");if(!n.InitData)throw new Error("Create SelectionRecordsKnockoutModel: searchResultModel.InitData is null");t=this;i=n;this.RecordsIds=ko.observableArray([]);this.Select=function(n){var r,f,e,o;if(n&&n.length!=0){if(i.IsBasketResults()){for(t.RecordsIds.valueWillMutate(),r=0;r<n.length;r++)(f=ko.utils.arrayFirst(t.RecordsIds(),function(t){return t==n[r]}),f)||t.RecordsIds.push(n[r]);t.RecordsIds.valueHasMutated();u();return}e={Ids:n};o=new eventAjax({success:function(n){t.RecordsIds(n.RecordsIds);u()},error:function(){},beforeSend:function(){},complete:function(){}});(new SearchRecordsResultsUtilities).AddRecordsToBasket(e,o,t)}};this.Deselect=function(n){var r,f,e;if(n&&n.length!=0){if(i.IsBasketResults()){for(t.RecordsIds.valueWillMutate(),r=0;r<n.length;r++)t.RecordsIds.remove(function(t){return t==n[r]});t.RecordsIds.valueHasMutated();u();return}f={Ids:n};e=new eventAjax({success:function(n){t.RecordsIds(n.RecordsIds);u()},error:function(){},beforeSend:function(){},complete:function(){}});(new SearchRecordsResultsUtilities).RemoveRecordsFromBasket(f,e,t)}};this.Clear=function(){var n=function(){u();i.ResetSelection()},r;if(i.IsBasketResults()){t.RecordsIds([]);n();return}r=new eventAjax({success:function(i){t.RecordsIds(i.RecordsIds);n()},error:function(){},beforeSend:function(){},complete:function(){}});(new SearchRecordsResultsUtilities).ClearBasket(r,t)};this.GetSelection=function(){return t.RecordsIds()?t.RecordsIds():[]};r=[];this.AddEventAfterSelection=function(n){n&&typeof n=="function"&&r.push(n)};this.Update=function(){var n=new eventAjax({success:function(n){t.RecordsIds(n.RecordsIds);u();i.ResetSelection()},error:function(){},beforeSend:function(){},complete:function(){}});(new SearchRecordsResultsUtilities).GetRecordsFromBasket(n,t)};f()}function GridViewKnockoutModel(n,t){function s(n){var r,t,u,e;if(f&&n&&n.rows&&n.rows.length!=0){for(r=[],t=0;t<n.rows.length;t++)r.push(n.rows[t].id);u={Ids:r};e=new eventAjax({success:function(n){var t=n.CopiesInfo,r;t&&t.length!=0&&(r=function(n){for(var i=0;i<t.length;i++)if(t[i].CatalogueId==n)return t[i];return null},$(i.Grid.grid).find(".gridview-copies-info").each(function(){var u=$(this).attr("data-cid"),n;if(u&&(n=r(u),n)){var t=0,i="",f="";switch(n.CatalogueSubType){case 2:t=n.ChildRecordCount;i=window.SearchResultsLocalizations.LabelIssuesViewToSeeCopies;break;case 4:t=n.ChildRecordCount;i=window.SearchResultsLocalizations.LabelVolumesViewToSeeCopies;break;default:t=n.AvailableNumberInOffice;i=n.AvailableNumberInOffice==1?window.SearchResultsLocalizations.LabelCopyCurrentlyAvailable:window.SearchResultsLocalizations.LabelCopiesCurrentlyAvailable;n.AvailableNumberInOffice>0&&(f=window.SearchResultsLocalizations.CopiesAvailableTitle_Start+" "+n.AvailableNumberInOffice+" "+window.SearchResultsLocalizations.CopiesAvailableTitle_End)}$(this).find(".gridview-copies-counting").text(t);$(this).find(".gridview-copies-title").text(i);$(this).find(".gridview-copies-title").attr("title",f);$(this).show()}}),i.Grid.onEvent.ShowCopiesInfo())},error:function(){},beforeSend:function(){},complete:function(){}});(new RecordCopiesUtilities).GetRecordsCopiesInfo(u,e,i)}}function h(){var n=document.getElementById(_string.trim(i.Grid.wrapperId,"#"));n&&window.addResizeListener(n,function(){_jqGrid.Utilities.Resize(i.Grid,1)})}if(!t&&!n)throw new Error("Create GridViewKnockoutModel: searchResultModel is null");if(!t&&!n.InitData)throw new Error("Create GridViewKnockoutModel: searchResultModel.InitData is null");var i=this,r=n,u=!1,e=!1,f=!1,o=!1;this.Grid={wrapperId:"#grid-view-record-results-wrapper",gridId:"#grid-view-record-results",grid:null,init:function(n){var t,f;for(i.Grid.jqGridFormatterInit(),n.loadComplete=function(n){_jqGrid.Utilities.Resize(i.Grid,1);i.Grid.initEvent(n);$(i.Grid.grid).jqGrid("init_tooltips",i.Grid.wrapperId);i.ResetSelection();s(n);$(i.Grid.wrapperId).find(".cbox.ace").each(function(){$(this).attr("aria-label","Add record to selection")})},n.caption="",t=0;t<n.colModel.length;t++)f=n.colModel[t],f.cellattr=_jqGrid.cellattr.emptyTitle;r&&r.Selection&&(n.onSelectAll=function(n,t){t?r.Selection.Select(n):r.Selection.Deselect(n)},n.onSelectRow=function(n,t){t?r.Selection.Select(new Array(n)):r.Selection.Deselect(new Array(n))});u&&(n.subGridRowExpanded=function(n,t){var r=_utilities.stripScripts($(i.Grid.grid).jqGrid("getLocalRow",t)._rowPreviewValue),u="#"+n;$(u).append(r)},n.subGrid=!0,n.subGridOptions={plusicon:"far fa-plus",minusicon:"far fa-minus",reloadOnExpand:!1});i.Grid.grid=$(i.Grid.gridId).jqGrid(n);$(i.Grid.grid).jqGrid("init_soutron",i.Grid.wrapperId);_jqGrid.Utilities.Resize(i.Grid,1)},unload:function(){i.Grid.grid&&$.jgrid.gridUnload(i.Grid.gridId)},reload:function(n){$(i.Grid.grid).jqGrid("clearGridData");var t;t=r&&r.Navigation?r.Navigation.PageSize():$(i.Grid.grid).jqGrid().getGridParam("rowNum");t=t||10;$(i.Grid.grid).jqGrid("setGridParam",{datatype:"local",rowNum:t,data:n}).trigger("reloadGrid");i.Grid.onEvent.UpdateSortIcons()},resize:function(){i.Grid.grid&&setTimeout(function(){$(i.Grid.grid).jqGrid("auto_resize",i.Grid.wrapperId,4)},0)},onEvent:{InitCheckbox:function(){$(i.Grid.grid).jqGrid("init_checkbox",i.Grid.wrapperId)},UpdateNumbering:function(){var n,t,u;if(r&&r.Navigation){if(r.Navigation.PagesCount()<2)return;n=r.Navigation.PageSize();t=r.Navigation.Page()}else t=$(i.Grid.grid).jqGrid().getGridParam("page"),n=$(i.Grid.grid).jqGrid().getGridParam("rowNum");u=n*(t-1)+1;$(i.Grid.grid).find(".jqgrid-rownum").each(function(n){$(this).text(u+n)})},HideSubGridIfPreviewIsEmpy:function(n){for(var r=n.rows,t=0;t<r.length;t++)r[t]._rowPreviewValue?$(i.Grid.grid).expandSubGridRow(r[t].id):$("#"+r[t].id+" td.sgcollapsed",i.Grid.grid).unbind("click").html("")},AttachOpenRecordClick:function(){$(i.Grid.grid).find(".gridview-clickable-cell").each(function(){var n=$(this).attr("data-cid");n&&$(this).click(function(t){_utilities.openRecord(this,n,t.ctrlKey);return})})},AttachPreviewClick:function(){$(i.Grid.grid).find(".open-preview").each(function(){var n=$(this).attr("data-cid");if(n){if(e)$(this).show();else return;$(this).click(function(){window._record.Preview(n,window.commonLocalizations.Preview)})}})},LoadBookCoversForFields:function(){var n=[],r,t,u,f;if($(i.Grid.grid).find(".bookcover-cell").each(function(){var t=$(this).attr("data-isbn");t&&n.push({Element:this,Isbn:t})}),n.length!=0){for(r="",t=0;t<n.length;t++)u=_utilities.getCleanIsbnValue(n[t].Isbn),r+=u,t!=n.length-1&&(r+=",");f={value:r,field:"ISBN",provider:"Google",size:"Medium","result-mode":"Url",format:"json"};$.ajax({url:window.soutronContext.Api.CatalogueBookCoverLink,type:"GET",dataType:"json",cache:!1,data:f,beforeSend:function(n){n.setRequestHeader("LmsApiToken",window.soutronContext.Api.ProtectToken)},success:function(t){var u=t.bookCovers,i,r,f;if(u&&u.length===n.length)for(i=0;i<n.length;i++)if(r=n[i].Element,f=u[i].imageRequestedUrl,f){var e=u[i].bookPreviewUrl,o=$(r).attr("data-cid"),s=$(r).attr("data-seq");$(r).find(".grid-bookcover-block").each(function(){var n="book-cover-"+o+"-"+s;$(this).find("."+n).attr("href",f);$(this).find(".grid-bookcover-image").attr("src",f);e?$(this).find(".preview-link").attr("href",e):$(this).find(".preview-link").hide();$(this).find("."+n).each(function(){var t={transition:"elastic",rel:n,scalePhotos:!0,scrolling:!0,preloading:!1,current:"{current} of {total}",close:"&times;",photo:!0,maxWidth:"100%",maxHeight:"100%",reposition:!0};$(this).colorbox(t)})});$(r).find(".grid-bookcover-empty-block").hide();$(r).find(".grid-bookcover-block ").show()}},complete:function(){},error:function(n,t){_message.errorAjax(n,t,n)}})}},InitSliderBookCoversForFields:function(){$(i.Grid.grid).find(".grid-image-values-block").each(function(){var t=$(this).attr("data-cid"),i=$(this).attr("data-seq"),n="images-"+t+"-"+i;$(this).find("."+n).each(function(){var t={transition:"elastic",rel:n,scalePhotos:!1,scrolling:!0,preloading:!1,current:"{current} of {total}",close:"&times;",photo:!0,maxWidth:"100%",maxHeight:"100%",reposition:!0};$(this).colorbox(t)})})},LoadBookCoversForGroups:function(){var t,n,u,h,o,s,c,e,f,l,a;if(r&&r.Navigation&&r.Navigation.IsGridView()&&(t=[],n=$("#grid-view-layout-block").find(".group-bookcover-field"),n&&n.length!=0)){for(u=0;u<n.length;u++){if(h=$(n[u]).attr("data-thumbnail_size_px")+"px",o=$(n[u]).attr("data-isbn"),!o){if(s=$(n[u]).attr("data-empty_link"),!s)continue;c=getBookCoverImgTag(s,h);$(n[u]).html(c);continue}t.push({Element:n[u],Isbn:o})}if(t.length!=0){for(e="",f=0;f<t.length;f++)l=_utilities.getCleanIsbnValue(t[f].Isbn),e+=l,f!=t.length-1&&(e+=",");a={value:e,field:"ISBN",provider:"Google",size:"Medium","result-mode":"Url",format:"json"};$.ajax({url:window.soutronContext.Api.CatalogueBookCoverLink,type:"GET",beforeSend:function(n){n.setRequestHeader("LmsApiToken",window.soutronContext.Api.ProtectToken)},dataType:"json",cache:!1,data:a,success:function(i){var u=i.bookCovers,r;if(u&&u.length===t.length)for(r=0;r<t.length;r++){var e=$(n[r]).attr("data-thumbnail_size_px")+"px",o=u[r].imageLargeUrl||u[r].imageMediumUrl||u[r].imageSmallUrl||u[r].imageRequestedUrl,s=u[r].imageSmallUrl||u[r].imageMediumUrl||u[r].imageLargeUrl||u[r].imageRequestedUrl,h='<a href="'+o+'" aria-label="Book cover image">'+getBookCoverImgTag(s,e)+"<\/a>",f="";u[r].bookPreviewUrl&&(f='<a target="_blank" href="'+u[r].bookPreviewUrl+'" aria-label="Google books preview"><img class="card-bookcover-preview-image" src="'+window._SearchRecords.GOOGLE_PREVIEW_LOGO+'" alt=""><\/a>');$(t[r].Element).html(h+f)}},complete:function(){i.Grid.onEvent.InitSliderBookCoversForGroups()},error:function(n,t,i){_message.errorAjax(n,t,i)}})}}},InitSliderBookCoversForGroups:function(){$(i.Grid.grid).find(".group-bookcover-field").each(function(n){var t="group-bookcover-field-"+n,i={transition:"elastic",rel:t,scalePhotos:!0,scrolling:!0,preloading:!1,current:"{current} of {total}",close:"&times;",photo:!0,maxWidth:"100%",maxHeight:"100%",reposition:!0};$(this).find('a:not(":has(img.card-bookcover-preview-image)")').colorbox(i)})},InitSliderImagesForGroups:function(){$(i.Grid.grid).find(".group-field-images").each(function(n){var t="group-field-images-"+n,i={transition:"elastic",rel:t,scalePhotos:!0,scrolling:!0,preloading:!1,current:"{current} of {total}",close:"&times;",photo:!0,maxWidth:"100%",maxHeight:"100%",reposition:!0};$(this).find('a:not(":has(img.card-bookcover-preview-image)")').colorbox(i)})},ShowPublishedDetails:function(){o&&$(i.Grid.gridId).find(".published-details-icon").each(function(){var t=$(this).attr("data-cid"),n=$(i.Grid.gridId).jqGrid("getLocalRow",t);n&&(n.isPublished===!0?($(this).addClass("fas fa-globe-americas green bigger-120").show(),$(this).attr("title",window.SearchResultsLocalizations.RecordPublishedTitle)):n.isPublished===!1&&($(this).addClass("fas fa-globe-americas orange bigger-120").show(),$(this).attr("title",window.SearchResultsLocalizations.RecordUnpublishedTitle)))})},ShowCopiesInfo:function(){f&&$(i.Grid.gridId).find(".gridview-copies-info").each(function(){var n=$(this).attr("data-cid");$(this).find(".gridview-copies-title").click(function(){window._record.Preview(n);return}).keydown(function(n){return n.keyCode==_enums.KEYBOARD_KEYS.Enter?($(this).click(),n.stopPropagation(),!1):!0})})},Actions:function(){$(i.Grid.grid).find(".actions-cell").each(function(){var n=$(this).attr("data-cid");n&&$(this).find(".action-preview-click").click(function(){window._record.Preview(n)})})},UpdateSortIcons:function(){var n,t;r&&r.Navigation&&($(i.Grid.wrapperId).find(".ui-jqgrid-sortable").each(function(){$(this).find(".s-ico").hide()}),n=r.Navigation.GetCurentSortFieldInfo(),n&&n.Fields&&n.Fields.length!=0)&&(t=r.Navigation.SortOrder(),$(i.Grid.wrapperId).find(".ui-jqgrid-sortable").each(function(){var i=$(this),f=$(i).attr("id"),u,r;if(f)for(u=0;u<n.Fields.length;u++)if((r=n.Fields[u],r.FieldId)&&f.endsWith("_"+r.FieldId)){if($(i).find(".s-ico").find(".ui-icon-asc").removeClass("ui-state-disabled"),$(i).find(".s-ico").find(".ui-icon-desc").removeClass("ui-state-disabled"),n.Fields.length==1)if(t==window._SearchRecords.SORT_ORDER.Ascending)$(i).find(".s-ico").find(".ui-icon-desc").addClass("ui-state-disabled");else if(t==window._SearchRecords.SORT_ORDER.Descending)$(i).find(".s-ico").find(".ui-icon-asc").addClass("ui-state-disabled");else return;else if(t==window._SearchRecords.SORT_ORDER.Ascending)if(r.FieldSortDirection==window._SearchRecords.SORT_ORDER.Ascending)$(i).find(".s-ico").find(".ui-icon-asc").addClass("ui-state-disabled");else if(r.FieldSortDirection==window._SearchRecords.SORT_ORDER.Descending)$(i).find(".s-ico").find(".ui-icon-desc").addClass("ui-state-disabled");else return;else if(r.FieldSortDirection==window._SearchRecords.SORT_ORDER.Ascending)$(i).find(".s-ico").find(".ui-icon-desc").addClass("ui-state-disabled");else if(r.FieldSortDirection==window._SearchRecords.SORT_ORDER.Descending)$(i).find(".s-ico").find(".ui-icon-asc").addClass("ui-state-disabled");else return;$(i).find(".s-ico").show()}}))}},initEvent:function(n){typeof i.Grid.onEvent.InitCheckbox=="function"&&i.Grid.onEvent.InitCheckbox();typeof i.Grid.onEvent.UpdateNumbering=="function"&&i.Grid.onEvent.UpdateNumbering();u&&typeof i.Grid.onEvent.HideSubGridIfPreviewIsEmpy=="function"&&i.Grid.onEvent.HideSubGridIfPreviewIsEmpy(n);typeof i.Grid.onEvent.LoadBookCoversForFields=="function"&&i.Grid.onEvent.LoadBookCoversForFields();typeof i.Grid.onEvent.InitSliderBookCoversForFields=="function"&&i.Grid.onEvent.InitSliderBookCoversForFields();typeof i.Grid.onEvent.LoadBookCoversForGroups=="function"&&i.Grid.onEvent.LoadBookCoversForGroups();typeof i.Grid.onEvent.InitSliderImagesForGroups=="function"&&i.Grid.onEvent.InitSliderImagesForGroups();typeof i.Grid.onEvent.AttachOpenRecordClick=="function"&&i.Grid.onEvent.AttachOpenRecordClick();typeof i.Grid.onEvent.AttachPreviewClick=="function"&&i.Grid.onEvent.AttachPreviewClick();typeof i.Grid.onEvent.ShowPublishedDetails=="function"&&i.Grid.onEvent.ShowPublishedDetails();r&&setTimeout(function(){window.GlobalEvents.AfterRenderSearchResultPage.fire(r.Navigation.View())},0)},attachDetailsHtmlToCellHtml:function(n,t){var i=`<div class="gridview-copies-info" data-cid="${t.id}" style="display: none">
    <span class="gridview-copies-counting"></span>
    <span class="role-button gridview-copies-title" tabindex="0"></span>
</div>
<div class="gridview-details-actions">
    <i class="published-details-icon" data-bs-toggle="tooltip" title="" data-cid="${t.id}" style="display: none" aria-hidden="true"></i>
    <button class="btn-transparent open-preview" data-cid="${t.id}" style="display: none;" title="${window.commonLocalizations.OpenPreview}" aria-label="${window.commonLocalizations.OpenPreview}">
        <i class="fad fa-eye blue" aria-hidden="true"></i>
    </button>
</div>`;return n="<div>"+n+"<\/div>",n+i},jqGridFormatterInit:function(){$.extend($.fn.fmatter,{SearchResult_Actions:function(n,t,i){return'<div class="actions-cell" style="text-align: center;" data-cid="'+i.id+'"><a class="role-button action-preview-click" title="Open Preview" aria-label="Open Preview"><i class="fad fa-eye blue bigger-130" aria-hidden="true"><\/i><\/a><\/div>'}});$.extend($.fn.fmatter,{SearchResult_Text:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_Digit:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_Date:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_ComplexDate:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_File:function(n,t,r){var t=t.colModel,f,s,o,u,e;if(!n||!n.Values||n.Values.length==0)return t.ShowDetails?i.Grid.attachDetailsHtmlToCellHtml("",r):"";for(f="",s=n.Values,o=0;o<s.length;o++)if(u=s[o],e="",u.AllowDownload&&u.CopyrightAcceptRequired?e='<a href="#" class="role-button" title="'+u.Value+'" aria-label="'+u.Value+'" onclick="ShowPopupForRemoteUrl(\''+u.FileUrl+'\')"><i class="bigger-120 '+u.FileIcon+'" aria-hidden="true"><\/i ><\/a>':u.AllowDownload&&!u.CopyrightAcceptRequired?e='<a href="'+u.FileUrl+'" class="role-button" title="'+u.Value+'" aria-label="'+u.Value+'"><i class="bigger-120 '+u.FileIcon+'" aria-hidden="true"><\/i ><\/a>':u.AllowView&&!u.AllowDownload&&(e='<i class="bigger-120 '+u.FileIcon+'" aria-hidden="true"><\/i >'),f+=e,t.IsSingleEntry)break;return f='<div class="center">'+f+"<\/div>",t.ShowDetails&&(f=i.Grid.attachDetailsHtmlToCellHtml(f,r)),f}});$.extend($.fn.fmatter,{SearchResult_Thesaurus:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_ValidationList:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_Link:function(n,t,r){var t=t.colModel,u,e,f;if(!n||!n.Values||n.Values.length==0)return t.ShowDetails?i.Grid.attachDetailsHtmlToCellHtml("",r):"";for(u="",e=n.Values,f=0;f<e.length;f++)if(u+=e[f].HtmlValue,t.IsSingleEntry)break;return u='<div class="center">'+u+"<\/div>",t.ShowDetails&&(u=i.Grid.attachDetailsHtmlToCellHtml(u,r)),u}});$.extend($.fn.fmatter,{SearchResult_Image:function(n,t,r){var t=t.colModel,l,o,s,e,u;if(!n||!n.Values||n.Values.length==0)return t.ShowDetails?i.Grid.attachDetailsHtmlToCellHtml("",r):"";var f="",h=window._SearchRecords.Utilities.GetThumbnailSize(t.ThumbnailSize),a=n.Values[0].BookCover===!0;if(a){var c=n.Values[0],v=`<div class="grid-bookcover-empty-block">
    <img class="grid-empty-bookcover" src="${c.EmptyUrl}" alt="" style="height:${h}">
</div>`,y=`<div class="grid-bookcover-block" style="display: none">
    <a class="book-cover-${r.id}-${t.Sequence}" href="" aria-label="Book cover image">
        <img class="grid-bookcover-image" src="" alt="" style="max-height:${h}; max-width:${h}">
    </a>
    <a class="preview-link" href="" target="_blank" aria-label="Google books preview">
        <img class="grid-bookcover-preview-image" src="${window._SearchRecords.GOOGLE_PREVIEW_LOGO}" alt="">
    </a>
</div>`;f=`<div class="bookcover-cell" data-cid="${r.id}" data-seq="${t.Sequence}" data-isbn="${c.Isbn}" data-size="${t.ThumbnailSize}">${c.Isbn?y:v}</div>`}else{if(l="",o="",t.IsSingleEntry)s=n.Values[0],l='<a href="'+s.LinkPopup+'" class="images-'+r.id+"-"+t.Sequence+'" aria-label="Open image"><img src="'+s.LinkImage+'" alt="'+s.AltText+'"><\/a>';else for(e=n.Values,o="",u=0;u<e.length;u++)o+='<a href="'+e[u].LinkPopup+'" class="images-'+r.id+"-"+t.Sequence+'"  aria-label="Open image"><img src="'+e[u].LinkImage+'" alt="'+e[u].AltText+'"><\/a>';f="<div class='grid-image-values-block' data-cid='"+r.id+"' data-seq='"+t.Sequence+"'>"+l+o+"<\/div>"}return t.ShowDetails&&(f=i.Grid.attachDetailsHtmlToCellHtml(f,r)),f}});$.extend($.fn.fmatter,{SearchResult_RichText:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_User:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_Frequency:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_Incremental:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_ISBN:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_ISSN:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_Rating:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}});$.extend($.fn.fmatter,{SearchResult_Group:function(n,t,r){var t=t.colModel,f,o,e,u;if(!n||!n.Values||n.Values.length==0)return t.ShowDetails?i.Grid.attachDetailsHtmlToCellHtml("",r):"";for(f="",o=n.Values,e=0;e<o.length;e++)if(u=_utilities.stripScripts(o[e].HtmlValue),t.Clickable&&(u='<span class="gridview-clickable-cell" data-cid="'+r.id+'">'+u+"<\/span>"),e>0&&(u="<br/>"+u),f+=u,t.IsSingleEntry)break;return t.ShowDetails&&(f=i.Grid.attachDetailsHtmlToCellHtml(f,r)),f}})},DefaultFormatter:function(n,t,r){var t=t.colModel,f,e,u,s,c,h,l,o;if(!n||!n.Values||n.Values.length==0)return t.ShowDetails?i.Grid.attachDetailsHtmlToCellHtml("",r):"";for(f="",e=n.Values,u=0;u<e.length;u++)if(s="grid-field-value",c="",e[u].Value&&(h=document.createElement("div"),h.innerHTML=e[u].Value.trim(),c=h.innerText),t.Clickable&&(s+=" gridview-clickable-cell"),l=$("<span/>").attr("data-cid",r.id).addClass(s).html(_utilities.stripScripts(e[u].HtmlValue)),o=l[0].outerHTML,u>0&&(o=t.Separator?t.Separator+o:" "+o),f+=o,t.IsSingleEntry)break;return t.ShowDetails&&(f=i.Grid.attachDetailsHtmlToCellHtml(f,r)),f}};this.ReloadRecords=function(n){if(!n||!n.Rows)throw new Error("GridViewKnockoutModel >  ReloadRecords: data is null");if(!n.Rows)throw new Error("GridViewKnockoutModel >  ReloadRecords: Rows is null");i.Grid.reload(n.Rows)};this.ResetSelection=function(){var n,t,u,e,f,o;if(r&&r.Selection&&i.Grid.grid&&(n=$(i.Grid.grid).jqGrid("getDataIDs"),t=r.Selection.GetSelection(),n&&t)){for(n.length<t.length?(u=n,e=t):(u=t,e=n),f=0;f<u.length;f++)for(o=0;o<e.length;o++)u[f]==e[o]&&$(i.Grid.grid).jqGrid("setSelection",u[f],!1);t.length==0&&n.length>0&&$(i.Grid.grid).jqGrid("resetSelection")}};this.Update=function(n){if(!n)throw new Error("Update GridViewKnockoutModel: view is null");if(!n.GridSettings)throw new Error("Update GridViewKnockoutModel: GridSettings is null");u=n.EnableTwoLines;e=n.EnablePreview;f=n.EnableCopyPreview;o=r?r.EnablePublishInfo()&&n.EnablePublished:n.EnablePublished;i.Grid.unload();i.Grid.init(n.GridSettings)};h()}function CardViewKnockoutModel(n){function c(n){var r,i,f,e;if(u&&n&&n.length!=0){for(r=[],i=0;i<n.length;i++)r.push(n[i].Id());f={Ids:r};e=new eventAjax({success:function(t){var u=t.CopiesInfo,s,f,i,r;if(u&&u.length!=0){for(s=function(t){for(var i=0;i<n.length;i++)if(n[i].Id()==t)return n[i];return null},f=0;f<u.length;f++)if(i=u[f],r=s(i.CatalogueId),r){var e=0,o="",h="";switch(i.CatalogueSubType){case 2:e=i.ChildRecordCount;o=window.SearchResultsLocalizations.LabelIssuesViewToSeeCopies;break;case 4:e=i.ChildRecordCount;o=window.SearchResultsLocalizations.LabelVolumesViewToSeeCopies;break;default:e=i.AvailableNumberInOffice;o=i.AvailableNumberInOffice==1?window.SearchResultsLocalizations.LabelCopyCurrentlyAvailable:window.SearchResultsLocalizations.LabelCopiesCurrentlyAvailable;i.AvailableNumberInOffice>0&&(h=window.SearchResultsLocalizations.CopiesAvailableTitle_Start+" "+i.AvailableNumberInOffice+" "+window.SearchResultsLocalizations.CopiesAvailableTitle_End)}r.CountCopies(e);r.CountCopiesTitle(o);r.CountCopiesTip(h)}l()}},error:function(){},beforeSend:function(){},complete:function(){}});(new RecordCopiesUtilities).GetRecordsCopiesInfo(f,e,t)}}function l(){if(u){var n=i.Navigation.IsThumbnail()?"#thumbnail-layout-block":"#citation-layout-block",t=i.Navigation.IsThumbnail()?".thumbnail-copies-block":".citation-copies-block",r=i.Navigation.IsThumbnail()?".thumbnail-copies-title":".citation-copies-title";$(n).find(t).each(function(){var n=$(this).attr("data-cid");$(this).find(r).click(function(){window._record.Preview(n);return})})}}function a(){var n,f,s,e,h,r,c,o,u,l,a;if(!i.Navigation.IsGridView()&&t.Records()&&t.Records().length!=0){for(n=[],f=0;f<t.Records().length;f++)for(s=t.Records()[f],e=1;e<=9;e++)(h="Field_"+e,s.hasOwnProperty(h))&&(r=s[h](),r&&r.BookCoverEnable())&&(c=r.Values()[0].Isbn,c)&&n.push({Field:r,Isbn:c});if(n.length!=0){for(o="",u=0;u<n.length;u++)l=_utilities.getCleanIsbnValue(n[u].Isbn),o+=l,u!=n.length-1&&(o+=",");a={value:o,field:"ISBN",provider:"Google",size:"Medium","result-mode":"Url",format:"json"};$.ajax({url:window.soutronContext.Api.CatalogueBookCoverLink,type:"GET",beforeSend:function(n){n.setRequestHeader("LmsApiToken",window.soutronContext.Api.ProtectToken)},dataType:"json",cache:!1,data:a,success:function(t){var r=t.bookCovers,i,u;if(r&&r.length===n.length){for(i=0;i<n.length;i++)(u=n[i].Field,u.BookCover)&&(r[i].imageSmallUrl||r[i].imageMediumUrl||r[i].imageLargeUrl||r[i].imageRequestedUrl)&&(u.BookCover().PreviewLink(r[i].bookPreviewUrl),u.BookCover().CoverSmallUrl(r[i].imageSmallUrl||r[i].imageRequestedUrl),u.BookCover().CoverMediumUrl(r[i].imageMediumUrl||r[i].imageRequestedUrl),u.BookCover().CoverLargeUrl(r[i].imageLargeUrl||r[i].imageRequestedUrl));v()}},complete:function(){},error:function(n,t,i){_message.errorAjax(n,t,i)}})}}}function v(){var o,r,u,f,n,e;if(!i.Navigation.IsGridView()&&t.Records()&&t.Records().length!=0)for(o=i.Navigation.IsThumbnail()?".thumbnail-field-":".citation-field-",r=0;r<t.Records().length;r++){u=t.Records()[r];for(let t=1;t<=9;t++)(f="Field_"+t,u.hasOwnProperty(f))&&(n=u[f](),n)&&n.BookCoverEnable()&&n.BookCover().ExistCover()&&(e="book-cover-"+u.Id()+"-"+n.Sequence(),$(o+t).find("."+e).each(function(){var n={transition:"elastic",rel:e,scalePhotos:!0,scrolling:!0,preloading:!1,current:"{current} of {total}",close:"&times;",photo:!0,maxWidth:"100%",maxHeight:"100%",reposition:!0};$(this).colorbox(n)}))}}function y(){var u,o,s,h,e,f,c,l;if(!i.Navigation.IsGridView()&&t.Records()&&t.Records().length!=0){var n=[],a=i.Navigation.IsThumbnail()?"#thumbnail-layout-block":"#citation-layout-block",r=$(a).find(".group-bookcover-field");if(r&&r.length!=0){for(u=0;u<r.length;u++){if(o=$(r[u]).attr("data-isbn"),!o){if(s=$(r[u]).attr("data-empty_link"),!s)continue;h=getBookCoverImgTag(s,"64px");$(r[u]).html(h);continue}n.push({Element:r[u],Isbn:o})}if(n.length!=0){for(e="",f=0;f<n.length;f++)c=_utilities.getCleanIsbnValue(n[f].Isbn),e+=c,f!=n.length-1&&(e+=",");l={value:e,field:"ISBN",provider:"Google",size:"Medium","result-mode":"Url",format:"json"};$.ajax({url:window.soutronContext.Api.CatalogueBookCoverLink,type:"GET",beforeSend:function(n){n.setRequestHeader("LmsApiToken",window.soutronContext.Api.ProtectToken)},dataType:"json",cache:!1,data:l,success:function(t){var u=t.bookCovers,i;if(u&&u.length===n.length){for(i=0;i<n.length;i++){var e=$(r[i]).attr("data-thumbnail_size_px")+"px",o=u[i].imageLargeUrl||u[i].imageMediumUrl||u[i].imageSmallUrl||u[i].imageRequestedUrl,s=u[i].imageSmallUrl||u[i].imageMediumUrl||u[i].imageLargeUrl||u[i].imageRequestedUrl,h='<a href="'+o+'" aria-label="Book cover image">'+getBookCoverImgTag(s,e)+"<\/a>",f="";u[i].bookPreviewUrl&&(f='<a target="_blank" href="'+u[i].bookPreviewUrl+'" aria-label="Google books preview"><img class="card-bookcover-preview-image" src="'+window._SearchRecords.GOOGLE_PREVIEW_LOGO+'" alt=""><\/a>');$(n[i].Element).html(h+f)}p()}},complete:function(){},error:function(n,t,i){_message.errorAjax(n,t,i)}})}}}}function p(){if(!i.Navigation.IsGridView()&&t.Records()&&t.Records().length!=0){var n=i.Navigation.IsThumbnail()?"#thumbnail-layout-block":"#citation-layout-block";$(n).find(".group-bookcover-field").each(function(n){var t=$(this).find('a:not(":has(img.card-bookcover-preview-image)")'),i,r;t&&t.length!=0&&(i="book-cover-from-groups-"+n,r={transition:"elastic",rel:i,scalePhotos:!0,scrolling:!0,preloading:!1,current:"{current} of {total}",close:"&times;",photo:!0,maxWidth:"100%",maxHeight:"100%",reposition:!0},$(t).colorbox(r))})}}function w(){if(!i.Navigation.IsGridView()&&t.Records()&&t.Records().length!=0){var r=i.Navigation.IsThumbnail()?"#thumbnail-layout-block":"#citation-layout-block",u=i.Navigation.IsThumbnail()?".thumbnail-field-":".citation-field-",n=t.Records()[0];$(r).find(".soutron-card").each(function(){var f=$(this).attr("data-cid"),i,t,r;if(f)for(let e=1;e<=9;e++)(i="Field_"+e,n.hasOwnProperty(i))&&(t=n[i](),t)&&(t.BookCoverEnable()||(r="images-"+f+"-"+t.Sequence(),$(this).find(u+e).each(function(){var n=$(this).find(".card-image-values-block"),i;n.length!=0&&(i={transition:"elastic",rel:r,title:t.Title(),scalePhotos:!0,scrolling:!0,preloading:!1,current:"{current} of {total}",close:"&times;",photo:!0,maxWidth:"100%",maxHeight:"100%",reposition:!0},$(n).find("."+r).colorbox(i))})))})}}function b(){if(!i.Navigation.IsGridView()&&t.Records()&&t.Records().length!=0){var n=i.Navigation.IsThumbnail()?"#thumbnail-layout-block":"#citation-layout-block";$(n).find(".group-field-images").each(function(n){var t="group-field-images-"+n,i={transition:"elastic",rel:t,scalePhotos:!0,scrolling:!0,preloading:!1,current:"{current} of {total}",close:"&times;",photo:!0,maxWidth:"100%",maxHeight:"100%",reposition:!0};$(this).find("a").colorbox(i)})}}function k(){if(!i.Navigation.IsGridView()&&t.Records()&&t.Records().length!=0){var r=i.Navigation.IsThumbnail()?"#thumbnail-layout-block":"#citation-layout-block",u=i.Navigation.IsThumbnail()?".thumbnail-field-":".citation-field-",n=t.Records()[0];$(r).find(".soutron-card").each(function(){var r=$(this).attr("data-cid"),i,t;if(r)for(let f=1;f<=9;f++)(i="Field_"+f,n.hasOwnProperty(i))&&(t=n[i](),t)&&t.Clickable()&&!t.BookCoverEnable()&&$(this).find(u+f).each(function(){var n=$(this).find(".card-field-single-text-value");n.length!=0&&($(this).css("cursor","pointer"),$(this).click(function(n){_utilities.openRecord(this,r,n.ctrlKey);return}))})})}}function d(){var f,r,u,n,e;if(!i.Navigation.IsGridView()&&t.Records()&&t.Records().length!=0){f=i.Navigation.IsThumbnail()?".thumbnail-field-":".citation-field-";r=t.Records()[0];for(let t=1;t<=9;t++)(u="Field_"+t,r.hasOwnProperty(u))&&(n=r[u](),n)&&(n.BookCoverEnable()||(e=n.NumOfLines(),$(f+t).each(function(){var n=$(this).find(".trim-ellipsis-lines"),t,i,r;if(n.length!=0&&(t=parseInt($(n).css("height")),$(n).addClass("line-clamp-"+e),i=parseInt($(n).css("height")),i<t)){if(r=$(n).find(".card-image-values-block, .card-bookcover-block"),r.length!==0)return;$(n).addClass("lines-is-trimmed")}})))}}function h(){t.ColumnCount()!=1&&r==null&&(i.Navigation.IsThumbnail()?r=function(){nt()}:i.Navigation.IsCitation()&&(r=function(){tt()}),setTimeout(function(){r&&typeof r=="function"&&(r(),r=null)},100))}function nt(){$(".soutron-card").find(".thumbnail-section").find(".empty-height-thumbnail-box").each(function(){$(this).css({height:""})});var n=[],i=0,r=function(n,t){for(var u,r,i=0;i<n.length;i++)u=$(n[i])[0].clientHeight,r=t-u,r>0&&$(n[i]).find(".empty-height-thumbnail-box").css({height:r+"px"})};$(".soutron-card").find(".thumbnail-section").each(function(u){var f=t.Records()[u],l;if(f){var a=!f.Field_3().ValuesExist()&&!f.Field_4().ValuesExist()&&!f.Field_5().ValuesExist()&&!f.Field_6().ValuesExist(),o=!f.Field_1().ValuesExist()&&!f.Field_2().ValuesExist(),s=!f.Field_7().ValuesExist()&&!f.Field_8().ValuesExist(),e=function(n){if(!n||!n.ValuesExist())return!0;var t=n.Type();switch(t){case window._SearchRecords.RECORD_FIELD_TYPE.File:case window._SearchRecords.RECORD_FIELD_TYPE.URL:case window._SearchRecords.RECORD_FIELD_TYPE.Image:return!0}return!1},h=e(f.Field_1())&&e(f.Field_2()),c=e(f.Field_7())&&e(f.Field_8());f.Field_1().ValuesExist()&&!f.Field_2().ValuesExist()?($(this).find(".thumbnail-field-1").css("max-height","100%"),e(f.Field_1())||$(this).find(".thumbnail-col-box-1").css("width","30%")):f.Field_2().ValuesExist()&&!f.Field_1().ValuesExist()&&($(this).find(".thumbnail-field-2").css("max-height","100%"),e(f.Field_1())||$(this).find(".thumbnail-col-box-1").css("width","30%"));f.Field_7().ValuesExist()&&!f.Field_8().ValuesExist()?($(this).find(".thumbnail-field-7").css("max-height","100%"),e(f.Field_7())||$(this).find(".thumbnail-col-box-3").css("width","20%")):f.Field_8().ValuesExist()&&!f.Field_7().ValuesExist()&&($(this).find(".thumbnail-field-8").css("max-height","100%"),e(f.Field_8())||$(this).find(".thumbnail-col-box-3").css("width","20%"));f.Field_1().ValuesExist()&&f.Field_1().Type()==10&&f.Field_2().ValuesExist()&&f.Field_2().Type()!=10&&$(this).find(".thumbnail-field-1").css("max-height","100%");f.Field_7().ValuesExist()&&f.Field_7().Type()==10&&f.Field_8().ValuesExist()&&f.Field_8().Type()!=10&&$(this).find(".thumbnail-field-7").css("max-height","100%");f.Field_2().ValuesExist()&&f.Field_2().Type()==10&&f.Field_1().ValuesExist()&&f.Field_1().Type()!=10&&$(this).find(".thumbnail-field-2").css("max-height","100%");f.Field_8().ValuesExist()&&f.Field_8().Type()==10&&f.Field_7().ValuesExist()&&f.Field_7().Type()!=10&&$(this).find(".thumbnail-field-8").css("max-height","100%");a?(s?$(this).find(".thumbnail-col-box-1").css("width","100%"):o?$(this).find(".thumbnail-col-box-3").css("width","100%"):o&&s||(o||s?!o&&s?$(this).find(".thumbnail-col-box-1").css("width","100%"):o&&!s&&$(this).find(".thumbnail-col-box-3").css("width","100%"):h&&c?($(this).find(".thumbnail-col-box-1").css("width","auto"),$(this).find(".thumbnail-col-box-3").css("width","auto")):($(this).find(".thumbnail-col-box-1").css("width","100%"),$(this).find(".thumbnail-col-box-3").css("width","100%"))),h?$(this).find(".thumbnail-col-box-1").css("justify-content","center").css("align-items","center"):($(this).find(".thumbnail-col-box-1").css("justify-content","normal"),e(f.Field_1())||($(this).find(".thumbnail-field-1").find(".card-values-block").css("-webkit-box-orient","horizontal"),f.Field_1().BookCoverEnable()&&($(this).find(".thumbnail-field-1").css("max-height","none"),$(this).find(".thumbnail-field-2").css("max-height","100%"))),e(f.Field_2())||($(this).find(".thumbnail-field-2").find(".card-values-block").css("-webkit-box-orient","horizontal"),f.Field_2().BookCoverEnable()&&($(this).find(".thumbnail-field-1").css("max-height","100%"),$(this).find(".thumbnail-field-2").css("max-height","none")))),c?$(this).find(".thumbnail-col-box-3").css("justify-content","center").css("align-items","center"):($(this).find(".thumbnail-col-box-3").css("justify-content","normal"),e(f.Field_7())||($(this).find(".thumbnail-field-7").find(".card-values-block").css("-webkit-box-orient","horizontal"),f.Field_7().BookCoverEnable()&&($(this).find(".thumbnail-field-7").css("max-height","none"),$(this).find(".thumbnail-field-8").css("max-height","100%"))),e(f.Field_8())||($(this).find(".thumbnail-field-8").find(".card-values-block").css("-webkit-box-orient","horizontal"),f.Field_8().BookCoverEnable()&&($(this).find(".thumbnail-field-7").css("max-height","100%"),$(this).find(".thumbnail-field-8").css("max-height","none"))))):s?h||$(this).find(".thumbnail-col-box-1").css("width","40%"):o?c||$(this).find(".thumbnail-col-box-3").css("width","40%"):h||c?(h?f.Field_1().BookCoverEnable()?($(this).find(".thumbnail-field-1").css("max-height","none"),$(this).find(".thumbnail-field-2").css("max-height","100%")):f.Field_2().BookCoverEnable()&&($(this).find(".thumbnail-field-1").css("max-height","100%"),$(this).find(".thumbnail-field-2").css("max-height","none")):$(this).find(".thumbnail-col-box-1").css("width","30%"),c?f.Field_7().BookCoverEnable()?($(this).find(".thumbnail-field-7").css("max-height","none"),$(this).find(".thumbnail-field-8").css("max-height","100%")):f.Field_8().BookCoverEnable()&&($(this).find(".thumbnail-field-7").css("max-height","100%"),$(this).find(".thumbnail-field-8").css("max-height","none")):$(this).find(".thumbnail-col-box-3").css("width","30%")):($(this).find(".thumbnail-col-box-1").css("width","30%"),$(this).find(".thumbnail-col-box-3").css("width","30%"));l=$(this)[0].clientHeight;l>i&&(i=l);n.push($(this));(u+1)%t.ColumnCount()==0&&(r(n,i),i=0,n.length=0)}});n&&n.length>0&&r(n,i)}function tt(){$(".soutron-card").find(".citation-section").find(".empty-height-citation-box").each(function(){$(this).css({height:""})});var n=[],i=0,r=function(n,t){for(var u,r,i=0;i<n.length;i++)u=$(n[i])[0].clientHeight,r=t-u,r>0&&$(n[i]).find(".empty-height-citation-box").css({height:r+"px"})};$(".soutron-card").find(".citation-section").each(function(u){var f=$(this)[0].clientHeight;f>i&&(i=f);n.push($(this));(u+1)%t.ColumnCount()==0&&(r(n,i),i=0,n.length=0)});n&&n.length>0&&r(n,i)}function it(){$(".card-image-values-block").each(function(){var n=$(this),i=$(this).find("img").length,t=0;$(this).find("img").each(function(){var r=new Image;r.onload=function(){if(t++,t==i){var r=$(n)[0].clientHeight;$(n).ace_scroll({size:r,hoverReset:!0,reset:!0,mouseWheel:!0,mouseWheelLock:!0,styleClass:"scroll-margin scroll-thin scroll-dark"})}};r.src=$(this).attr("src")})})}function rt(){window.addResizeListener(document.getElementById("search-results-container"),function(){h("resize")})}var f,r,g;if(!n)throw new Error("Create CardViewKnockoutModel: searchResultModel is null");if(!n.InitData)throw new Error("Create CardViewKnockoutModel: searchResultModel.InitData is null");var t=this,i=n,o=!1,s=!1,u=!1,e=!1;this.ColumnCount=ko.observable(1);this.CardClass=ko.computed(function(){return"record-"+t.ColumnCount()});this.Fields=ko.observableArray();this.Records=ko.observableArray([]);this.Records.subscribe(function(n){n&&n.length>0&&setTimeout(function(){a();y();w();b();k();d();h("Records count [Records.subscribe] ("+n.length+") ");it();i&&window.GlobalEvents.AfterRenderSearchResultPage.fire(i.Navigation.View())},0);t.ResetSelection()});this.ReloadRecords=function(n){var rt,g,nt,y,w,f,r,p,b,ut,tt,k,a,et,it,d,h,l,v;if(!n||!n.Rows)throw new Error("CardViewKnockoutModel >  ReloadRecords: data is null");if(!n.Rows)throw new Error("CardViewKnockoutModel >  ReloadRecords: Rows is null");for(rt=1,i.Navigation.PagesCount()>1&&(rt=i.Navigation.PageSize()*(i.Navigation.Page()-1)+1),g=[],nt=0;nt<n.Rows.length;nt++){y=n.Rows[nt];w={};for(f in y)if(y.hasOwnProperty(f)&&t.Fields().hasOwnProperty(f)){r=new CardFieldKnockoutModel(i);switch(f){case"id":continue;case"isPublished":continue;case"_rowPreviewValue":continue;default:if(r.RecordId(y.id),r.Sequence(t.Fields()[f].Sequence()),r.Type(t.Fields()[f].Type()),r.LabelPosition(t.Fields()[f].LabelPosition()),r.Clickable(t.Fields()[f].Clickable()),r.NumOfLines(t.Fields()[f].NumOfLines()),r.IsSingleEntry(t.Fields()[f].IsSingleEntry()),r.Separator(t.Fields()[f].Separator()),r.ThumbnailSize(t.Fields()[f].ThumbnailSize()),p=t.Fields()[f].FieldFormatting(),r.FieldFormatting(p),b=y[f].Values,ut=[],b&&b.length>0)for(tt=r.Separator(),k=0;k<b.length;k++){a=b[k];tt&&!r.IsSingleEntry()&&r.Type()!=window._SearchRecords.RECORD_FIELD_TYPE.File&&k!=b.length-1&&(a.HtmlValue+=tt,a.Value+=tt);switch(r.Type()){case window._SearchRecords.RECORD_FIELD_TYPE.Image:r.ValuesExist()&&r.Values()[0].BookCover==!0||(et='<a href="'+a.LinkPopup+'" class="images'+r.UniquePartClass()+'"  aria-label="Open image"><img src="'+a.LinkImage+'" alt="'+a.AltText+'"><\/a>',a.HtmlValue=et)}if(p)switch(r.Type()){case window._SearchRecords.RECORD_FIELD_TYPE.Image:if(r.ValuesExist()&&r.Values()[0].BookCover==!0)break;var ft=p.indexOf("%VALUE_FORMATING%"),ot="",st="";ft>-1&&(ot=p.substring(0,ft),st=p.substring(ft+17));a.HtmlValue=ot+a.HtmlValue+st;break;default:a.HtmlValue=p.replace(/%VALUE_FORMATING%/g,a.HtmlValue)}ut.push(a)}r.Values(ut);it=t.Fields()[f].TitleFormatting();r.TitleFormatting(it);it?(d=t.Fields()[f].Title(),d&&(d=it.replace(/%TITLE_FORMATING%/g,d)),r.Title(d)):r.Title(t.Fields()[f].Title())}w[f]=r}for(h in t.Fields())w.hasOwnProperty(h)||(l=new CardFieldKnockoutModel(i),l.Sequence(t.Fields()[h].Sequence()),l.Title(t.Fields()[h].Title()),l.Type(t.Fields()[h].Type()),l.LabelPosition(t.Fields()[h].LabelPosition()),l.Clickable(t.Fields()[h].Clickable()),l.NumOfLines(t.Fields()[h].NumOfLines()),l.IsSingleEntry(t.Fields()[h].IsSingleEntry()),l.Separator(t.Fields()[h].Separator()),l.ThumbnailSize(t.Fields()[h].ThumbnailSize()),l.TitleFormatting(t.Fields()[h].TitleFormatting()),l.FieldFormatting(t.Fields()[h].FieldFormatting()),l.Values([]),w[h]=l);if(Object.keys(w).length!=Object.keys(t.Fields()).length)throw new Error("CardViewKnockoutModel >  ReloadRecords: The number of data fields does not match the number of template fields");v=new CardFieldsKnockoutModel(i);v.Fields(w);y.hasOwnProperty("id")&&v.Id(y.id);e&&y.hasOwnProperty("isPublished")&&v.IsPublished(y.isPublished);v.Num(rt++);v.EnableTwoLines(o);v.EnablePreview(s);v.EnableCopyPreview(u);v.EnablePublished(e);g.push(v)}t.Records(g);c(g)};this.ResetSelection=function(){var r,u,f,n;if(t.Records()&&t.Records().length!=0){if(t.PauseAutoEvent(),r=t.Records(),u=i.Selection.GetSelection(),r&&u){for(n=0;n<r.length;n++)for(f=0;f<u.length;f++)r[n].Id()==u[f]&&r[n].IsSelected(!0);if(u.length==0&&r.length>0)for(n=0;n<r.length;n++)r[n].IsSelected(!1)}t.ContinueAutoEvent()}};this.Update=function(n){var c,h,f,r;if(!n)throw new Error("Update CardViewKnockoutModel: view is null");if(!n.GridSettings)throw new Error("Update CardViewKnockoutModel: GridSettings is null");if(n.GridSettings.colModel.length!=n.GridSettings.colNames.length)throw new Error("Update CardViewKnockoutModel: colNames not compatible with colModel");for(t.ColumnCount(n.ColumnCount),o=n.EnableTwoLines,s=n.EnablePreview,u=n.EnableCopyPreview,e=i.EnablePublishInfo()&&n.EnablePublished,c={},h=0;h<n.GridSettings.colModel.length;h++)f=n.GridSettings.colModel[h],r=new CardFieldKnockoutModel(i),r.Sequence(f.Sequence),r.Title(n.GridSettings.colNames[h]),r.Type(f.Type),r.LabelPosition(f.LabelPosition),r.Clickable(f.Clickable),r.NumOfLines(f.NumOfLines),r.IsSingleEntry(f.IsSingleEntry),r.Separator(f.Separator),r.ThumbnailSize(f.ThumbnailSize),r.TitleFormatting(f.TitleFormatting),r.FieldFormatting(f.FieldFormatting),c[f.name]=r;t.Fields(c)};f=!1;this.PauseAutoEvent=function(){f=!0};this.ContinueAutoEvent=function(){f=!1};this.IsStopAutoEvent=function(){return f};r=null;g=0;rt()}function CardFieldsKnockoutModel(n){function i(n){var i=t.Fields(),u;if(!i)return new CardFieldKnockoutModel(r,!0);for(u in i)if(i.hasOwnProperty(u)&&i[u].Sequence()==n)return i[u];return new CardFieldKnockoutModel(r,!0)}if(!n)throw new Error("Create CardFieldsKnockoutModel: searchResultModel is null");var t=this,r=n;this.Num=ko.observable(0);this.Id=ko.observable(undefined);this.EnableTwoLines=ko.observable(!1);this.EnablePreview=ko.observable(!1);this.EnableCopyPreview=ko.observable(!1);this.EnablePublished=ko.observable(!1);this.CountCopies=ko.observable(null);this.CountCopiesTitle=ko.observable("");this.CountCopiesTip=ko.observable("");this.CountCopiesIsVisible=ko.computed(function(){return t.CountCopies()!==null});this.IsSelected=ko.observable(!1);this.IsSelected.subscribe(function(n){r.ThumbnailView.IsStopAutoEvent()||(n?r.Selection.Select(new Array(t.Id())):r.Selection.Deselect(new Array(t.Id())))});this.SelectedClass=ko.computed(function(){var n="";return t.IsSelected()&&(n="card-is-selected"),n});this.IsPublished=ko.observable(undefined);this.PublishedVisible=ko.computed(function(){return t.IsPublished()===!0||t.IsPublished()===!1});this.PublishedClass=ko.computed(function(){var n="";return t.IsPublished()===!0?n="fas fa-globe-americas green bigger-120":t.IsPublished()===!1&&(n="fas fa-globe-americas orange bigger-120"),n});this.PublishedTitle=ko.computed(function(){var n="";return t.IsPublished()===!0?n=window.SearchResultsLocalizations.RecordPublishedTitle:t.IsPublished()===!1&&(n=window.SearchResultsLocalizations.RecordUnpublishedTitle),n});this.Fields=ko.observable(undefined);this.Field_1=ko.computed(function(){return i(1)});this.Field_2=ko.computed(function(){return i(2)});this.Field_3=ko.computed(function(){return i(3)});this.Field_4=ko.computed(function(){return i(4)});this.Field_5=ko.computed(function(){return i(5)});this.Field_6=ko.computed(function(){return i(6)});this.Field_7=ko.computed(function(){return i(7)});this.Field_8=ko.computed(function(){return i(8)});this.Field_9=ko.computed(function(){return i(9)});this.PreviewRecord=function(){t.EnablePreview()&&t.Id()&&window._record.Preview(t.Id())}}function CardFieldKnockoutModel(n,t){if(!n)throw new Error("Create CardFieldKnockoutModel: searchResultModel is null");var i=this,r=n;this.FieldIsNotAttached=ko.observable(t===!0);this.Sequence=ko.observable(0);this.Type=ko.observable(window._SearchRecords.RECORD_FIELD_TYPE.Unknown);this.RecordId=ko.observable(undefined);this.Title=ko.observable("");this.TitleWithOutHtml=ko.computed(function(){if(!i.Title())return i.Title();var n=$("<div><\/div>").append(i.Title());return $(n).text()});this.LabelPosition=ko.observable(window._SearchRecords.LABEL_POSITIONS.NoLabel);this.Clickable=ko.observable(!1);this.NumOfLines=ko.observable(1);this.IsSingleEntry=ko.observable(!0);this.Separator=ko.observable("");this.ThumbnailSize=ko.observable(window._SearchRecords.THUMBNAIL_SIZES.Medium);this.TitleFormatting=ko.observable("");this.FieldFormatting=ko.observable("");this.Values=ko.observableArray([]);this.Values.subscribe(function(n){i.Type()==window._SearchRecords.RECORD_FIELD_TYPE.Image&&n&&n.length>0&&n[0].BookCover==!0&&i.BookCover(new CardBookCoverViewModel(i.ThumbnailSize(),n[0].EmptyUrl,i))});this.ValuesExist=ko.computed(function(){var n=!i.FieldIsNotAttached()&&i.Values()&&i.Values().length>0;return n&&i.BookCoverEnable()&&(n=i.BookCover&&i.BookCover()!=null&&i.BookCover().ExistCover()),n});this.ValueIsSingle=ko.computed(function(){return i.IsSingleEntry()||i.ValuesExist()&&i.Values().length==1?!0:!1});this.ValueIsMulti=ko.computed(function(){return i.ValueIsSingle()?!1:!0});this.ValueTemplate=ko.computed(function(){if(i.FieldIsNotAttached())return"card-template-without-field";if(!i.ValuesExist())return"card-template-empty-value";var n="";switch(i.Type()){case window._SearchRecords.RECORD_FIELD_TYPE.Text:n="card-template-text-value";break;case window._SearchRecords.RECORD_FIELD_TYPE.File:n="card-template-file-value";break;case window._SearchRecords.RECORD_FIELD_TYPE.Image:n=i.ValuesExist()&&i.Values()[0].BookCover==!0?"card-template-book-cover-value":"card-template-image-value";break;default:n="card-template-text-value"}return n});this.UniquePartClass=ko.computed(function(){return"-"+i.RecordId()+"-"+i.Sequence()});this.BookCoverEnable=ko.computed(function(){return i.Values()&&i.Values().length>0&&i.Values()[0].BookCover==!0});this.BookCover=ko.observable(null)}function CardBookCoverViewModel(n,t,i){var r=this,f=i,u=f.FieldFormatting(),e=f.UniquePartClass();this.ThumbnailSize=ko.observable(n||window._SearchRecords.THUMBNAIL_SIZES.Small);this.EmptyUrl=ko.observable(t);this.PreviewLink=ko.observable("");this.CoverLargeUrl=ko.observable("");this.CoverMediumUrl=ko.observable("");this.CoverSmallUrl=ko.observable("");this.ThumbnailUrl=ko.computed(function(){switch(r.ThumbnailSize()){case window._SearchRecords.THUMBNAIL_SIZES.Small:return r.CoverSmallUrl()||r.CoverMediumUrl()||r.CoverLargeUrl();case window._SearchRecords.THUMBNAIL_SIZES.Medium:return r.CoverMediumUrl()||r.CoverLargeUrl()||r.CoverSmallUrl();default:return r.CoverLargeUrl()||r.CoverMediumUrl()||r.CoverSmallUrl()}});this.ThumbnailAltText=ko.observable("");this.ThumbnailSizePx=ko.computed(function(){return window._SearchRecords.Utilities.GetThumbnailSize(r.ThumbnailSize())});this.SourseUrl=ko.computed(function(){return r.CoverLargeUrl()!=""?r.CoverLargeUrl():r.CoverMediumUrl()!=""?r.CoverMediumUrl():r.CoverSmallUrl()!=""?r.CoverSmallUrl():void 0});this.LogoUrl=ko.observable(window._SearchRecords.GOOGLE_PREVIEW_LOGO);this.LogoAltText=ko.observable("");this.ExistCover=ko.computed(function(){return r.ThumbnailUrl()!=""||r.EmptyUrl()!=""});this.ExistThumbnail=ko.computed(function(){return r.ThumbnailUrl()!=""});this.Html=ko.computed(function(){var n="",t,i,f;return r.ExistCover()?(t="",i="",u&&(f=u.indexOf("%VALUE_FORMATING%"),f>-1&&(t=u.substring(0,f),i=u.substring(f+17))),!r.ExistThumbnail())?(n=getBookCoverImgTag(r.EmptyUrl(),r.ThumbnailSizePx()),t+n+i):(n='<a href="'+r.SourseUrl()+'" class="book-cover'+e+'" aria-label="Book cover image">'+getBookCoverImgTag(r.ThumbnailUrl(),r.ThumbnailSizePx(),r.ThumbnailAltText())+"<\/a >",r.PreviewLink()&&(n+='<a target="_blank" href="'+r.PreviewLink()+'" aria-label="Google books preview"><img class="card-bookcover-preview-image" src="'+r.LogoUrl()+'" alt="'+r.LogoAltText()+'"><\/a>'),t+n+i):n})}function getBookCoverImgTag(n,t,i){return'<img class="card-bookcover-image" style="max-width:'+t+";max-height:"+t+'" src="'+n+'" alt="'+(i||"")+'">'}function RecordsRelatedViewer(n,t){function r(){$(t).each(function(){ko.cleanNode($(this)[0]);ko.applyBindings(i,$(this)[0]);$(this).on("fullscreened.ace.widget",function(){$(this).hasClass("fullscreen")?($(i.Grid.grid).jqGrid("showCol",["_Relationdescription"]),$(i.Grid.wrapperId).find(".ui-search-toolbar").show()):($(i.Grid.grid).jqGrid("hideCol",["_Relationdescription"]),$(i.Grid.wrapperId).find(".ui-search-toolbar").hide());_jqGrid.Utilities.Resize(i.Grid,1)})});var r=n.GridData.Rows;i.Grid.init(n.GridTemplate);i.Grid.reload(r);i.IsRecordsExist(r.length>0);window.addResizeListener(document.getElementById(_string.trim(i.Grid.wrapperId,"#")),function(){_jqGrid.Utilities.Resize(i.Grid,1)});_jqGrid.Funcs.ToolbarShowIf(i.Grid,r.length)}var i=this;this.IsLoading=ko.observable(!1);this.IsRecordsExist=ko.observable(!1);this.Grid={wrapperId:"#grid-related-records-wrapper",gridId:"#grid-related-records",grid:null,init:function(n){var r,t;if(i.Grid.jqGridFormatterInit(),n.loadComplete=function(n){_jqGrid.Utilities.Resize(i.Grid,1);i.Grid.initEvent(n);$(i.Grid.grid).jqGrid("init_soutron",i.Grid.wrapperId);$(i.Grid.grid).jqGrid("init_tooltips",i.Grid.wrapperId)},n.caption="",n.altRows=!0,n.rownumbers=!1,n.pager="grid-pager-related-records",n.pagerpos="left",n){for(r=0;r<n.colModel.length;r++)t=n.colModel[r],t.label=_jqGrid.Customization.LabelFocused(n.colNames[r]),t.stype="text",t.searchoptions={sopt:["cn"]},t.searchByField=t.name+".Values.0.Value",t.sorttype=_jqGrid.sorttype.values;n.colNames=[]}i.Grid.grid=$(i.Grid.gridId).jqGrid(n);$(i.Grid.grid).jqGrid("init_soutron",i.Grid.wrapperId);$(i.Grid.wrapperId).find("#grid-pager-related-records_center").remove();$(i.Grid.gridId).jqGrid("filterToolbar",{stringResult:!0,searchOnEnter:!1});$(i.Grid.wrapperId).find(".ui-search-toolbar").hide()},unload:function(){i.Grid.grid&&$.jgrid.gridUnload(i.Grid.gridId)},reload:function(n){$(i.Grid.grid).jqGrid("clearGridData");$(i.Grid.grid).jqGrid("setGridParam",{datatype:"local",rowNum:10,data:n}).trigger("reloadGrid");_jqGrid.Funcs.ToolbarShowIf(i.Grid,n.length)},onEvent:{AttachOpenRecordClick:function(){$(i.Grid.grid).find(".gridview-clickable-cell").each(function(){var n=$(this).attr("data-cid");n&&($(this).css("cursor","pointer"),$(this).click(function(t){_utilities.openRecord(this,n,t.ctrlKey);return}))})}},initEvent:function(){i.Grid.onEvent.AttachOpenRecordClick()},jqGridFormatterInit:function(){$.extend($.fn.fmatter,{SearchResult_Text:function(n,t,r){return i.Grid.DefaultFormatter(n,t,r)}})},DefaultFormatter:function(n,t,i){var t=t.colModel,f,u,r,e,o,s,h;if(!n||!n.Values||n.Values.length==0)return"";for(f="",u=n.Values,r=0;r<u.length;r++){e="grid-field-value";o="";u[r].Value&&(s=document.createElement("div"),s.innerHTML=u[r].Value.trim(),o=s.innerText);t.Clickable&&(e+=" gridview-clickable-cell");h=$("<span/>").attr("data-cid",i.id).addClass(e).attr("title",o).html(_utilities.stripScripts(u[r].HtmlValue));f=h[0].outerHTML;break}return f}};this.CurrentRecordChangedHandler=function(n){var t=n.CurrentRecordId;$.ajax({url:_utilities.getAbsoluteURL("/RecordUtilities/GetRelatedRecords"),cache:!1,type:"GET",data:{recordId:t},before:function(){i.IsLoading(!0)},success:function(n){var t=JSON.parse(n.rows);if(!$.isArray(t)){i.IsRecordsExist(!1);return}i.IsRecordsExist(t.length>0);i.Grid.reload(t)},complete:function(){i.IsLoading(!1);window._RecordUtilities.AdjustLayout()}})};r()}function RecordsPartsViewer(n,t){function f(n,t){if(i=new GridViewKnockoutModel(null,!0),n.EnableTwoLines=!1,i.Grid.wrapperId="#grid-record-parts-wrapper",i.Grid.gridId="#grid-record-parts",n.GridSettings.pager="#grid-pager-record-parts",n.GridSettings.caption="",n.GridSettings.gridview=!0,n.GridSettings.altRows=!0,n.GridSettings.loadonce=!0,n.GridSettings.datatype="local",n.GridSettings.multiselect=!1,n.GridSettings.colModel&&n.GridSettings.colModel.length>0)for(let t=0;t<n.GridSettings.colModel.length;t++){var r=n.GridSettings.colModel[t];r.sortable=!0;r.search=!0;r.searchoptions={sopt:["cn"]};r.searchByField=r.name+".Values.0.Value";r.sorttype=_jqGrid.sorttype.values;t>2&&(r.hidden=!0)}i.Update(n);i.Grid.reload(t);$(i.Grid.gridId).jqGrid("filterToolbar",{stringResult:!0,searchOnEnter:!1});$(i.Grid.wrapperId).find(".ui-search-toolbar").hide()}function e(){$(t).each(function(){ko.cleanNode($(this)[0]);ko.applyBindings(r,$(this)[0]);$(this).on("fullscreened.ace.widget",function(){var n;if(i&&i.Grid){if($(this).hasClass("fullscreen")){$(i.Grid.wrapperId).find(".ui-search-toolbar").show();for(let t=0;t<u.GridSettings.colModel.length;t++)(n=u.GridSettings.colModel[t].name,n!="_actions")&&$(i.Grid.grid).jqGrid("showCol",[n])}else{for(let t=0;t<u.GridSettings.colModel.length;t++)n=u.GridSettings.colModel[t].name,t>2&&$(i.Grid.grid).jqGrid("hideCol",[n]);$(i.Grid.wrapperId).find(".ui-search-toolbar").hide()}_jqGrid.Utilities.Resize(i.Grid,1)}})});var e=n.GridData.Rows;f(u,e);r.IsPartsExist(e.length>0);window.addResizeListener(document.getElementById("widget-record-parts"),function(){i&&i.Grid&&_jqGrid.Utilities.Resize(i.Grid,1)});_jqGrid.Funcs.ToolbarShowIf(i.Grid,e.length)}var r=this,u=n.ViewTemplate,i=null;this.IsLoading=ko.observable(!1);this.IsPartsExist=ko.observable(!1);this.CurrentRecordChangedHandler=function(n){var t=n.CurrentRecordId;$.ajax({url:_utilities.getAbsoluteURL("/RecordUtilities/GetRecordParts"),cache:!1,type:"GET",data:{recordId:t},before:function(){r.IsLoading(!0)},success:function(n){var t=JSON.parse(n.rows);if(!$.isArray(t)){r.IsPartsExist(!1);return}r.IsPartsExist(t.length>0);i.Grid.reload(t)},complete:function(){r.IsLoading(!1);window._RecordUtilities.AdjustLayout()}})};e()}function RecordRelationsTreeAmendmentsLineMacros(n,t){function f(){u=null;var t=new RecordRelationsTreeOptions({Callback:{AttachCustomEvents:function(n){$(n).closest(".tree-node").on("click",function(){var e=$(this).closest("li"),n=$(e).attr("id"),r=$(e).attr("data-cid"),f,t;(i.SetState(r,n),f=window[_const.Macros.HIERARCHY_TREE_AMENDMENTS],f&&f.SetState(r,n),i.OpenAmendmentsNode(n),t=u.GetNode(n).children,t&&t.length!=0)&&(u.DeleteNode(t[0],n),u.OpenNode(n,r,!0))});if(i.ExistAmendmentsMacros())$(n).find(".goto-action").on("click",function(){i.AmendmentsMacrosIsShown(!0);var n=$(this).closest("li").attr("id");return i.GoToAmendmentsNode(n),!1})}},Container:$(n).find("#record-tree-amendments-line"),ExternalKo:!0,ExpandAllAfterCreating:!0,CurrentRecordChangedHandlerOff:!0,RelationType:r.relationType,SearchResultId:r.searchResultId,CurrentNodeId:r.currentNodeId,RecordId:r.recordId,Actions:['<span class="role-button goto-action ms-1" title="'+window.recordViewLocalizations.FindInRecordAmendmentsTreeTitle+'">    <i class="fad fa-arrow-alt-down green" aria-hidden="true"><\/i><\/span>']});i.ExistAmendmentsMacros()||(t.Actions=null);u=new RecordRelationsTree(t)}var i=this,u=null,r={directLineEnabled:t.DirectLineEnabled,hasAmendment:t.HasAmendment,treeIsEmpty:t.TreeIsEmpty,relationType:6,currentNodeId:t.CurrentNodePath,searchResultId:t.SearchResultId,recordId:t.CID};this.ExistAmendmentsMacros=ko.observable(!1);this.AmendmentsMacrosIsShown=ko.observable(!1);i.AmendmentsMacrosIsShown.subscribe(function(){var n=window[_const.Macros.HIERARCHY_TREE_AMENDMENTS],t,i,u;n&&(n.IsEnabled()?n.ToggleShow():(n.Enable(),t=new ButtonLoadingAndLock($("#toggle-amendments-button")),t.Lock(),i=function(){t.UnLock()},u=function(){t.UnLock()},n.Update(r.recordId,r.currentNodeId,i,u)))});this.ToggleAmendments=function(){i.AmendmentsMacrosIsShown(!i.AmendmentsMacrosIsShown())};this.OpenAmendmentsNode=function(n){if(!n)throw new Error("RecordRelationsTreeAmendmentsLineMacros/OpenAmendmentsNode: nodeId is null");var t=window[_const.Macros.HIERARCHY_TREE_AMENDMENTS];t&&t.OpenNode(n)};this.GoToAmendmentsNode=function(n){if(!n)throw new Error("RecordRelationsTreeAmendmentsLineMacros/GoToAmendmentsNode: nodeId is null");var t=window[_const.Macros.HIERARCHY_TREE_AMENDMENTS];t&&t.GoToNode(n)};this.Update=function(n){var t={RelationType:r.relationType,CurrentRecordId:n,IsForced:!0};i.CurrentRecordChangedHandler(t)};this.SetState=function(n,t,i){typeof n!="object"&&(r.recordId=n);typeof t!="object"&&(r.currentNodeId=t);typeof i!="object"&&(r.searchResultId=i);u&&u.SetState(r.recordId,r.currentNodeId,r.searchResultId)};this.CheckState=function(){if(i.IsEmpty(r.treeIsEmpty),!r.hasAmendment&&r.treeIsEmpty){i.ExistAmendmentsMacros(!1);return}$("#relations-tree-amendments-macros").length>0&&i.ExistAmendmentsMacros(!0)};this.Init=function(){i.IsEnabled()&&(i.CheckState(),f(),ko.applyBindings(i,$(n)[0]))};r.directLineEnabled?i.Enable():i.Disable();i.Init();this.CurrentRecordChangedHandler=function(t){i.IsEnabled()&&(t.RelationType!=3||t.IsClicked!=!0)&&(t.IsClicked!==!0||t.RelationType!=r.relationType)&&(t.RelationType!=r.relationType||t.IsForced===!0)&&(console.log(t.CurrentRecordId),$.ajax({url:_utilities.getAbsoluteURL("/RecordView/GetRecordRelationsTree"),cache:!1,type:"GET",data:{recordId:t.CurrentRecordId,relationType:r.relationType},before:function(){i.Loading(!0)},success:function(t){var u;if(!$(t).hasClass("macros-layout"))throw new Error("RecordRelationsTreeAmendmentsLineMacros/CurrentRecordChangedHandler: top element must contain the 'macros-layout' class");var f=$(t).attr("data-CurrentNodeId"),e=$(t).attr("data-RecordId"),o=$(t).attr("data-SearchResultId"),s=$(t).attr("data-TreeIsEmpty")==1;i.SetState(e,f,o);r.treeIsEmpty=s;u=$(t).find("#record-tree-amendments-line");ko.cleanNode($(n)[0]);$(n).find("#record-tree-amendments-line").html($(u).html());i.Init()},complete:function(){i.Loading(!1);window._RecordUtilities.AdjustLayout()}}))};GlobalEvents.CurrentRecordChanged.bind(i.CurrentRecordChangedHandler)}function RecordRelationsTreeAmendmentsMacros(n,t){function f(n){var t=new RecordRelationsTreeOptions({Callback:{AfterLoadTree:function(){$.isFunction(n)&&n()},AttachCustomEvents:function(n){$(n).closest(".tree-node").find(".tree-node-content").on("click",function(){var t=$(this).closest("li"),i=$(t).attr("id"),u=$(t).attr("data-cid"),n;(r.OpenNode(i,u,!0),n=window[_const.Macros.HIERARCHY_TREE_AMENDMENTS_LINE],n)&&n.Update(u,i)})}},Container:$("#record-tree-amendments"),ExternalKo:!0,ExpandedLevelsCount:i.expandedLevelsCount,CurrentRecordChangedHandlerOff:!0,RelationType:i.relationType,SearchResultId:i.searchResultId,CurrentNodeId:i.currentNodeId,RecordId:i.recordId});r=new RecordRelationsTree(t)}var u=this,r=null,i={expandedLevelsCount:t.ExpandedLevelsCount,directLineEnabled:t.DirectLineEnabled,treeIsEmpty:t.TreeIsEmpty,relationType:3,currentNodeId:t.CurrentNodePath,searchResultId:t.SearchResultId,recordId:t.CID};this.IsCollapsed=ko.observable(!1);this.ToggleCollapsible=function(){r&&(r.ToggleCollapsible(),u.IsCollapsed(r.IsCollapsed()))};this.OpenNode=function(n){if(!n)throw new Error("RecordRelationsTreeAmendmentsMacros/OpenNode: nodeId is null");if(r){r.OpenNode(n);return}f(function(){r.OpenNode(n)})};this.GoToNode=function(n){if(!n)throw new Error("RecordRelationsTreeAmendmentsMacros/GoToNode: nodeId is null");if(r){r.GoToNode(n);return}f(function(){r.GoToNode(n)})};this.GoToCurrentRecord=function(){r&&r.OpenNode(r.GetCurrentNodeId())};this.SetState=function(n,t,u){typeof n!="object"&&(i.recordId=n);typeof t!="object"&&(i.currentNodeId=t);typeof u!="object"&&(i.searchResultId=u);r&&r.SetState(i.recordId,i.currentNodeId,i.searchResultId)};this.CheckState=function(){u.IsEmpty(i.treeIsEmpty)};this.Update=function(n,t,r,f){var e={SuccessCallback:r,ErrorCallback:f,RelationType:i.relationType,CurrentRecordId:n,IsForced:!0};u.CurrentRecordChangedHandler(e)};this.Init=function(){u.IsEnabled()&&(u.CheckState(),f(),ko.applyBindings(u,$(n)[0]))};i.directLineEnabled?u.Disable():u.Enable();u.Init();this.CurrentRecordChangedHandler=function(t){u.IsEnabled()&&(t.RelationType!=6||t.IsClicked!=!0)&&(t.IsClicked!==!0||t.RelationType!=i.relationType)&&(t.RelationType!=i.relationType||t.IsForced===!0)&&(console.log(t.CurrentRecordId),$.ajax({url:_utilities.getAbsoluteURL("/RecordView/GetRecordRelationsTree"),cache:!1,type:"GET",data:{recordId:t.CurrentRecordId,relationType:i.relationType},before:function(){u.Loading(!0)},success:function(r){if(!$(r).hasClass("macros-layout"))throw new Error("RecordRelationsTreeAmendmentsMacros/CurrentRecordChangedHandler: top element must contain the 'macros-layout' class");var f=$(r).attr("data-CurrentNodeId"),e=$(r).attr("data-RecordId"),o=$(r).attr("data-SearchResultId"),s=$(r).attr("data-TreeIsEmpty")==1;u.SetState(e,f,o);i.treeIsEmpty=s;ko.cleanNode($(n)[0]);$(n).html(r);u.Init();$.isFunction(t.SuccessCallback)&&t.SuccessCallback()},complete:function(){u.Loading(!1);window._RecordUtilities.AdjustLayout()},error:function(){$.isFunction(t.ErrorCallback)&&t.ErrorCallback()}}))};GlobalEvents.CurrentRecordChanged.bind(u.CurrentRecordChangedHandler)}function RecordRelationsTree(n){function e(n){var r=window.soutronContext.TreeLoadPortionLimit,u=Math.round(n.length/r),i,t;if(n.length<=r)o(n);else for(i=c(n,u),t=0;t<i.length;t++)o(i[t])}function c(n,t){for(var u=n.length,f=[],i=0,r;i<u;)r=Math.ceil((u-i)/t--),f.push(n.slice(i,i+r)),i+=r;return f}function o(n){var u,r,f;if(n.length!==0){u=[];r=[];for(let t=0;t<n.length;t++)n[t]!="#"&&(u.push(n[t].cid),r.push(n[t].nodeId));t.loadingMaxNodes++;f=(t.loadingMaxNodes-t.loadedNodes)*100/t.loadingMaxNodes;i.progressControl.css("width",f+"%").attr("aria-valuenow",f).show();$.ajax({url:_utilities.getAbsoluteURL("RecordView/GetRecordRelationsTreeViewNodesText"),type:"POST",dataType:"json",data:{cids:u.toString(),searchResultId:t.searchResultId},success:function(n){var u,e;for(t.loadedNodes++,u=0;u<n.length;u++){var f=n[u],o=$(i.jstreeEl).find("#"+r[u]+"> div > .tree-node"),h=$(o).find(".tree-node-content");$(h).html(f.Html);$(h).attr("title",f.Title);f.IsPublished||o.addClass("opacity-5");e=t.treeInst.get_node(t.treeInst._model.data[r[u]]);e.data.loaded=!0;e.li_attr["node-is_published"]=f.IsPublished;e.text=o[0].outerHTML}s()},error:function(n,i){t.loadedNodes++;n.readyState!==0&&window._toast.error(i);s()}})}}function s(){var n=(t.loadingMaxNodes-t.loadedNodes)*100/t.loadingMaxNodes;i.progressControl.css("width",n+"%").attr("aria-valuenow",n);t.loadingMaxNodes===t.loadedNodes&&(i.progressControl.hide(),t.loadingMaxNodes=0,t.loadedNodes=0,$(i.jstreeEl).removeClass("skeleton-line"))}function l(){$(i.widgetBox).on("fullscreened.ace.widget",function(){if($(this).hasClass("fullscreen")){var n=$(i.widgetBox).height();$(this).css({maxHeight:n+"px",overflow:"auto"});$(i.widgetBody).removeClass("macros-widget-body-height")}else $(this).css({maxHeight:"",overflow:""}),$(i.widgetBody).addClass("macros-widget-body-height")})}function f(i){$(i).find("ul > li .node-actions").each(function(){var i=$(this).closest("li").attr("data-cid"),t;if($(this).find('[data-soutron="preview-action"]').click(function(){return window._record.Preview(i,""),!1}),t=$(this).attr("data-custom_actions"),t!=1){if(n.Actions&&n.Actions.length>0)for(let t=0;t<n.Actions.length;t++)$(n.Actions[t]).appendTo(this);$(this).attr("data-custom_actions",1)}$.isFunction(u.AttachCustomEvents)&&u.AttachCustomEvents(this)});$(i).find("ul > li .tree-node ").on({click:function(){var n=$(this).closest("li").attr("data-cid"),i=$(this).closest("li").attr("id");GlobalEvents.CurrentRecordChanged.fire({RelationType:t.relationType,CurrentRecordId:n,IsClicked:!0});r.OpenNode(i,n,!0,!0)},mouseenter:function(){var n=$(this).closest("li").attr("data-cid")==t.currentRecordId;n?$(this).find(".tree-node-actions").find('[data-soutron="preview-action"]').hide():$(this).find(".tree-node-actions").find('[data-soutron="preview-action"]').show();$(this).find(".tree-node-actions").addClass("inline").show()},mouseleave:function(){$(this).find(".tree-node-actions").removeClass("inline").hide()}})}function h(){if(i.containerEl=n.Container,i.jstreeEl=$(i.containerEl).find(".jstree"),i.widgetBox=i.jstreeEl.closest(".widget-box"),i.widgetBody=i.widgetBox.find(".widget-body"),i.progressControl=i.widgetBox.find(".progress-bar"),t.loadingMaxNodes=0,t.loadedNodes=0,t.jstreeWasInitialized=!1,n.ExternalKo||ko.applyBindings(r,$(i.containerEl)[0]),l(),i.jstreeEl&&i.jstreeEl.length==1){$.isFunction(u.BeforeLoadTree)&&u.BeforeLoadTree();$(i.jstreeEl).jstree({plugins:[,"html_data"],core:{check_callback:!0},progressive_render:!0}).bind("ready.jstree",function(n,o){t.treeInst=o.instance;var s=[];t.expandAllAfterCreating?Object.getOwnPropertyNames(t.treeInst._model.data).forEach(function(n){n!="#"&&(t.treeInst._model.data[n].li_attr["data-opened"]=!0,s.push({cid:t.treeInst._model.data[n].data.cid,nodeId:n}))}):Object.getOwnPropertyNames(t.treeInst._model.data).forEach(function(n){if(n!="#"){t.treeInst._model.data[n].parents.length<t.expandedLevelsCount&&(t.treeInst._model.data[n].li_attr["data-opened"]=!0);var i=t.treeInst._model.data[n].data.loaded;i&&s.push({cid:t.treeInst._model.data[n].data.cid,nodeId:n})}});t.currentNodeId&&r.ActivateHighlightAndSetScrollToNode(t.currentNodeId);e(s);f(i.jstreeEl);t.jstreeWasInitialized=!0;r.Loading(!1);$.isFunction(u.AfterLoadTree)&&u.AfterLoadTree(n,o)}).bind("open_node.jstree",function(n,o){var y=o.node.id,v,s,h,c,l,a;if($(i.jstreeEl).find("#"+y).each(function(){f(this);r.ActivateNode(r.GetCurrentNodeId(),this)}),$.isFunction(u.AfterOpenNode)&&u.AfterOpenNode(n,o),v=o.node.li_attr["data-opened"],!v&&t.jstreeWasInitialized){o.node.li_attr["data-opened"]=!0;s=o.node.children;h=[];for(c in s)s.hasOwnProperty(c)&&(l=t.treeInst._model.data[s[c]],l.parent=o.node.id,a=t.treeInst.get_node(l),h.push({cid:a.li_attr["data-cid"],nodeId:a.id}));h.length>0&&e(h)}});$(i.jstreeEl).on("keydown",".jstree-anchor",function(n){if(n.which===13||n.which===32){var t=$(this).closest(".jstree-node"),i=$(t).attr("aria-selected")==="true";i?$(jstreeEl).jstree("deselect_node",t):$(jstreeEl).jstree("select_node",t);n.preventDefault()}})}}if(!n)throw new Error("RecordRelationsTree/root: options is null");if(!n.Container)throw new Error("RecordRelationsTree/root: options.Container is null");if(n.Container.length!=1)throw new Error("RecordRelationsTree/root: options.Container length != 1");var i={containerEl:null,jstreeEl:null,widgetBox:null,widgetBody:null,progressControl:null},t={expandedLevelsCount:n.ExpandedLevelsCount,expandAllAfterCreating:n.ExpandAllAfterCreating,relationType:n.RelationType,currentNodeId:n.CurrentNodeId,currentRecordId:n.RecordId,searchResultId:n.SearchResultId,loadingMaxNodes:0,loadedNodes:0,jstreeWasInitialized:!1,treeInst:null},r=this,u=n.Callback;this.IsCollapsed=ko.observable(!1);this.CurrentRecordChangedHandler=function(n){r.IsEnabled()&&(n.IsClicked!==!0||n.RelationType!=t.relationType)&&(n.RelationType!=t.relationType||n.IsForced===!0)&&(console.log(n.CurrentRecordId),$.ajax({url:_utilities.getAbsoluteURL("/RecordView/GetRecordRelationsTree"),cache:!1,type:"GET",data:{recordId:n.CurrentRecordId,relationType:t.relationType},beforeSend:function(){r.IsLoading(!0)},success:function(n){if(!$(n).hasClass("macros-layout"))throw new Error("RecordRelationsTree/CurrentRecordChangedHandler: top element must contain the 'macros-layout' class");var u=$(n).attr("data-CurrentNodeId"),f=$(n).attr("data-RecordId"),e=$(n).attr("data-SearchResultId"),o=$(n).attr("data-TreeIsEmpty")==1;r.SetState(f,u,e);t.treeIsEmpty=o;ko.cleanNode($(i.containerEl)[0]);$(i.containerEl).html(n);n.trim().length>0&&(i.jstreeEl=$(i.containerEl).find(".jstree"),h())},complete:function(){r.IsLoading(!1);window._RecordUtilities.AdjustLayout()}}))};n.CurrentRecordChangedHandlerOff||(GlobalEvents.CurrentRecordChanged.bind(r.CurrentRecordChangedHandler),r.Enable());this.GetCurrentNodeId=function(){return t.currentNodeId};this.GetNodeEl=function(n){if(!n)throw new Error("RecordRelationsTree/GetNodeEl: nodeId is null");return $(i.jstreeEl).find("#"+n+"> div > .tree-node")};this.HighlightNode=function(n){if(!n)return null;var t=null;return(t=typeof n=="string"||n instanceof String?r.GetNodeEl(n):n,!t||t.length==0)?null:($(t).find(".tree-node-content").addClass("skeleton-line"),setTimeout(function(){$(t).find(".tree-node-content").removeClass("skeleton-line")},2e3),t)};this.SetScrollToNode=function(n){var t,u;return n?(t=null,t=typeof n=="string"||n instanceof String?r.GetNodeEl(n):n,!t||t.length==0)?null:(u=$(t).position().top-80,$(i.jstreeEl).closest(".widget-body").scrollTop(u),t):null};this.ActivateNode=function(n,t){if(!n)return null;$(t||i.jstreeEl).find(".active-element-b").removeClass("active-element-b");var u=null;return(u=typeof n=="string"||n instanceof String?r.GetNodeEl(n):n,!u||u.length==0)?null:($(u).addClass("active-element-b"),u)};this.GoToNode=function(n){var t=r.SetScrollToNode(n);r.HighlightNode(t)};this.ActivateHighlightAndSetScrollToNode=function(n){var t=r.ActivateNode(n);r.HighlightNode(t);r.SetScrollToNode(t)};this.GetNode=function(n){if(!n)throw new Error("RecordRelationsTree/GetNode: nodeId is null");return t.treeInst?t.treeInst.get_node(n):null};this.OpenNode=function(n,i,u,f){if(f!==!0&&f!==!1&&(f=r.GetCurrentNodeId()==n),!n)throw new Error("RecordRelationsTree/OpenNode: nodeId is null");if(!t.treeInst)return null;typeof n!="object"&&(t.currentNodeId=n);typeof i!="object"&&i&&(t.currentRecordId=i);t.treeInst._open_to(n);var e=r.HighlightNode(n);return e?(f===!0&&r.ActivateNode(n),u!==!0&&r.SetScrollToNode(e),e):null};this.DeleteNode=function(n,t){if(!n)throw new Error("RecordRelationsTree/nodeId: nodeId is null");$(i.jstreeEl).jstree("delete_node","#"+n);t&&f($(i.jstreeEl).find("#"+t).parent())};this.OpenAll=function(){var t=[],n=$(i.jstreeEl).jstree(!0)._model.data;for(let i in n)n.hasOwnProperty(i)&&i!=="#"&&(n[i].state.opened=!0,n[i].data.loaded||(t.push({cid:n[i].data.cid,nodeId:i}),n[i].li_attr["data-opened"]=!0));$(i.jstreeEl).jstree(!0).redraw(!0);t.length>0&&e(t);f(i.jstreeEl)};this.CloseAll=function(){$(i.jstreeEl).jstree("close_all")};this.ToggleCollapsible=function(){r.IsCollapsed()?(r.OpenAll(r.GetCurrentNodeId()),r.ActivateHighlightAndSetScrollToNode(r.GetCurrentNodeId())):r.CloseAll();r.IsCollapsed(!r.IsCollapsed())};this.SetState=function(n,i,r){typeof n!="object"&&(t.recordId=n);typeof i!="object"&&(t.currentNodeId=i);typeof r!="object"&&(t.searchResultId=r)};h()}function RecordRelationsTreeOptions(n){var t={Callback:{BeforeLoadTree:undefined,AfterLoadTree:undefined,AfterOpenNode:undefined,AttachCustomEvents:undefined},Container:null,ExternalKo:!1,ExpandAllAfterCreating:!1,ExpandedLevelsCount:3,CurrentRecordChangedHandlerOff:!1,RelationType:null,SearchResultId:null,CurrentNodeId:null,RecordId:null,Actions:[]};return $.extend({},t,n)}function RecordStatisticViewModel(n,t){function r(){$("#widget-record-statistic").on("fullscreened.ace.widget",function(){$(this).hasClass("fullscreen")&&$(this).ace_scroll("destroy")});$($(t)[0]).find(".widget-main").ace_scroll(_templates.ace_scroll.GetDefaultOptions({size:_const.size.SCROLL_WIDGET}))}function u(){$(t).each(function(){ko.applyBindings(i,$(this)[0])});r()}var i=this;this.Statistics=ko.observableArray(n);this.IsLoading=ko.observable(!1);this.IsExist=ko.computed(function(){return i.Statistics().length>0});this.CurrentRecordChangedHandler=function(n){var t=n.CurrentRecordId;$.ajax({url:_utilities.getAbsoluteURL("/RecordUtilities/GetRecordStatistic?rnd="+ +new Date),cache:!1,type:"GET",data:{recordId:t},before:function(){i.IsLoading(!0)},success:function(n){i.Statistics(n)},complete:function(){i.IsLoading(!1)}})};u()}function RecordPublishedStatusViewModel(n,t){var i=this;this.Update=function(n){var i=window.recordViewLocalizations.RecordPublishedTitle,r="fas fa-globe-americas green";n||(i=window.recordViewLocalizations.RecordUnpublishedTitle,r="fas fa-globe-americas orange");$(t).each(function(){$(this).attr("title",i);$(this).attr("class",r);$(this).show()})}}function ReviewsBox(n,t,i){function a(n){$.ajax({dataType:"json",url:_utilities.getAbsoluteURL("/Reviews/GetRatingsAndComments/NaN"+ +new Date),data:{cid:r.RecordId(),questionId:n,mode:n!=null?f.ByIdRatingQuestion:f.AllCommentsWithRatings|f.AllCommentsWithoutRatings},before:function(){r.IsLoading(!0)},success:function(n){var i=$.parseJSON(n.content),t;i.length==0?r.ShowNoReviewsMessage(!0):r.ShowNoReviewsMessage(!1);t=[];$.each(i,function(n,i){var r={UserFullName:i.UserFullName.trim(),DateString:i.DateString,Date:new Date(i.Date),RatingValue:i.RatingValue,CommentText:i.CommentText,CommentTitle:i.CommentTitle,CommentId:i.CommentId,HasRating:i.HasRating};r.GetStarCss=function(n,t){return n<=t?"star-on-png bigger-110":"star-off-png bigger-110"};r.ActionReviewRemoveId="remove-review-action-"+_utilities.getNextUniqueCounter();t.push(r)});r.ReviewContainer(t);c()},complete:function(){r.IsLoading(!1)},error:function(n){n.readyState!=0&&window._toast.error(commonLocalizations.ErrorWhileProcessing)}})}function v(n){r.RecordId(n.RecordId);r.QuestionsToRead(n.RatingQuestions);r.SelectedQuestionToRead(null);r.SelectedQuestionToRead.valueHasMutated();r.AverageRating(n.AverageRating);r.RatingsCount(n.RatingsCount);r.ReviewsCount(n.ReviewsCount);r.WritingMode(!1);r.ReadingMode(!0);u()}function e(){r.CommentTitle("");r.CommentText("");r.RatingValue(0);var t=$("#starRatingfor-"+n.RecordId);$("span.star-off-png",t).each(function(n,t){$(t).attr("class","star-off-png")})}function o(){r.EmailToAbuse("");r.SubjectOfAbuse("");r.ReasonOfAbuse("");r.CommentIdToAbuse(null)}function u(){r.ShowSuccessMsg(!1);r.ShowErrorMsg(!1);r.ErrorMsg("");r.SuccessMsg("")}function s(){$("#reviews").hide()}function h(){$("#reviews").show()}function c(){var n=$($(i)[0]).find(".reviews-container");n.hasClass("ace-scroll")||n.ace_scroll(_templates.ace_scroll.GetDefaultOptions({size:_const.size.SCROLL_WIDGET}))}function y(){ko.applyBindings(r,$(i)[0]);r.IsDialog()||(n.CurrentRecordHasRatingFieldType?(h(),setOptionsForWritingMode(r,n.OptionsForWrite)):s())}var r=this,f={ByIdRatingQuestion:1,AllCommentsWithRatings:2,AllCommentsWithoutRatings:4},l=[{Key:1,Value:reviewsLocalizations.DateByDescending},{Key:2,Value:reviewsLocalizations.DateByAscending},{Key:3,Value:reviewsLocalizations.RatingByDescending},{Key:4,Value:reviewsLocalizations.RatingByAscending}];this.RecordId=ko.observable(n.RecordId);this.QuestionsToRead=ko.observableArray(n.RatingQuestions);this.SelectedQuestionToRead=ko.observable();this.SelectedQuestionToRead.subscribe(function(n){a(n)});this.IsWritingModeAvailable=ko.observable();this.QuestionsToWrite=ko.observableArray();this.SelectedQuestionToWrite=ko.observable();this.AverageRating=ko.observable(n.AverageRating);this.RatingsCount=ko.observable(n.RatingsCount);this.ReviewsCount=ko.observable(n.ReviewsCount);this.ShowNoReviewsMessage=ko.observable();this.SortQuestionsList=ko.observable(l);this.SelectedSortMode=ko.observable();this.CommentTitle=ko.observable();this.CommentText=ko.observable();this.RatingValue=ko.observable(0);this.EmailToAbuse=ko.observable();this.SubjectOfAbuse=ko.observable();this.ReasonOfAbuse=ko.observable();this.CommentIdToAbuse=ko.observable();this.IdForLabel=ko.observable(n.RecordId);this.IsLoading=ko.observable(!1);this.IsDialog=ko.observable(t);this.ShowErrorMsg=ko.observable(!1);this.ErrorMsg=ko.observable();this.ShowSuccessMsg=ko.observable(!1);this.SuccessMsg=ko.observable();this.ReviewContainer=ko.observable();this.ReadingMode=ko.observable(!0);this.WritingMode=ko.observable(!1);this.ReportAbuseMode=ko.observable(!1);this.GlobalCommentMode=ko.observable();this.ShowCancelBtn=ko.computed(function(){return r.WritingMode()||r.ReportAbuseMode()==!0});this.WriteReview=function(){r.ReadingMode(!1);r.WritingMode(!0)};this.ReadReviews=function(){r.ReportAbuseMode()?o():e();u();r.WritingMode(!1);r.ReportAbuseMode(!1);r.ReadingMode(!0)};this.CreateRatingStars=function(t){$(t).attr("id","starRatingfor-"+n.RecordId);for(var i=0;i<5;i++)$("<span>").attr("class","cursor-pointer star-off-png").attr("seq",i+1).appendTo(t);$("span",t).each(function(){$(this,t).hover(function(){var t=$("#starRatingfor-"+n.RecordId+" span");$.each(t,function(n,t){$(t).addClass("star-off-png");$(t).removeClass("star-on-png")});$(this).prevAll().add(this).addClass("star-on-png");$(this).prevAll().add(this).removeClass("star-off-png")},function(){if($(this).prevAll().add(this).addClass("star-off-png"),$(this).prevAll().add(this).removeClass("star-on-png"),r.RatingValue()!=0){var t=$("#starRatingfor-"+n.RecordId+" span");$.each(t,function(n,t){n<r.RatingValue()&&($(t).addClass("star-on-png"),$(t).removeClass("star-off-png"))})}}).click(function(){var t=parseInt($(this).attr("seq")),i=$("#starRatingfor-"+n.RecordId+" span");$.each(i,function(n,i){n<t?($(i).addClass("star-on-png"),$(i).removeClass("star-off-png")):($(i).addClass("star-off-png"),$(i).removeClass("star-on-png"))});r.RatingValue(t)})})};this.SelectedSortMode.subscribe(function(n){var t=r.ReviewContainer();t&&t.length>0&&n==1&&(t.sort(function(n,t){var i=new Date(Date.parse(n.Date)),r=new Date(Date.parse(t.Date));return i>r?-1:i<r?1:0}),r.ReviewContainer(t));t&&t.length>0&&n==2&&(t.sort(function(n,t){var i=new Date(Date.parse(n.Date)),r=new Date(Date.parse(t.Date));return i<r?-1:i>r?1:0}),r.ReviewContainer(t));t&&t.length>0&&n==3&&(t.sort(function(n,t){return t.RatingValue-n.RatingValue}),r.ReviewContainer(t));t&&t.length>0&&n==4&&(t.sort(function(n,t){return n.RatingValue-t.RatingValue}),r.ReviewContainer(t))});this.CloseBox=function(){r.ReportAbuseMode()?o():e();r.WritingMode(!1);r.ReportAbuseMode(!1);r.ReadingMode(!0);u();$("#questionDialog-"+n.RecordId).length!=0&&$("#questionDialog-"+n.RecordId).modal("hide")};this.SubmitComment=function(){u();$.ajax({type:"POST",dataType:"json",url:_utilities.getAbsoluteURL("/Reviews/SaveReview"),data:{cid:r.RecordId(),commentTitle:r.CommentTitle(),commentText:r.CommentText(),ratingValue:r.RatingValue(),questionId:r.GlobalCommentMode()==!1?r.SelectedQuestionToWrite():null},success:function(n){n.success?(r.GlobalCommentMode()?(r.SelectedQuestionToRead(null),r.SelectedQuestionToRead.valueHasMutated()):(r.SelectedQuestionToRead(r.SelectedQuestionToWrite()),r.SelectedQuestionToRead.valueHasMutated()),setOptionsForWritingMode(r,n.optionsForWrite),u(),r.WritingMode(!1),r.ReadingMode(!0),e()):n.message!=null?(r.ErrorMsg(n.message),r.ShowErrorMsg(!0)):window._toast.error(commonLocalizations.InternalServerError)}})};this.ReportAbuse=function(n){r.ReadingMode(!1);r.WritingMode(!1);r.ReportAbuseMode(!0);r.CommentIdToAbuse(n.CommentId)};this.SendAbuse=function(){$.ajax({type:"POST",dataType:"json",url:_utilities.getAbsoluteURL("/Reviews/SendAbuse"),data:{commentId:r.CommentIdToAbuse(),email:r.EmailToAbuse(),subject:r.SubjectOfAbuse(),body:r.ReasonOfAbuse()},before:function(){r.IsLoading(!0)},success:function(n){n.success?(r.ShowErrorMsg(!1),r.SuccessMsg(n.message),r.ShowSuccessMsg(!0)):(r.ShowSuccessMsg(!1),r.ErrorMsg(n.message),r.ShowErrorMsg(!0))},complete:function(){r.IsLoading(!1)}})};this.CurrentRecordChangedHandler=function(n){var t=n.CurrentRecordId;$.ajax({url:_utilities.getAbsoluteURL("/RecordUtilities/GetRecordReviews"),cache:!1,type:"GET",data:{recordId:t},before:function(){r.IsLoading(!0)},success:function(n){n.CurrentRecordHasRatingFieldType?(v(n),setOptionsForWritingMode(r,n.OptionsForWrite),setTimeout(function(){h()},100)):s();c()},complete:function(){r.IsLoading(!1)}})};y()}function roundHalf(n){return Math.round(n*2)/2}function populateStars(n,t){for(var r=Math.floor(t),u=r<t,i=1;i<=r;i++)$("[seq='"+i+"']",n).addClass("star-on-png");u&&$("[seq='"+i+"']",n).addClass("star-half-png")}function setOptionsForWritingMode(n,t){n.IsWritingModeAvailable(t.IsWritingModeAvailable);n.IsWritingModeAvailable()&&(n.GlobalCommentMode(t.ShowGlobalComment),n.GlobalCommentMode()||n.QuestionsToWrite(t.QuestionsToWrite))}function RecordsNavigationViewModel(n,t){function r(n){if(n.success===!1){window.location=_utilities.getAbsoluteURL("/Navigation/SearchResultExpired");return}i.CurrentRecordIndex(n.CurrentRecordIndex);i.CurrentRecordId=n.CurrentRecordId;i.CurrentContentTypeRecordsCount=n.CurrentContentTypeRecordsCount;window.GlobalEvents.CurrentRecordChanged.fire({RelationType:null,CurrentRecordId:n.CurrentRecordId,CurrentRecordIndex:i.CurrentRecordIndex(),CurrentContentTypeRecordsCount:i.CurrentContentTypeRecordsCount,IsClicked:!1,IsForced:!1})}function u(){$(t).each(function(){ko.applyBindings(i,$(this)[0])})}var i=this;this.CurrentRecordId=n.CurrentRecordId;this.CurrentContentTypeRecordsCount=n.CurrentContentTypeRecordsCount;this.CurrentRecordIndex=ko.observable(n.CurrentRecordIndex);this.CurrentRecordChangedHandler=function(){};this.NextRecord=function(){$.ajax({url:_utilities.getAbsoluteURL("/Navigation/GetNextRecordId"),type:"GET",cache:!1,success:function(n){r(n)}})};this.PreviusRecord=function(){$.ajax({url:_utilities.getAbsoluteURL("/Navigation/GetPreviousRecordId"),type:"GET",cache:!1,success:function(n){r(n)}})};this.FirstRecord=function(){$.ajax({url:_utilities.getAbsoluteURL("/Navigation/GetFirstRecordId"),type:"GET",cache:!1,success:function(n){r(n)}})};this.LastRecord=function(){$.ajax({url:_utilities.getAbsoluteURL("/Navigation/GetLastRecordId"),type:"GET",cache:!1,success:function(n){r(n)}})};this.GoToResult=function(){window.location.href=_utilities.getAbsoluteURL("/SearchResults/")};u()}function RecordManagementViewModel(n,t){function u(n){var t=$(n).attr("termId"),i=$(n).attr("content-loaded");i||$.get(_utilities.getAbsoluteURL("/UserDefinedSearch/GetUserDefinedField/"+t),function(t){$(n).siblings(".term-user-defined-model").html(t);t&&$.trim(t)!==""||$(n).siblings(".term-user-defined-model").css("display","none").css("box-shadow","none");$(n).attr("content-loaded",1)})}function i(n,t){$(function(i){var r="",u={rel:n,scrolling:!0,preloading:!1,current:"{current} of {total}",close:"&times;",photo:!0,maxWidth:"100%",maxHeight:"100%",reposition:!0,onOpen:function(){r=document.body.style.overflow;document.body.style.overflow="hidden"},onClosed:function(){document.body.style.overflow=r},onComplete:function(){i.colorbox.resize()}};i(t).colorbox(u);i("#cboxLoadingGraphic").html("<i class='fad fa-spinner orange fa-pulse' aria-hidden='true'><\/i>");i(document).one("ajaxloadstart.page",function(){i("#colorbox, #cboxOverlay").remove()})})}function f(n){var o,f,t,i,r,a,l,u;if($("[data-meta='dynamic").remove(),n&&n.length!=0){for(o="",f=0;f<n.length;f++){t=n[f];i=[];t.MultipleTags?i=t.ContentValue.split("{multi}"):i.push(t.ContentValue);for(let n=0;n<i.length;n++)if(r=t.TagName,r){var s=t.NameAttr,h=t.NameValue,c=t.ContentAttr,e=i[n];if(r=="title"){o=e;continue}s&&h&&(a=r+"["+s+'="'+h+'"]',l=document.querySelector(a),l&&i.length==1?l.setAttribute(c,e):(u=document.createElement(r),u[s]=h,c&&e&&(u[c]=e),u.setAttribute("data-meta","dynamic"),document.getElementsByTagName("head")[0].appendChild(u)))}}document.title=o}}function e(n){for(let i=0;i<300;i++){var t=!1;if(setTimeout(function(){window._recordPublishedStatus&&(t=!0,window._recordPublishedStatus.Update(n))},100),t)break}}function o(n){window.RecordViewActionsPanel&&window.RecordViewActionsPanel.UpdateCurrentRecordId&&window.RecordViewActionsPanel.UpdateCurrentRecordId(n);window._RecordUtilities.HideEmptyRows();setTimeout(function(){window._RecordUtilities.AdjustLayout()},0);window.GlobalEvents.CatalogueRecordLoaded.fire()}function s(){$(".thesaurus-field-text").hover(function(){u(this)});$(n).each(function(){ko.applyBindings(r,$(this)[0])});i("colorbox",'.ace-thumbnails [data-rel="colorbox"]');i("bookcover",".bookcover-image-link");o();f(t.MetaTags);e(t.IsPublished)}var r=this;this.IsLoading=ko.observable(!1);this.CurrentRecordChangedHandler=function(t){var s=t.CurrentRecordId;$.ajax({url:_utilities.getAbsoluteURL("/RecordView/GetFullRecordViewHtml"),type:"GET",data:{id:s},cache:!1,async:!0,beforeSend:function(){r.IsLoading(!0)},success:function(t){var h=t.result,r;if(!h.Success){window._toast.error(h.Message);return}r=h.Data.model;$(n).find(".panel-content").empty();$(n).find(".panel-content").html(r.RecordHtml);$("tr").has(".nonPublicField").css("display","none");window.history.replaceState({},"Title",_utilities.getAbsoluteURL("/RecordView/Index/")+s);$(".thesaurus-field-text").hover(function(){u(this)});i("colorbox",'.ace-thumbnails [data-rel="colorbox"]');i("bookcover",".bookcover-image-link");f(r.PageMetaData);e(r.IsPublished);o(s)},complete:function(){r.IsLoading(!1)}})};s()}function RecordManagementViewModelOptions(n){return $.extend({},{Callback:{},MetaTags:[],IsPublished:!1},n)}function CollectionsUtilities(){this.DeleteCollection=function(n,t,i){n&&n.hId||t.Error();$.ajax({type:"POST",url:_utilities.getAbsoluteURL("/Collections/DeleteCollection"),data:{hId:n.hId,collectionId:n.collectionId,deleteChild:n.deleteChild},cache:!1,async:!0,beforeSend:function(){t.BeforeSend(n,i)},success:function(r){if(!r.Success){window._toast.error(r.Message);t.Error(r,n,i);return}t.Success(r,n,i)},complete:function(){t.Complete(n,i)}})};this.SetCollectionFavorite=function(n,t,i){n&&n.id||t.Error();$.ajax({type:"POST",url:_utilities.getAbsoluteURL("/Collections/SetCollectionFavorite"),data:{id:n.id,isFavorite:n.isFavorite},cache:!1,async:!0,beforeSend:function(){t.BeforeSend(n,i)},success:function(r){if(!r.Success){window._toast.error(r.Message);t.Error(r,n,i);return}t.Success(r,n,i)},complete:function(){t.Complete(n,i)},error:function(n,t,i){_message.errorAjax(n,t,i)}})};this.OpenCollectionEditorDialog=function(n){if(!n.CollectionId){if(window._collectionEditorDialog){window._collectionEditorDialog.Show(n);return}window._collectionEditorDialog=new CollectionEditorDialog;window._collectionEditorDialog.Show(n);return}var t=n.Callback;$.ajax({type:"GET",url:_utilities.getAbsoluteURL("Collections/Edit?id="+n.CollectionId),contentType:"application/json, UTF-8",dataType:"json",beforeSend:function(){t.BeforeLoadCollection&&typeof t.BeforeLoadCollection=="function"&&t.BeforeLoadCollection()},success:function(t){if(!t.Success){window._toast.error(t.Message);return}if(n.CollectionData=t.Data,window._collectionEditorDialog){window._collectionEditorDialog.Show(n);return}window._collectionEditorDialog=new CollectionEditorDialog;window._collectionEditorDialog.Show(n)},complete:function(){t.AfterLoadCollection&&typeof t.AfterLoadCollection=="function"&&t.AfterLoadCollection()},error:function(n,t,i){_message.errorAjax(n,t,i)}})};this.OpenConfirmDeleteCollectionDialog=function(n){if(window._confirmDeleteCollectionDialog){window._confirmDeleteCollectionDialog.Show(n);return}window._confirmDeleteCollectionDialog=new ConfirmDeleteCollectionDialog;window._confirmDeleteCollectionDialog.Show(n)};this.OpenCollectionManagemenPage=function(){var n=_utilities.getAbsoluteURL("Collections");window.open(n,"_self")};this.OpenCollectionManagemenPageWithCreateNew=function(){var n=_utilities.getAbsoluteURL("Collections?event=create");window.open(n,"_self")};this.OpenCollectionManagemenPageWithCreateNewAndAutoAddRecords=function(n){var t=_utilities.getPortalURL("Collections?event=create_and_add&cid="+n);window.open(t,"_self")};this.AddRecordsToCollections=function(n,t,i){if(!n||!n.collectionsIds){t.Error();return}n.collectionsIds.length!=0&&$.ajax({type:"POST",url:_utilities.getAbsoluteURL("/Collections/AddRecordsToCollections"),data:{collectionsIds:n.collectionsIds,catalogueId:n.catalogueId},cache:!1,async:!0,beforeSend:function(){t.BeforeSend(n,i)},success:function(r){if(!r.Success){window._toast.error(r.Message);t.Error(r,n,i);return}window._toast.success("Record(s) have been added to selected collections successfully");t.Success(r,n,i)},complete:function(){t.Complete(n,i)},error:function(n,t,i){_message.errorAjax(n,t,i)}})};this.RemoveRecordsFromCollections=function(n,t,i){if(!n||!n.collectionsIds){t.Error();return}n.collectionsIds.length!=0&&$.ajax({type:"POST",url:_utilities.getAbsoluteURL("/Collections/RemoveRecordsFromCollections"),data:{collectionsIds:n.collectionsIds,catalogueId:n.catalogueId},cache:!1,async:!0,beforeSend:function(){t.BeforeSend(n,i)},success:function(r){if(!r.Success){window._toast.error(r.Message);t.Error(r,n,i);return}window._toast.success("Record(s) have been removed from selected collections successfully");t.Success(r,n,i)},complete:function(){t.Complete(n,i)},error:function(n,t,i){_message.errorAjax(n,t,i)}})};this.ChangePositionNodeInTree=function(n,t,i){if(!n){t.Error();return}$.ajax({type:"POST",url:_utilities.getAbsoluteURL("/Collections/ChangePositionNodeInTree"),data:{moveHid:n.moveHid,parentHid:n.parentHid,collectionId:n.collectionId,seq:n.seq},cache:!1,async:!0,beforeSend:function(){t.BeforeSend(n,i)},success:function(r){if(!r.Success){window._toast.error(r.Message);t.Error(r,n,i);return}t.Success(r,n,i)},complete:function(){t.Complete(n,i)},error:function(n,t,i){_message.errorAjax(n,t,i)}})}}function AddingRecordsToCollectionDialog(){function h(){var r=l(),u,f;if(r.length==0){window._toast.error(window.CollectionLocalizations.NoCollectionsSelectedMessage);setTimeout(function(){n.Dialog.$dialog.getButton("btn-action-run").stopSpin()},0);return}u={collectionsIds:r,catalogueId:i};f=new eventAjax({beforeSend:function(){},complete:function(){},success:function(){t.Success&&typeof t.Success=="function"&&t.Success(r,n);e()},error:function(){n.Dialog.$dialog.getButton("btn-action-run").stopSpin()}});n.AddingMode()?(new CollectionsUtilities).AddRecordsToCollections(u,f):(new CollectionsUtilities).RemoveRecordsFromCollections(u,f)}function c(){(new CollectionsUtilities).OpenCollectionManagemenPageWithCreateNewAndAutoAddRecords(i)}function e(){n.Dialog.close()}function l(){function f(n,t){for(var i,r=0;r<n.length;r++)i=n[r],i.state.selected&&t.push(i.li_attr["data-id"]),i.children&&i.children.length>0&&f(i.children,t);return t}var t=[],i=u.get_json(),r,n;if(!i||i.length==0)return t;for(r=0;r<i.length;r++)n=i[r],n.state.selected&&t.push(n.li_attr["data-id"]),n.children&&n.children.length>0&&f(n.children,t);return t}function a(){var t=$(n.Dialog.DIALOG_CONTENT_SELECTOR).find("#collections-tree-managing-records").find(".jstree");$(t).jstree({plugins:["types","html_data","checkbox"],core:{check_callback:!0},checkbox:{three_state:!1}}).bind("ready.jstree",function(n,t){u||(u=t.instance);$(n.target).find("li").each(function(){o(this)})}).bind("changed.jstree",function(){}).bind("open_node.jstree",function(n,i){var r=i.node.id;$(t).find("#"+r).find("li").each(function(){o(this)})});$(t).on("keydown",".jstree-anchor",function(n){if(n.which===13||n.which===32){var i=$(this).closest(".jstree-node"),r=$(i).attr("aria-selected")==="true";r?$(t).jstree("deselect_node",i):$(t).jstree("select_node",i);n.preventDefault()}});$(n.Dialog.DIALOG_CONTENT_SELECTOR).find("#collections-tree-managing-records").show()}function o(n){$(n).soutronTooltip("toggle");var t=$(n).attr("data-allow_edit");t=="0"&&$(n).find(".jstree-anchor .soutron-checkbox-icon").hide()}var n=this,t={},i=null,r=0,s=!1,f=!1,u;this.AddingMode=ko.observable(!0);n.Dialog={DIALOG_CONTENT_ID:"dialog-"+(new Date).getTime(),DIALOG_CONTENT_SELECTOR:"",DIALOG_TITLE:"",DIALOG_SIZE:BootstrapDialog.SIZE_WIDE,DIALOG_TYPE:BootstrapDialog.TYPE_PRIMARY,$dialog:null,init:function(t){n.Dialog.DIALOG_CONTENT_SELECTOR="#"+n.Dialog.DIALOG_CONTENT_ID;var i=[{id:"btn-action-create-collection",icon:"far fa-code-branch",label:"Create New Collection",cssClass:"btn btn-sm btn-success float-start hidden",autospin:!0,action:function(){c()}},{id:"btn-action-run",icon:"fas fa-check",label:window.commonLocalizations.Apply,cssClass:"btn btn-sm btn-success float-end",autospin:!0,action:function(){h()}},{icon:"fas fa-ban",label:window.commonLocalizations.Cancel,cssClass:"btn btn-sm btn-default float-end",action:function(){e()}}];n.Dialog.$dialog=new BootstrapDialog({autodestroy:!1,message:$(t),title:n.Dialog.DIALOG_TITLE,size:n.Dialog.DIALOG_SIZE,type:n.Dialog.DIALOG_TYPE,cssClass:"soutron-popup",closeByBackdrop:!0,draggable:!0,spinicon:_const.class.SPINNER_ICON,buttons:i,onshown:function(){f&&$("#"+n.Dialog.DIALOG_CONTENT_ID).closest(".modal-content").find("#btn-action-create-collection").removeClass("hidden");n.Dialog.$dialog.getButton("btn-action-run").stopSpin();n.Dialog.$dialog.getButton("btn-action-create-collection").stopSpin();n.AddingMode()?($("#"+n.Dialog.DIALOG_CONTENT_ID).find("#adding-records-warning-tip").text(r+" "+window.FillingCollectionLocalizations.XrecordsWillAddedToSelectedCollectionsMessage),$("#"+n.Dialog.DIALOG_CONTENT_ID).find("#adding-records-warning-tip").attr("class","alert alert-block alert-success")):($("#"+n.Dialog.DIALOG_CONTENT_ID).find("#adding-records-warning-tip").text(r+" "+window.FillingCollectionLocalizations.XrecordsWillDeletedFromSelectedCollectionsMessage),$("#"+n.Dialog.DIALOG_CONTENT_ID).find("#adding-records-warning-tip").attr("class","alert alert-danger"));var t;n.AddingMode()?(t=window.commonLocalizations.AddingRecordsToCollectionDialogCaption,n.Dialog.$dialog.setType(BootstrapDialog.TYPE_PRIMARY)):(t=window.commonLocalizations.RemoveRecordsFromCollectionDialogCaption,n.Dialog.$dialog.setType(BootstrapDialog.TYPE_DANGER));n.Dialog.$dialog.setTitle(t);ko.cleanNode($(n.Dialog.DIALOG_CONTENT_SELECTOR)[0]);ko.applyBindings(n,$(n.Dialog.DIALOG_CONTENT_SELECTOR)[0]);a()}})},open:function(u){$.ajax({type:"GET",url:_utilities.getAbsoluteURL("Collections/GetFillingCollectionDialogLayout?addingMode="+u+"&catalogueId="+i),contentType:"application/json, UTF-8",dataType:"json",beforeSend:function(){t.BeforeLoadLayout&&typeof t.BeforeLoadLayout=="function"&&t.BeforeLoadLayout(n.Dialog,n)},success:function(t){var u,e;if(!t.addingMode&&t.isEmptyTree){u=window.CollectionLocalizations.NoCollectionsFromCanRemoveSelectedRecordMessage;i&&(u=window.CollectionLocalizations.NoCollectionsFromCanRemoveRecordMessage);window._toast.error(u);return}r=i?1:t.countItems;s=t.allowSharingCollection;f=t.allowCreateCollection;e=$(document.createElement("div")).attr("id",n.Dialog.DIALOG_CONTENT_ID).append(t.layout);n.Dialog.init(e);n.Dialog.$dialog.open()},complete:function(){t.AfterLoadLayout&&typeof t.AfterLoadLayout=="function"&&t.AfterLoadLayout(n.Dialog,n)}})},close:function(){n.Dialog.$dialog&&n.Dialog.$dialog.close()}};this.Show=function(r){return t=r?r.Callback:null,n.AddingMode(r.AddingMode),i=r.CatalogueId,n.Dialog.open(r.AddingMode),n};this.GetViewModel=function(){return{}};this.Update=function(){}}function AddingRecordsToCollectionDialogOptions(n){var t={Callback:{BeforeLoadLayout:undefined,AfterLoadLayout:undefined,Success:undefined,Error:undefined},AddingMode:!0,CatalogueId:!0};return $.extend({},t,n)}RecordRelationsTreeAmendmentsLineMacros.prototype=new BaseMacrosJsModel;RecordRelationsTreeAmendmentsMacros.prototype=new BaseMacrosJsModel;RecordRelationsTree.prototype=new BaseMacrosJsModel;var reviewsLocalizations=window.reviewsLocalizations||{DateByDescending:"Date by descending",DateByAscending:"Date by ascending",RatingByDescending:"Rating by descending",RatingByAscending:"Rating by ascending"}